xpra icon
Bug tracker and wiki

Changeset 139 in xpra


Ignore:
Timestamp:
08/25/11 16:09:44 (21 months ago)
Author:
antoine
Message:

batch keymap updates together: piping key mapping to xkbcomp can make it fire hundreds of times and we don't want to fire 100s of updates over the wire.

Also send the new modifiers when the keymap changes so we can clear it and then re-apply it after setting the new keymap.

Location:
trunk/src/xpra
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/xpra/client.py

    r136 r139  
    354354        self._protocol = Protocol(conn, self.process_packet) 
    355355        ClientSource(self._protocol) 
     356 
     357        self._remote_version = None 
     358        self._keymap_changing = False 
     359        self._keymap = gtk.gdk.keymap_get_default() 
     360        self._do_keys_changed() 
    356361        self.send_hello() 
    357362 
    358         self._remote_version = None 
    359         self._keymap = gtk.gdk.keymap_get_default() 
    360363        self._keymap.connect("keys-changed", self._keys_changed) 
    361         self._do_keys_changed() 
    362  
    363364        self._xsettings_watcher = None 
    364365        self._root_props_watcher = None 
     
    423424    def _keys_changed(self, *args): 
    424425        self._keymap = gtk.gdk.keymap_get_default() 
    425         self._do_keys_changed(True) 
     426        if not self._keymap_changing: 
     427            self._keymap_changing = True 
     428            gobject.timeout_add(500, self._do_keys_changed, True) 
    426429 
    427430    def _do_keys_changed(self, sendkeymap=False): 
     431        self._keymap_changing = False 
    428432        self._modifier_map = grok_modifier_map(gtk.gdk.display_get_default()) 
    429433        if sendkeymap: 
     
    431435            self.query_xkbmap() 
    432436            log.info("keys_changed") 
    433             self.send(["keymap-changed", self.xkbmap_print, self.xkbmap_query, self.xmodmap_data]) 
     437            (_, _, current_mask) = gtk.gdk.get_default_root_window().get_pointer() 
     438            self.send(["keymap-changed", self.xkbmap_print, self.xkbmap_query, self.xmodmap_data, self.mask_to_names(current_mask)]) 
    434439 
    435440    def update_focus(self, id, gotit): 
     
    468473        if self.xmodmap_data: 
    469474            capabilities_request["xmodmap_data"] = self.xmodmap_data 
     475        (_, _, current_mask) = gtk.gdk.get_default_root_window().get_pointer() 
     476        modifiers = self.mask_to_names(current_mask) 
     477        log.debug("sending modifiers=%s" % str(modifiers)) 
     478        capabilities_request["modifiers"] = modifiers 
    470479        root_w, root_h = gtk.gdk.get_default_root_window().get_size() 
    471480        capabilities_request["desktop_size"] = [root_w, root_h] 
  • trunk/src/xpra/server.py

    r138 r139  
    677677    def _calculate_capabilities(self, client_capabilities): 
    678678        capabilities = {} 
    679         for cap in ("deflate", "__prerelease_version", "challenge_response", "jpeg", "keymap", "xkbmap_query", "xmodmap_data"): 
     679        for cap in ("deflate", "__prerelease_version", "challenge_response", "jpeg", "keymap", "xkbmap_query", "xmodmap_data", "modifiers"): 
    680680            if cap in client_capabilities: 
    681681                capabilities[cap] = client_capabilities[cap] 
     
    793793        if "jpeg" in capabilities: 
    794794            self._protocol.jpegquality = capabilities["jpeg"] 
    795         # clear the modifiers since this is a new client, if any are set they will be set on the next keypress 
    796         self._make_keymask_match([]) 
    797795        if "keymap" in capabilities: 
    798796            self.xkbmap_print = capabilities["keymap"] 
    799797            self.xkbmap_query = capabilities.get("xkbmap_query", None) 
    800798            self.xmodmap_data = capabilities.get("xmodmap_data", None) 
     799            #always clear modifiers before setting a new keymap 
     800            self._make_keymask_match([]) 
    801801            self.set_keymap() 
     802        # now we can set the modifiers to match the client 
     803        modifiers = capabilities.get("modifiers", []) 
     804        log.debug("setting modifiers to %s" % str(modifiers)) 
     805        self._make_keymask_match(modifiers) 
    802806        # We send the new-window packets sorted by id because this sorts them 
    803807        # from oldest to newest -- and preserving window creation order means 
     
    873877        if len(packet)==3: 
    874878            (_, self.xkbmap_print, self.xkbmap_query) = packet 
    875         elif len(packet)==4: 
    876             (_, self.xkbmap_print, self.xkbmap_query, self.xmodmap_data) = packet 
     879        elif len(packet)==5: 
     880            (_, self.xkbmap_print, self.xkbmap_query, self.xmodmap_data, modifiers) = packet 
     881        self._make_keymask_match([]) 
    877882        self.set_keymap() 
     883        self._make_keymask_match(modifiers) 
    878884 
    879885    def _process_key_action(self, proto, packet): 
Note: See TracChangeset for help on using the changeset viewer.