From 814576031455d2b1952c2d6d9b833c9ba4a8d126 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sat, 15 Aug 2015 00:36:39 -0400 Subject: [PATCH] X11: Handle keyboard layout changing during app's run on Ubuntu 12.04 (etc). Fixes Bugzilla #3050 (in addition to Jason Wyatt's patch, prior to this). --- src/video/x11/SDL_x11events.c | 11 +++++++++-- src/video/x11/SDL_x11video.c | 1 + src/video/x11/SDL_x11video.h | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index fd08f4e676af7..7ec4edf7536a5 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -1134,8 +1134,15 @@ X11_DispatchEvent(_THIS) } else { SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_RESTORED, 0, 0); } - } - + } + } else if (xevent.xproperty.atom == videodata->XKLAVIER_STATE) { + /* Hack for Ubuntu 12.04 (etc) that doesn't send MappingNotify + events when the keyboard layout changes (for example, + changing from English to French on the menubar's keyboard + icon). Since it changes the XKLAVIER_STATE property, we + notice and reinit our keymap here. This might not be the + right approach, but it seems to work. */ + X11_UpdateKeymap(_this); } } break; diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c index bc0eabdc95fa5..9d07438ea8e64 100644 --- a/src/video/x11/SDL_x11video.c +++ b/src/video/x11/SDL_x11video.c @@ -408,6 +408,7 @@ X11_VideoInit(_THIS) GET_ATOM(XdndDrop); GET_ATOM(XdndFinished); GET_ATOM(XdndSelection); + GET_ATOM(XKLAVIER_STATE); /* Detect the window manager */ X11_CheckWindowManager(_this); diff --git a/src/video/x11/SDL_x11video.h b/src/video/x11/SDL_x11video.h index 3fc273e2f1ef4..a544113eeefbc 100644 --- a/src/video/x11/SDL_x11video.h +++ b/src/video/x11/SDL_x11video.h @@ -111,6 +111,7 @@ typedef struct SDL_VideoData Atom XdndDrop; Atom XdndFinished; Atom XdndSelection; + Atom XKLAVIER_STATE; SDL_Scancode key_layout[256]; SDL_bool selection_waiting;