Xpra-org / xpra

Persistent remote applications for X11; screen sharing for X11, MacOS and MSWindows.
https://xpra.org/
GNU General Public License v2.0
1.99k stars 169 forks source link

Page_Up, Page_Down translated to \, Menu #4396

Open donaldsycamore opened 1 month ago

donaldsycamore commented 1 month ago

Describe the bug On Debian Bookworm (latest stable), with Xpra installed via Xpra-provided debian packages, with GNOME 3 & Wayland, in Seamless mode, and US keymap, Page_Up on the client is translated to the "\" key, and Page_Down is translated to Menu.

  1. server command: xpra start --start=xfce4-terminal
  2. client command: xpra gui -> connect -> SSH, username & hostname -> copnnect
  3. xpra toolbox -> Keyboard running in a normal login session correctly shows Page_Up and Page_Down. xpra toolbox -> Keyboard running on the Xpra server shows KP_Divide and Menu

System Information (please complete the following information):

Additional context

2024-10-18 09:19:22,706 parse_key_event(<Gdk.EventKey object at 0x7fac347e0be0 (void at 0x3bbc3640)>, True)=KeyEvent(modifiers=['mod2'], keyname=Page_Down, keyval=65366, keycode=117, group=0, string=, pressed=True)
2024-10-18 09:19:22,706 handle_key_action(GLClientWindow(7 : GLAreaBacking(0x7, (1440, 1011))), KeyEvent(modifiers=['mod2'], keyname=Page_Down, keyval=65366, keycode=117, group=0, string=, pressed=True)) wid=7
2024-10-18 09:19:22,707 key_handled_as_shortcut(GLClientWindow(7 : GLAreaBacking(0x7, (1440, 1011))), 'Page_Down', ['mod2'], True) shortcuts_enabled=True, shortcuts=None
2024-10-18 09:19:22,707 send_key_action(7, KeyEvent(modifiers=['mod2'], keyname=Page_Down, keyval=65366, keycode=117, group=0, string=, pressed=True))
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/xpra/client/base/client.py", line 1253, in call_handler
    handler(packet)
  File "/usr/lib/python3/dist-packages/xpra/client/mixins/windows.py", line 1251, in _process_new_override_redirect
    return self._process_new_common(packet, True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/xpra/client/mixins/windows.py", line 955, in _process_new_common
    return self.make_new_window(wid, wx, wy, ww, wh, bw, bh, metadata, override_redirect, client_properties)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/xpra/client/mixins/windows.py", line 992, in make_new_window
    self.patch_OR_popup_transient_for(metadata)
  File "/usr/lib/python3/dist-packages/xpra/client/mixins/windows.py", line 974, in patch_OR_popup_transient_for
    twid = self._find_pid_focused_window(pid, True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/xpra/client/mixins/windows.py", line 959, in _find_pid_focused_window
    if twin._override_redirect != OR:
       ^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'ClientTray' object has no attribute '_override_redirect'
2024-10-18 09:19:22,805 parse_key_event(<Gdk.EventKey object at 0x7fac347e28f0 (void at 0x3d231470)>, False)=KeyEvent(modifiers=['mod2'], keyname=Page_Down, keyval=65366, keycode=117, group=0, string=, pressed=False)
2024-10-18 09:19:22,805 handle_key_action(GLClientWindow(7 : GLAreaBacking(0x7, (1440, 1011))), KeyEvent(modifiers=['mod2'], keyname=Page_Down, keyval=65366, keycode=117, group=0, string=, pressed=False)) wid=7
2024-10-18 09:19:22,805 key_handled_as_shortcut(GLClientWindow(7 : GLAreaBacking(0x7, (1440, 1011))), 'Page_Down', ['mod2'], False) shortcuts_enabled=True, shortcuts=None
2024-10-18 09:19:22,805 send_key_action(7, KeyEvent(modifiers=['mod2'], keyname=Page_Down, keyval=65366, keycode=117, group=0, string=, pressed=False))

Keyboard debugging on the client shows logs like:

PageUp:

2024-10-18 09:18:38,840 parse_key_event(<Gdk.EventKey object at 0x7fac347e0500 (void at 0x3d231330)>, True)=KeyEvent(modifiers=['mod2'], keyname=Page_Up, keyval=65365, keycode=112, group=0, string=, pressed=True)
2024-10-18 09:18:38,840 handle_key_action(GLClientWindow(7 : GLAreaBacking(0x7, (1440, 1011))), KeyEvent(modifiers=['mod2'], keyname=Page_Up, keyval=65365, keycode=112, group=0, string=, pressed=True)) wid=7
2024-10-18 09:18:38,840 key_handled_as_shortcut(GLClientWindow(7 : GLAreaBacking(0x7, (1440, 1011))), 'Page_Up', ['mod2'], True) shortcuts_enabled=True, shortcuts=None
2024-10-18 09:18:38,841 send_key_action(7, KeyEvent(modifiers=['mod2'], keyname=Page_Up, keyval=65365, keycode=112, group=0, string=, pressed=True))
2024-10-18 09:18:38,922 parse_key_event(<Gdk.EventKey object at 0x7fac347e1e00 (void at 0x3d231150)>, False)=KeyEvent(modifiers=['mod2'], keyname=Page_Up, keyval=65365, keycode=112, group=0, string=, pressed=False)
2024-10-18 09:18:38,922 handle_key_action(GLClientWindow(7 : GLAreaBacking(0x7, (1440, 1011))), KeyEvent(modifiers=['mod2'], keyname=Page_Up, keyval=65365, keycode=112, group=0, string=, pressed=False)) wid=7
2024-10-18 09:18:38,922 key_handled_as_shortcut(GLClientWindow(7 : GLAreaBacking(0x7, (1440, 1011))), 'Page_Up', ['mod2'], False) shortcuts_enabled=True, shortcuts=None
2024-10-18 09:18:38,923 send_key_action(7, KeyEvent(modifiers=['mod2'], keyname=Page_Up, keyval=65365, keycode=112, group=0, string=, pressed=False))

PageDown:

2024-10-18 09:19:22,706 parse_key_event(<Gdk.EventKey object at 0x7fac347e0be0 (void at 0x3bbc3640)>, True)=KeyEvent(modifiers=['mod2'], keyname=Page_Down, keyval=65366, keycode=117, group=0, string=, pressed=True)
2024-10-18 09:19:22,706 handle_key_action(GLClientWindow(7 : GLAreaBacking(0x7, (1440, 1011))), KeyEvent(modifiers=['mod2'], keyname=Page_Down, keyval=65366, keycode=117, group=0, string=, pressed=True)) wid=7
2024-10-18 09:19:22,707 key_handled_as_shortcut(GLClientWindow(7 : GLAreaBacking(0x7, (1440, 1011))), 'Page_Down', ['mod2'], True) shortcuts_enabled=True, shortcuts=None
2024-10-18 09:19:22,707 send_key_action(7, KeyEvent(modifiers=['mod2'], keyname=Page_Down, keyval=65366, keycode=117, group=0, string=, pressed=True))
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/xpra/client/base/client.py", line 1253, in call_handler
    handler(packet)
  File "/usr/lib/python3/dist-packages/xpra/client/mixins/windows.py", line 1251, in _process_new_override_redirect
    return self._process_new_common(packet, True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/xpra/client/mixins/windows.py", line 955, in _process_new_common
    return self.make_new_window(wid, wx, wy, ww, wh, bw, bh, metadata, override_redirect, client_properties)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/xpra/client/mixins/windows.py", line 992, in make_new_window
    self.patch_OR_popup_transient_for(metadata)
  File "/usr/lib/python3/dist-packages/xpra/client/mixins/windows.py", line 974, in patch_OR_popup_transient_for
    twid = self._find_pid_focused_window(pid, True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/xpra/client/mixins/windows.py", line 959, in _find_pid_focused_window
    if twin._override_redirect != OR:
       ^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'ClientTray' object has no attribute '_override_redirect'
2024-10-18 09:19:22,805 parse_key_event(<Gdk.EventKey object at 0x7fac347e28f0 (void at 0x3d231470)>, False)=KeyEvent(modifiers=['mod2'], keyname=Page_Down, keyval=65366, keycode=117, group=0, string=, pressed=False)
2024-10-18 09:19:22,805 handle_key_action(GLClientWindow(7 : GLAreaBacking(0x7, (1440, 1011))), KeyEvent(modifiers=['mod2'], keyname=Page_Down, keyval=65366, keycode=117, group=0, string=, pressed=False)) wid=7
2024-10-18 09:19:22,805 key_handled_as_shortcut(GLClientWindow(7 : GLAreaBacking(0x7, (1440, 1011))), 'Page_Down', ['mod2'], False) shortcuts_enabled=True, shortcuts=None
2024-10-18 09:19:22,805 send_key_action(7, KeyEvent(modifiers=['mod2'], keyname=Page_Down, keyval=65366, keycode=117, group=0, string=, pressed=False))

This issue also occurs when I use a client running on PostmarketOS (Alpine Linux) to connect to this same session.

totaam commented 1 month ago

AttributeError: 'ClientTray' object has no attribute '_override_redirect'

This is unrelated and fixed in 65eea920fb13134e32ab828028ca0ca5d4e47a02 - thanks for reporting it.

parse_key_event(<Gdk.EventKey object at 0x7fac347e0be0 (void at 0x3bbc3640)>, True)= \ KeyEvent(modifiers=['mod2'], keyname=Page_Down, keyval=65366, keycode=117, group=0, string=, pressed=True)

Looks correct to me. The problem may be server-side. Is this a default us layout or a more complicated one?

donaldsycamore commented 1 month ago

Yes, US layout (the norm here in New Zealand).

totaam commented 1 month ago

I believe that c57e4d45130335c967db045bef0f68f36c42c47f fixes the problem and will be backported to older branches. Until then, you can easily apply it by hand.

Hopefully it doesn't break any other platform..

donaldsycamore commented 1 month ago

Thanks, that indeed fixes it for me.

totaam commented 4 weeks ago

This has caused some breakage: #4404 and #4396, so I have reverted the commit in the v6.2.x branch. A better solution is needed.

totaam commented 4 weeks ago

@donaldsycamore is that a Wayland session by any chance?

totaam commented 4 weeks ago

I think I know what happened here:

The commit above is a better fix and only uses the client keycode for X11 clients, other clients fall through to https://github.com/Xpra-org/xpra/blob/ce124c6415d1e1a57a7c4fe5e36158e2eb3f926e/xpra/x11/server/keyboard_config.py#L477-L478

@donaldsycamore please confirm that fb72d9021d6342566b977fd0ccf8c4e211b38735 also works for you.