xpra icon
Bug tracker and wiki

Ticket #817: win32-keyboard-layout-change.patch

File win32-keyboard-layout-change.patch, 4.7 KB (added by Antoine Martin, 5 years ago)

relatively unobtrusive patch

  • xpra/client/client_window_base.py

     
    6767        self.update_metadata(metadata)
    6868
    6969
     70    def keyboard_layout_changed(self, *args):
     71        #used by win32 hooks to tell us about keyboard layout changes for this window
     72        log.info("keyboard_layout_changed%s", args)
     73        self._client.window_keyboard_layout_changed(self)
     74
     75
    7076    def get_desktop_workspace(self):
    7177        return None
    7278
  • xpra/client/gtk_base/gtk_keyboard_helper.py

     
    2727            self._keymap = None
    2828        self.update()
    2929        if self._keymap:
    30             self._keymap_change_handler_id = self._keymap.connect("keys-changed", self._keys_changed)
     30            self._keymap_change_handler_id = self._keymap.connect("keys-changed", self.keymap_changed)
    3131
    32     def _keys_changed(self, *args):
    33         log("keys_changed")
     32    def keymap_changed(self, *args):
     33        log("keymap_changed%s", args)
    3434        self._keymap.disconnect(self._keymap_change_handler_id)
    3535        self._keymap = gdk.keymap_get_default()
    36         self._keymap_change_handler_id = self._keymap.connect("keys-changed", self._keys_changed)
     36        self._keymap_change_handler_id = self._keymap.connect("keys-changed", self.keymap_changed)
    3737        if self._keymap_changing:
    3838            #timer due already
    3939            return
  • xpra/client/keyboard_helper.py

     
    5858            pass
    5959        self.send = nosend
    6060
     61    def keymap_changed(self, *args):
     62        pass
    6163
     64
    6265    def parse_shortcuts(self, strs):
    6366        #TODO: maybe parse with re instead?
    6467        if len(strs)==0:
  • xpra/client/ui_client_base.py

     
    18611861        #subclasses that wish to implement the feature may override this method
    18621862        return None
    18631863
     1864    def window_keyboard_layout_changed(self, window):
     1865        #win32 can change the keyboard mapping per window...
     1866        log.info("window_keyboard_layout_changed(%s)", window)
     1867        if self.keyboard_helper:
     1868            self.keyboard_helper.keymap_changed()
    18641869
     1870
    18651871    def get_client_window_classes(self, metadata, override_redirect):
    18661872        return [self.ClientWindowClass]
    18671873
  • xpra/platform/win32/gui.py

     
    196196
    197197    #glue code for gtk to win32 APIs:
    198198    #add event hook class:
    199     win32hooks = Win32Hooks(handle)
     199    win32hooks = Win32Hooks(handle, window.keyboard_layout_changed)
    200200    log("add_window_hooks(%s) added hooks for hwnd %#x: %s", window, handle, win32hooks)
    201201    window.win32hooks = win32hooks
    202202    win32hooks.max_size = None
  • xpra/platform/win32/window_hooks.py

     
    3434
    3535class Win32Hooks(object):
    3636
    37     def __init__(self, hwnd):
     37    def __init__(self, hwnd, language_change_cb=None):
    3838        self._hwnd = hwnd
     39        self._language_change_cb = language_change_cb
    3940        self._message_map = {
    4041                     win32con.WM_GETMINMAXINFO          : self.on_getminmaxinfo,
     42                     #win32con.WM_INPUTLANGCHANGEREQUEST : self.on_inputlangchange,
     43                     win32con.WM_INPUTLANGCHANGE        : self.on_inputlangchange,
    4144                     }
    4245        self.max_size = None
    4346        self._oldwndproc = win32gui.SetWindowLong(hwnd, win32con.GWL_WNDPROC, self._wndproc)
     
    5255            self.caption_height = 26
    5356        log("Win32Hooks: window frame size is %sx%s", self.frame_width, self.frame_height)
    5457
     58    def on_inputlangchange(self, hwnd, msg, wparam, lparam):
     59        log.info("on_inputlangchange%s", (hwnd, msg, wparam, lparam))
     60        if self._language_change_cb:
     61            self._language_change_cb()
     62
    5563    def on_getminmaxinfo(self, hwnd, msg, wparam, lparam):
    5664        if self.max_size:
    5765            info = ctypes.cast(lparam, ctypes.POINTER(MINMAXINFO)).contents