Skip to content

Commit 79ace78

Browse files
committed
ILXQtTaskbarAbstractBackend: add setDesktopLayout() function
- Use it in DesktopSwitch::settingsChanged()
1 parent 1b7dadc commit 79ace78

File tree

6 files changed

+33
-8
lines changed

6 files changed

+33
-8
lines changed

panel/backends/ilxqttaskbarabstractbackend.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ class ILXQtTaskbarAbstractBackend : public QObject
6060

6161
virtual bool isWindowOnScreen(QScreen *screen, WId windowId) const = 0;
6262

63+
virtual bool setDesktopLayout(Qt::Orientation orientation, int rows, int columns, bool rightToLeft) = 0;
64+
6365
// X11 Specific
6466
virtual void moveApplication(WId windowId) = 0;
6567
virtual void resizeApplication(WId windowId) = 0;

panel/backends/lxqttaskbardummybackend.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ bool LXQtTaskBarDummyBackend::isWindowOnScreen(QScreen *, WId) const
131131
return false;
132132
}
133133

134+
bool setDesktopLayout(Qt::Orientation, int, int, bool)
135+
{
136+
return false;
137+
}
138+
134139
/************************************************
135140
* X11 Specific
136141
************************************************/

panel/backends/lxqttaskbardummybackend.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ class LXQtTaskBarDummyBackend : public ILXQtTaskbarAbstractBackend
5353

5454
bool isWindowOnScreen(QScreen *screen, WId windowId) const override;
5555

56+
virtual bool setDesktopLayout(Qt::Orientation orientation, int rows, int columns, bool rightToLeft) override;
57+
5658
// X11 Specific
5759
void moveApplication(WId windowId) override;
5860
void resizeApplication(WId windowId) override;

panel/backends/xcb/lxqttaskbarbackend_x11.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,25 @@ bool LXQtTaskbarX11Backend::isWindowOnScreen(QScreen *screen, WId windowId) cons
520520
return screen->geometry().intersects(r);
521521
}
522522

523+
bool LXQtTaskbarX11Backend::setDesktopLayout(Qt::Orientation orientation, int rows, int columns, bool rightToLeft)
524+
{
525+
NETRootInfo mDesktops(m_xcbConnection, NET::NumberOfDesktops | NET::CurrentDesktop | NET::DesktopNames, NET::WM2DesktopLayout);
526+
527+
if (orientation == Qt::Horizontal)
528+
{
529+
mDesktops.setDesktopLayout(NET::OrientationHorizontal,
530+
columns, rows,
531+
rightToLeft ? NET::DesktopLayoutCornerTopRight : NET::DesktopLayoutCornerTopLeft);
532+
}
533+
else
534+
{
535+
mDesktops.setDesktopLayout(NET::OrientationHorizontal,
536+
rows, columns,
537+
rightToLeft ? NET::DesktopLayoutCornerTopRight : NET::DesktopLayoutCornerTopLeft);
538+
}
539+
return true;
540+
}
541+
523542
/************************************************
524543
* X11 Specific
525544
************************************************/

panel/backends/xcb/lxqttaskbarbackend_x11.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ class LXQtTaskbarX11Backend : public ILXQtTaskbarAbstractBackend
5555

5656
virtual bool isWindowOnScreen(QScreen *screen, WId windowId) const override;
5757

58+
virtual bool setDesktopLayout(Qt::Orientation orientation, int rows, int columns, bool rightToLeft) override;
59+
5860
// X11 Specific
5961
virtual void moveApplication(WId windowId) override;
6062
virtual void resizeApplication(WId windowId) override;

plugin-desktopswitch/desktopswitch.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -245,14 +245,9 @@ void DesktopSwitch::settingsChanged()
245245
// "DesktopSwitch::realign()". Therefore, the desktop layout should not be changed
246246
// inside the latter method.
247247
int columns = static_cast<int>(ceil(static_cast<float>(m_desktopCount) / mRows));
248-
if (panel()->isHorizontal())
249-
{
250-
//mDesktops->setDesktopLayout(NET::OrientationHorizontal, columns, mRows, mWidget.isRightToLeft() ? NET::DesktopLayoutCornerTopRight : NET::DesktopLayoutCornerTopLeft);
251-
}
252-
else
253-
{
254-
//mDesktops->setDesktopLayout(NET::OrientationHorizontal, mRows, columns, mWidget.isRightToLeft() ? NET::DesktopLayoutCornerTopRight : NET::DesktopLayoutCornerTopLeft);
255-
}
248+
mBackend->setDesktopLayout(panel()->isHorizontal() ? Qt::Horizontal : Qt::Vertical,
249+
mRows, columns, mWidget.isRightToLeft());
250+
256251
realign(); // in case it isn't called when the desktop layout changes
257252
}
258253
if (need_refresh)

0 commit comments

Comments
 (0)