Move control of desktop layout from pager to KWin

The desktop layout (number of rows) should be
controlled by the window manager as it is also
responsible for the number of desktops and the
names of them.

The setting for the rows is moved from the pager
UI to the virtual desktops KCM. The desktop layout
is set when KWin starts and updated by the KCM.

With this change there is no process claiming the
manager selection for pager any more. This means
the KDE Plasma Workspaces are no longer compliant
to the complete section of _NET_DESKTOP_LAYOUT in
the EWMH.

REVIEW: 102073
BUG: 277965
FEATURE: 105779
FEATURE: 213353
FIXED-IN: 4.8.0
This commit is contained in:
Martin Gräßlin 2011-07-24 14:59:39 +02:00
parent c37c9de57b
commit fb4d148f53
3 changed files with 42 additions and 10 deletions

View file

@ -76,11 +76,6 @@ void KWinDesktopConfig::init()
m_ui->desktopNames->setMaxDesktops(maxDesktops);
m_ui->desktopNames->numberChanged(defaultDesktops);
// number of rows are still missing in Plasma - hide them for now
// TODO: bring them back when trunk is open and bug Plasma devs ;-)
m_ui->label->hide();
m_ui->rowsSpinBox->hide();
QVBoxLayout* layout = new QVBoxLayout(this);
layout->addWidget(m_ui);
@ -210,12 +205,14 @@ void KWinDesktopConfig::init()
//number of desktops widgets
m_ui->numberLabel->setEnabled(false);
m_ui->numberSpinBox->setEnabled(false);
m_ui->rowsSpinBox->setEnabled(false);
} else {
KConfigGroup cfgGroup(m_config.data(), groupname.constData());
if (cfgGroup.isEntryImmutable("Number")) {
//number of desktops widgets
m_ui->numberLabel->setEnabled(false);
m_ui->numberSpinBox->setEnabled(false);
m_ui->rowsSpinBox->setEnabled(false);
}
}
// End check for immutable
@ -246,6 +243,8 @@ void KWinDesktopConfig::defaults()
m_ui->wrapAroundBox->setChecked(true);
m_ui->rowsSpinBox->setValue(2);
m_editor->allDefault();
emit changed(true);
@ -259,13 +258,15 @@ void KWinDesktopConfig::load()
#ifdef Q_WS_X11
// get number of desktops
NETRootInfo info(QX11Info::display(), NET::NumberOfDesktops | NET::DesktopNames);
unsigned long properties[] = {NET::NumberOfDesktops | NET::DesktopNames, NET::WM2DesktopLayout };
NETRootInfo info(QX11Info::display(), properties, 2);
for (int i = 1; i <= maxDesktops; i++) {
QString name = QString::fromUtf8(info.desktopName(i));
m_desktopNames << name;
m_ui->desktopNames->setName(i, name);
}
m_ui->rowsSpinBox->setValue(info.desktopLayoutColumnsRows().height());
#endif
// Popup info
@ -306,7 +307,8 @@ void KWinDesktopConfig::save()
{
// TODO: plasma stuff
#ifdef Q_WS_X11
NETRootInfo info(QX11Info::display(), NET::NumberOfDesktops | NET::DesktopNames);
unsigned long properties[] = {NET::NumberOfDesktops | NET::DesktopNames, NET::WM2DesktopLayout };
NETRootInfo info(QX11Info::display(), properties, 2);
// set desktop names
for (int i = 1; i <= maxDesktops; i++) {
QString desktopName = m_desktopNames[ i -1 ];
@ -316,10 +318,30 @@ void KWinDesktopConfig::save()
info.activate();
}
// set number of desktops
info.setNumberOfDesktops(m_ui->numberSpinBox->value());
const int numberDesktops = m_ui->numberSpinBox->value();
info.setNumberOfDesktops(numberDesktops);
info.activate();
int rows =m_ui->rowsSpinBox->value();
rows = qBound(1, rows, numberDesktops);
// avoid weird cases like having 3 rows for 4 desktops, where the last row is unused
int columns = numberDesktops / rows;
if (numberDesktops % rows > 0) {
columns++;
}
info.setDesktopLayout(NET::OrientationHorizontal, columns, rows, NET::DesktopLayoutCornerTopLeft);
info.activate();
XSync(QX11Info::display(), false);
// save the desktops
QString groupname;
const int screenNumber = DefaultScreen(QX11Info::display());
if (screenNumber == 0)
groupname = "Desktops";
else
groupname.sprintf("Desktops-screen-%d", screenNumber);
KConfigGroup group(m_config, groupname);
group.writeEntry("Rows", rows);
#endif
// Popup info

View file

@ -65,7 +65,7 @@
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="text">
<string>Number of rows:</string>
@ -78,7 +78,7 @@
<item row="1" column="1">
<widget class="KIntSpinBox" name="rowsSpinBox">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
</widget>
</item>

View file

@ -1093,6 +1093,16 @@ void Workspace::loadDesktopSettings()
rootInfo->setDesktopName(i, s.toUtf8().data());
desktop_focus_chain[i-1] = i;
}
int rows = group.readEntry<int>("Rows", 2);
rows = qBound(1, rows, n);
// avoid weird cases like having 3 rows for 4 desktops, where the last row is unused
int columns = n / rows;
if (n % rows > 0) {
columns++;
}
rootInfo->setDesktopLayout(NET::OrientationHorizontal, columns, rows, NET::DesktopLayoutCornerTopLeft);
rootInfo->activate();
_loading_desktop_settings = false;
}