lxqt / lxqt-panel

The LXQt desktop panel
https://lxqt-project.org
GNU Lesser General Public License v2.1
180 stars 135 forks source link

Wayland taskbar support #2031

Closed gfgit closed 6 months ago

gfgit commented 7 months ago

Depends on #2024 (Qt6 port) and #2029 (WM abstraction)

This is an experimental implementation on taskbar, desktopswitch and showdesktop functionality for KWin Wayland compositor. It uses following protocols:

Code is inspired by libtaskmanager/waylandtasksmodel.cpp

Ideally the Wayland backend should have sub-backends targeting specific compositors when no standard protocol is available.

It also uses layer shell protocol to place panel on screen edge.

NOTE: panel auto-hide is not working yet

stefonarch commented 7 months ago

Heureka!

In plasma session all 3 elements of lxqt-panel are working perfectly ;) just starting from cli.

Less luck in openbox with kwin nested session (both cli and .desktop file in /usr/share/applications)

screenshot_2024-02-24_14 20 10

Maybe kwin needs more arguments, --no-kactivities and else.

stefonarch commented 7 months ago

NOTE: panel auto-hide is not working yet

On my slower VM (neon-unstable) this works, but empty taskbar also in plasma-session EDIT: works also on the dev edition.

gfgit commented 7 months ago
  • showdesktop segfaults panel, sorry only screenshot

Protocol access is not guarded yet. Infact we should wait for compositor to grant the protocol before starting using it. in your case I think the protocol is not grabted (hence taskbar empty) and you explicitly use make a request to show desktop which fails. Need to investigate why nested session does not grant protocol

stefonarch commented 7 months ago

I fiddled with env vars (see featherpad window) and.... all working, also showdesktop amd autohide! Not sure which one is needed and about the Qt one. Some invisible icon issues, the share dir doesn't work here.

kwin

gfgit commented 7 months ago

In kwin_wayland nested inside openbox I can reproduce crash if clicking show desktop button. Crash does not happen if I set KWIN_WAYLAND_NO_PERMISSION_CHECKS=1 env variable before starting KWin. Also FancyMenu is completely empty and also Favorites and All Apps categories are empty and without icon. I think XDG env variables are not set correctly

stefonarch commented 7 months ago

Also FancyMenu is completely empty and also Favorites and All Apps categories are empty and without icon. I think XDG env variables are not set correctly

Here I didn't install wip_qt6 of lxqt-qtplugin yet.

I'm using this script to start openbox at the bottom line exec openbox and inserted those 3 env vars too. The I use just kwin_wayland lxqt-panel. For some reason if I try directly form sddm to start a kwin script I've no cursor. I'm happy when I can stop using Neon for testing...

stefonarch commented 7 months ago

Found only one issue: the favorites dialog is normal window and behind, and similar for plugin directorymenu: it displays a window center screen. bug

Disabled also all kwin effects, now it's snappy.

stefonarch commented 7 months ago

Just for the record: Only export XDG_SESSION_DESKTOP=KDE is needed for a working taskbar. And also "mount" plugin opens a normal window center screen, looks like a layer-shell-qt bug to me as it doesn't happen without.

EDIT: seems a focus thing, if typing in the search first the favorites menu is adiacent at the panel:

favorites

Another misalignment with bottom panel:

submenu1

stefonarch commented 7 months ago

Testing with labwc, no popup is shown as normal window, but some misalignment can be found, like the favorites menu close to the panel or directorymenu covering the panel on the right. AND: autohide working!

https://github.com/lxqt/lxqt-panel/assets/10681413/66fb5ae7-71c6-4c49-bda9-009160f6ebeb

Crash when clicking showdesktop is here present too.

gfgit commented 7 months ago

Only export XDG_SESSION_DESKTOP=KDE is needed

Not working here :(

EDIT: It works, I was using an old .desktop file

XDG_CURRENT_DESKTOP=KDE makes it load icons from breeze theme using KDE Platform integration (I still have to install lxqt qtplugin which would replace this)

XDG_SESSION_DESKTOP=KDE is needed because .desktop file contains OnlyShowId=KDE

XDG_MENU_PREFIX=lxqt- makes FancyMenu load the applications

I have same popup issues and also "Open With" both from dolphin and from PCManFM-Qt does not work

gfgit commented 7 months ago

For future works: I've found this code inside Qt sources:

QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
{
#if QT_CONFIG(dbus)
    // Make double sure that we are in a wayland environment. In particular check
    // WAYLAND_DISPLAY so also XWayland apps benefit from portal-based color picking.
    // Outside wayland we'll rather rely on other means than the XDG desktop portal.
    if (!qEnvironmentVariableIsEmpty("WAYLAND_DISPLAY")
        || QGuiApplication::platformName().startsWith("wayland"_L1)) {
        return new XdgDesktopPortalColorPicker(portalWindowIdentifier(parent), parent);
    }
    return nullptr;
#else
    Q_UNUSED(parent);
    return nullptr;
#endif
}

So we could replace out color picker logic with XDG Portal equivalent

stefonarch commented 7 months ago

"Open With" both from dolphin and from PCManFM-Qt does not work

No issue here with both filemanager.

stefonarch commented 7 months ago

Launching lxqt-globalkeysd default shortcut Alt+F1 is opening the panel menu, but can't be changed obviously. Kwin-only.

gfgit commented 7 months ago

Color picker now uses XDG Desktop Portal on Wayland. Pasting color to clipboard does not seem to work yet. Also we should show some sort of error if portal says color picking is not supported of if no portal is available at all. Logic is already implemented, we just need the UI part

stefonarch commented 7 months ago

Pasting color to clipboard does not seem to work yet.

Usually this is piped to wl-copy, to take inspiration.

stefonarch commented 7 months ago

I noticed that kwin has no "shade" (roll up) feature anymore, I thought it was possible once. Only lawc has it afaik.

gfgit commented 7 months ago

I often get this error when doing incremental builds:

ninja: error: dependency cycle: panel/lxqt-panel_autogen/timestamp -> panel/qwayland-org-kde-plasma-virtual-desktop.h -> panel/lxqt-panel_autogen -> panel/CMakeFiles/lxqt-panel_autogen -> panel/lxqt-panel_autogen/timestamp
21:37:32: The process "/usr/bin/cmake" exited with code 1.
Error while building/deploying project lxqt-panel (kit: Desktop)
When executing step "Build"
stefonarch commented 7 months ago

Issues seen now on arch, not Neon:

EDIT: Not sure if that was working on the previous commit, recompiled this morning and right click on statusnotifier items is not working anymore. Looks like I've issues with libdbusmenu-lxqt

stefonarch commented 7 months ago

Just noticed that right click menu items in statusbar probably never worked also on Neon.

stefonarch commented 7 months ago

Not sure but for the popups shown centered and as normal windows: https://wayland.app/protocols/wlr-layer-shell-unstable-v1#zwlr_layer_surface_v1:request:get_popup

stefonarch commented 7 months ago

One difference I see between compositors: a right panel with less than 100% loses its exclusive zone in labwc, sway and Hyprland, but not in kwin and wayfire.

It doesn't "see" other exclusicve zones than the ones from itself, but that will rarely be an issue.

"Showdesktop" crashes the panel on labwc (on the others non-kwin probably too), but restarts automatically fine, this needs fixing.

EDIT: "showdesktop" restarts the panel on kwin too, "desktop switch" works on kwin and is invisible on the others. which is quite nice.

stefonarch commented 7 months ago

Forgot the backtrace, probably not very useful.

#0  0x000075663d6f99d4 in wl_proxy_get_version () at /usr/lib/libwayland-client.so.0
#1  0x0000592fc2e96049 in ??? ()
#2  0x0000592fc2e8429a in ??? ()
#3  0x000075663bd90ca9 in ??? () at /usr/lib/libQt6Core.so.6
#4  0x000075663c6e2077 in QAction::activate(QAction::ActionEvent) () at /usr/lib/libQt6Gui.so.6
#5  0x000075663cdfeb1c in ??? () at /usr/lib/libQt6Widgets.so.6
#6  0x000075663ce0d245 in QAbstractButton::mouseReleaseEvent(QMouseEvent*) () at /usr/lib/libQt6Widgets.so.6
#7  0x000075663cf1f6fe in QToolButton::mouseReleaseEvent(QMouseEvent*) () at /usr/lib/libQt6Widgets.so.6
#8  0x000075663cd45065 in QWidget::event(QEvent*) () at /usr/lib/libQt6Widgets.so.6
#9  0x000075663ccf438b in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
    at /usr/lib/libQt6Widgets.so.6
#10 0x000075663ccf6be8 in QApplication::notify(QObject*, QEvent*) () at /usr/lib/libQt6Widgets.so.6
#11 0x000075663bd39818 in QCoreApplication::notifyInternal2(QObject*, QEvent*) ()
    at /usr/lib/libQt6Core.so.6
#12 0x000075663ccf2327 in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool, bool) () at /usr/lib/libQt6Widgets.so.6                                    
#13 0x000075663cd57a97 in ??? () at /usr/lib/libQt6Widgets.so.6
#14 0x000075663cd58db0 in ??? () at /usr/lib/libQt6Widgets.so.6
#15 0x000075663ccf438b in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
    at /usr/lib/libQt6Widgets.so.6
#16 0x000075663bd39818 in QCoreApplication::notifyInternal2(QObject*, QEvent*) ()
    at /usr/lib/libQt6Core.so.6
#17 0x000075663c36f9e5 in QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) () at /usr/lib/libQt6Gui.so.6                                                                             
#18 0x000075663c3da85c in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt6Gui.so.6                                                                             
#19 0x000075663c7b26c4 in ??? () at /usr/lib/libQt6Gui.so.6
#20 0x000075663b52bf69 in ??? () at /usr/lib/libglib-2.0.so.0
#21 0x000075663b58a3a7 in ??? () at /usr/lib/libglib-2.0.so.0
#22 0x000075663b52a162 in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0
#23 0x000075663bf739c4 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
    at /usr/lib/libQt6Core.so.6
#24 0x000075663bd43d6e in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) ()
    at /usr/lib/libQt6Core.so.6
#25 0x000075663bd3c2b8 in QCoreApplication::exec() () at /usr/lib/libQt6Core.so.6
#26 0x0000592fc2e4c29a in ??? ()
#27 0x000075663b643cd0 in ??? () at /usr/lib/libc.so.6
#28 0x000075663b643d8a in __libc_start_main () at /usr/lib/libc.so.6
#29 0x0000592fc2e4cb25 in _start ()
stefonarch commented 7 months ago

@gfgit What do you think about https://github.com/labwc/labwc/issues/1572#issuecomment-1973000293 ?

Keyboard navigation and search are working only under kwin and Hyprland.

gfgit commented 7 months ago

@gfgit What do you think about labwc/labwc#1572 (comment) ?

Keyboard navigation and search are working only under kwin and Hyprland.

Well if it's working on Hyprland it should mean it's not a wlroots issue. Also if at least panel dependencies get merged for Qt6 it would be easier for third-party devs to test this bug with lxqt-panel

We could try replicate the same workaround and see if it works and then revert it when compositors get fixed

gfgit commented 7 months ago

At the moment I'm a bit busy so I might delay this change a bit. But thank you for linking this!

stefonarch commented 7 months ago

Also if at least panel dependencies get merged for Qt6 it would be easier for third-party devs to test this bug with lxqt-panel

Hopefully soon. I filed bug reports to sway too; wayfire dev have compiled it already and had already an open issue.

stefonarch commented 6 months ago

@gfgit Could you implement this for "Configure panel" window? https://github.com/lxqt/lxqt-config/issues/984

With some help from @tsujan I did already https://github.com/stefonarch/lxqt-session/commit/201d6ee402f5a27a71568b05cfb80d56e4708634

tsujan commented 6 months ago

@gfgit Could you implement this for "Configure panel" window?

I really think we need to avoid overusing layer-shell-qt.

gfgit commented 6 months ago

I really think we need to avoid overusing layer-shell-qt.

Hi, I was thinking the same thing. Isn't lxqt-config just a normal app? lxqt-leave might be an exception in this, but on non-tiling compositors it should open at sceen center like any other window...

tsujan commented 6 months ago

Isn't lxqt-config just a normal app?

Yes.

lxqt-leave might be an exception in this

@stefonarch has already taken care of it and waits for my Qt6 PR for lxqt-session to be merged (which should be merged only with other Qt6 PRs for components that depend on liblxqt, including lxqt-panel).

but on non-tiling compositors it should open at sceen center like any other window...

Stacking Wayland compositors have their options for that — for centering (default in LabWC) or not — and, IMHO, we should respect those options.

stefonarch commented 6 months ago

It's ok if you don't use tiling WM like sway or hyprland where you need again window rules to make them float. I tested with the lxqt-leave and it behaves ok. We only need to force position IMO, not layer or keyboard to avoid those rules which are never 100% working. Example Hyprland:

# LXQt Settings windows, policykit
windowrule = float,^(lxqt-.*)$
windowrule = float, ^(pavucontrol-qt)$

sway

# LXQt (config) windows
    for_window [app_id="^lxqt-.*$"] floating enable
tsujan commented 6 months ago

It's ok if you don't use tiling WM

Tiling WMs need to fix their UX problems themselves. It's not our job to do their work for them ;)

stefonarch commented 6 months ago

It's ok if you don't use tiling WM

Tiling WMs need to fix their UX problems themselves. It's not our job to do their work for them ;)

I know you dislike them ;)

My opinion is this: if we can provide a good out-of-the-box experience we should do it. We pretend also being modular and to work with any WM/compositor.

tsujan commented 6 months ago

We pretend also being modular

Being modular is one thing, adding codes to compensate for others' problems is another. The latter would make LXQt codes dirty and unmaintainable if we didn't avoid it.

stefonarch commented 6 months ago

Trying to build again on Neon stable it fails here: https://paste.debian.net/1310396/ After fixing this I get in plugin-taskbar/lxqttaskbarplugin.h line 62 "undefined inteface"

stefonarch commented 6 months ago

After fixing this I get in plugin-taskbar/lxqttaskbarplugin.h line 62 "undefined interface"

I see this happens if I compile directly this branch. If I compile first wip_qt6 branch it does compile. So it looks there is something missing here.

stefonarch commented 6 months ago

I continue to consider not centering the panel config dialog a bug we should fix - in tiling WM at least it doesn't get covered by a left or right panel:

screen_area_sab_00:54:32_

stefonarch commented 6 months ago

@gfgit Just learned that qmpanel has working taskbar support on wayland for wlroots-based compositors: https://github.com/jlindgren90/qmpanel/blob/master/panel/taskbar.cpp

gfgit commented 6 months ago

in tiling WM at least it doesn't get covered by a left or right panel

Isn't this supposed to just work™ with layer shell protocol on the panel which reserves screen space?

stefonarch commented 6 months ago

It should and it's somehow an exception, as issues with alignment (tooltips, fancymenu dialog) can be seen only on bottom and right panels. I first thought it was about right panels only.

gfgit commented 6 months ago

It should and it's somehow an exception, as issues with alignment (tooltips, fancymenu dialog) can be seen only on bottom and right panels. I first thought it was about right panels only.

I think it's worth filing a bug to affected tiling compositors and see if they can fix it.

stefonarch commented 6 months ago

I think it's worth filing a bug to affected tiling compositors and see if they can fix it.

Maybe I wasn't clear: this is an issue on stacking WMs, in tiling WM without window rules it's tiled as any other: screen_area_sab_02:36:09_ with windowrule = float,^(lxqt-.*)$ it is floating, with layershell code it would always be floating and centered on any WM:

screen_area_sab_02:27:21_

I noticed that in kwin_wayland it is centered by default.

Consolatis commented 6 months ago

I continue to consider not centering the panel config dialog a bug we should fix - in tiling WM at least it doesn't get covered by a left or right panel:

screen_area_sab_00:54:32_

What compositor is that? If the panel is correctly configured to use the exclusive zone (and updates it on window resize), the window should likely not overlap the panel area.

The protocol does not enforce that restriction though. It also says about the exclusive zone:

 A positive zone is the distance from the edge in surface-local
 coordinates to consider exclusive.

So that would mean if the panel is anchored to the top, right and bottom edges, the exclusive zone should be set to the panel width rather than height.

stefonarch commented 6 months ago

What compositor is that?

It's labwc. I made a test assuming that wayfire had the same issue, but it behaves like kwin, centering this panel config dialog without rules. The exclusive zone works fine as in the other screenshots (Hyprland) but only if the panel width i set to 100% .

stefonarch commented 6 months ago

I didn't keep in mind that I was on a branch (for testing exit session) which didn't have the panel focus fix and maybe else. So there is no issue with exclusive zone on left/right panels in labwc git:

screen_area_sab_21:30:16_

tsujan commented 6 months ago

probably for this feature of the floating panel in plasma

Do they really call it a feature or are you joking? The second problem of Plasma 6 that attracted my attention yesterday was its panel (under X11 — wasn't brave enough to log into its Wayland session).

stefonarch commented 6 months ago

Do they really call it a feature or are you joking

I put it first between " " but removed them as I'm trying to be polite;) I logged into plasma and disabled the floating panel but this space didn't disappear, it's in Neon too I saw. Maybe open a bug report is necessary.

stefonarch commented 6 months ago

Could this solve eventually the alignment issues in bottom/right panels?

git://code.qt.io/qt/qtwayland.git:

 QRect placementAnchor = m_window->window()->property("_q_waylandPopupAnchorRect").toRect();
    if (!placementAnchor.isValid()) {
        placementAnchor = QRect(m_window->geometry().topLeft() - parent->geometry().topLeft(), QSize(1,1));
    }
...
    positioner->set_anchor_rect(placementAnchor.x(),
                                placementAnchor.y(),
                                placementAnchor.width(),
                                placementAnchor.height());»
stefonarch commented 6 months ago

Just another maybe useful snippet for alignment: https://github.com/jlindgren90/qmpanel/pull/8/files

stefonarch commented 6 months ago

Not sure what has changed - it was some time I didn't use kwin_wayland session, but can't get the taskbar to work now anymore.

As it looks that the review of taskbar-refactor will take much time I think we should have a PR only for the panel wayland code for now.