X11: Call XRefreshKeyboardMapping() when we get various MappingNotify events.
authorRyan C. Gordon
Tue, 30 Jun 2015 14:41:17 -0400
changeset 9788ecda7d71342e
parent 9787 08b2895a935a
child 9789 137993bad5c7
X11: Call XRefreshKeyboardMapping() when we get various MappingNotify events.

According to the Xlib docs, you need to do this or Xlib's internal state gets
out of sync.
src/video/x11/SDL_x11events.c
src/video/x11/SDL_x11sym.h
     1.1 --- a/src/video/x11/SDL_x11events.c	Tue Jun 30 14:39:39 2015 -0400
     1.2 +++ b/src/video/x11/SDL_x11events.c	Tue Jun 30 14:41:17 2015 -0400
     1.3 @@ -649,9 +649,15 @@
     1.4              }
     1.5          } else if (xevent.type == MappingNotify) {
     1.6              /* Has the keyboard layout changed? */
     1.7 +            const int request = xevent.xmapping.request;
     1.8 +
     1.9  #ifdef DEBUG_XEVENTS
    1.10              printf("window %p: MappingNotify!\n", data);
    1.11  #endif
    1.12 +            if ((request == MappingKeyboard) || (request == MappingModifier)) {
    1.13 +                X11_XRefreshKeyboardMapping(&xevent.xmapping);
    1.14 +            }
    1.15 +
    1.16              X11_UpdateKeymap(_this);
    1.17          }
    1.18          return;
     2.1 --- a/src/video/x11/SDL_x11sym.h	Tue Jun 30 14:39:39 2015 -0400
     2.2 +++ b/src/video/x11/SDL_x11sym.h	Tue Jun 30 14:41:17 2015 -0400
     2.3 @@ -152,6 +152,7 @@
     2.4  SDL_X11_SYM(SDL_X11_XSynchronizeRetType,XSynchronize,(Display* a,Bool b),(a,b),return)
     2.5  SDL_X11_SYM(SDL_X11_XESetWireToEventRetType,XESetWireToEvent,(Display* a,int b,SDL_X11_XESetWireToEventRetType c),(a,b,c),return)
     2.6  SDL_X11_SYM(SDL_X11_XESetEventToWireRetType,XESetEventToWire,(Display* a,int b,SDL_X11_XESetEventToWireRetType c),(a,b,c),return)
     2.7 +SDL_X11_SYM(void,XRefreshKeyboardMapping,(XMappingEvent *a),(a),)
     2.8  
     2.9  #if SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS
    2.10  SDL_X11_SYM(Bool,XGetEventData,(Display* a,XGenericEventCookie* b),(a,b),return)