Make sure the X event is an Xkb event before checking the Xkb event type
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c
index 1bf10d5..5d0517e 100644
--- a/src/video/x11/SDL_x11events.c
+++ b/src/video/x11/SDL_x11events.c
@@ -808,7 +808,8 @@ X11_DispatchEvent(_THIS, XEvent *xevent)
if (SDL_GetKeyboardFocus() != NULL) {
X11_ReconcileKeyboardState(_this);
}
- } else if (xevent->type == MappingNotify || xkbEvent->any.xkb_type == XkbStateNotify) {
+ } else if (xevent->type == MappingNotify ||
+ (xevent->type == videodata->xkb_event && xkbEvent->any.xkb_type == XkbStateNotify)) {
/* Has the keyboard layout changed? */
const int request = xevent->xmapping.request;
diff --git a/src/video/x11/SDL_x11keyboard.c b/src/video/x11/SDL_x11keyboard.c
index 2d8c24c..2214ba3 100644
--- a/src/video/x11/SDL_x11keyboard.c
+++ b/src/video/x11/SDL_x11keyboard.c
@@ -278,7 +278,7 @@ X11_InitKeyboard(_THIS)
int xkb_major = XkbMajorVersion;
int xkb_minor = XkbMinorVersion;
- if (X11_XkbQueryExtension(data->display, NULL, NULL, NULL, &xkb_major, &xkb_minor)) {
+ if (X11_XkbQueryExtension(data->display, NULL, &data->xkb_event, NULL, &xkb_major, &xkb_minor)) {
data->xkb = X11_XkbGetMap(data->display, XkbAllClientInfoMask, XkbUseCoreKbd);
}
diff --git a/src/video/x11/SDL_x11video.h b/src/video/x11/SDL_x11video.h
index 1609674..26617e6 100644
--- a/src/video/x11/SDL_x11video.h
+++ b/src/video/x11/SDL_x11video.h
@@ -143,6 +143,7 @@ typedef struct SDL_VideoData
#if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
XkbDescPtr xkb;
#endif
+ int xkb_event;
KeyCode filter_code;
Time filter_time;