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

widgets: fall back to Xwayland #234

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

DemiMarie
Copy link

The widgets do not work under Wayland, so just use Xwayland for now.

If GTK somehow still connects to Wayland despite WAYLAND_DISPLAY being unset I will not be happy.

This is broken under KDE because of a bug in KDE (https://bugs.kde.org/show_bug.cgi?id=468085), but that can be fixed.

Copy link

codecov bot commented Nov 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.18%. Comparing base (a3e4d17) to head (fb35583).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #234      +/-   ##
==========================================
- Coverage   93.43%   93.18%   -0.26%     
==========================================
  Files          57       58       +1     
  Lines       10999    11046      +47     
==========================================
+ Hits        10277    10293      +16     
- Misses        722      753      +31     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@marmarek
Copy link
Member

This doesn't seem to work. For some reason it still connects to Wayland anyway. It does it when I set XDG_SESSION_TYPE=x11 too. The only way I could find to force it to use X11 is chmod 0 /run/user/1000/wayland-0 (and then indeed widget seems to work), which ofc is not feasible.
When I say "seems to work", I mean the icon shows up, the menu shows up on click and is functional (looks to be quite reliable), but I can close the menu only with the "esc" key. Clicking on the widget again doesn't close it, and also clicking outsize of the menu doesn't close it either (that latter one is kinda expected, widgets from VMs behave the same way, for similar reason).

@marmarek
Copy link
Member

Defaulting to wayland-0 seems to be caused by https://gitlab.gnome.org/GNOME/gtk/-/commit/55ea6e4dcc4bbe6c7fc40c8e814ad2ee99b3b2e2 (if I got the URL right, right now it says HTTP 503...). Setting WAYLAND_DISPLAY to an empty value seems to work better. But still, the issue with closing the menu remains. Note that closing the menu by clicking on the widget the second time works fine with nm-applet, so it's likely not directly a KDE issue but more like an interaction of some more components. But with real Xorg, widgets work in this regard just fine...

@qubesos-bot
Copy link

qubesos-bot commented Nov 25, 2024

OpenQA test summary

Complete test suite and dependencies: https://openqa.qubes-os.org/tests/overview?distri=qubesos&version=4.3&build=2024122307-4.3&flavor=pull-requests

Test run included the following:

New failures, excluding unstable

Compared to: https://openqa.qubes-os.org/tests/overview?distri=qubesos&version=4.3&build=2024111705-4.3&flavor=update

Failed tests

87 failures

Fixed failures

Compared to: https://openqa.qubes-os.org/tests/119126#dependencies

4 fixed
  • system_tests_extra

    • TC_00_QVCTest_whonix-gateway-17: test_010_screenshare (failure)
      ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^... AssertionError: 0 == 0
  • system_tests_kde_gui_interactive

    • gui_keyboard_layout: Failed (test died)
      # Test died: command 'test "$(cd ~user;ls e1*)" = "$(qvm-run -p wor...
  • system_tests_basic_vm_qrexec_gui_zfs

    • switch_pool: Failed (test died)
      # Test died: command 'dnf install -y ./zfs-release.rpm' failed at /...
  • system_tests_audio@hw1

Unstable tests

  • system_tests_update

    update2/Failed (1/5 times with errors)
    • job 121711 # Test died: command '(set -o pipefail; qubesctl --show-output stat...
  • system_tests_update@hw1

    update2/Failed (1/5 times with errors)
    • job 121711 # Test died: command '(set -o pipefail; qubesctl --show-output stat...
  • system_tests_update@hw7

    update2/Failed (1/5 times with errors)
    • job 121711 # Test died: command '(set -o pipefail; qubesctl --show-output stat...

@DemiMarie
Copy link
Author

Is it necessary for clicking outside the menu to close the menu, or is it good enough to require clicking again on the widget? The latter might be fixable in the menu itself, by closing the menu when the widget is clicked.

@marmarta
Copy link
Member

Is it necessary for clicking outside the menu to close the menu, or is it good enough to require clicking again on the widget? The latter might be fixable in the menu itself, by closing the menu when the widget is clicked.

It is necessary, it is a dom0 widget, it should not have the bad behavior of the vm widgets (which also should work better wrt to closing, but that's out of scope here).

@DemiMarie
Copy link
Author

Is it necessary for clicking outside the menu to close the menu, or is it good enough to require clicking again on the widget? The latter might be fixable in the menu itself, by closing the menu when the widget is clicked.

It is necessary, it is a dom0 widget, it should not have the bad behavior of the vm widgets (which also should work better wrt to closing, but that's out of scope here).

Can you try my most recent commit? That dismisses the menu when it loses focus.

@marmarta
Copy link
Member

I don't think this addresses the root cause, which is some wayland failure - this works correctly under X and so, from what you said previously, should work correctly under XWayland. I don't think we want to patch the whole world, if it requires additional workarounds like this (which BTW duplicate what the menu generally does on its own) I don't think this is a good solution.

qui/tray/domains.py Outdated Show resolved Hide resolved
qui/tray/domains.py Outdated Show resolved Hide resolved
@marmarek
Copy link
Member

pylint complains a lot, and also rpm fails to build (%files not updated)

@DemiMarie
Copy link
Author

This has been tested on a real KDE Wayland session and works fine.

@marmarek
Copy link
Member

Can you try to make it with GTK window? It should be significantly less verbose (if works). See for example https://stackoverflow.com/a/33294727

But also, make it conditional on Wayland session, we don't need this on real X11.

@DemiMarie
Copy link
Author

Can you try to make it with GTK window? It should be significantly less verbose (if works). See for example https://stackoverflow.com/a/33294727

Done, and it is indeed less verbose.

But also, make it conditional on Wayland session, we don't need this on real X11.

Also done, along with removing the change to widget-wrapper. GDK_BACKEND is now used to select the X11 backend even if WAYLAND_DISPLAY is set to something valid.

@DemiMarie
Copy link
Author

Tested and working on real hardware, in a real Xwayland session, using an RPM built in the Qubes executor from the same commit I just pushed.

No-op implementation of the hack, for use on stock X11.
"""

__slots__ = ()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slots are generally discouraged unless really necessary (mostly in very memory constrained environments, or when operating on enormous data sets).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ll delete this, but why are slots discouraged? I use them for the run-time checking they provide.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They severely limit extensibility.

__slots__ = ()

@classmethod
def get(cls, /) -> "DisgustingX11FullscreenWindowHack":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's weird to have this as a class method here. Shouldn't it be a function outside of those classes (returning one or the other)?

Copy link
Author

@DemiMarie DemiMarie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review comments addressed and all widgets tested.

qui/tray/gross_gtk3_bug_workaround.py Outdated Show resolved Hide resolved
No-op implementation of the hack, for use on stock X11.
"""

__slots__ = ()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ll delete this, but why are slots discouraged? I use them for the run-time checking they provide.

@DemiMarie DemiMarie requested a review from marmarek December 24, 2024 09:42
This has two parts:

1. Set GDK_BACKEND=x11, so that GDK3 chooses to use X11 as its backend.
   This must be done while only one thread is running, as otherwise
   undefined behavior results.  It also must be done before
   gi.overrides.Gdk is imported, as otherwise it will be too late to set
   the GDK backend.  Therefore, this code is run very early, and
   RuntimeError is raised if the preconditions are violated.

2. Create a fullscreen invisible window for mouse input.  This works
   around Xwayland not passing all pointer input to X11.  The menu is
   dismissed if the user clicks on the fullscreen window.  This hack
   is only used if WAYLAND_DISPLAY is set.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants