xpra icon
Bug tracker and wiki

This bug tracker and wiki are being discontinued
please use https://github.com/Xpra-org/xpra instead.


Ticket #1380: x11-sync-xkb-layout-group.patch

File x11-sync-xkb-layout-group.patch, 4.3 KB (added by Antoine Martin, 4 years ago)

original patch

  • xpra-1.0/xpra/server/server_base.py

    diff -aur src.org/xpra-1.0/xpra/server/server_base.py src.mod/xpra-1.0/xpra/server/server_base.py
    old new  
    9292        ServerCore.__init__(self)
    9393        log("ServerBase.__init__()")
    9494        self.init_uuid()
     95        self.recent_layout_group = False
    9596
    9697        # This must happen early, before loading in windows at least:
    9798        self._server_sources = {}
     
    25732574        modifiers = props.get("modifiers", [])
    25742575        ss.make_keymask_match(modifiers)
    25752576
     2577    def set_layout_group(self, grp):
     2578        log.info('Server does not support layouts group selecting')
     2579        return grp
     2580
    25762581    def _process_key_action(self, proto, packet):
    25772582        if self.readonly:
    25782583            return
    2579         wid, keyname, pressed, modifiers, keyval, _, client_keycode = packet[1:8]
     2584        wid, keyname, pressed, modifiers, keyval, _, client_keycode, group = packet[1:9]
    25802585        #group = packet[8] #unused!
     2586        if group != self.recent_layout_group:
     2587            self.recent_layout_group = self.set_layout_group(group)
    25812588        ss = self._server_sources.get(proto)
    25822589        if ss is None:
    25832590            return
  • xpra-1.0/xpra/x11/bindings/keyboard_bindings.pyx

    diff -aur src.org/xpra-1.0/xpra/x11/bindings/keyboard_bindings.pyx src.mod/xpra-1.0/xpra/x11/bindings/keyboard_bindings.pyx
    old new  
    5151    ctypedef CARD32 XID
    5252
    5353    ctypedef int Bool
     54    ctypedef int Status
    5455    ctypedef CARD32 Atom
    5556    ctypedef XID Window
    5657    ctypedef XID KeySym
     
    9293    int XUngrabKey(Display * display, int keycode, unsigned int modifiers,
    9394                   Window grab_window)
    9495    int XQueryKeymap(Display * display, char [32] keys_return)
     96    int XFlush(Display *dpy)
    9597
    9698
    9799
     
    99101    unsigned long XkbUseCoreKbd
    100102    unsigned long XkbDfltXIId
    101103    unsigned long XkbBellNotifyMask
     104    unsigned long XkbMapNotifyMask
     105    unsigned long XkbStateNotifyMask
    102106    unsigned int XkbGBN_AllComponentsMask
    103107    unsigned int XkbGBN_GeometryMask
    104108
     
    114118    ctypedef struct XkbDescRec:
    115119        pass
    116120    ctypedef XkbDescRec* XkbDescPtr
     121    ctypedef struct _XkbStateRec:
     122        unsigned char   group
     123        pass
     124    ctypedef _XkbStateRec XkbStateRec
     125    ctypedef _XkbStateRec *XkbStatePtr
    117126
    118127
    119128cdef extern from "X11/extensions/XKBrules.h":
     
    155164
    156165    XkbDescPtr XkbGetKeyboardByName(Display *display, unsigned int deviceSpec, XkbComponentNamesPtr names,
    157166                                    unsigned int want, unsigned int need, Bool load)
     167    Status XkbGetState(Display *dpy, unsigned int deviceSpec, XkbStatePtr statePtr)
     168    Bool   XkbLockGroup(Display *dpy, unsigned int deviceSpec, unsigned int group)
    158169
    159170
    160171cdef extern from "X11/extensions/XTest.h":
     
    347358            log("X11 keymap property updated: %s", self.getXkbProperties())
    348359        return True
    349360
     361    # honestly stealed from https://pypi.python.org/pypi/xkbgroup/0.1.4.1 :)
     362    # (which does not work in 3.5 though and is too huge by itself for this simple task)
     363    # from here
     364    def set_layout_group(self, grp):
     365        log("Setting XKB layout group `%s`", grp)
     366        if XkbLockGroup(self.display, XkbUseCoreKbd, grp):
     367            XFlush(self.display)
     368        else:
     369            log.warn("Cannot lock on layout group `%s`", grp)
     370        return self.get_layout_group()
     371
     372    def get_layout_group(self):
     373        cdef XkbStateRec xkb_state = XkbStateRec()
     374        XkbGetState(self.display, XkbUseCoreKbd, &xkb_state)
     375        return xkb_state.group
     376    #till here
    350377
    351378    def hasXkb(self):
    352379        if self.Xkb_checked:
  • xpra-1.0/xpra/x11/x11_server_base.py

    diff -aur src.org/xpra-1.0/xpra/x11/x11_server_base.py src.mod/xpra-1.0/xpra/x11/x11_server_base.py
    old new  
    195195        #clear all modifiers
    196196        clean_keyboard_state()
    197197
     198    def set_layout_group(self, grp):
     199        return X11Keyboard.set_layout_group(grp)
    198200
    199201    def init_packet_handlers(self):
    200202        GTKServerBase.init_packet_handlers(self)