Skip to content

Commit

Permalink
#567: add missing "is_modifier" function that got lost during merge. …
Browse files Browse the repository at this point in the history
…Re-add it from "ServerBase.is_modifier" since we already use this flag for key repeat.

Note: this may be a bit more lax since we also match the modifier key by keysym, but this should also be fine.

git-svn-id: https://xpra.org/svn/Xpra/trunk@6522 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed May 20, 2014
1 parent ee01008 commit edf3d22
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/xpra/server/server_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1361,7 +1361,12 @@ def get_keycode(self, ss, client_keycode, keyname, modifiers):
return ss.get_keycode(client_keycode, keyname, modifiers)

def is_modifier(self, keyname, keycode):
return keyname in DEFAULT_MODIFIER_MEANINGS.keys()
if keyname in DEFAULT_MODIFIER_MEANINGS.keys():
return True
#keyboard config should always exist if we are here?
if self.keyboard_config:
return self.keyboard_config.is_modifier(keycode)
return False

def fake_key(self, keycode, press):
pass
Expand Down Expand Up @@ -1389,10 +1394,11 @@ def unpress():
if keycode in self.keys_pressed:
del self.keys_pressed[keycode]
self.fake_key(keycode, False)
is_mod = self.is_modifier(name, keycode)
if pressed:
if keycode not in self.keys_pressed:
press()
if not self.keyboard_sync and not self.keyboard_config.is_modifier(keycode):
if not self.keyboard_sync and not is_mod:
#keyboard is not synced: client manages repeat so unpress
#it immediately unless this is a modifier key
#(as modifiers are synced via many packets: key, focus and mouse events)
Expand All @@ -1404,7 +1410,6 @@ def unpress():
unpress()
else:
keylog("handle keycode %s: key %s was already unpressed, ignoring", keycode, name)
is_mod = self.is_modifier(name, keycode)
if not is_mod and self.keyboard_sync and self.key_repeat_delay>0 and self.key_repeat_interval>0:
self._key_repeat(wid, pressed, name, keyval, keycode, modifiers, self.key_repeat_delay)

Expand Down
9 changes: 9 additions & 0 deletions src/xpra/x11/server_keyboard_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,15 @@ def compute_modifier_map(self):
log("modifier_map(%s)=%s", self.xkbmap_mod_meanings, self.modifier_map)


def is_modifier(self, keycode):
for mod, keys in self.keycodes_for_modifier_keynames.items():
if keycode in keys:
log("is_modifier(%s) found modifier: %s", keycode, mod)
return True
log("is_modifier(%s) not found", keycode)
return False


def set_keymap(self):
if not self.enabled:
return
Expand Down

0 comments on commit edf3d22

Please sign in to comment.