Skip to content

Commit

Permalink
added support for setting desktoplayout
Browse files Browse the repository at this point in the history
  • Loading branch information
palinek authored and paulolieuthier committed Mar 3, 2015
1 parent d47c009 commit 12620bb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 8 additions & 3 deletions plugin-desktopswitch/desktopswitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@
#include <lxqt-globalkeys.h>
#include <LXQt/GridLayout>
#include <KF5/KWindowSystem/KWindowSystem>
#include <KF5/KWindowSystem/NETWM>
#include <QX11Info>
#include <cmath>

#include <QHBoxLayout>
#include "desktopswitch.h"
#include "desktopswitchbutton.h"
#include "desktopswitchconfiguration.h"
Expand All @@ -44,7 +46,8 @@ DesktopSwitch::DesktopSwitch(const ILxQtPanelPluginStartupInfo &startupInfo) :
ILxQtPanelPlugin(startupInfo),
m_pSignalMapper(new QSignalMapper(this)),
m_desktopCount(KWindowSystem::numberOfDesktops()),
mRows(1)
mRows(1),
mDesktops(new NETRootInfo(QX11Info::connection(), NET::NumberOfDesktops | NET::CurrentDesktop | NET::DesktopNames, NET::WM2DesktopLayout))
{
m_buttons = new QButtonGroup(this);
connect (m_pSignalMapper, SIGNAL(mapped(int)), this, SLOT(setDesktop(int)));
Expand Down Expand Up @@ -142,17 +145,19 @@ void DesktopSwitch::settingsChanged()

void DesktopSwitch::realign()
{
int columns = static_cast<int>(ceil(static_cast<float>(m_desktopCount) / mRows));
mLayout->setEnabled(false);

if (panel()->isHorizontal())
{
mLayout->setRowCount(mRows);
mLayout->setColumnCount(0);
mDesktops->setDesktopLayout(NET::OrientationHorizontal, columns, mRows, NET::DesktopLayoutCornerTopLeft);
}
else
{
mLayout->setColumnCount(mRows);
mLayout->setRowCount(0);
mDesktops->setDesktopLayout(NET::OrientationHorizontal, mRows, columns, NET::DesktopLayoutCornerTopLeft);
}
mLayout->setEnabled(true);
}
Expand Down
3 changes: 3 additions & 0 deletions plugin-desktopswitch/desktopswitch.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@

#include "../panel/ilxqtpanelplugin.h"
#include <QFrame>
#include <QScopedPointer>

class QSignalMapper;
class QButtonGroup;
class NETRootInfo;
namespace LxQt {
class GridLayout;
}
Expand Down Expand Up @@ -74,6 +76,7 @@ class DesktopSwitch : public QObject, public ILxQtPanelPlugin
DesktopSwitchWidget mWidget;
LxQt::GridLayout *mLayout;
int mRows;
QScopedPointer<NETRootInfo> mDesktops;

void setup();

Expand Down

0 comments on commit 12620bb

Please sign in to comment.