Make sure the X event is an Xkb event before checking the Xkb event type

This commit is contained in:
Sam Lantinga 2021-11-10 12:46:54 -08:00
parent a1c125c1f5
commit eda4c40732
3 changed files with 4 additions and 2 deletions

View File

@ -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;

View File

@ -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);
}

View File

@ -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;