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 @@ -60,6 +60,8 @@ void testIsOnAllDesktops(); void testIsDemandingAttention(); void testSkipTaskbar(); + void testIsShadable(); + void testIsShaded(); void testTitle(); void testAppId(); void testVirtualDesktop(); @@ -215,6 +217,8 @@ QTest::newRow("IsOnAllDesktops") << int(PlasmaWindowModel::IsOnAllDesktops) << QByteArrayLiteral("IsOnAllDesktops"); QTest::newRow("IsDemandingAttention") << int(PlasmaWindowModel::IsDemandingAttention) << QByteArrayLiteral("IsDemandingAttention"); QTest::newRow("SkipTaskbar") << int(PlasmaWindowModel::SkipTaskbar) << QByteArrayLiteral("SkipTaskbar"); + QTest::newRow("IsShadable") << int(PlasmaWindowModel::IsShadable) << QByteArrayLiteral("IsShadable"); + QTest::newRow("IsShaded") << int(PlasmaWindowModel::IsShaded) << QByteArrayLiteral("IsShaded"); } void PlasmaWindowModelTest::testRoleNames() @@ -292,6 +296,8 @@ QTest::newRow("VirtualDesktop") << int(PlasmaWindowModel::VirtualDesktop) << QVariant(0); QTest::newRow("IsOnAllDesktops") << int(PlasmaWindowModel::IsOnAllDesktops) << QVariant(false); QTest::newRow("IsDemandingAttention") << int(PlasmaWindowModel::IsDemandingAttention) << QVariant(false); + QTest::newRow("IsShadable") << int(PlasmaWindowModel::IsShadable) << QVariant(false); + QTest::newRow("IsShaded") << int(PlasmaWindowModel::IsShaded) << QVariant(false); QTest::newRow("SkipTaskbar") << int(PlasmaWindowModel::SkipTaskbar) << QVariant(false); } @@ -372,6 +378,16 @@ QVERIFY(testBooleanData(PlasmaWindowModel::SkipTaskbar, &PlasmaWindowInterface::setSkipTaskbar)); } +void PlasmaWindowModelTest::testIsShadable() +{ + QVERIFY(testBooleanData(PlasmaWindowModel::IsShadable, &PlasmaWindowInterface::setShadable)); +} + +void PlasmaWindowModelTest::testIsShaded() +{ + QVERIFY(testBooleanData(PlasmaWindowModel::IsShaded, &PlasmaWindowInterface::setShaded)); +} + void PlasmaWindowModelTest::testTitle() { auto model = m_pw->createWindowModel(); @@ -481,6 +497,8 @@ QVERIFY(minimizedRequestedSpy.isValid()); QSignalSpy maximizeRequestedSpy(w, &PlasmaWindowInterface::maximizedRequested); QVERIFY(maximizeRequestedSpy.isValid()); + QSignalSpy shadeRequestedSpy(w, &PlasmaWindowInterface::shadedRequested); + QVERIFY(shadeRequestedSpy.isValid()); // first let's use some invalid row numbers model->requestActivate(-1); @@ -493,13 +511,15 @@ 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(virtualDesktopRequestedSpy.isEmpty()); QVERIFY(minimizedRequestedSpy.isEmpty()); QVERIFY(maximizeRequestedSpy.isEmpty()); + QVERIFY(shadeRequestedSpy.isEmpty()); // now with the proper row // activate @@ -511,14 +531,16 @@ QCOMPARE(virtualDesktopRequestedSpy.count(), 0); QCOMPARE(minimizedRequestedSpy.count(), 0); QCOMPARE(maximizeRequestedSpy.count(), 0); + QCOMPARE(shadeRequestedSpy.count(), 0); // close model->requestClose(0); QVERIFY(closeRequestedSpy.wait()); QCOMPARE(activateRequestedSpy.count(), 1); QCOMPARE(closeRequestedSpy.count(), 1); QCOMPARE(virtualDesktopRequestedSpy.count(), 0); QCOMPARE(minimizedRequestedSpy.count(), 0); QCOMPARE(maximizeRequestedSpy.count(), 0); + QCOMPARE(shadeRequestedSpy.count(), 0); // virtual desktop model->requestVirtualDesktop(0, 1); QVERIFY(virtualDesktopRequestedSpy.wait()); @@ -528,6 +550,7 @@ QCOMPARE(closeRequestedSpy.count(), 1); QCOMPARE(minimizedRequestedSpy.count(), 0); QCOMPARE(maximizeRequestedSpy.count(), 0); + QCOMPARE(shadeRequestedSpy.count(), 0); // minimize model->requestToggleMinimized(0); QVERIFY(minimizedRequestedSpy.wait()); @@ -537,6 +560,7 @@ QCOMPARE(closeRequestedSpy.count(), 1); QCOMPARE(virtualDesktopRequestedSpy.count(), 1); QCOMPARE(maximizeRequestedSpy.count(), 0); + QCOMPARE(shadeRequestedSpy.count(), 0); // maximize model->requestToggleMaximized(0); QVERIFY(maximizeRequestedSpy.wait()); @@ -546,6 +570,17 @@ QCOMPARE(closeRequestedSpy.count(), 1); QCOMPARE(virtualDesktopRequestedSpy.count(), 1); QCOMPARE(minimizedRequestedSpy.count(), 1); + QCOMPARE(shadeRequestedSpy.count(), 0); + // shade + model->requestToggleShaded(0); + QVERIFY(shadeRequestedSpy.wait()); + QCOMPARE(shadeRequestedSpy.count(), 1); + QCOMPARE(shadeRequestedSpy.first().first().toBool(), true); + QCOMPARE(activateRequestedSpy.count(), 1); + QCOMPARE(closeRequestedSpy.count(), 1); + QCOMPARE(virtualDesktopRequestedSpy.count(), 1); + QCOMPARE(minimizedRequestedSpy.count(), 1); + QCOMPARE(maximizeRequestedSpy.count(), 1); // the toggles can also support a different state QSignalSpy dataChangedSpy(model, &PlasmaWindowModel::dataChanged); @@ -564,6 +599,13 @@ QVERIFY(maximizeRequestedSpy.wait()); QCOMPARE(maximizeRequestedSpy.count(), 2); QCOMPARE(maximizeRequestedSpy.last().first().toBool(), false); + // shaded + w->setShaded(true); + QVERIFY(dataChangedSpy.wait()); + model->requestToggleShaded(0); + QVERIFY(shadeRequestedSpy.wait()); + QCOMPARE(shadeRequestedSpy.count(), 2); + QCOMPARE(shadeRequestedSpy.last().first().toBool(), false); } QTEST_GUILESS_MAIN(PlasmaWindowModelTest) diff --git a/src/client/plasmawindowmanagement.h b/src/client/plasmawindowmanagement.h --- a/src/client/plasmawindowmanagement.h +++ b/src/client/plasmawindowmanagement.h @@ -222,6 +222,14 @@ bool isFullscreenable() const; bool skipTaskbar() const; QIcon icon() const; + /** + * @since 5.7 + */ + bool isShadable() const; + /** + * @since 5.7 + */ + bool isShaded() const; void requestActivate(); void requestClose(); @@ -250,6 +258,12 @@ void unsetMinimizedGeometry(Surface *panel); /** + * Requests the window at this model row index have its maximized state toggled. + * @since 5.7 + */ + void requestToggleShaded(); + + /** * An internal window identifier. * This is not a global window identifier. * This identifier does not correspond to QWindow::winId in any way. @@ -274,6 +288,8 @@ void fullscreenableChanged(); void skipTaskbarChanged(); void iconChanged(); + void shadableChanged(); + void shadedChanged(); 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 @@ -263,6 +263,8 @@ bool maximizeable = false; bool fullscreenable = false; bool skipTaskbar = false; + bool shadable = false; + bool shaded = false; QIcon icon; private: @@ -285,6 +287,8 @@ void setMaximizeable(bool set); void setFullscreenable(bool set); void setSkipTaskbar(bool skip); + void setShadable(bool set); + void setShaded(bool set); static Private *cast(void *data) { return reinterpret_cast(data); @@ -364,6 +368,8 @@ p->setMaximizeable(state & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_MAXIMIZABLE); p->setMinimizeable(state & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_MINIMIZABLE); 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); } void PlasmaWindow::Private::themedIconNameChangedCallback(void *data, org_kde_plasma_window *window, const char *name) @@ -492,6 +498,24 @@ emit q->skipTaskbarChanged(); } +void PlasmaWindow::Private::setShadable(bool set) +{ + if (shadable == set) { + return; + } + shadable = set; + emit q->shadableChanged(); +} + +void PlasmaWindow::Private::setShaded(bool set) +{ + if (shaded == set) { + return; + } + shaded = set; + emit q->shadedChanged(); +} + PlasmaWindow::Private::Private(org_kde_plasma_window *w, quint32 internalId, PlasmaWindow *q) : internalId(internalId) , q(q) @@ -622,6 +646,16 @@ return d->icon; } +bool PlasmaWindow::isShadable() const +{ + return d->shadable; +} + +bool PlasmaWindow::isShaded() const +{ + return d->shaded; +} + void PlasmaWindow::requestActivate() { org_kde_plasma_window_set_state(d->window, @@ -675,6 +709,19 @@ org_kde_plasma_window_unset_minimized_geometry(d->window, *panel); } +void PlasmaWindow::requestToggleShaded() +{ + if (d->shaded) { + org_kde_plasma_window_set_state(d->window, + ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SHADED, + 0); + } else { + org_kde_plasma_window_set_state(d->window, + ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SHADED, + ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SHADED); + } +} + quint32 PlasmaWindow::internalId() const { return d->internalId; diff --git a/src/client/plasmawindowmodel.h b/src/client/plasmawindowmodel.h --- a/src/client/plasmawindowmodel.h +++ b/src/client/plasmawindowmodel.h @@ -74,7 +74,9 @@ VirtualDesktop, IsOnAllDesktops, IsDemandingAttention, - SkipTaskbar + SkipTaskbar, + IsShadable, + IsShaded }; explicit PlasmaWindowModel(PlasmaWindowManagement *parent); @@ -123,6 +125,11 @@ */ Q_INVOKABLE void setMinimizedGeometry(int row, Surface *panel, const QRect &geom); + /** + * Requests the window at this model row index have its shaded state toggled. + * @since 5.7 + */ + Q_INVOKABLE void requestToggleShaded(int row); private: class Private; diff --git a/src/client/plasmawindowmodel.cpp b/src/client/plasmawindowmodel.cpp --- a/src/client/plasmawindowmodel.cpp +++ b/src/client/plasmawindowmodel.cpp @@ -131,6 +131,14 @@ QObject::connect(window, &PlasmaWindow::skipTaskbarChanged, [window, this] { dataChanged(window, SkipTaskbar); } ); + + QObject::connect(window, &PlasmaWindow::shadableChanged, + [window, this] { dataChanged(window, IsShadable); } + ); + + QObject::connect(window, &PlasmaWindow::shadedChanged, + [window, this] { dataChanged(window, IsShaded); } + ); } void PlasmaWindowModel::Private::dataChanged(PlasmaWindow *window, int role) @@ -223,6 +231,10 @@ return window->isDemandingAttention(); } else if (role == SkipTaskbar) { return window->skipTaskbar(); + } else if (role == IsShadable) { + return window->isShadable(); + } else if (role == IsShaded) { + return window->isShaded(); } return QVariant(); @@ -280,5 +292,12 @@ } } +Q_INVOKABLE void PlasmaWindowModel::requestToggleShaded(int row) +{ + if (row >= 0 && row < d->windows.count()) { + d->windows.at(row)->requestToggleShaded(); + } +} + } } 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 @@ -17,7 +17,7 @@ along with this program. If not, see . ]]> - + This interface manages application windows. It provides requests to show and hide the desktop and emits @@ -41,6 +41,8 @@ + + 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 @@ -85,6 +85,14 @@ void setFullscreenable(bool set); void setSkipTaskbar(bool skip); void setThemedIconName(const QString &iconName); + /** + * @since 5.7 + */ + void setShadable(bool set); + /** + * @since 5.7 + */ + void setShaded(bool set); void unmap(); @@ -111,6 +119,8 @@ void fullscreenableRequested(bool set); void skipTaskbarRequested(bool set); QRect minimizedGeometriesChanged(); + void shadableRequested(bool set); + void shadedRequested(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 @@ -445,6 +445,12 @@ if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SKIPTASKBAR) { emit p->q->skipTaskbarRequested(state & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SKIPTASKBAR); } + if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SHADABLE) { + emit p->q->shadableRequested(state & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SHADABLE); + } + if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SHADED) { + emit p->q->shadedRequested(state & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SHADED); + } } 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) @@ -589,5 +595,15 @@ d->setThemedIconName(iconName); } +void PlasmaWindowInterface::setShadable(bool set) +{ + d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SHADABLE, set); +} + +void PlasmaWindowInterface::setShaded(bool set) +{ + d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SHADED, set); +} + } }