Skip to content

Commit

Permalink
TaskBar: LXQtTaskButton remove X11 specific code
Browse files Browse the repository at this point in the history
  • Loading branch information
gfgit committed Feb 21, 2024
1 parent 8609956 commit e923744
Showing 1 changed file with 35 additions and 33 deletions.
68 changes: 35 additions & 33 deletions plugin-taskbar/lxqttaskbutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void LXQtTaskButton::updateIcon()
QIcon ico;
if (mParentTaskBar->isIconByClass())
{
ico = XdgIcon::fromTheme(QString::fromUtf8(KWindowInfo{mWindow, NET::Properties(), NET::WM2WindowClass}.windowClassClass()).toLower());
ico = XdgIcon::fromTheme(mBackend->getWindowClass(mWindow).toLower());
}
if (ico.isNull())
{
Expand Down Expand Up @@ -515,8 +515,7 @@ void LXQtTaskButton::contextMenuEvent(QContextMenuEvent* event)
return;
}

KWindowInfo info(mWindow, NET::Properties(), NET::WM2AllowedActions);
NET::States state = KWindowInfo(mWindow, NET::WMState).state();
const LXQtTaskBarWindowState state = mBackend->getWindowState(mWindow);

QMenu * menu = new QMenu(tr("Application"));
menu->setAttribute(Qt::WA_DeleteOnClose);
Expand Down Expand Up @@ -585,74 +584,79 @@ void LXQtTaskButton::contextMenuEvent(QContextMenuEvent* event)
menu->addSeparator();
a = menu->addAction(tr("Move To N&ext Monitor"));
connect(a, &QAction::triggered, this, [this] { moveApplicationToPrevNextMonitor(true); });
a->setEnabled(info.actionSupported(NET::ActionMove) && (!(state & NET::FullScreen) || ((state & NET::FullScreen) && info.actionSupported(NET::ActionFullScreen))));
a->setEnabled(mBackend->supportsAction(mWindow, LXQtTaskBarBackendAction::Move) &&
(state != LXQtTaskBarWindowState::FullScreen
|| ((state == LXQtTaskBarWindowState::FullScreen) && mBackend->supportsAction(mWindow, LXQtTaskBarBackendAction::FullScreen))));
a = menu->addAction(tr("Move To &Previous Monitor"));
connect(a, &QAction::triggered, this, [this] { moveApplicationToPrevNextMonitor(false); });
}

menu->addSeparator();
a = menu->addAction(tr("&Move"));
a->setEnabled(info.actionSupported(NET::ActionMove) && !(state & NET::Max) && !(state & NET::FullScreen));
a->setEnabled(mBackend->supportsAction(mWindow, LXQtTaskBarBackendAction::Move)
&& state != LXQtTaskBarWindowState::Maximized
&& state != LXQtTaskBarWindowState::FullScreen);
connect(a, &QAction::triggered, this, &LXQtTaskButton::moveApplication);
a = menu->addAction(tr("Resi&ze"));
a->setEnabled(info.actionSupported(NET::ActionResize) && !(state & NET::Max) && !(state & NET::FullScreen));
a->setEnabled(mBackend->supportsAction(mWindow, LXQtTaskBarBackendAction::Resize)
&& state != LXQtTaskBarWindowState::Maximized
&& state != LXQtTaskBarWindowState::FullScreen);
connect(a, &QAction::triggered, this, &LXQtTaskButton::resizeApplication);

/********** State menu **********/
menu->addSeparator();

LXQtTaskBarWindowState windowState = mBackend->getWindowState(mWindow);

a = menu->addAction(tr("Ma&ximize"));
a->setEnabled(info.actionSupported(NET::ActionMax)
&& windowState != LXQtTaskBarWindowState::Maximized
&& windowState != LXQtTaskBarWindowState::Hidden);
a->setEnabled(mBackend->supportsAction(mWindow, LXQtTaskBarBackendAction::Maximize)
&& state != LXQtTaskBarWindowState::Maximized
&& state != LXQtTaskBarWindowState::Hidden);
a->setData(int(LXQtTaskBarWindowState::Maximized));
connect(a, &QAction::triggered, this, &LXQtTaskButton::maximizeApplication);

