Xpra: Ticket #2255: kaptain: wrong pointer and keyboard focus for concurrent windows

I have encountered an odd issue with kaptain.

kaptain is a quite old GUI frontend für CLI commands. A repository is here: https://github.com/mviereck/kaptain

Code to reproduce:

xpra start :22
xpra attach :22
DISPLAY=:22 kaptain /dev/stdin <<< 'start -> @close="exit" @fork("xterm")="xterm";'

This creates a small dialog that allows to run xterm. The xterm window does not get keyboard or mouse input and cannot be closed. It can be moved and maximized.

Other applications started with DISPLAY=:22 command are affected, too.

I've tested with and without OpenGL, with xpra-py2 and xpra-py3 and with xpra versions 2.5 and 3.0 on debian buster.

The issue seems to be special for the combination of kaptain and xpra. It works well with other X servers like Xephyr or nxagent.

This might or might not be related to https://www.xpra.org/trac/ticket/1941#comment:8

Do you have an idea?



Thu, 04 Apr 2019 16:21:54 GMT - mviereck: summary changed


Fri, 05 Apr 2019 05:20:19 GMT - Antoine Martin: status changed; resolution set

First, as I keep having to repeat this, I really hope that you already know that you should not be using the form:

DISPLAY=:NN someapp

To start applications on the xpra display, always use xpra start --start=someapp instead. If the command is a shell command, you can wrap it: --start="sh -c 'whatever shell command goes here'"


As for the bug. Running the client with -d metadata, we can see the kaptain window coming up:

process_new_common: [4, 0, 0, 104, 97, {b'xid': b'0xc00003', b'client-machine': b'desktop', b'pid': 25991, b'title': b'kaptain', \
    b'class-instance': (b'kaptain', b'Kaptain'), b'group-leader-xid': 12582917, b'window-type': (b'DIALOG', b'NORMAL'), \
    b'size-constraints': {b'gravity': 1, b'minimum-size': (104, 97)}, b'icon-title': b'', b'decorations': 30, b'modal': True, \
    b'iconic': False}], ..., OR=False

It is a DIALOG modal window, and so it will capture all input until dismissed. For details see #1895.

When forwarding multiple applications through the same xpra connection and one of the windows is modal, you need to tell xpra not to honour the modal flag for that session:

xpra attach --modal-windows=no

FYI: the latest GTK API (WindowModality but even then we wouldn't be able to specify which windows this needs to apply to).


Fri, 05 Apr 2019 08:20:30 GMT - mviereck:

Great, thank you! --modal-windows=no fixed it for me.

First, as I keep having to repeat this, I really hope that you already know that you should not be using the form: DISPLAY=:NN someapp

I am aware of that. However, in the context of x11docker that is not possible because the applications run in an isolated container that xpra cannot access. At least x11docker sets the environment variables that xpra sets for its clients.

Thank you for giving some insight, too! It helps me to understand what is going on.

Though, I am wondering why the issue does not appear if I run kaptain on other X servers or on display :0. I've also tried a few different window managers (kwin, xfwm4, openbox). Maybe it is common to ignore the modal flag, and only xpra honours it by default.

Just an idea: You could allow XPRA_MODAL_WINDOWS=0 to set --modal-windows=no.


Fri, 05 Apr 2019 11:46:16 GMT - Antoine Martin:

Maybe it is common to ignore the modal flag, and only xpra honours it by default.

They do honour it, but this modal flag is per application - it just so happens that xpra ends up being multiple applications that the window manager sees as just one.

Just an idea: You could allow XPRA_MODAL_WINDOWS=0 to set --modal-windows=no.

XPRA_MODAL_WINDOWS has been removed earlier today.


Fri, 05 Apr 2019 14:25:54 GMT - Antoine Martin:

They do honour it..

Looking at the GTK source code, they're not actually given the choice: the "modal" behaviour is enforced by GTK, it uses X11 grabs to do so. gtk_grab_add : Makes @widget the current grabbed widget. This means that interaction with other widgets in the same application is blocked and mouse as well as keyboard events are delivered to this widget. If @widget is not sensitive, it is not set as the current grabbed widget and this function does nothing.


Sat, 06 Apr 2019 20:09:16 GMT - mviereck:

Thanks for the additional information.

They do honour it, but this modal flag is per application - it just so happens that xpra ends up being multiple applications that the window manager sees as just one.

That makes sense, good to know.


Sun, 23 Jun 2019 07:15:54 GMT - mviereck:

Just a note: man xpra does not show option --modal-windows.

xpra --help shows:

    --modal-windows=MODAL_WINDOWS
                        Honour modal windows. Default: 'True'.

Sun, 23 Jun 2019 13:05:29 GMT - Antoine Martin:

Just a note: man xpra does not show option --modal-windows.

Oops, thanks for pointing that out: fixed in r23020.


Sat, 23 Jan 2021 05:46:19 GMT - migration script:

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