Skip to content

Commit

Permalink
TaskBar: remove last X11 specific code
Browse files Browse the repository at this point in the history
  • Loading branch information
gfgit committed Jan 28, 2024
1 parent 01704dd commit 9b6ae3f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 23 deletions.
11 changes: 3 additions & 8 deletions plugin-taskbar/lxqttaskbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@

#include "lxqttaskbarbackend_x11.h"

//TODO: remove
#include <KX11Extras>

using namespace LXQt;

/************************************************
Expand Down Expand Up @@ -108,21 +105,19 @@ LXQtTaskBar::LXQtTaskBar(ILXQtPanelPlugin *plugin, QWidget *parent) :


// Temporary workaround
auto onWindowChanged_ = [this](WId window, NET::Properties prop, NET::Properties2 prop2)
auto onWindowChanged_ = [this](WId window, int prop)
{
auto i = mKnownWindows.find(window);
if (mKnownWindows.end() != i)
{
if (!(*i)->onWindowChanged(window, prop, prop2) && acceptWindow(window))
if (!(*i)->onWindowChanged(window, LXQtTaskBarWindowProperty(prop)))
{ // window is removed from a group because of class change, so we should add it again
addWindow(window);
}
}
};

connect(KX11Extras::self(),
static_cast<void (KX11Extras::*)(WId, NET::Properties, NET::Properties2)>(&KX11Extras::windowChanged),
this, onWindowChanged_);
connect(mBackend, &ILXQtTaskbarAbstractBackend::windowPropertyChanged, this, onWindowChanged_);

connect(mBackend, &ILXQtTaskbarAbstractBackend::windowAdded, this, &LXQtTaskBar::onWindowAdded);
connect(mBackend, &ILXQtTaskbarAbstractBackend::windowRemoved, this, &LXQtTaskBar::onWindowRemoved);
Expand Down
24 changes: 11 additions & 13 deletions plugin-taskbar/lxqttaskgroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,8 +617,10 @@ void LXQtTaskGroup::wheelEvent(QWheelEvent* event)
/************************************************
************************************************/
bool LXQtTaskGroup::onWindowChanged(WId window, NET::Properties prop, NET::Properties2 prop2)
{ // returns true if the class is preserved
bool LXQtTaskGroup::onWindowChanged(WId window, LXQtTaskBarWindowProperty prop)
{
// Returns true if the class is preserved

bool needsRefreshVisibility{false};
QVector<LXQtTaskButton *> buttons;
if (mButtonHash.contains(window))
Expand All @@ -631,17 +633,16 @@ bool LXQtTaskGroup::onWindowChanged(WId window, NET::Properties prop, NET::Prope
if (!buttons.isEmpty())
{
// if class is changed the window won't belong to our group any more
if (parentTaskBar()->isGroupingEnabled() && prop2.testFlag(NET::WM2WindowClass))
if (parentTaskBar()->isGroupingEnabled() && prop == LXQtTaskBarWindowProperty::WindowClass)
{
KWindowInfo info(window, NET::Properties(), NET::WM2WindowClass);
if (QString::fromUtf8(info.windowClassClass()) != mGroupName)
if (mBackend->getWindowClass(windowId()) != mGroupName)
{
onWindowRemoved(window);
return false;
}
}
// window changed virtual desktop
if (prop.testFlag(NET::WMDesktop) || prop.testFlag(NET::WMGeometry))
if (prop == LXQtTaskBarWindowProperty::Workspace)
{
if (parentTaskBar()->isShowOnlyOneDesktopTasks()
|| parentTaskBar()->isShowOnlyCurrentScreenTasks())
Expand All @@ -650,31 +651,28 @@ bool LXQtTaskGroup::onWindowChanged(WId window, NET::Properties prop, NET::Prope
}
}

if (prop.testFlag(NET::WMVisibleName) || prop.testFlag(NET::WMName))
if (prop == LXQtTaskBarWindowProperty::Title)
std::for_each(buttons.begin(), buttons.end(), std::mem_fn(&LXQtTaskButton::updateText));

// XXX: we are setting window icon geometry -> don't need to handle NET::WMIconGeometry
// Icon of the button can be based on windowClass
if (prop.testFlag(NET::WMIcon) || prop2.testFlag(NET::WM2WindowClass))
if (prop == LXQtTaskBarWindowProperty::Icon)
std::for_each(buttons.begin(), buttons.end(), std::mem_fn(&LXQtTaskButton::updateIcon));

bool set_urgency = false;
bool urgency = false;
if (prop2.testFlag(NET::WM2Urgency))
if (prop == LXQtTaskBarWindowProperty::Urgency)
{
set_urgency = true;
//FIXME: original code here did not consider "demand attention", was it intentional?
urgency = mBackend->applicationDemandsAttention(window);
}
if (prop.testFlag(NET::WMState))
if (prop == LXQtTaskBarWindowProperty::State)
{
KWindowInfo info{window, NET::WMState};
if (!set_urgency)
urgency = mBackend->applicationDemandsAttention(window);
std::for_each(buttons.begin(), buttons.end(), std::bind(&LXQtTaskButton::setUrgencyHint, std::placeholders::_1, urgency));
set_urgency = false;
if (info.hasState(NET::SkipTaskbar))
onWindowRemoved(window);

if (parentTaskBar()->isShowOnlyMinimizedTasks())
{
Expand Down
5 changes: 3 additions & 2 deletions plugin-taskbar/lxqttaskgroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

#include "lxqttaskbutton.h"

#include <KF5/KWindowSystem/kwindowsystem.h>
#include "lxqttaskbartypes.h"

class QVBoxLayout;
class ILXQtPanelPlugin;
Expand All @@ -60,7 +60,8 @@ class LXQtTaskGroup: public LXQtTaskButton
// if circular is true, then it will go around the list of buttons
LXQtTaskButton * getNextPrevChildButton(bool next, bool circular);

bool onWindowChanged(WId window, NET::Properties prop, NET::Properties2 prop2);
bool onWindowChanged(WId window, LXQtTaskBarWindowProperty prop);

void setAutoRotation(bool value, ILXQtPanel::Position position);
Qt::ToolButtonStyle popupButtonStyle() const;
void setToolButtonsStyle(Qt::ToolButtonStyle style);
Expand Down

0 comments on commit 9b6ae3f

Please sign in to comment.