if (event->modifiers() & Qt::ShiftModifier)
{
a = menu->addAction(tr("Maximize vertically"));
a->setEnabled(info.actionSupported(NET::ActionMaxVert)
&& windowState != LXQtTaskBarWindowState::MaximizedVertically
&& windowState != LXQtTaskBarWindowState::Hidden);
a->setEnabled(mBackend->supportsAction(mWindow, LXQtTaskBarBackendAction::MaximizeVertically)
&& state != LXQtTaskBarWindowState::MaximizedVertically
&& state != LXQtTaskBarWindowState::Hidden);
a->setData(int(LXQtTaskBarWindowState::MaximizedVertically));
connect(a, &QAction::triggered, this, &LXQtTaskButton::maximizeApplication);

a = menu->addAction(tr("Maximize horizontally"));
a->setEnabled(info.actionSupported(NET::ActionMaxHoriz)
&& windowState != LXQtTaskBarWindowState::MaximizedHorizontally
&& windowState != LXQtTaskBarWindowState::Hidden);
a->setEnabled(mBackend->supportsAction(mWindow, LXQtTaskBarBackendAction::MaximizeHorizontally)
&& state != LXQtTaskBarWindowState::MaximizedHorizontally
&& state != LXQtTaskBarWindowState::Hidden);
a->setData(int(LXQtTaskBarWindowState::MaximizedHorizontally));
connect(a, &QAction::triggered, this, &LXQtTaskButton::maximizeApplication);
}

a = menu->addAction(tr("&Restore"));
a->setEnabled(windowState == LXQtTaskBarWindowState::Hidden
|| windowState == LXQtTaskBarWindowState::Minimized
|| windowState == LXQtTaskBarWindowState::Maximized
|| windowState == LXQtTaskBarWindowState::MaximizedVertically
|| windowState == LXQtTaskBarWindowState::MaximizedHorizontally);
a->setEnabled(state == LXQtTaskBarWindowState::Hidden
|| state == LXQtTaskBarWindowState::Minimized
|| state == LXQtTaskBarWindowState::Maximized
|| state == LXQtTaskBarWindowState::MaximizedVertically
|| state == LXQtTaskBarWindowState::MaximizedHorizontally);
connect(a, &QAction::triggered, this, &LXQtTaskButton::deMaximizeApplication);

a = menu->addAction(tr("Mi&nimize"));
a->setEnabled(info.actionSupported(NET::ActionMinimize)
&& windowState != LXQtTaskBarWindowState::Hidden
&& windowState != LXQtTaskBarWindowState::Minimized);
a->setEnabled(mBackend->supportsAction(mWindow, LXQtTaskBarBackendAction::Minimize)
&& state != LXQtTaskBarWindowState::Hidden
&& state != LXQtTaskBarWindowState::Minimized);
connect(a, &QAction::triggered, this, &LXQtTaskButton::minimizeApplication);

if (windowState == LXQtTaskBarWindowState::RolledUp)
if (state == LXQtTaskBarWindowState::RolledUp)
{
a = menu->addAction(tr("Roll down"));
a->setEnabled(info.actionSupported(NET::ActionShade)
&& windowState != LXQtTaskBarWindowState::Hidden
&& windowState != LXQtTaskBarWindowState::Minimized);
a->setEnabled(mBackend->supportsAction(mWindow, LXQtTaskBarBackendAction::RollUp)
&& state != LXQtTaskBarWindowState::Hidden
&& state != LXQtTaskBarWindowState::Minimized);
connect(a, &QAction::triggered, this, &LXQtTaskButton::unShadeApplication);
}
else
{
a = menu->addAction(tr("Roll up"));
a->setEnabled(info.actionSupported(NET::ActionShade)
&& windowState != LXQtTaskBarWindowState::Hidden);
a->setEnabled(mBackend->supportsAction(mWindow, LXQtTaskBarBackendAction::RollUp)
&& state != LXQtTaskBarWindowState::Hidden);
connect(a, &QAction::triggered, this, &LXQtTaskButton::shadeApplication);
}

Expand All @@ -663,7 +667,6 @@ void LXQtTaskButton::contextMenuEvent(QContextMenuEvent* event)

LXQtTaskBarWindowLayer currentLayer = mBackend->getWindowLayer(mWindow);

// FIXME: There is no info.actionSupported(NET::ActionKeepAbove)
a = layerMenu->addAction(tr("Always on &top"));
a->setEnabled(currentLayer != LXQtTaskBarWindowLayer::KeepAbove);
a->setData(int(LXQtTaskBarWindowLayer::KeepAbove));
Expand All @@ -674,7 +677,6 @@ void LXQtTaskButton::contextMenuEvent(QContextMenuEvent* event)
a->setData(int(LXQtTaskBarWindowLayer::Normal));
connect(a, &QAction::triggered, this, &LXQtTaskButton::setApplicationLayer);

// FIXME: There is no info.actionSupported(NET::ActionKeepBelow)
a = layerMenu->addAction(tr("Always on &bottom"));
a->setEnabled(currentLayer != LXQtTaskBarWindowLayer::KeepBelow);
a->setData(int(LXQtTaskBarWindowLayer::KeepBelow));
Expand Down

0 comments on commit e923744

Please sign in to comment.