Skip to content
This repository has been archived by the owner on Feb 8, 2023. It is now read-only.

Commit

Permalink
Fix keymap updating for X11 backend
Browse files Browse the repository at this point in the history
  • Loading branch information
renom authored and icculus committed Apr 19, 2021
1 parent 509228c commit de6d290
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/video/x11/SDL_x11events.c
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,7 @@ X11_DispatchEvent(_THIS)
Display *display;
SDL_WindowData *data;
XEvent xevent;
XkbEvent* xkbEvent;
int orig_event_type;
KeyCode orig_keycode;
XClientMessageEvent m;
Expand All @@ -688,6 +689,7 @@ X11_DispatchEvent(_THIS)

SDL_zero(xevent); /* valgrind fix. --ryan. */
X11_XNextEvent(display, &xevent);
xkbEvent = (XkbEvent*) &xevent;

/* Save the original keycode for dead keys, which are filtered out by
the XFilterEvent() call below.
Expand Down Expand Up @@ -768,7 +770,7 @@ X11_DispatchEvent(_THIS)
if (SDL_GetKeyboardFocus() != NULL) {
X11_ReconcileKeyboardState(_this);
}
} else if (xevent.type == MappingNotify) {
} else if (xevent.type == MappingNotify || xkbEvent->any.xkb_type == XkbStateNotify) {
/* Has the keyboard layout changed? */
const int request = xevent.xmapping.request;

Expand Down
1 change: 1 addition & 0 deletions src/video/x11/SDL_x11sym.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ SDL_X11_SYM(XkbDescPtr,XkbGetMap,(Display* a,unsigned int b,unsigned int c),(a,b
SDL_X11_SYM(void,XkbFreeClientMap,(XkbDescPtr a,unsigned int b, Bool c),(a,b,c),)
SDL_X11_SYM(void,XkbFreeKeyboard,(XkbDescPtr a,unsigned int b, Bool c),(a,b,c),)
SDL_X11_SYM(Bool,XkbSetDetectableAutoRepeat,(Display* a, Bool b, Bool* c),(a,b,c),return)
SDL_X11_SYM(Bool,XkbSelectEvents,(Display* a, unsigned int b, unsigned int c, unsigned int d),(a,b,c,d),return)
#endif

#if NeedWidePrototypes
Expand Down
2 changes: 2 additions & 0 deletions src/video/x11/SDL_x11window.c
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,8 @@ X11_CreateWindow(_THIS, SDL_Window * window)
PropertyChangeMask | StructureNotifyMask |
KeymapStateMask | fevent));

X11_XkbSelectEvents(display, XkbUseCoreKbd, XkbStateNotifyMask, XkbStateNotifyMask);

X11_XFlush(display);

return 0;
Expand Down

0 comments on commit de6d290

Please sign in to comment.