Skip to content

Commit

Permalink
include "keyboard.state" in xpra info
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@6426 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed May 9, 2014
1 parent 84daec8 commit 73c2f12
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/xpra/x11/server_keyboard_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def get_info(self):
v = getattr(self, "xkbmap_mod_"+x)
if v:
info["modifiers."+x] = v
info["state.modifiers"] = self.get_current_mask()
log("keyboard info: %s", "\n".join(["%s=%s" % (k,v) for k,v in info.items()]))
return info

Expand Down Expand Up @@ -293,6 +294,10 @@ def get_keycode(self, client_keycode, keyname, modifiers):
return keycode


def get_current_mask(self):
_, _, current_mask = gtk.gdk.get_default_root_window().get_pointer()
return mask_to_names(current_mask, self.modifier_map)

def make_keymask_match(self, modifier_list, ignored_modifier_keycode=None, ignored_modifier_keynames=None):
"""
Given a list of modifiers that should be set, try to press the right keys
Expand All @@ -313,10 +318,6 @@ def make_keymask_match(self, modifier_list, ignored_modifier_keycode=None, ignor
so we try to find the matching modifier in the currently pressed keys (keys_pressed)
to make sure we unpress the right one.
"""
def get_current_mask():
_, _, current_mask = gtk.gdk.get_default_root_window().get_pointer()
return mask_to_names(current_mask, self.modifier_map)

if not self.keynames_for_mod:
log("make_keymask_match: ignored as keynames_for_mod not assigned yet")
return
Expand All @@ -332,7 +333,7 @@ def is_ignored(modifier_keynames):
return True
return False

current = set(get_current_mask())
current = set(self.get_current_mask())
wanted = set(modifier_list)
if current==wanted:
return
Expand Down Expand Up @@ -378,15 +379,15 @@ def change_mask(modifiers, press, info):
X11Keyboard.xtest_fake_key(keycode, False)
else:
X11Keyboard.xtest_fake_key(keycode, press)
new_mask = get_current_mask()
new_mask = self.get_current_mask()
success = (modifier in new_mask)==press
log("make_keymask_match(%s) %s modifier %s using %s, success: %s", info, modifier_list, modifier, keycode, success)
if success:
break
elif not nuisance:
log("%s %s with keycode %s did not work - trying to undo it!", info, modifier, keycode)
X11Keyboard.xtest_fake_key(keycode, not press)
new_mask = get_current_mask()
new_mask = self.get_current_mask()
#maybe doing the full keypress (down+up or u+down) worked:
if (modifier in new_mask)==press:
break
Expand Down
2 changes: 2 additions & 0 deletions src/xpra/x11/x11_server_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ def do_get_info(self, proto, server_sources, window_ids):
fx = None
info["server.fakeXinerama"] = self.fake_xinerama and bool(fx)
info["server.libfakeXinerama"] = fx or ""
#this is added here because the server keyboard config doesn't know about "keys_pressed"..
info["keyboard.state.keys_pressed"] = list(self.keys_pressed.keys())
return info

def get_window_info(self, window):
Expand Down

0 comments on commit 73c2f12

Please sign in to comment.