xpra icon
Bug tracker and wiki

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


Ticket #13: release-keys-on-unfocus1.diff

File release-keys-on-unfocus1.diff, 2.1 KB (added by Timo Juhani Lindfors, 10 years ago)

proof-of-concept to fix the bug

  • src/xpra/client.py

    diff --git a/src/xpra/client.py b/src/xpra/client.py
    index 7339c87..a5ba8ab 100644
    a b class ClientWindow(gtk.Window): 
    7373        self._failed_pixbuf_index = 0
    7474        self._refresh_timer = None
    7575        self._refresh_requested = 0
     76        self._heldKeys = {}
    7677
    7778        self.update_metadata(metadata)
    7879
    class ClientWindow(gtk.Window): 
    279280            """ for versions newer than 0.0.7.24, we send ALL the raw information we have """
    280281            keycode = event.hardware_keycode
    281282            log.debug("key_action(%s,%s) modifiers=%s, name=%s, state=%s, keyval=%s, string=%s, keycode=%s" % (event, depressed, modifiers, name, event.state, event.keyval, event.string, keycode))
    282             self._client.send(["key-action", self._id, nn(name), depressed, modifiers, nn(event.keyval), nn(event.string), nn(keycode)])
     283            keyEvent = ["key-action", self._id, nn(name), depressed, modifiers, nn(event.keyval), nn(event.string), nn(keycode)]
     284            self._client.send(keyEvent)
     285            if depressed:
     286                assert(keyEvent[3])
     287                self._heldKeys[nn(keycode)] = keyEvent[:]
     288            else:
     289                if nn(keycode) in self._heldKeys:
     290                    del self._heldKeys[nn(keycode)]
    283291        else:
    284292            """ versions before 0.0.7.24 only accept 4 parameters (no keyval, keycode, ...) """
    285293            if name is not None:
    286294                self._client.send(["key-action", self._id, nn(name), depressed, modifiers])
    287295
     296    def release_keys(self):
     297        for keyEvent in self._heldKeys.values():
     298            assert(keyEvent[3])
     299            keyEvent[3] = False
     300            self._client.send(keyEvent)
     301        self._heldKeys = {}
     302
    288303    def do_key_press_event(self, event):
    289304        self._key_action(event, True)
    290305
    class XpraClient(gobject.GObject): 
    436451            self.send(["focus", id])
    437452            self._focused = id
    438453        if not gotit and self._focused is id:
     454            assert id > 0
     455            self._id_to_window[id].release_keys()
    439456            self.send(["focus", 0])
    440457            self._focused = None
    441458