xpra icon
Bug tracker and wiki

Changeset 127 in xpra


Ignore:
Timestamp:
08/14/11 21:01:07 (22 months ago)
Author:
antoine
Message:

detect changes to the client keymap and apply them immediately (new protocol message - will be ignored by older clients)

Location:
trunk/src/xpra
Files:
3 edited

Legend:

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

    r120 r127  
    326326 
    327327    def __init__(self, conn, compression_level, jpegquality, title, password_file, 
    328                  pulseaudio, clipboard, refresh_delay, max_bandwidth, opts, xkbmap_print, xkbmap_query): 
     328                 pulseaudio, clipboard, refresh_delay, max_bandwidth, opts): 
    329329        gobject.GObject.__init__(self) 
    330330        self._window_to_id = {} 
     
    336336        self.refresh_delay = refresh_delay 
    337337        self.max_bandwidth = max_bandwidth 
    338         self.xkbmap_print = xkbmap_print 
    339         self.xkbmap_query = xkbmap_query 
    340338        if self.max_bandwidth>0.0 and self.jpegquality==0: 
    341339            """ jpegquality was not set, use a better start value """ 
     
    348346        self._keymap = gtk.gdk.keymap_get_default() 
    349347        self._keymap.connect("keys-changed", self._keys_changed) 
    350         self._keys_changed() 
     348        self._do_keys_changed() 
    351349 
    352350        self._xsettings_watcher = None 
     
    387385        gtk.main() 
    388386 
     387    def query_xkbmap(self): 
     388        def get_xkbmap_data(arg): 
     389            # Find the client's current keymap so we can send it to the server: 
     390            try: 
     391                import subprocess 
     392                cmd = ["setxkbmap", arg] 
     393                process = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False) 
     394                (out,_) = process.communicate(None) 
     395                if process.returncode==0: 
     396                    return out 
     397                else: 
     398                    log.error("'setxkbmap %s' failed with exit code %s\n" % (arg, process.returncode)) 
     399            except Exception, e: 
     400                log.error("error running 'setxkbmap %s': %s\n" % (arg, e)) 
     401                return None 
     402        self.xkbmap_print = get_xkbmap_data("-print") 
     403        self.xkbmap_query = get_xkbmap_data("-query") 
     404 
    389405    def _keys_changed(self, *args): 
     406        self._do_keys_changed(True) 
     407 
     408    def _do_keys_changed(self, sendkeymap=False): 
    390409        self._modifier_map = grok_modifier_map(gtk.gdk.display_get_default()) 
     410        if sendkeymap: 
     411            #old clients won't know what to do with it, but that's ok 
     412            self.query_xkbmap() 
     413            log.info("keys_changed") 
     414            self.send(["keymap-changed", self.xkbmap_print, self.xkbmap_query]) 
    391415 
    392416    def update_focus(self, id, gotit): 
     
    418442        if self.jpegquality: 
    419443            capabilities_request["jpeg"] = self.jpegquality 
     444        self.query_xkbmap() 
    420445        if self.xkbmap_print: 
    421446            capabilities_request["keymap"] = self.xkbmap_print 
  • trunk/src/xpra/scripts/main.py

    r120 r127  
    289289        title = "@title@ %s" % opts.title_suffix 
    290290 
    291     def get_xkbmap_data(arg): 
    292     # Find the client's current keymap so we can send it to the server: 
    293         try: 
    294             import subprocess 
    295             cmd = ["setxkbmap", arg] 
    296             process = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False) 
    297             (out,_) = process.communicate(None) 
    298             if process.returncode==0: 
    299                 return out 
    300             else: 
    301                 sys.stdout.write("'setxkbmap %s' failed with exit code %s\n" % (arg, process.returncode)) 
    302         except Exception, e: 
    303             sys.stdout.write("error running 'setxkbmap %s': %s\n" % (arg, e)) 
    304             return None 
    305     xkbmap_print = get_xkbmap_data("-print") 
    306     xkbmap_query = get_xkbmap_data("-query") 
    307291    app = XpraClient(conn, opts.compression_level, opts.jpegquality, title, opts.password_file, 
    308292                     opts.pulseaudio, opts.clipboard, 
    309                      opts.auto_refresh_delay, opts.max_bandwidth, opts, xkbmap_print, xkbmap_query) 
     293                     opts.auto_refresh_delay, opts.max_bandwidth, opts) 
    310294    app.connect("handshake-complete", handshake_complete_msg) 
    311295    app.connect("received-gibberish", got_gibberish_msg) 
  • trunk/src/xpra/server.py

    r122 r127  
    846846        (_, id) = packet 
    847847        self._focus(id) 
     848     
     849    def _process_keymap(self, proto, packet): 
     850        (_, keymap, xkbmap_query) = packet 
     851        self.set_keymap(keymap, xkbmap_query) 
    848852 
    849853    def _process_key_action(self, proto, packet): 
     
    929933        "focus": _process_focus, 
    930934        "key-action": _process_key_action, 
     935        "keymap-changed": _process_keymap, 
    931936        "button-action": _process_button_action, 
    932937        "pointer-position": _process_pointer_position, 
Note: See TracChangeset for help on using the changeset viewer.