Skip to content

Commit

Permalink
Check for kwin_wayland in XDG_CURRENT_DESKTOP; Add debug messages
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusbritanicus committed Mar 27, 2024
1 parent c6b353f commit a01b215
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 31 deletions.
14 changes: 9 additions & 5 deletions panel/backends/wayland/lxqttaskbarbackendwayland.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ LXQtTaskbarWaylandBackend::LXQtTaskbarWaylandBackend(QObject *parent)
QList<QByteArray> desktopsList = qgetenv("XDG_CURRENT_DESKTOP").toLower().split(':');
qDebug() << "--------------> Current desktop" << desktopsList;
for( QByteArray desktop: desktopsList ) {
if ( desktop == "plasma" || desktop == "kde" )
if ( desktop == "plasma" || desktop == "kde" || desktop == "kwin_wayland" )
{
qDebug() << "--------------> Using plasma backend";
m_backend = new LXQtTaskbarPlasmaBackend();
Expand All @@ -29,28 +29,28 @@ LXQtTaskbarWaylandBackend::LXQtTaskbarWaylandBackend(QObject *parent)

else if ( desktop == "wayfire" )
{
qDebug() << "--------------> Using wlroots backend";
qDebug() << "--------------> Using wayfire backend";
m_backend = new LXQtTaskbarWlrootsBackend();
break;
}

else if ( desktop == "sway" )
{
qDebug() << "--------------> Using wlroots backend";
qDebug() << "--------------> Using sway backend";
m_backend = new LXQtTaskbarWlrootsBackend();
break;
}

else if ( desktop == "labwc" )
{
qDebug() << "--------------> Using wlroots backend";
qDebug() << "--------------> Using labwc backend";
m_backend = new LXQtTaskbarWlrootsBackend();
break;
}

else if ( desktop == "hyprland" )

This comment has been minimized.

Copy link
@stefonarch

stefonarch Mar 27, 2024

Collaborator

afaik Hyprland insists in being capitalized. Adding a fallback to use labwc/wlroots generic backend?

This comment has been minimized.

Copy link
@marcusbritanicus

marcusbritanicus Mar 27, 2024

Author

Note Line 20. When reading XDG_CURRENT_DESKTOP, we're lower-casing it before splitting.

This comment has been minimized.

Copy link
@marcusbritanicus

marcusbritanicus Mar 27, 2024

Author

afaik Hyprland insists in being capitalized. Adding a fallback to use labwc/wlroots generic backend?

Currently, these are all placeholders. Once we start developing plugins, a suitable plugin will be loaded, and it will make more sense.

{
qDebug() << "--------------> Using wlroots backend";
qDebug() << "--------------> Using hyprland backend";
m_backend = new LXQtTaskbarWlrootsBackend();
break;
}
Expand All @@ -60,6 +60,10 @@ LXQtTaskbarWaylandBackend::LXQtTaskbarWaylandBackend(QObject *parent)
// m_backend = nullptr;
}
}

if ( m_backend == nullptr ) {
qDebug() << "--------------> Using dummy backend. No window management will be done";
}
}


Expand Down
34 changes: 9 additions & 25 deletions panel/backends/wayland/wlroots/lxqttaskbarbackendwlr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,31 +29,9 @@ LXQtTaskbarWlrootsBackend::LXQtTaskbarWlrootsBackend(QObject *parent) :
m_workspaceInfo.reset(new LXQtWlrootsWaylandWorkspaceInfo);

connect(m_managment.get(), &LXQtTaskBarWlrootsWindowManagment::windowCreated, this, [this](LXQtTaskBarWlrootsWindow *window) {
qDebug() << "--------------> window created" << window->title << window->appId;
addWindow(window);
});

// connect(m_managment.get(), &LXQtTaskBarWlrootsWindowManagment::stackingOrderChanged,
// this, [this](const QString &order) {
// // stackingOrder = order.split(QLatin1Char(';'));
// // for (const auto &window : std::as_const(windows)) {
// // this->dataChanged(window.get(), StackingOrder);
// // }
// });

connect(m_workspaceInfo.get(), &LXQtWlrootsWaylandWorkspaceInfo::currentDesktopChanged, this,
[this](){
int idx = m_workspaceInfo->position(m_workspaceInfo->currentDesktop());
idx += 1; // Make 1-based
emit currentWorkspaceChanged(idx);
});

connect(m_workspaceInfo.get(), &LXQtWlrootsWaylandWorkspaceInfo::numberOfDesktopsChanged,
this, &ILXQtTaskbarAbstractBackend::workspacesCountChanged);

connect(m_workspaceInfo.get(), &LXQtWlrootsWaylandWorkspaceInfo::desktopNameChanged,
this, [this](int idx) {
emit workspaceNameChanged(idx + 1); // Make 1-based
});
}

bool LXQtTaskbarWlrootsBackend::supportsAction(WId, LXQtTaskBarBackendAction action) const
Expand Down Expand Up @@ -111,6 +89,8 @@ QVector<WId> LXQtTaskbarWlrootsBackend::getCurrentWindows() const
{
wids << window->getWindowId();
}

qDebug() << "--------------> current windows" << wids;
return wids;
}

Expand Down Expand Up @@ -323,6 +303,12 @@ void LXQtTaskbarWlrootsBackend::addWindow(LXQtTaskBarWlrootsWindow *window)
return;
}

/** Add the window once it's ready */
connect(window, &LXQtTaskBarWlrootsWindow::windowReady, this, [window, this] {
qDebug() << "--------------> windowReady; adding window";
emit windowAdded( window->getWindowId() );
});

auto removeWindow = [window, this]
{
auto it = findWindow(windows, window);
Expand Down Expand Up @@ -453,8 +439,6 @@ void LXQtTaskbarWlrootsBackend::addWindow(LXQtTaskBarWlrootsWindow *window)
windows.emplace_back(window);
// updateWindowAcceptance(window);
}

emit windowAdded( window->getWindowId() );
}

bool LXQtTaskbarWlrootsBackend::acceptWindow(LXQtTaskBarWlrootsWindow *window) const
Expand Down
18 changes: 17 additions & 1 deletion panel/backends/wayland/wlroots/lxqttaskbarwlrwindowmanagment.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "lxqttaskbarwlrwindowmanagment.h"

#include <QString>
#include <QFuture>
#include <QtConcurrent>
#include <QGuiApplication>
Expand Down Expand Up @@ -63,6 +64,8 @@ void LXQtTaskBarWlrootsWindowManagment::zwlr_foreign_toplevel_manager_v1_topleve
LXQtTaskBarWlrootsWindow::LXQtTaskBarWlrootsWindow(::zwlr_foreign_toplevel_handle_v1 *id)
: zwlr_foreign_toplevel_handle_v1(id)
{
title = QString::fromUtf8( "untitled" );
appId = QString::fromUtf8( "unknown" );
}

LXQtTaskBarWlrootsWindow::~LXQtTaskBarWlrootsWindow()
Expand All @@ -78,14 +81,27 @@ void LXQtTaskBarWlrootsWindow::activate()
void LXQtTaskBarWlrootsWindow::zwlr_foreign_toplevel_handle_v1_title(const QString &title)
{
this->title = title;
titleRecieved = true;
emit titleChanged();

if ( titleRecieved && appIdRecieved )
{
qDebug() << "--------------> windowReady!!" << getWindowId() << title << appId;
emit windowReady();
}
}

void LXQtTaskBarWlrootsWindow::zwlr_foreign_toplevel_handle_v1_app_id(const QString &app_id)
{
this->appId = app_id;
appIdRecieved = true;
emit appIdChanged();
// Code to get the icon needs to be inserted here

if ( appIdRecieved && titleRecieved )
{
qDebug() << "--------------> windowReady!!" << getWindowId() << title << appId;
emit windowReady();
}
}

void LXQtTaskBarWlrootsWindow::zwlr_foreign_toplevel_handle_v1_output_enter(struct ::wl_output *output)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ class LXQtTaskBarWlrootsWindow : public QObject,
void closed();
void parentChanged();

/** We wait to get the title and appId to emit this */
void windowReady();

protected:
void zwlr_foreign_toplevel_handle_v1_title(const QString &title);
void zwlr_foreign_toplevel_handle_v1_app_id(const QString &app_id);
Expand All @@ -82,4 +85,7 @@ class LXQtTaskBarWlrootsWindow : public QObject,
void setParentWindow(LXQtTaskBarWlrootsWindow *parent);

QMetaObject::Connection parentWindowUnmappedConnection;

mutable bool titleRecieved = false;
mutable bool appIdRecieved = false;
};
3 changes: 3 additions & 0 deletions plugin-taskbar/lxqttaskbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ void LXQtTaskBar::addWindow(WId window)
// If grouping disabled group behaves like regular button
const QString group_id = mGroupingEnabled ? mBackend->getWindowClass(window) : QString::number(window);

qDebug() << "-------------->" << group_id;

LXQtTaskGroup *group = nullptr;
auto i_group = mKnownWindows.find(window);
if (mKnownWindows.end() != i_group)
Expand Down Expand Up @@ -345,6 +347,7 @@ void LXQtTaskBar::onWindowChanged(WId window, int prop)

void LXQtTaskBar::onWindowAdded(WId window)
{
qDebug() << "--------------> onWindowAdded" << window;
auto const pos = mKnownWindows.find(window);
if (mKnownWindows.end() == pos)
addWindow(window);
Expand Down

0 comments on commit a01b215

Please sign in to comment.