X11: Handle keyboard layout changing during app's run on Ubuntu 12.04 (etc).
authorRyan C. Gordon <icculus@icculus.org>
Sat, 15 Aug 2015 00:36:39 -0400
changeset 984541ce18cb4b3b
parent 9844 7e9624bde3a7
child 9846 9f0a0c7de41a
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
src/video/x11/SDL_x11video.c
src/video/x11/SDL_x11video.h
     1.1 --- a/src/video/x11/SDL_x11events.c	Fri Aug 14 23:38:40 2015 -0400
     1.2 +++ b/src/video/x11/SDL_x11events.c	Sat Aug 15 00:36:39 2015 -0400
     1.3 @@ -1134,8 +1134,15 @@
     1.4                      } else {
     1.5                          SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_RESTORED, 0, 0);
     1.6                      }
     1.7 -                 }
     1.8 -
     1.9 +                }
    1.10 +            } else if (xevent.xproperty.atom == videodata->XKLAVIER_STATE) {
    1.11 +                /* Hack for Ubuntu 12.04 (etc) that doesn't send MappingNotify
    1.12 +                   events when the keyboard layout changes (for example,
    1.13 +                   changing from English to French on the menubar's keyboard
    1.14 +                   icon). Since it changes the XKLAVIER_STATE property, we
    1.15 +                   notice and reinit our keymap here. This might not be the
    1.16 +                   right approach, but it seems to work. */
    1.17 +                X11_UpdateKeymap(_this);
    1.18              }
    1.19          }
    1.20          break;
     2.1 --- a/src/video/x11/SDL_x11video.c	Fri Aug 14 23:38:40 2015 -0400
     2.2 +++ b/src/video/x11/SDL_x11video.c	Sat Aug 15 00:36:39 2015 -0400
     2.3 @@ -408,6 +408,7 @@
     2.4      GET_ATOM(XdndDrop);
     2.5      GET_ATOM(XdndFinished);
     2.6      GET_ATOM(XdndSelection);
     2.7 +    GET_ATOM(XKLAVIER_STATE);
     2.8  
     2.9      /* Detect the window manager */
    2.10      X11_CheckWindowManager(_this);
     3.1 --- a/src/video/x11/SDL_x11video.h	Fri Aug 14 23:38:40 2015 -0400
     3.2 +++ b/src/video/x11/SDL_x11video.h	Sat Aug 15 00:36:39 2015 -0400
     3.3 @@ -111,6 +111,7 @@
     3.4      Atom XdndDrop;
     3.5      Atom XdndFinished;
     3.6      Atom XdndSelection;
     3.7 +    Atom XKLAVIER_STATE;
     3.8  
     3.9      SDL_Scancode key_layout[256];
    3.10      SDL_bool selection_waiting;