From ee1e49ad68a6abdb2edc15829d47f3615eac6b7f Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Tue, 22 Jan 2019 10:18:46 +0100 Subject: [PATCH] Add rows info to the plasma virtual desktop protocol Summary: in order for the pager to work correctly and not having to use a weird mix of wayland and dbus apis, the rows number needs to be in the protocol Test Plan: new passing autotest Reviewers: #plasma, #kwin, davidedmundson Reviewed By: #plasma, #kwin, davidedmundson Subscribers: zzag, davidedmundson, hein, kde-frameworks-devel Tags: #frameworks Maniphest Tasks: T4457 Differential Revision: https://phabricator.kde.org/D17691 --- .../client/test_plasma_virtual_desktop.cpp | 13 +++++++++++++ src/wayland/plasmavirtualdesktop_interface.cpp | 17 ++++++++++++++++- src/wayland/plasmavirtualdesktop_interface.h | 5 +++-- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/wayland/autotests/client/test_plasma_virtual_desktop.cpp b/src/wayland/autotests/client/test_plasma_virtual_desktop.cpp index 8ebc6a16e9..b797258fbb 100644 --- a/src/wayland/autotests/client/test_plasma_virtual_desktop.cpp +++ b/src/wayland/autotests/client/test_plasma_virtual_desktop.cpp @@ -46,6 +46,7 @@ private Q_SLOTS: void cleanup(); void testCreate(); + void testSetRows(); void testConnectNewClient(); void testDestroy(); void testActivate(); @@ -268,6 +269,18 @@ void TestVirtualDesktop::testCreate() } } +void TestVirtualDesktop::testSetRows() +{ + //rebuild some desktops + testCreate(); + + QSignalSpy rowsChangedSpy(m_plasmaVirtualDesktopManagement, &PlasmaVirtualDesktopManagement::rowsChanged); + + m_plasmaVirtualDesktopManagementInterface->setRows(3); + QVERIFY(rowsChangedSpy.wait()); + QCOMPARE(m_plasmaVirtualDesktopManagement->rows(), 3); +} + void TestVirtualDesktop::testConnectNewClient() { //rebuild some desktops diff --git a/src/wayland/plasmavirtualdesktop_interface.cpp b/src/wayland/plasmavirtualdesktop_interface.cpp index 540efd430b..9cb1e3a019 100644 --- a/src/wayland/plasmavirtualdesktop_interface.cpp +++ b/src/wayland/plasmavirtualdesktop_interface.cpp @@ -91,7 +91,7 @@ private: static const quint32 s_version; }; -const quint32 PlasmaVirtualDesktopManagementInterface::Private::s_version = 1; +const quint32 PlasmaVirtualDesktopManagementInterface::Private::s_version = 2; #ifndef DOXYGEN_SHOULD_SKIP_THIS const struct org_kde_plasma_virtual_desktop_management_interface PlasmaVirtualDesktopManagementInterface::Private::s_interface = { @@ -190,6 +190,21 @@ PlasmaVirtualDesktopManagementInterface::Private *PlasmaVirtualDesktopManagement return reinterpret_cast(d.data()); } +void PlasmaVirtualDesktopManagementInterface::setRows(quint32 rows) +{ + if (rows == 0) { + return; + } + + Q_D(); + for (auto it = d->resources.constBegin(); it != d->resources.constEnd(); ++it) { + if (wl_resource_get_version(*it) < ORG_KDE_PLASMA_VIRTUAL_DESKTOP_MANAGEMENT_ROWS_SINCE_VERSION) { + continue; + } + org_kde_plasma_virtual_desktop_management_send_rows(*it, rows); + } +} + PlasmaVirtualDesktopInterface *PlasmaVirtualDesktopManagementInterface::desktop(const QString &id) { Q_D(); diff --git a/src/wayland/plasmavirtualdesktop_interface.h b/src/wayland/plasmavirtualdesktop_interface.h index 9beda79147..b67078f725 100644 --- a/src/wayland/plasmavirtualdesktop_interface.h +++ b/src/wayland/plasmavirtualdesktop_interface.h @@ -46,9 +46,10 @@ public: virtual ~PlasmaVirtualDesktopManagementInterface(); /** - * Sets a new layout for this desktop grid. + * Sets how many rows the virtual desktops should be laid into + * @since 5.55 */ - void setLayout(quint32 rows, quint32 columns); + void setRows(quint32 rows); /** * @returns A desktop identified uniquely by this id.