Xpra: Ticket #50: a trick for transferring keyboard modifiers to xpra server

at present xpra client only transfers the output of "xmodmap -pke" to xpra server. this is enough for simple cases.

However if xmodmap_data contains modifications of keyboard modifiers like Shift_L Control_R, xmodmap in xpra server usually screws up.

We'd better clear the relavent modifiers and readd them after applying keymap table from "xmodmap -pke".

Unfortunately xmodmap do not have a "-pme" feature. I came up with a quick hack by make a wrapper of xmodmap to print "clear" and "add" clauses around keymap table.

Mon, 28 Nov 2011 08:31:15 GMT - Heroxbd: attachment set

xmodmap wrapper

Mon, 28 Nov 2011 11:28:08 GMT - Antoine Martin: owner, status changed

Thanks! Will do some thorough testing and assuming all goes well, merge it. (too late for though... building as we speak)

What are the keys that you were having problems with? Also, what is your client and server OS? Does your setxkbmap understand the "-query" option? (I have found this to be sufficient in almost all cases - as relying on just "-print" is not always enough..)

Mon, 28 Nov 2011 18:13:27 GMT - Antoine Martin:

btw, here is a patch that does the same thing from the client code:

Index: xpra/xposix/gui.py
--- xpra/xposix/gui.py	(revision 310)
+++ xpra/xposix/gui.py	(working copy)
@@ -244,11 +244,26 @@
             log.error("the server will try to guess your keyboard mapping, which works reasonably well in most cases");
             log.error("however, upgrading 'setxkbmap' to a version that supports the '-query' parameter is preferred");
         xmodmap_data = get_keyboard_data("xmodmap", "-pke");
+        if xmodmap_data:
+            #try to ensure the modifiers are set properly:
+            clear_modifiers = """clear Lock
+clear Ctrl
+clear mod1
+clear mod4
+clear shift
+            set_modifiers = """
+add Ctrl = Control_L Control_R
+add mod1 = Alt_L Alt_R
+add mod4 = Super_L Super_R
+add shift = Shift_L Shift_R
+            xmodmap_data = clear_modifiers + xmodmap_data + set_modifiers
         return xkbmap_print, xkbmap_query, xmodmap_data
     def get_keyboard_repeat(self):

Does that also work for you?

Sat, 03 Dec 2011 20:52:38 GMT - Antoine Martin: status changed; resolution set

not heard back, but r325 does something better: rather than hardcoding those values, we parse the output from "xmodmap -pm" and generate the clear/add lines on the fly

Mon, 20 Feb 2012 20:13:44 GMT - Antoine Martin: version, milestone changed

Sat, 23 Jan 2021 04:44:11 GMT - migration script:

this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/50