x11: Wrap platform functions in XWindowsKeyState class
This commit is contained in:
parent
624a718f2d
commit
2c32270d49
|
@ -203,4 +203,31 @@ public:
|
|||
virtual Atom* XListProperties(Display* display, Window w,
|
||||
int* num_prop_return) = 0;
|
||||
virtual char* XGetAtomName(Display* display, Atom atom) = 0;
|
||||
virtual void XkbFreeKeyboard(XkbDescPtr xkb, unsigned int which,
|
||||
Bool freeDesc) = 0;
|
||||
virtual XkbDescPtr XkbGetMap(Display* display, unsigned int which,
|
||||
unsigned int deviceSpec) = 0;
|
||||
virtual Status XkbGetState(Display* display, unsigned int deviceSet,
|
||||
XkbStatePtr rtrnState) = 0;
|
||||
virtual int XQueryKeymap(Display* display, char keys_return[32]) = 0;
|
||||
virtual Status XkbGetUpdatedMap(Display* display, unsigned int which,
|
||||
XkbDescPtr desc) = 0;
|
||||
virtual Bool XkbLockGroup(Display* display, unsigned int deviceSpec,
|
||||
unsigned int group) = 0;
|
||||
virtual int XDisplayKeycodes(Display* display, int* min_keycodes_return,
|
||||
int* max_keycodes_return) = 0;
|
||||
virtual KeySym* XGetKeyboardMapping(Display* display,
|
||||
unsigned int first_keycode,
|
||||
int keycode_count,
|
||||
int* keysyms_per_keycode_return) = 0;
|
||||
virtual int do_XkbKeyNumGroups(XkbDescPtr m_xkb, KeyCode desc) = 0;
|
||||
virtual XkbKeyTypePtr do_XkbKeyKeyType(XkbDescPtr m_xkb, KeyCode keycode,
|
||||
int eGroup) = 0;
|
||||
virtual KeySym do_XkbKeySymEntry(XkbDescPtr m_xkb, KeyCode keycode,
|
||||
int level, int eGroup) = 0;
|
||||
virtual Bool do_XkbKeyHasActions(XkbDescPtr m_xkb, KeyCode keycode) = 0;
|
||||
virtual XkbAction* do_XkbKeyActionEntry(XkbDescPtr m_xkb, KeyCode keycode,
|
||||
int level, int eGroup) = 0;
|
||||
virtual unsigned char do_XkbKeyGroupInfo(XkbDescPtr m_xkb,
|
||||
KeyCode keycode) = 0;
|
||||
};
|
||||
|
|
|
@ -225,12 +225,14 @@ Bool XWindowsImpl::XkbSelectEvents(Display* display, unsigned int deviceID,
|
|||
return ::XkbSelectEvents(display, deviceID, affect, values);
|
||||
}
|
||||
|
||||
Bool XWindowsImpl::XkbSelectEventDetails(Display* display, unsigned int deviceID,
|
||||
Bool XWindowsImpl::XkbSelectEventDetails(Display* display,
|
||||
unsigned int deviceID,
|
||||
unsigned int eventType,
|
||||
unsigned long affect,
|
||||
unsigned long details)
|
||||
{
|
||||
return ::XkbSelectEventDetails(display, deviceID, eventType, affect, details);
|
||||
return ::XkbSelectEventDetails(display, deviceID, eventType, affect,
|
||||
details);
|
||||
}
|
||||
|
||||
Bool XWindowsImpl::XRRQueryExtension(Display* display, int* event_base_return,
|
||||
|
@ -271,8 +273,7 @@ Bool XWindowsImpl::XineramaIsActive(Display* display)
|
|||
#endif
|
||||
}
|
||||
|
||||
void* XWindowsImpl::XineramaQueryScreens(Display* display,
|
||||
int* number)
|
||||
void* XWindowsImpl::XineramaQueryScreens(Display* display, int* number)
|
||||
{
|
||||
#if HAVE_X11_EXTENSIONS_XINERAMA_H
|
||||
return ::XineramaQueryScreens(display, number);
|
||||
|
@ -281,7 +282,8 @@ void* XWindowsImpl::XineramaQueryScreens(Display* display,
|
|||
#endif
|
||||
}
|
||||
|
||||
Window XWindowsImpl::XCreateWindow(Display* display, Window parent, int x, int y,
|
||||
Window XWindowsImpl::XCreateWindow(Display* display, Window parent,
|
||||
int x, int y,
|
||||
unsigned int width, unsigned int height,
|
||||
unsigned int border_width, int depth,
|
||||
unsigned int klass, Visual* visual,
|
||||
|
@ -326,7 +328,8 @@ int XWindowsImpl::XSelectInput(Display* display, Window w, long event_mask)
|
|||
}
|
||||
|
||||
Bool XWindowsImpl::XCheckIfEvent(Display* display, XEvent* event,
|
||||
Bool (*predicate)(Display *, XEvent *, XPointer),
|
||||
Bool (*predicate)(Display *, XEvent *,
|
||||
XPointer),
|
||||
XPointer arg)
|
||||
{
|
||||
return ::XCheckIfEvent(display, event, predicate, arg);
|
||||
|
@ -550,3 +553,89 @@ char* XWindowsImpl::XGetAtomName(Display* display, Atom atom)
|
|||
{
|
||||
return ::XGetAtomName(display, atom);
|
||||
}
|
||||
|
||||
void XWindowsImpl::XkbFreeKeyboard(XkbDescPtr xkb, unsigned int which,
|
||||
Bool freeDesc)
|
||||
{
|
||||
::XkbFreeKeyboard(xkb, which, freeDesc);
|
||||
}
|
||||
|
||||
XkbDescPtr XWindowsImpl::XkbGetMap(Display* display, unsigned int which,
|
||||
unsigned int deviceSpec)
|
||||
{
|
||||
return ::XkbGetMap(display, which, deviceSpec);
|
||||
}
|
||||
|
||||
Status XWindowsImpl::XkbGetState(Display* display, unsigned int deviceSet,
|
||||
XkbStatePtr rtrnState)
|
||||
{
|
||||
return ::XkbGetState(display, deviceSet, rtrnState);
|
||||
}
|
||||
|
||||
int XWindowsImpl::XQueryKeymap(Display* display, char keys_return[32])
|
||||
{
|
||||
return ::XQueryKeymap(display, keys_return);
|
||||
}
|
||||
|
||||
Status XWindowsImpl::XkbGetUpdatedMap(Display* display, unsigned int which,
|
||||
XkbDescPtr desc)
|
||||
{
|
||||
return ::XkbGetUpdatedMap(display, which, desc);
|
||||
}
|
||||
|
||||
Bool XWindowsImpl::XkbLockGroup(Display* display, unsigned int deviceSpec,
|
||||
unsigned int group)
|
||||
{
|
||||
return ::XkbLockGroup(display, deviceSpec, group);
|
||||
}
|
||||
|
||||
int XWindowsImpl::XDisplayKeycodes(Display* display, int* min_keycodes_return,
|
||||
int* max_keycodes_return)
|
||||
{
|
||||
return ::XDisplayKeycodes(display, min_keycodes_return,
|
||||
max_keycodes_return);
|
||||
}
|
||||
|
||||
KeySym* XWindowsImpl::XGetKeyboardMapping(Display* display,
|
||||
unsigned int first_keycode,
|
||||
int keycode_count,
|
||||
int* keysyms_per_keycode_return)
|
||||
{
|
||||
return ::XGetKeyboardMapping(display, first_keycode, keycode_count,
|
||||
keysyms_per_keycode_return);
|
||||
}
|
||||
|
||||
int XWindowsImpl::do_XkbKeyNumGroups(XkbDescPtr m_xkb, KeyCode desc)
|
||||
|
||||
{
|
||||
return XkbKeyNumGroups(m_xkb, desc);
|
||||
}
|
||||
|
||||
XkbKeyTypePtr XWindowsImpl::do_XkbKeyKeyType(XkbDescPtr m_xkb, KeyCode keycode,
|
||||
int eGroup)
|
||||
{
|
||||
return do_XkbKeyKeyType(m_xkb, keycode, eGroup);
|
||||
}
|
||||
|
||||
KeySym XWindowsImpl::do_XkbKeySymEntry(XkbDescPtr m_xkb, KeyCode keycode,
|
||||
int level, int eGroup)
|
||||
{
|
||||
return do_XkbKeySymEntry(m_xkb, keycode, level, eGroup);
|
||||
}
|
||||
|
||||
Bool XWindowsImpl::do_XkbKeyHasActions(XkbDescPtr m_xkb, KeyCode keycode)
|
||||
{
|
||||
return do_XkbKeyHasActions(m_xkb, keycode);
|
||||
}
|
||||
|
||||
XkbAction* XWindowsImpl::do_XkbKeyActionEntry(XkbDescPtr m_xkb, KeyCode keycode,
|
||||
int level, int eGroup)
|
||||
{
|
||||
return do_XkbKeyActionEntry(m_xkb, keycode, level, eGroup);
|
||||
}
|
||||
|
||||
unsigned char XWindowsImpl::do_XkbKeyGroupInfo(XkbDescPtr m_xkb,
|
||||
KeyCode keycode)
|
||||
{
|
||||
return do_XkbKeyGroupInfo(m_xkb, keycode);
|
||||
}
|
||||
|
|
|
@ -77,8 +77,7 @@ public:
|
|||
virtual Bool XineramaQueryExtension(Display* display, int* event_base,
|
||||
int* error_base);
|
||||
virtual Bool XineramaIsActive(Display* display);
|
||||
virtual void* XineramaQueryScreens(Display* display,
|
||||
int* number);
|
||||
virtual void* XineramaQueryScreens(Display* display, int* number);
|
||||
virtual Window XCreateWindow(Display* display, Window parent, int x, int y,
|
||||
unsigned int width, unsigned int height,
|
||||
unsigned int border_width, int depth,
|
||||
|
@ -151,7 +150,8 @@ public:
|
|||
virtual Atom XInternAtom(Display* display, _Xconst char* atom_name,
|
||||
Bool only_if_exists);
|
||||
virtual int XGetScreenSaver(Display* display, int* timeout_return,
|
||||
int* interval_return, int* prefer_blanking_return,
|
||||
int* interval_return,
|
||||
int* prefer_blanking_return,
|
||||
int* allow_exposures_return);
|
||||
virtual int XSetScreenSaver(Display* display, int timeout, int interval,
|
||||
int prefer_blanking, int allow_exposures);
|
||||
|
@ -165,4 +165,31 @@ public:
|
|||
virtual Atom* XListProperties(Display* display, Window w,
|
||||
int* num_prop_return);
|
||||
virtual char* XGetAtomName(Display* display, Atom atom);
|
||||
virtual void XkbFreeKeyboard(XkbDescPtr xkb, unsigned int which,
|
||||
Bool freeDesc);
|
||||
virtual XkbDescPtr XkbGetMap(Display* display, unsigned int which,
|
||||
unsigned int deviceSpec);
|
||||
virtual Status XkbGetState(Display* display, unsigned int deviceSet,
|
||||
XkbStatePtr rtrnState);
|
||||
virtual int XQueryKeymap(Display* display, char keys_return[32]);
|
||||
virtual Status XkbGetUpdatedMap(Display* display, unsigned int which,
|
||||
XkbDescPtr desc);
|
||||
virtual Bool XkbLockGroup(Display* display, unsigned int deviceSpec,
|
||||
unsigned int group);
|
||||
virtual int XDisplayKeycodes(Display* display, int* min_keycodes_return,
|
||||
int* max_keycodes_return);
|
||||
virtual KeySym* XGetKeyboardMapping(Display* display,
|
||||
unsigned int first_keycode,
|
||||
int keycode_count,
|
||||
int* keysyms_per_keycode_return);
|
||||
virtual int do_XkbKeyNumGroups(XkbDescPtr m_xkb, KeyCode desc);
|
||||
virtual XkbKeyTypePtr do_XkbKeyKeyType(XkbDescPtr m_xkb, KeyCode keycode,
|
||||
int eGroup);
|
||||
virtual KeySym do_XkbKeySymEntry(XkbDescPtr m_xkb, KeyCode keycode,
|
||||
int level, int eGroup);
|
||||
virtual Bool do_XkbKeyHasActions(XkbDescPtr m_xkb, KeyCode keycode);
|
||||
virtual XkbAction* do_XkbKeyActionEntry(XkbDescPtr m_xkb, KeyCode keycode,
|
||||
int level, int eGroup);
|
||||
virtual unsigned char do_XkbKeyGroupInfo(XkbDescPtr m_xkb,
|
||||
KeyCode keycode);
|
||||
};
|
||||
|
|
|
@ -40,17 +40,19 @@
|
|||
|
||||
static const size_t ModifiersFromXDefaultSize = 32;
|
||||
|
||||
XWindowsKeyState::XWindowsKeyState(
|
||||
XWindowsKeyState::XWindowsKeyState(IXWindowsImpl* impl,
|
||||
Display* display, bool useXKB,
|
||||
IEventQueue* events) :
|
||||
KeyState(events),
|
||||
m_display(display),
|
||||
m_modifierFromX(ModifiersFromXDefaultSize)
|
||||
{
|
||||
m_impl = impl;
|
||||
|
||||
init(display, useXKB);
|
||||
}
|
||||
|
||||
XWindowsKeyState::XWindowsKeyState(
|
||||
XWindowsKeyState::XWindowsKeyState(IXWindowsImpl* impl,
|
||||
Display* display, bool useXKB,
|
||||
IEventQueue* events, barrier::KeyMap& keyMap) :
|
||||
KeyState(events, keyMap),
|
||||
|
@ -64,7 +66,7 @@ XWindowsKeyState::~XWindowsKeyState()
|
|||
{
|
||||
#if HAVE_XKB_EXTENSION
|
||||
if (m_xkb != NULL) {
|
||||
XkbFreeKeyboard(m_xkb, 0, True);
|
||||
m_impl->XkbFreeKeyboard(m_xkb, 0, True);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -75,7 +77,8 @@ XWindowsKeyState::init(Display* display, bool useXKB)
|
|||
XGetKeyboardControl(m_display, &m_keyboardState);
|
||||
#if HAVE_XKB_EXTENSION
|
||||
if (useXKB) {
|
||||
m_xkb = XkbGetMap(m_display, XkbKeyActionsMask | XkbKeyBehaviorsMask |
|
||||
m_xkb = m_impl->XkbGetMap(m_display,
|
||||
XkbKeyActionsMask | XkbKeyBehaviorsMask |
|
||||
XkbAllClientInfoMask, XkbUseCoreKbd);
|
||||
}
|
||||
else {
|
||||
|
@ -177,8 +180,9 @@ XWindowsKeyState::pollActiveModifiers() const
|
|||
Window root = DefaultRootWindow(m_display), window;
|
||||
int xRoot, yRoot, xWindow, yWindow;
|
||||
unsigned int state = 0;
|
||||
if (XQueryPointer(m_display, root, &root, &window,
|
||||
&xRoot, &yRoot, &xWindow, &yWindow, &state) == False) {
|
||||
if (m_impl->XQueryPointer(m_display, root, &root, &window,
|
||||
&xRoot, &yRoot, &xWindow, &yWindow, &state
|
||||
) == False) {
|
||||
state = 0;
|
||||
}
|
||||
return mapModifiersFromX(state);
|
||||
|
@ -195,7 +199,7 @@ XWindowsKeyState::pollActiveGroup() const
|
|||
#if HAVE_XKB_EXTENSION
|
||||
if (m_xkb != NULL) {
|
||||
XkbStateRec state;
|
||||
if (XkbGetState(m_display, XkbUseCoreKbd, &state) == Success) {
|
||||
if (m_impl->XkbGetState(m_display, XkbUseCoreKbd, &state) == Success) {
|
||||
return state.group;
|
||||
}
|
||||
}
|
||||
|
@ -207,7 +211,7 @@ void
|
|||
XWindowsKeyState::pollPressedKeys(KeyButtonSet& pressedKeys) const
|
||||
{
|
||||
char keys[32];
|
||||
XQueryKeymap(m_display, keys);
|
||||
m_impl->XQueryKeymap(m_display, keys);
|
||||
for (UInt32 i = 0; i < 32; ++i) {
|
||||
for (UInt32 j = 0; j < 8; ++j) {
|
||||
if ((keys[i] & (1u << j)) != 0) {
|
||||
|
@ -228,8 +232,9 @@ XWindowsKeyState::getKeyMap(barrier::KeyMap& keyMap)
|
|||
|
||||
#if HAVE_XKB_EXTENSION
|
||||
if (m_xkb != NULL) {
|
||||
if (XkbGetUpdatedMap(m_display, XkbKeyActionsMask |
|
||||
XkbKeyBehaviorsMask | XkbAllClientInfoMask, m_xkb) == Success) {
|
||||
unsigned mask = XkbKeyActionsMask | XkbKeyBehaviorsMask |
|
||||
XkbAllClientInfoMask;
|
||||
if (m_impl->XkbGetUpdatedMap(m_display, mask, m_xkb) == Success) {
|
||||
updateKeysymMapXKB(keyMap);
|
||||
return;
|
||||
}
|
||||
|
@ -254,8 +259,8 @@ XWindowsKeyState::fakeKey(const Keystroke& keystroke)
|
|||
break;
|
||||
}
|
||||
}
|
||||
XTestFakeKeyEvent(m_display, keystroke.m_data.m_button.m_button,
|
||||
keystroke.m_data.m_button.m_press ? True : False,
|
||||
m_impl->XTestFakeKeyEvent(m_display, keystroke.m_data.m_button.m_button,
|
||||
keystroke.m_data.m_button.m_press,
|
||||
CurrentTime);
|
||||
break;
|
||||
|
||||
|
@ -264,8 +269,9 @@ XWindowsKeyState::fakeKey(const Keystroke& keystroke)
|
|||
LOG((CLOG_DEBUG1 " group %d", keystroke.m_data.m_group.m_group));
|
||||
#if HAVE_XKB_EXTENSION
|
||||
if (m_xkb != NULL) {
|
||||
if (XkbLockGroup(m_display, XkbUseCoreKbd,
|
||||
keystroke.m_data.m_group.m_group) == False) {
|
||||
if (m_impl->XkbLockGroup(m_display, XkbUseCoreKbd,
|
||||
keystroke.m_data.m_group.m_group
|
||||
) == False) {
|
||||
LOG((CLOG_DEBUG1 "XkbLockGroup request not sent"));
|
||||
}
|
||||
}
|
||||
|
@ -279,9 +285,10 @@ XWindowsKeyState::fakeKey(const Keystroke& keystroke)
|
|||
LOG((CLOG_DEBUG1 " group %+d", keystroke.m_data.m_group.m_group));
|
||||
#if HAVE_XKB_EXTENSION
|
||||
if (m_xkb != NULL) {
|
||||
if (XkbLockGroup(m_display, XkbUseCoreKbd,
|
||||
if (m_impl->XkbLockGroup(m_display, XkbUseCoreKbd,
|
||||
getEffectiveGroup(pollActiveGroup(),
|
||||
keystroke.m_data.m_group.m_group)) == False) {
|
||||
keystroke.m_data.m_group.m_group)
|
||||
) == False) {
|
||||
LOG((CLOG_DEBUG1 "XkbLockGroup request not sent"));
|
||||
}
|
||||
}
|
||||
|
@ -320,12 +327,12 @@ XWindowsKeyState::updateKeysymMap(barrier::KeyMap& keyMap)
|
|||
|
||||
// get the number of keycodes
|
||||
int minKeycode, maxKeycode;
|
||||
XDisplayKeycodes(m_display, &minKeycode, &maxKeycode);
|
||||
m_impl->XDisplayKeycodes(m_display, &minKeycode, &maxKeycode);
|
||||
int numKeycodes = maxKeycode - minKeycode + 1;
|
||||
|
||||
// get the keyboard mapping for all keys
|
||||
int keysymsPerKeycode;
|
||||
KeySym* allKeysyms = XGetKeyboardMapping(m_display,
|
||||
KeySym* allKeysyms = m_impl->XGetKeyboardMapping(m_display,
|
||||
minKeycode, numKeycodes,
|
||||
&keysymsPerKeycode);
|
||||
|
||||
|
@ -343,7 +350,7 @@ XWindowsKeyState::updateKeysymMap(barrier::KeyMap& keyMap)
|
|||
}
|
||||
}
|
||||
}
|
||||
XFree(allKeysyms);
|
||||
m_impl->XFree(allKeysyms);
|
||||
allKeysyms = tmpKeysyms;
|
||||
}
|
||||
|
||||
|
@ -365,7 +372,7 @@ XWindowsKeyState::updateKeysymMap(barrier::KeyMap& keyMap)
|
|||
// going to ignore all KeySyms except the first modifier KeySym,
|
||||
// which means button 1 above won't map to Meta, just Alt.
|
||||
std::map<KeyCode, unsigned int> modifierButtons;
|
||||
XModifierKeymap* modifiers = XGetModifierMapping(m_display);
|
||||
XModifierKeymap* modifiers = m_impl->XGetModifierMapping(m_display);
|
||||
for (unsigned int i = 0; i < 8; ++i) {
|
||||
const KeyCode* buttons =
|
||||
modifiers->modifiermap + i * modifiers->max_keypermod;
|
||||
|
@ -560,7 +567,7 @@ XWindowsKeyState::updateKeysymMapXKB(barrier::KeyMap& keyMap)
|
|||
// find the number of groups
|
||||
int maxNumGroups = 0;
|
||||
for (int i = m_xkb->min_key_code; i <= m_xkb->max_key_code; ++i) {
|
||||
int numGroups = XkbKeyNumGroups(m_xkb, static_cast<KeyCode>(i));
|
||||
int numGroups = m_impl->do_XkbKeyNumGroups(m_xkb, static_cast<KeyCode>(i));
|
||||
if (numGroups > maxNumGroups) {
|
||||
maxNumGroups = numGroups;
|
||||
}
|
||||
|
@ -596,7 +603,7 @@ XWindowsKeyState::updateKeysymMapXKB(barrier::KeyMap& keyMap)
|
|||
item.m_client = 0;
|
||||
|
||||
// skip keys with no groups (they generate no symbols)
|
||||
if (XkbKeyNumGroups(m_xkb, keycode) == 0) {
|
||||
if (m_impl->do_XkbKeyNumGroups(m_xkb, keycode) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -612,7 +619,8 @@ XWindowsKeyState::updateKeysymMapXKB(barrier::KeyMap& keyMap)
|
|||
int eGroup = getEffectiveGroup(keycode, group);
|
||||
|
||||
// get key info
|
||||
XkbKeyTypePtr type = XkbKeyKeyType(m_xkb, keycode, eGroup);
|
||||
XkbKeyTypePtr type = m_impl->do_XkbKeyKeyType(m_xkb, keycode,
|
||||
eGroup);
|
||||
|
||||
// set modifiers the item is sensitive to
|
||||
item.m_sensitive = type->mods.mask;
|
||||
|
@ -641,16 +649,18 @@ XWindowsKeyState::updateKeysymMapXKB(barrier::KeyMap& keyMap)
|
|||
}
|
||||
|
||||
// get the keysym for this item
|
||||
KeySym keysym = XkbKeySymEntry(m_xkb, keycode, level, eGroup);
|
||||
KeySym keysym = m_impl->do_XkbKeySymEntry(m_xkb, keycode, level,
|
||||
eGroup);
|
||||
|
||||
// check for group change actions, locking modifiers, and
|
||||
// modifier masks.
|
||||
item.m_lock = false;
|
||||
bool isModifier = false;
|
||||
UInt32 modifierMask = m_xkb->map->modmap[keycode];
|
||||
if (XkbKeyHasActions(m_xkb, keycode) == True) {
|
||||
if (m_impl->do_XkbKeyHasActions(m_xkb, keycode) == True) {
|
||||
XkbAction* action =
|
||||
XkbKeyActionEntry(m_xkb, keycode, level, eGroup);
|
||||
m_impl->do_XkbKeyActionEntry(m_xkb, keycode, level,
|
||||
eGroup);
|
||||
if (action->type == XkbSA_SetMods ||
|
||||
action->type == XkbSA_LockMods) {
|
||||
isModifier = true;
|
||||
|
@ -799,19 +809,19 @@ XWindowsKeyState::hasModifiersXKB() const
|
|||
// iterate over all keycodes
|
||||
for (int i = m_xkb->min_key_code; i <= m_xkb->max_key_code; ++i) {
|
||||
KeyCode keycode = static_cast<KeyCode>(i);
|
||||
if (XkbKeyHasActions(m_xkb, keycode) == True) {
|
||||
if (m_impl->do_XkbKeyHasActions(m_xkb, keycode) == True) {
|
||||
// iterate over all groups
|
||||
int numGroups = XkbKeyNumGroups(m_xkb, keycode);
|
||||
int numGroups = m_impl->do_XkbKeyNumGroups(m_xkb, keycode);
|
||||
for (int group = 0; group < numGroups; ++group) {
|
||||
// iterate over all shift levels for the button (including none)
|
||||
XkbKeyTypePtr type = XkbKeyKeyType(m_xkb, keycode, group);
|
||||
XkbKeyTypePtr type = m_impl->do_XkbKeyKeyType(m_xkb, keycode, group);
|
||||
for (int j = -1; j < type->map_count; ++j) {
|
||||
if (j != -1 && !type->map[j].active) {
|
||||
continue;
|
||||
}
|
||||
int level = ((j == -1) ? 0 : type->map[j].level);
|
||||
XkbAction* action =
|
||||
XkbKeyActionEntry(m_xkb, keycode, level, group);
|
||||
m_impl->do_XkbKeyActionEntry(m_xkb, keycode, level, group);
|
||||
if (action->type == XkbSA_SetMods ||
|
||||
action->type == XkbSA_LockMods) {
|
||||
return true;
|
||||
|
@ -830,9 +840,9 @@ XWindowsKeyState::getEffectiveGroup(KeyCode keycode, int group) const
|
|||
(void)keycode;
|
||||
#if HAVE_XKB_EXTENSION
|
||||
// get effective group for key
|
||||
int numGroups = XkbKeyNumGroups(m_xkb, keycode);
|
||||
int numGroups = m_impl->do_XkbKeyNumGroups(m_xkb, keycode);
|
||||
if (group >= numGroups) {
|
||||
unsigned char groupInfo = XkbKeyGroupInfo(m_xkb, keycode);
|
||||
unsigned char groupInfo = m_impl->do_XkbKeyGroupInfo(m_xkb, keycode);
|
||||
switch (XkbOutOfRangeGroupAction(groupInfo)) {
|
||||
case XkbClampIntoRange:
|
||||
group = numGroups - 1;
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "barrier/KeyState.h"
|
||||
#include "common/stdmap.h"
|
||||
#include "common/stdvector.h"
|
||||
#include "XWindowsImpl.h"
|
||||
|
||||
#if X_DISPLAY_MISSING
|
||||
# error X11 is required to build barrier
|
||||
|
@ -50,8 +51,9 @@ public:
|
|||
kGroupPollAndSet = -2
|
||||
};
|
||||
|
||||
XWindowsKeyState(Display*, bool useXKB, IEventQueue* events);
|
||||
XWindowsKeyState(Display*, bool useXKB,
|
||||
XWindowsKeyState(IXWindowsImpl* impl, Display*, bool useXKB,
|
||||
IEventQueue* events);
|
||||
XWindowsKeyState(IXWindowsImpl* impl, Display*, bool useXKB,
|
||||
IEventQueue* events, barrier::KeyMap& keyMap);
|
||||
~XWindowsKeyState();
|
||||
|
||||
|
@ -145,6 +147,8 @@ private:
|
|||
typedef std::map<KeyCode, unsigned int> NonXKBModifierMap;
|
||||
typedef std::map<UInt32, XKBModifierInfo> XKBModifierMap;
|
||||
|
||||
IXWindowsImpl* m_impl;
|
||||
|
||||
Display* m_display;
|
||||
#if HAVE_XKB_EXTENSION
|
||||
XkbDescPtr m_xkb;
|
||||
|
|
|
@ -116,7 +116,8 @@ XWindowsScreen::XWindowsScreen(
|
|||
m_window = openWindow();
|
||||
m_screensaver = new XWindowsScreenSaver(m_impl, m_display,
|
||||
m_window, getEventTarget(), events);
|
||||
m_keyState = new XWindowsKeyState(m_display, m_xkb, events, m_keyMap);
|
||||
m_keyState = new XWindowsKeyState(m_impl, m_display, m_xkb, events,
|
||||
m_keyMap);
|
||||
LOG((CLOG_DEBUG "screen shape: %d,%d %dx%d %s", m_x, m_y, m_w, m_h, m_xinerama ? "(xinerama)" : ""));
|
||||
LOG((CLOG_DEBUG "window is 0x%08x", m_window));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue