xpra icon
Bug tracker and wiki

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


Ticket #817: per-window-layouts.patch

File per-window-layouts.patch, 7.5 KB (added by Antoine Martin, 6 years ago)

adds code to support different layouts on each window and switch on focus

  • xpra/client/client_window_base.py

     
    1616focuslog = Logger("focus")
    1717mouselog = Logger("mouse")
    1818workspacelog = Logger("workspace")
    19 keylog = Logger("keyboard")
     19layoutlog = Logger("layout")
    2020metalog = Logger("metadata")
    2121
    2222
     
    4949        self._focused = False
    5050        self.border = border
    5151        self.max_window_size = max_window_size
     52        self.keyboard_layout = None
    5253        self.button_state = {}
    5354
    5455        self.init_window(metadata)
     
    583584
    584585    def keyboard_layout_changed(self, *args):
    585586        #used by win32 hooks to tell us about keyboard layout changes for this window
    586         keylog("keyboard_layout_changed%s", args)
     587        layoutlog("keyboard_layout_changed%s", args)
    587588        self._client.window_keyboard_layout_changed(self)
    588589
    589590
  • xpra/client/gtk_base/gtk_keyboard_helper.py

     
    3939            #timer due already
    4040            return
    4141        self._keymap_changing = True
    42         def do_keys_changed():
     42        glib.timeout_add(500, self.do_keymap_changed)
     43
     44    def do_keymap_changed(self):
     45        if not self._keymap_change_handler_id:
    4346            #re-register the change handler:
    4447            self._keymap_change_handler_id = self._keymap.connect("keys-changed", self.keymap_changed)
    45             self._keymap_changing = False
    46             if self.locked:
    47                 #automatic changes not allowed!
    48                 log.info("ignoring keymap change: layout is locked to '%s'", self.layout_str())
    49                 return
    50             if self.update():
    51                 log.info("keymap has been changed to '%s', sending updated mappings to the server", self.layout_str())
    52                 if self.xkbmap_layout:
    53                     self.send_layout()
    54                 self.send_keymap()
    55         glib.timeout_add(500, do_keys_changed)
     48        self._keymap_changing = False
     49        if self.locked:
     50            #automatic changes not allowed!
     51            log.info("ignoring keymap change: layout is locked to '%s'", self.layout_str())
     52            return
     53        if self.update():
     54            log.info("keymap has been changed to '%s', sending updated mappings to the server", self.layout_str())
     55            if self.xkbmap_layout:
     56                self.send_layout()
     57            self.send_keymap()
    5658
    5759    def update(self):
    5860        old_hash = self.hash
  • xpra/client/keyboard_helper.py

     
    77
    88from xpra.log import Logger
    99log = Logger("keyboard")
     10layoutlog = Logger("layout")
    1011
    1112from xpra.keyboard.mask import DEFAULT_MODIFIER_MEANINGS, DEFAULT_MODIFIER_NUISANCE
    1213from xpra.util import nonl, csv
     
    276277
    277278
    278279    def send_layout(self):
    279         log("send_layout()")
     280        layoutlog("send_layout()")
    280281        self.send("layout-changed", self.xkbmap_layout or "", self.xkbmap_variant or "")
    281282
    282283    def send_keymap(self):
    283         log("send_keymap()")
     284        layoutlog("send_keymap()")
    284285        self.send("keymap-changed", self.get_keymap_properties())
    285286
    286287
  • xpra/client/ui_client_base.py

     
    2323soundlog = Logger("client", "sound")
    2424traylog = Logger("client", "tray")
    2525keylog = Logger("client", "keyboard")
     26layoutlog = Logger("client", "layout")
    2627workspacelog = Logger("client", "workspace")
    2728rpclog = Logger("client", "rpc")
    2829grablog = Logger("client", "grab")
     
    8586
    8687RPC_TIMEOUT = int(os.environ.get("XPRA_RPC_TIMEOUT", "5000"))
    8788
     89PER_WINDOW_LAYOUTS = os.environ.get("XPRA_PER_WINDOW_LAYOUTS", "1")=="1"
    8890
     91
    8992"""
    9093Utility superclass for client classes which have a UI.
    9194See gtk_client_base and its subclasses.
     
    142145        self.server_max_desktop_size = None
    143146        self.server_display = None
    144147        self.server_randr = False
     148        self.server_fast_keyboard_switching = False
    145149        self.pixel_counter = deque(maxlen=1000)
    146150        self.server_ping_latency = deque(maxlen=1000)
    147151        self.server_load = None
     
    243247        #helpers and associated flags:
    244248        self.client_extras = None
    245249        self.keyboard_helper = None
     250        self.current_window_keyboard_layout = None
    246251        self.kh_warning = False
    247252        self.clipboard_helper = None
    248253        self.menu_helper = None
     
    10131018
    10141019    def window_keyboard_layout_changed(self, window):
    10151020        #win32 can change the keyboard mapping per window...
    1016         keylog("window_keyboard_layout_changed(%s)", window)
    1017         if self.keyboard_helper:
    1018             self.keyboard_helper.keymap_changed()
     1021        wid = self._window_to_id.get(window)
     1022        layoutlog("window_keyboard_layout_changed(%s) wid=%s, focus=%s, fast_keyboard_switching=%s", window, wid, self._focused, self.server_fast_keyboard_switching)
     1023        if self.keyboard_helper and (wid==self._focused or self._focused is None):
     1024            if self.server_fast_keyboard_switching:
     1025                self.keyboard_helper.do_keymap_changed()
     1026                window.keyboard_layout = self.keyboard_helper.hash
     1027                self.current_window_keyboard_layout = self.keyboard_helper.hash
     1028            else:
     1029                self.keyboard_helper.keymap_changed()
    10191030
    10201031    def get_keymap_properties(self):
    10211032        props = self.keyboard_helper.get_keymap_properties()
     
    10511062                self.keyboard_helper.clear_repeat()
    10521063            self.send_focus(wid)
    10531064            self._focused = wid
     1065            #check if the new window getting the focus uses a different layout:
     1066            window = self._id_to_window.get(wid)
     1067            if window and self.server_fast_keyboard_switching and PER_WINDOW_LAYOUTS:
     1068                layoutlog("focusing window %i with layout %s, current layout %s", wid, window.keyboard_layout, self.current_window_keyboard_layout)
     1069                self.window_keyboard_layout_changed(window)
    10541070        if not gotit:
    10551071            if self._window_with_grab:
    10561072                self.window_ungrab()
     
    16141630        log("server actual desktop size=%s", self.server_actual_desktop_size)
    16151631        self.server_randr = c.boolget("resize_screen")
    16161632        log("server has randr: %s", self.server_randr)
     1633        self.server_fast_keyboard_switching = c.boolget("keyboard.fast-switching")
    16171634        self.server_sound_sequence = c.boolget("sound_sequence")
    16181635        self.server_sound_eos_sequence = c.boolget("sound.eos-sequence")
    16191636        self.server_av_sync = c.boolget("av-sync.enabled")
  • xpra/log.py

     
    143143                ("printing"     , "Printing"),
    144144                ("file"         , "File transfers"),
    145145                ("keyboard"     , "Keyboard mapping and key event handling"),
     146                ("layout"       , "Keyboard layout"),
    146147                ("screen"       , "Screen and workarea dimension"),
    147148                ("fps"          , "Frames per second"),
    148149                ("xsettings"    , "XSettings synchronization"),