Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VirtualBox context menus disappear #4246

Open
callegar opened this issue Jun 1, 2024 · 14 comments
Open

VirtualBox context menus disappear #4246

callegar opened this issue Jun 1, 2024 · 14 comments
Labels
bug Something isn't working

Comments

@callegar
Copy link

callegar commented Jun 1, 2024

Describe the bug

Trying to use VirtualBox under xpra. Encountering an issue even before launching the virtual machines. In the main VirtualBox Window, pressing the right mouse button should open a contex menu. Under xpra this context menu cannot be used: it opens and closes automatically before you can even move the mouse on it.

To Reproduce
Steps to reproduce the behavior:

  1. Start xpra on the server with xpra start :101 and then get a terminal on it (e.g. DISPLAY=:101 konsole)
  2. Attach to the client xpra attach ssh://server/101
  3. In the terminal from the server start VirtualBox
  4. In the VirtualBox window go to an entry corresponding to a virtual machine, press the right mouse button to get the context menu

See the context menu appearing and disappearing before you can use it.

System Information (please complete the following information):

  • Server OS: Manjaro (arch)
  • Client OS: Manjaro (arch)
  • Xpra Server Version 6.0.1
  • Xpra Client Version 6.0.1

Additional context

Both client and server use KDE plasma 6 with a wayland session.

@callegar callegar added the bug Something isn't working label Jun 1, 2024
@totaam
Copy link
Collaborator

totaam commented Jun 1, 2024

Works fine on Fedora with Gnome - could be some incompatibility with KDE.

@totaam
Copy link
Collaborator

totaam commented Jun 1, 2024

.. and then get a terminal on it (e.g. DISPLAY=:101 konsole)

Don't do that.
Use --start=konsole to get the correct environment setup.

@callegar
Copy link
Author

callegar commented Jun 8, 2024

Thanks for the advice, now using --start. Does not change the issue with the floating context menus, though. Might indeed be plasma specific or even plasma 6 specific or plasma 6 on wayland specific.

@totaam
Copy link
Collaborator

totaam commented Jun 8, 2024

Does not change the issue with the floating context menus

I didn't think it would. That's a separate issue.

plasma 6 on wayland specific

Yes, that's likely.
Wayland makes all sorts of window positioning issues "interesting".

@callegar
Copy link
Author

callegar commented Jun 8, 2024

Also reported at KDE https://bugs.kde.org/show_bug.cgi?id=488208

@callegar
Copy link
Author

callegar commented Jun 8, 2024

Seems 100% reproducible for me, so I hope they can check it.

@totaam
Copy link
Collaborator

totaam commented Jun 8, 2024

@callegar they're probably going to say that xpra is at fault.

@callegar
Copy link
Author

Even if it was, which may well not be, I hope they will help by looking into it. xpra is a too important piece for having it misbehave in KDE, IMHO. Furthermore, the post X era where each DE has its own implementation of the wayland protocols really requires a lot of cooperation to assure that things remain consistent across desktops.

@callegar
Copy link
Author

Issue is actually not limited to VirtualBox. I see a similar behavior with konsole. If I go on the sandwich button and press it, then a menu appears. When I try to show a submenu, the submenu flashes and disappears. At the same time I get messages such as:

(Xpra:54999): Gdk-WARNING **: 16:14:13.755: Couldn't map as window 0x620b98e10110 as popup because it doesn't have a parent

(Xpra:54999): Gdk-WARNING **: 16:14:18.089: Tried to map a popup with a non-top most parent

(Xpra:54999): Gdk-WARNING **: 16:14:20.503: Tried to map a popup with a non-top most parent
Gdk-Message: 16:14:33.630: Window 0x620b98e29c30 is a temporary window without parent, application will not be able to position it on screen.

@callegar
Copy link
Author

In any case, forcing the xpra client to work in X11 mode rather than in wayland mode works around the issue. Enough to do GDK_BACKEND=x11 xpra attach --ssh=ssh --dpi <dpi> ssh://<host>/<display> --start konsole.

@totaam
Copy link
Collaborator

totaam commented Jun 20, 2024

I see a similar behavior with konsole

Works fine here on Fedora + Gnome Shell.

The problem comes from this:
Window 0x620b98e29c30 is a temporary window without parent, application will not be able to position it on screen.

X11 applications routinely place their windows wherever they like, but Wayland decided to break the vast majority of existing applications by not providing an API for doing that (it does exist, as can be seen when using XWayland).
We try hard to find a parent:

def patch_OR_popup_transient_for(self, metadata: typedict) -> None:
pid = metadata.intget("pid", 0)
twid = metadata.intget("transient-for", 0)
if is_Wayland():
# if this is a sub-popup (ie: a submenu),
# then GTK-Wayland refuses to show it unless we set transient-for
# to point to the parent popup.
# Even if under X11, `WM_TRANSIENT_FOR` points to the parent / top-level window...
twid = self._find_pid_focused_window(pid, True)
# try to ensure popup windows have a transient-for:
if not twid:
twid = self._find_pid_focused_window(pid)
if twid:
metadata["transient-for"] = twid

def _find_pid_focused_window(self, pid: int, OR=False) -> int:
for twid, twin in self._id_to_window.items():
if twin._override_redirect != OR:
continue
if twin._metadata.intget("pid", -1) == pid:
if OR or twid == self._focused:
return twid
return 0

And there's only so much guessing we can do without getting it wrong.
Perhaps the version of VirtualBox also makes a difference: newer versions are more likely to bend over backwards to try to satisfy all these new Wayland windows relationship restrictions.

@callegar
Copy link
Author

callegar commented Jul 7, 2024

Unfortunately it is not only a VirtualBox problem. The fact that it affects the very default terminal application for KDE (konsole) makes it more serious. Pinging again the Kwin developers...

@callegar
Copy link
Author

callegar commented Jul 7, 2024

Would it be possible/sensible to default to Xwayland on Kwin plasma until this can be addressed?

@totaam
Copy link
Collaborator

totaam commented Jul 8, 2024

until this can be addressed?

It's unlikely to be addressed.
Requiring Xwayland will also cause other problems and packaging difficulties.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants