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

Wlroots taskbar #2046

Conversation

marcusbritanicus
Copy link
Contributor

@marcusbritanicus marcusbritanicus commented Mar 27, 2024

This PR adds a generic wlroots backend support for the the taskbar and desktop-switcher plugins.

@gfgit: I took lxqt-panel:git, then merged #2041 and #2043. I hope this is what I was supposed to do. If something's amiss, please do let me know.

One of the issues we face is the wlroots backend does not support virtual desktops. However, various compositors (wayfire, sway, hyprland, etc) have their own mechanisms to provide this feature.

  1. swaymsg provides a very fine-grained control to handle windows and virtual-desktops on sway.
  2. Wayfire:git has a rudimentary IPC support (not as developed as swaymsg) with which we can develop something similar to swaymsg. Alternatively, I am developing three protocols that provide virtual-desktop and toplevel management support via protocols.
  3. Hyprthing is for Hyprland what swaymsg is for sway? I do not know much about this.

So it would be beneficial if we provide per-compositor support. As discussed in #2531, the best way forward is to develop a plugin interface for the wayland backend. Currently, I have the following structure in mind:

panel/backends/
  - wayland/
    - plasma/
      * lxqtbackendplasma.cpp
      * lxqtbackendplasma.h
    - wlroots/
      * lxqtbackendwlroots.cpp
      * lxqtbackendwlroots.h
    - wayfire/
      * lxqtbackendwayfire.cpp
      * lxqtbackendwayfire.h
    - sway/
      * lxqtbackendsway.cpp
      * lxqtbackendsway.h
    - hyprland/
      * lxqtbackendhyprland.cpp
      * lxqtbackendhyprland.h
    - lxqtwaylandbackend.cpp
    - lxqtwaylandbackend.h
  - xcb/
    - lxqttaskbarbackend_x11.cpp
    - lxqttaskbarbackend_x11.h
  - ilxqttaskbarabstractbackend.cpp
  - ilxqttaskbarabstractbackend.h
  - lxqttaskbardummybackend.cpp
  - lxqttaskbardummybackend.h

Few points:

  1. lxqtwaylandbackend.cpp should attempt to detect the DE and load the suitable plugin. The DE detection can be based on a user settings or XDG_CURRENT_DESKTOP.
  2. If we're using a protocol (say, like wlr-foreign-toplevel, or wayfire-desktop-shell), we should also attempt to verify that the compositor is advertising the said protocol.
  3. If the compositor-specific protocol/support is unavailable (for example, when using wayfire, if ipc plugin is not loaded or similar), we should fallback to wlroots.
  4. If wlroots (i.e. wlr-foreign-toplevel) is not available (for example, foregin-toplevel plugin is not loaded in wayfire), the default dummy wayland backend (as provided by lxqtwaylandbackend.cpp will be used).

Changes made:

  1. I have moved all the files from panel/backends/wayland/ to panel/backends/wayland/plasma
  2. panel/backends/wayland/wlroots implements the wlroots backend.
  3. Line 50/51 panel/lxqtpanelapplication.cpp to use only wlroots backend. (This needs to be fixed)

Current state:

  1. On a wlroots-based compositor, following works:
    • Listing all the currently open windows.
    • Click to focus
    • Add newly opened windows
    • Remove closed windows
    • desktop-switcher plugin (It will simply show only one virtual desktop named ("Desktop 1" with id "desktop-1")
  2. On a wlroots-based compositor, following does not work:
    • Grouping does not work properly
    • Window icons
  3. On a wlroots-based compositor, what will not work:
    • Move to output, move to desktop, shade, pin on top/bottom (No support from the protocol)
    • Anything related to virtual desktops (at least until ext-workspace-* support gets added)
  4. In it's current state, taskbar and desktop-switcher plugins will crash the panel when run on any non-wlroots compositor (for example, plasma).

Note: For the purpose of our discussion here, by "non-wlroots compositor", what I mean is a compositor that does not implement wlr-foreign-toplevel protocol.

cc: @stefonarch @tsujan

gfgit added 30 commits March 26, 2024 12:35
This is an abstract interface to operate windows
and workspaces
- Move WindowProperty enum to lxqttaskbartypes.h
This model will manage the tasks shown
Also use it to get window icon
- Don't rely on global screen coordinates

- This will be needed for future Wayland port,
  Where we don't have global screen coordinates

- Keep compatible behavior on X11
This new window propery flag is needed to notify geometry changes
This will be used to avoid crashing panel in case no backend could be
created.
A warning message will be printed in this case.
@gfgit gfgit force-pushed the work/gfgit/wayland_taskbar branch from 83634a0 to 1fc5594 Compare June 8, 2024 15:41
This was referenced Jun 10, 2024
@V10lator
Copy link

V10lator commented Jul 1, 2024

Tried to compile this but:

/var/tmp/portage/lxqt-base/lxqt-panel-2.0.9999/work/lxqt-panel-2.0.9999/plugin-taskbar/lxqttaskbutton.cpp: In member function ‘virtual void LXQtTaskButton::contextMenuEvent(QContextMenuEvent*)’:
/var/tmp/portage/lxqt-base/lxqt-panel-2.0.9999/work/lxqt-panel-2.0.9999/plugin-taskbar/lxqttaskbutton.cpp:693:87: error: ‘SetLayer’ is not a member of ‘LXQtTaskBarBackendAction’
  693 |     layerMenu->setEnabled(mBackend->supportsAction(mWindow, LXQtTaskBarBackendAction::SetLayer));
      |                                                                                       ^~~~~~~~
/var/tmp/portage/lxqt-base/lxqt-panel-2.0.9999/work/lxqt-panel-2.0.9999/plugin-taskbar/lxqttaskbutton.cpp:697:28: error: redeclaration of ‘LXQtTaskBarWindowLayer currentLayer’
  697 |     LXQtTaskBarWindowLayer currentLayer = mBackend->getWindowLayer(mWindow);
      |                            ^~~~~~~~~~~~
/var/tmp/portage/lxqt-base/lxqt-panel-2.0.9999/work/lxqt-panel-2.0.9999/plugin-taskbar/lxqttaskbutton.cpp:695:28: note: ‘LXQtTaskBarWindowLayer currentLayer’ previously declared here
  695 |     LXQtTaskBarWindowLayer currentLayer = mBackend->getWindowLayer(mWindow);

//EDIT: Wrote a little patch which fixes these compiler errors:

diff '--color=auto' -Nru lxqt-panel-2.0.9999.old/panel/backends/lxqttaskbartypes.h lxqt-panel-2.0.9999/panel/backends/lxqttaskbartypes.h
--- lxqt-panel-2.0.9999.old/panel/backends/lxqttaskbartypes.h   2024-07-01 12:08:20.142187494 +0200
+++ lxqt-panel-2.0.9999/panel/backends/lxqttaskbartypes.h       2024-07-01 12:19:46.181045346 +0200
@@ -43,7 +43,8 @@
   Minimize,
   RollUp,
   FullScreen,
-    DesktopSwitch
+    DesktopSwitch,
+    SetLayer
};

enum class LXQtTaskBarWindowProperty
diff '--color=auto' -Nru lxqt-panel-2.0.9999.old/plugin-taskbar/lxqttaskbutton.cpp lxqt-panel-2.0.9999/plugin-taskbar/lxqttaskbutton.cpp
--- lxqt-panel-2.0.9999.old/plugin-taskbar/lxqttaskbutton.cpp   2024-07-01 12:08:20.322185931 +0200
+++ lxqt-panel-2.0.9999/plugin-taskbar/lxqttaskbutton.cpp       2024-07-01 12:21:04.386830488 +0200
@@ -694,8 +694,6 @@

   LXQtTaskBarWindowLayer currentLayer = mBackend->getWindowLayer(mWindow);

-    LXQtTaskBarWindowLayer currentLayer = mBackend->getWindowLayer(mWindow);
-
   a = layerMenu->addAction(tr("Always on &top"));
   a->setEnabled(currentLayer != LXQtTaskBarWindowLayer::KeepAbove);
   a->setData(int(LXQtTaskBarWindowLayer::KeepAbove));

Now I'm facing some warnings (unused variables and stuff like that) and a linking error:

/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld.bfd: cannot find -llxqt-panel-backend-wlroots: No such file or directory
collect2: error: ld returned 1 exit status

@stefonarch
Copy link
Member

No idea what's going wrong at your side - no issues compiling it here, except those warnings you mentioned. @marcusbritanicus may have better insight.

@marcusbritanicus
Copy link
Contributor Author

@stefonarch Strangely, @V10lator is right. I can compile it on my system as well, but if you look into my sources, you'll find that the enum SetLayer isn't there. I believe this happened due to the recent rebase. There are also a few other inconsistencies. Fixing these would be possible, but I would rather wait for ILXQtAbstractWMInterface.

@stefonarch
Copy link
Member

but I would rather wait for ILXQtAbstractWMInterface.

Sure, but it's good having more eyes on it, thanks @V10lator !

@gfgit
Copy link
Member

gfgit commented Jul 9, 2024

@marcusbritanicus I've created a basic plugin infrastruture, see #2075

@gfgit gfgit force-pushed the work/gfgit/wayland_taskbar branch from 1fc5594 to 1a1691c Compare July 9, 2024 17:17
@marcusbritanicus
Copy link
Contributor Author

@gfgit I had a cursory glance at the code. It looks good. I liked the idea of ILXQtBackendLibrary. Now that you've created the backend library, I'll close this PR. I'll create a fresh one incorporating a few simplifications for the wlr generic backend. I'll make another one for Wayfire.

PS: I'll be busy this month. But, I'll start the work right away, though the progress will be a bit slow.

@tsujan
Copy link
Member

tsujan commented Jul 9, 2024

@marcusbritanicus
Would you please review #2075? If yes, please self-request a review.

@marcusbritanicus
Copy link
Contributor Author

Sure, I will review it.

@gfgit gfgit force-pushed the work/gfgit/wayland_taskbar branch from 4301ecf to ad5cf4a Compare July 12, 2024 09:15
@stefonarch
Copy link
Member

Fixing these would be possible, but I would rather wait for ILXQtAbstractWMInterface.

If it's not to much hassle fixing the issues here would be fine IMO - as it's the only working wayland panel we have in git atm.

@marcusbritanicus
Copy link
Contributor Author

as it's the only working wayland panel

I had not considered this. I have been looking at #2075 bit-by-bit. I had added a few comments, though I am not sure if others can see it. I still need to tinker with it a bit. Once that's done, I will rewrite this on top of #2075. It will be much cleaner.

@stefonarch
Copy link
Member

I have been looking at #2075 bit-by-bit. I had added a few comments, though I am not sure if others can see it.

I can't see anything, but good to hear that things are moving :)

@stefonarch
Copy link
Member

stefonarch commented Jul 26, 2024

Looks like labwc will implement cosmic-workspace-unstable-v1 for workspaces:
labwc/labwc#2030

So maybe this will allow us to build also a labwc backend at some point I think.

@marcusbritanicus
Copy link
Contributor Author

It is worth working on this. There is an old PR in wayland-protocols, and Cosmic is the one working on it. Once it merges, it is likely that wayfire will also adopt it. After all, the original protocol was proposed by ammen99.

@Consolatis
Copy link

Consolatis commented Jul 27, 2024

Note that labwc will only implement version 1 of the protocol, and only listing + activating workspaces (e.g. not allowing clients to create / remove them). Due to the capabilities system within the protocol that should not be an issue though as clients can simply hide corresponding actions from the user if the given compositor does not support them.

Version 2 added a rename request and a ominous tiling_state that isn't really well defined.

There is an old PR in wayland-protocols, and Cosmic is the one working on it. Once it merges, it is likely that wayfire will also adopt it.

The key here is the word "once". I'd prefer to not wait another 3 years.

@marcusbritanicus marcusbritanicus deleted the wlroots-taskbar branch August 17, 2024 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

7 participants