material-decoration icon indicating copy to clipboard operation
material-decoration copied to clipboard

[Question] LIM: Wayland?

Open chippmann opened this issue 4 years ago • 18 comments

Is the lim branch also compatible with wayland?

chippmann avatar Apr 17 '20 13:04 chippmann

No. There's a few #ifdef HAVE_X11 that I've commented out to simplify porting appmenu from plasma-workspace.

  • https://github.com/Zren/material-decoration/blob/lim/src/AppMenuModel.cc#L28
  • https://github.com/KDE/plasma-workspace/tree/master/appmenu
  • https://github.com/psifidotos/applet-window-appmenu/blob/master/plugin/appmenumodel.cpp

Zren avatar Apr 19 '20 00:04 Zren

Ah bummer. Anyway thanks a lot for your work! I keep watching. How big of a task do you think will the wayland support be (i might have a look into it once i have a bit more time)

chippmann avatar Apr 19 '20 05:04 chippmann

If the widget works in walyand, then it should be possible.

The hard part is testing it, as while you can restart plasmashell easily in wayland, you can't really easily test kwin_wayland as killing it will restart your session.

Zren avatar Apr 22 '20 18:04 Zren

As of earlier today, when Plasma 5.19 was released, the Global Menu works under Wayland. From my testing, LIM does not work as it currently is under Wayland, but perhaps due to the advancements it could with a bit of tweaking? The global menu is currently the only thing keeping me on X11, so it'd be awesome to be able to migrate.

baduhai avatar Jun 09 '20 19:06 baduhai

FWIW, applet-window-appmenu has added wayland support recently.

trmdi avatar Aug 06 '20 03:08 trmdi

I'd noticed the LibTaskManager changes in Plasma 5.19, but wasn't entirely sure how to link it.

Relevant changes:

  • https://github.com/psifidotos/applet-window-appmenu/compare/1b54d13c23cb4964566aa0510aca9a29aa1af96f...master

  • https://github.com/psifidotos/applet-window-appmenu/commit/83e19b38cf952241c3994234348f53504febfd80
  • https://github.com/psifidotos/applet-window-appmenu/commit/1b08fc22e8d8d73a07e4c0ad6405f9db8c4560df

  • https://github.com/psifidotos/applet-window-appmenu/commit/2799bfd7aad973f599f66532f31b8f27e478b89e
  • https://github.com/psifidotos/applet-window-appmenu/commit/63f820ee571576e2f51f1e3df7dee60c70d7fda8
  • https://github.com/psifidotos/applet-window-appmenu/commit/72d5b3f8f3e8d8793796b27563ea6937be0f2f5b
  • https://github.com/psifidotos/applet-window-appmenu/commit/01f66220967b21b78b6c7cac21b2ed0ccf623fb5
  • https://github.com/psifidotos/applet-window-appmenu/commit/6857f034e7a98635e1c92e708b2ce6d0d5257bff

  • https://github.com/psifidotos/applet-window-appmenu/blame/master/lib/appmenuapplet.cpp
  • https://github.com/psifidotos/applet-window-appmenu/blame/master/plugin/appmenumodel.cpp
  • https://github.com/psifidotos/applet-window-appmenu/blame/master/plugin/wm/abstractwindowmanager.cpp
  • https://github.com/psifidotos/applet-window-appmenu/blame/master/plugin/wm/x11fallbackwindowmanager.cpp
  • https://github.com/psifidotos/applet-window-appmenu/blame/master/plugin/wm/waylandwindowmanager.cpp

Zren avatar Aug 06 '20 14:08 Zren

Here's the commit for how the Global Menu widget implemented LibTaskManager.

  • https://github.com/kde/plasma-workspace/commit/d8d079e42e62e2133477470c1d6b7c4559bcee55

I found I could link with PW::LibTaskManager or taskmanager as it's aliased using add_library(PW::LibTaskManager ALIAS taskmanager). I needed to use #include <taskmanager/tasksmodel.h> to import the TasksModel class. I could only find /usr/include/taskmanager/tasksmodel.h.

  • https://github.com/KDE/plasma-workspace/tree/master/libtaskmanager
  • https://github.com/KDE/plasma-workspace/blob/master/libtaskmanager/CMakeLists.txt#L32
  • locate tasksmodel.h | grep /usr/

Annoyingly, I need to link against Qt5::Quick as TasksModel imports QQmlParserStatus.

The Global Menu widget only calls m_tasksModel->activeTask(), it doesn't need a way to set windowId like LIM needs.

  • https://github.com/kde/plasma-workspace/commit/d8d079e42e62e2133477470c1d6b7c4559bcee55#diff-d51bd2cf6262943da13d8d4e441ebfd8R142

Zren avatar Aug 07 '20 19:08 Zren

All I really need is to connect to the wayland server, find the PlasmaWindow instance, then get it's applicationMenuServiceName() and applicationMenuObjectPath().

  • https://github.com/KDE/plasma-workspace/blob/master/libtaskmanager/waylandtasksmodel.cpp#L122
  • https://github.com/KDE/kwayland/blob/master/src/client/plasmawindowmanagement.h#L247

PlasmaWindow::uuid() was added in the most recent KF5 v5.73.

psifidotos' appmenu widget has a nice WaylandWindowManager::windowFor(QVariant wid) I can use. It checks if PlasmaWindow::isValid() && PlasmaWindow::internalId() == wid.toUInt(). Unfortunately, internalId() is deprecated in the latest KF5 v5.73.

  • https://github.com/psifidotos/applet-window-appmenu/compare/1b54d13c23cb4964566aa0510aca9a29aa1af96f...master#diff-91738585b755500885894ad0c046669dR104

Zren avatar Aug 08 '20 02:08 Zren

Seems like the replacement for internalId() is uuid(), which doesn't seem so hard to adapt.

baduhai avatar Oct 22 '20 14:10 baduhai

Note: I haven't actually gotten wayland working, I'm just poking at KDecoration code.

For some reason, wayland menus show up with a titlebar. Even the standard ApplicationMenu icon button from Breeze.

2021-03-15___21-49-11

Oddly, the AppIcon button menu displays properly.

  • decoration->requestShowWindowMenu https://invent.kde.org/plasma/kdecoration/-/blob/master/src/decorationbutton.cpp#L58-62
  • DecoratedClientImpl::requestShowWindowMenu https://invent.kde.org/plasma/kwin/-/blob/master/src/decorations/decoratedclient.cpp#L229
  • Workspace::showWindowMenu https://invent.kde.org/plasma/kwin/-/blob/master/src/useractions.cpp#L1539
  • UserActionsMenu::show() https://invent.kde.org/plasma/kwin/-/blob/master/src/useractions.cpp#L117
  • UserActionsMenu::init() https://invent.kde.org/plasma/kwin/-/blob/master/src/useractions.cpp#L217
m_menu = new QMenu;
connect(m_menu, &QMenu::aboutToShow, this, &UserActionsMenu::menuAboutToShow);
connect(m_menu, &QMenu::triggered, this, &UserActionsMenu::slotWindowOperation, Qt::QueuedConnection);

QMenu *advancedMenu = new QMenu(m_menu);
connect(advancedMenu, &QMenu::aboutToShow, [this, advancedMenu]() {
    if (m_client) {
        advancedMenu->setPalette(m_client->palette());
    }
});

The ApplicationMenu has a similar call:

  • Workspace::showApplicationMenu https://invent.kde.org/plasma/kwin/-/blob/master/src/useractions.cpp#L1544
  • ApplicationMenu::showApplicationMenu https://invent.kde.org/plasma/kwin/-/blob/master/src/appmenu.cpp#L103
  • Related code: https://invent.kde.org/plasma/kwin/-/commit/93938d60b84df81733da7b3f697332fc76fe085b2

Zren avatar Mar 16 '21 02:03 Zren

5.22 fixed a lot of issues with the global menu on wayland, perhaps there could be some progress now?

That search feature is sweet, and with LIM, it'd be the ultimate setup.

baduhai avatar Jun 17 '21 13:06 baduhai

I've recently switched to Wayland and this feature would be so, so sweet to have! 🙂

Vistaus avatar Jan 13 '22 16:01 Vistaus

@Zren Have you had time to look at this yet?

Vistaus avatar Mar 22 '23 13:03 Vistaus

Hello! Maybe some help is needed?

amorozov avatar May 17 '23 15:05 amorozov

Actually came here just to ping like the folks above. Recently shifted from Gnome to KDE and the absolute waste of space that is a titlebar is doing my head in.

I'm unlikely to find time to help unfortunately.

flukejones avatar May 17 '23 21:05 flukejones

Also came across this - https://invent.kde.org/plasma/breeze/-/merge_requests/126, is it the same code as this?

flukejones avatar May 17 '23 21:05 flukejones

Well, as the annotation says, it's based on the material decoration code. Likely its code slightly differs from the original one. Also it doesn't support the continuation button yet.

amorozov avatar May 20 '23 08:05 amorozov

By the end of the year we will move to Plasma 6 which will have Wayland by default. It would be nice to have the LIM ported to Plasma 6 and if possible to Wayland.

guiodic avatar Aug 05 '23 11:08 guiodic