diff --git a/autotests/client/test_plasma_window_model.cpp b/autotests/client/test_plasma_window_model.cpp --- a/autotests/client/test_plasma_window_model.cpp +++ b/autotests/client/test_plasma_window_model.cpp @@ -62,6 +62,8 @@ void testSkipTaskbar(); void testIsShadable(); void testIsShaded(); + void testIsMovable(); + void testIsResizable(); void testTitle(); void testAppId(); void testVirtualDesktop(); @@ -219,6 +221,8 @@ QTest::newRow("SkipTaskbar") << int(PlasmaWindowModel::SkipTaskbar) << QByteArrayLiteral("SkipTaskbar"); QTest::newRow("IsShadable") << int(PlasmaWindowModel::IsShadable) << QByteArrayLiteral("IsShadable"); QTest::newRow("IsShaded") << int(PlasmaWindowModel::IsShaded) << QByteArrayLiteral("IsShaded"); + QTest::newRow("IsMovable") << int(PlasmaWindowModel::IsMovable) << QByteArrayLiteral("IsMovable"); + QTest::newRow("IsResizable") << int(PlasmaWindowModel::IsResizable) << QByteArrayLiteral("IsResizable"); } void PlasmaWindowModelTest::testRoleNames() @@ -299,6 +303,8 @@ QTest::newRow("IsShadable") << int(PlasmaWindowModel::IsShadable) << QVariant(false); QTest::newRow("IsShaded") << int(PlasmaWindowModel::IsShaded) << QVariant(false); QTest::newRow("SkipTaskbar") << int(PlasmaWindowModel::SkipTaskbar) << QVariant(false); + QTest::newRow("IsMovable") << int(PlasmaWindowModel::IsMovable) << QVariant(false); + QTest::newRow("IsResizable") << int(PlasmaWindowModel::IsResizable) << QVariant(false); } void PlasmaWindowModelTest::testDefaultData() @@ -388,6 +394,16 @@ QVERIFY(testBooleanData(PlasmaWindowModel::IsShaded, &PlasmaWindowInterface::setShaded)); } +void PlasmaWindowModelTest::testIsMovable() +{ + QVERIFY(testBooleanData(PlasmaWindowModel::IsMovable, &PlasmaWindowInterface::setMovable)); +} + +void PlasmaWindowModelTest::testIsResizable() +{ + QVERIFY(testBooleanData(PlasmaWindowModel::IsResizable, &PlasmaWindowInterface::setResizable)); +} + void PlasmaWindowModelTest::testTitle() { auto model = m_pw->createWindowModel(); @@ -491,6 +507,10 @@ QVERIFY(activateRequestedSpy.isValid()); QSignalSpy closeRequestedSpy(w, &PlasmaWindowInterface::closeRequested); QVERIFY(closeRequestedSpy.isValid()); + QSignalSpy moveModeRequestedSpy(w, &PlasmaWindowInterface::moveModeRequested); + QVERIFY(moveModeRequestedSpy.isValid()); + QSignalSpy resizeModeRequestedSpy(w, &PlasmaWindowInterface::resizeModeRequested); + QVERIFY(resizeModeRequestedSpy.isValid()); QSignalSpy virtualDesktopRequestedSpy(w, &PlasmaWindowInterface::virtualDesktopRequested); QVERIFY(virtualDesktopRequestedSpy.isValid()); QSignalSpy minimizedRequestedSpy(w, &PlasmaWindowInterface::minimizedRequested); @@ -508,14 +528,18 @@ model->requestToggleMaximized(-1); model->requestActivate(1); model->requestClose(1); + model->requestMoveMode(1); + model->requestResizeMode(1); model->requestVirtualDesktop(1, 1); model->requestToggleMinimized(1); model->requestToggleMaximized(1); model->requestToggleShaded(1); // that should not have triggered any signals QVERIFY(!activateRequestedSpy.wait(100)); QVERIFY(activateRequestedSpy.isEmpty()); QVERIFY(closeRequestedSpy.isEmpty()); + QVERIFY(moveModeRequestedSpy.isEmpty()); + QVERIFY(resizeModeRequestedSpy.isEmpty()); QVERIFY(virtualDesktopRequestedSpy.isEmpty()); QVERIFY(minimizedRequestedSpy.isEmpty()); QVERIFY(maximizeRequestedSpy.isEmpty()); @@ -528,6 +552,8 @@ QCOMPARE(activateRequestedSpy.count(), 1); QCOMPARE(activateRequestedSpy.first().first().toBool(), true); QCOMPARE(closeRequestedSpy.count(), 0); + QCOMPARE(moveModeRequestedSpy.count(), 0); + QCOMPARE(resizeModeRequestedSpy.count(), 0); QCOMPARE(virtualDesktopRequestedSpy.count(), 0); QCOMPARE(minimizedRequestedSpy.count(), 0); QCOMPARE(maximizeRequestedSpy.count(), 0); @@ -537,6 +563,30 @@ QVERIFY(closeRequestedSpy.wait()); QCOMPARE(activateRequestedSpy.count(), 1); QCOMPARE(closeRequestedSpy.count(), 1); + QCOMPARE(moveModeRequestedSpy.count(), 0); + QCOMPARE(resizeModeRequestedSpy.count(), 0); + QCOMPARE(virtualDesktopRequestedSpy.count(), 0); + QCOMPARE(minimizedRequestedSpy.count(), 0); + QCOMPARE(maximizeRequestedSpy.count(), 0); + QCOMPARE(shadeRequestedSpy.count(), 0); + // move mode + model->requestMoveMode(0); + QVERIFY(moveModeRequestedSpy.wait()); + QCOMPARE(activateRequestedSpy.count(), 1); + QCOMPARE(closeRequestedSpy.count(), 1); + QCOMPARE(moveModeRequestedSpy.count(), 1); + QCOMPARE(resizeModeRequestedSpy.count(), 0); + QCOMPARE(virtualDesktopRequestedSpy.count(), 0); + QCOMPARE(minimizedRequestedSpy.count(), 0); + QCOMPARE(maximizeRequestedSpy.count(), 0); + QCOMPARE(shadeRequestedSpy.count(), 0); + // resizeMode + model->requestResizeMode(0); + QVERIFY(resizeModeRequestedSpy.wait()); + QCOMPARE(activateRequestedSpy.count(), 1); + QCOMPARE(closeRequestedSpy.count(), 1); + QCOMPARE(moveModeRequestedSpy.count(), 1); + QCOMPARE(resizeModeRequestedSpy.count(), 1); QCOMPARE(virtualDesktopRequestedSpy.count(), 0); QCOMPARE(minimizedRequestedSpy.count(), 0); QCOMPARE(maximizeRequestedSpy.count(), 0); @@ -548,6 +598,8 @@ QCOMPARE(virtualDesktopRequestedSpy.first().first().toUInt(), 1u); QCOMPARE(activateRequestedSpy.count(), 1); QCOMPARE(closeRequestedSpy.count(), 1); + QCOMPARE(moveModeRequestedSpy.count(), 1); + QCOMPARE(resizeModeRequestedSpy.count(), 1); QCOMPARE(minimizedRequestedSpy.count(), 0); QCOMPARE(maximizeRequestedSpy.count(), 0); QCOMPARE(shadeRequestedSpy.count(), 0); @@ -558,6 +610,8 @@ QCOMPARE(minimizedRequestedSpy.first().first().toBool(), true); QCOMPARE(activateRequestedSpy.count(), 1); QCOMPARE(closeRequestedSpy.count(), 1); + QCOMPARE(moveModeRequestedSpy.count(), 1); + QCOMPARE(resizeModeRequestedSpy.count(), 1); QCOMPARE(virtualDesktopRequestedSpy.count(), 1); QCOMPARE(maximizeRequestedSpy.count(), 0); QCOMPARE(shadeRequestedSpy.count(), 0); @@ -568,6 +622,7 @@ QCOMPARE(maximizeRequestedSpy.first().first().toBool(), true); QCOMPARE(activateRequestedSpy.count(), 1); QCOMPARE(closeRequestedSpy.count(), 1); + QCOMPARE(moveModeRequestedSpy.count(), 1); QCOMPARE(virtualDesktopRequestedSpy.count(), 1); QCOMPARE(minimizedRequestedSpy.count(), 1); QCOMPARE(shadeRequestedSpy.count(), 0); @@ -578,6 +633,8 @@ QCOMPARE(shadeRequestedSpy.first().first().toBool(), true); QCOMPARE(activateRequestedSpy.count(), 1); QCOMPARE(closeRequestedSpy.count(), 1); + QCOMPARE(moveModeRequestedSpy.count(), 1); + QCOMPARE(resizeModeRequestedSpy.count(), 1); QCOMPARE(virtualDesktopRequestedSpy.count(), 1); QCOMPARE(minimizedRequestedSpy.count(), 1); QCOMPARE(maximizeRequestedSpy.count(), 1); diff --git a/src/client/plasmawindowmanagement.h b/src/client/plasmawindowmanagement.h --- a/src/client/plasmawindowmanagement.h +++ b/src/client/plasmawindowmanagement.h @@ -230,9 +230,25 @@ * @since 5.7 */ bool isShaded() const; + /** + * @since 5.7 + */ + bool isMovable() const; + /** + * @since 5.7 + */ + bool isResizable() const; void requestActivate(); void requestClose(); + /** + * @since 5.7 + */ + void requestMoveMode(); + /** + * @since 5.7 + */ + void requestResizeMode(); void requestVirtualDesktop(quint32 desktop); /** * Requests the window at this model row index have its minimized state toggled. @@ -296,6 +312,14 @@ * @since 5.7 */ void shadedChanged(); + /** + * @since 5.7 + */ + void movableChanged(); + /** + * @since 5.7 + */ + void resizableChanged(); void unmapped(); private: diff --git a/src/client/plasmawindowmanagement.cpp b/src/client/plasmawindowmanagement.cpp --- a/src/client/plasmawindowmanagement.cpp +++ b/src/client/plasmawindowmanagement.cpp @@ -265,6 +265,8 @@ bool skipTaskbar = false; bool shadable = false; bool shaded = false; + bool movable = false; + bool resizable = false; QIcon icon; private: @@ -289,6 +291,8 @@ void setSkipTaskbar(bool skip); void setShadable(bool set); void setShaded(bool set); + void setMovable(bool set); + void setResizable(bool set); static Private *cast(void *data) { return reinterpret_cast(data); @@ -370,6 +374,8 @@ p->setSkipTaskbar(state & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SKIPTASKBAR); p->setShadable(state & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SHADABLE); p->setShaded(state & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SHADED); + p->setMovable(state & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_MOVABLE); + p->setResizable(state & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_RESIZABLE); } void PlasmaWindow::Private::themedIconNameChangedCallback(void *data, org_kde_plasma_window *window, const char *name) @@ -516,6 +522,24 @@ emit q->shadedChanged(); } +void PlasmaWindow::Private::setMovable(bool set) +{ + if (movable == set) { + return; + } + movable = set; + emit q->movableChanged(); +} + +void PlasmaWindow::Private::setResizable(bool set) +{ + if (resizable == set) { + return; + } + resizable = set; + emit q->resizableChanged(); +} + PlasmaWindow::Private::Private(org_kde_plasma_window *w, quint32 internalId, PlasmaWindow *q) : internalId(internalId) , q(q) @@ -656,6 +680,16 @@ return d->shaded; } +bool PlasmaWindow::isResizable() const +{ + return d->resizable; +} + +bool PlasmaWindow::isMovable() const +{ + return d->movable; +} + void PlasmaWindow::requestActivate() { org_kde_plasma_window_set_state(d->window, @@ -668,6 +702,16 @@ org_kde_plasma_window_close(d->window); } +void PlasmaWindow::requestMoveMode() +{ + org_kde_plasma_window_request_move_mode(d->window); +} + +void PlasmaWindow::requestResizeMode() +{ + org_kde_plasma_window_request_resize_mode(d->window); +} + void PlasmaWindow::requestVirtualDesktop(quint32 desktop) { org_kde_plasma_window_set_virtual_desktop(d->window, desktop); diff --git a/src/client/plasmawindowmodel.h b/src/client/plasmawindowmodel.h --- a/src/client/plasmawindowmodel.h +++ b/src/client/plasmawindowmodel.h @@ -82,7 +82,15 @@ /** * @since 5.7 */ - IsShaded + IsShaded, + /** + * @since 5.7 + */ + IsMovable, + /** + * @since 5.7 + */ + IsResizable }; explicit PlasmaWindowModel(PlasmaWindowManagement *parent); @@ -110,6 +118,18 @@ Q_INVOKABLE void requestClose(int row); /** + * Request move mode for the window at this model row index. + * @since 5.7 + **/ + Q_INVOKABLE void requestMoveMode(int row); + + /** + * Request resize mode for the window at this model row index. + * @since 5.7 + **/ + Q_INVOKABLE void requestResizeMode(int row); + + /** * Request the window at this model row index be moved to this virtual desktop. **/ Q_INVOKABLE void requestVirtualDesktop(int row, quint32 desktop); diff --git a/src/client/plasmawindowmodel.cpp b/src/client/plasmawindowmodel.cpp --- a/src/client/plasmawindowmodel.cpp +++ b/src/client/plasmawindowmodel.cpp @@ -139,6 +139,14 @@ QObject::connect(window, &PlasmaWindow::shadedChanged, [window, this] { this->dataChanged(window, IsShaded); } ); + + QObject::connect(window, &PlasmaWindow::movableChanged, + [window, this] { this->dataChanged(window, IsMovable); } + ); + + QObject::connect(window, &PlasmaWindow::resizableChanged, + [window, this] { this->dataChanged(window, IsResizable); } + ); } void PlasmaWindowModel::Private::dataChanged(PlasmaWindow *window, int role) @@ -235,6 +243,10 @@ return window->isShadable(); } else if (role == IsShaded) { return window->isShaded(); + } else if (role == IsMovable) { + return window->isMovable(); + } else if (role == IsResizable) { + return window->isResizable(); } return QVariant(); @@ -264,6 +276,20 @@ } } +Q_INVOKABLE void PlasmaWindowModel::requestMoveMode(int row) +{ + if (row >= 0 && row < d->windows.count()) { + d->windows.at(row)->requestMoveMode(); + } +} + +Q_INVOKABLE void PlasmaWindowModel::requestResizeMode(int row) +{ + if (row >= 0 && row < d->windows.count()) { + d->windows.at(row)->requestResizeMode(); + } +} + Q_INVOKABLE void PlasmaWindowModel::requestVirtualDesktop(int row, quint32 desktop) { if (row >= 0 && row < d->windows.count()) { diff --git a/src/client/protocols/plasma-window-management.xml b/src/client/protocols/plasma-window-management.xml --- a/src/client/protocols/plasma-window-management.xml +++ b/src/client/protocols/plasma-window-management.xml @@ -43,6 +43,8 @@ + + @@ -143,6 +145,18 @@ + + + Request move mode for this window. + + + + + + Request resize mode for this window. + + + This event will be sent as soon as the window title is changed. diff --git a/src/server/plasmawindowmanagement_interface.h b/src/server/plasmawindowmanagement_interface.h --- a/src/server/plasmawindowmanagement_interface.h +++ b/src/server/plasmawindowmanagement_interface.h @@ -93,6 +93,14 @@ * @since 5.7 */ void setShaded(bool set); + /** + * @since 5.7 + */ + void setMovable(bool set); + /** + * @since 5.7 + */ + void setResizable(bool set); void unmap(); @@ -105,6 +113,14 @@ Q_SIGNALS: void closeRequested(); + /** + * @since 5.7 + */ + void moveModeRequested(); + /** + * @since 5.7 + */ + void resizeModeRequested(); void virtualDesktopRequested(quint32 desktop); void activeRequested(bool set); void minimizedRequested(bool set); @@ -127,6 +143,14 @@ * @since 5.7 */ void shadedRequested(bool set); + /** + * @since 5.7 + */ + void movableRequested(bool set); + /** + * @since 5.7 + */ + void resizableRequested(bool set); private: friend class PlasmaWindowManagementInterface; diff --git a/src/server/plasmawindowmanagement_interface.cpp b/src/server/plasmawindowmanagement_interface.cpp --- a/src/server/plasmawindowmanagement_interface.cpp +++ b/src/server/plasmawindowmanagement_interface.cpp @@ -16,7 +16,7 @@ You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . -*********************************************************************/ +****************************************************close*****************/ #include "plasmawindowmanagement_interface.h" #include "global_p.h" #include "resource_p.h" @@ -88,6 +88,8 @@ static void setStateCallback(wl_client *client, wl_resource *resource, uint32_t flags, uint32_t state); static void setVirtualDesktopCallback(wl_client *client, wl_resource *resource, uint32_t number); static void closeCallback(wl_client *client, wl_resource *resource); + static void requestMoveModeCallback(wl_client *client, wl_resource *resource); + static void requestResizeModeCallback(wl_client *client, wl_resource *resource); static void setMinimizedGeometryCallback(wl_client *client, wl_resource *resource, wl_resource *panel, uint32_t x, uint32_t y, uint32_t width, uint32_t height); static void unsetMinimizedGeometryCallback(wl_client *client, wl_resource *resource, wl_resource *panel); static Private *cast(wl_resource *resource) { @@ -249,7 +251,9 @@ setVirtualDesktopCallback, setMinimizedGeometryCallback, unsetMinimizedGeometryCallback, - closeCallback + closeCallback, + requestMoveModeCallback, + requestResizeModeCallback }; #endif @@ -398,6 +402,20 @@ emit p->q->closeRequested(); } +void PlasmaWindowInterface::Private::requestMoveModeCallback(wl_client *client, wl_resource *resource) +{ + Q_UNUSED(client) + Private *p = cast(resource); + emit p->q->moveModeRequested(); +} + +void PlasmaWindowInterface::Private::requestResizeModeCallback(wl_client *client, wl_resource *resource) +{ + Q_UNUSED(client) + Private *p = cast(resource); + emit p->q->resizeModeRequested(); +} + void PlasmaWindowInterface::Private::setVirtualDesktopCallback(wl_client *client, wl_resource *resource, uint32_t number) { Q_UNUSED(client) @@ -451,6 +469,12 @@ if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SHADED) { emit p->q->shadedRequested(state & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SHADED); } + if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_MOVABLE) { + emit p->q->movableRequested(state & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_MOVABLE); + } + if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_RESIZABLE) { + emit p->q->resizableRequested(state & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_RESIZABLE); + } } void PlasmaWindowInterface::Private::setMinimizedGeometryCallback(wl_client *client, wl_resource *resource, wl_resource *panel, uint32_t x, uint32_t y, uint32_t width, uint32_t height) @@ -605,5 +629,15 @@ d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SHADED, set); } +void PlasmaWindowInterface::setMovable(bool set) +{ + d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_MOVABLE, set); +} + +void PlasmaWindowInterface::setResizable(bool set) +{ + d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_RESIZABLE, set); +} + } }