mirror of
https://github.com/glfw/glfw.git
synced 2026-09-22 08:50:15 +00:00
X11: Query and keep track of Xkb group index
For users with multiple keyboard layouts configured, glfwGetKeyName
works fine only with the primary layout. Switching layouts results in
changing the group index. This commit querries the current group index
when initializing keyboard input and keeps track of any change to it.
As a result the scancode -> keyname mapping may change while the program
is running (needs to be documented).
Fixes #1462.
Closes #1528.
(cherry picked from commit 36f90800d8)
This commit is contained in:
committed by
Camilla Löwy
parent
84fa724456
commit
b3eb6dd38b
+10
-1
@@ -1180,6 +1180,15 @@ static void processEvent(XEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
if (_glfw.x11.xkb.available && event->type == _glfw.x11.xkb.eventBase)
|
||||
{
|
||||
if (((XkbEvent *)event)->any.xkb_type == XkbStateNotify &&
|
||||
((XkbEvent *)event)->state.changed & XkbGroupStateMask)
|
||||
{
|
||||
_glfw.x11.xkb.group = ((XkbEvent *)event)->state.group;
|
||||
}
|
||||
}
|
||||
|
||||
if (event->type == GenericEvent)
|
||||
{
|
||||
if (_glfw.x11.xi.available)
|
||||
@@ -2780,7 +2789,7 @@ const char* _glfwPlatformGetScancodeName(int scancode)
|
||||
if (!_glfw.x11.xkb.available)
|
||||
return NULL;
|
||||
|
||||
const KeySym keysym = XkbKeycodeToKeysym(_glfw.x11.display, scancode, 0, 0);
|
||||
const KeySym keysym = XkbKeycodeToKeysym(_glfw.x11.display, scancode, _glfw.x11.xkb.group, 0);
|
||||
if (keysym == NoSymbol)
|
||||
return NULL;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user