From 0a042dad69523dd4858fcfb4dfc00ec7ae067b8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 3 Jan 2017 07:28:29 +0100 Subject: [PATCH] Sync opacity from an internal QWindow to its ShellClient Summary: This change adds support for opacity on a KWin internal QWindow. Calling QWindow::setOpacity syncs the value to the ShellClient representation of the QWindow. This is needed for fading out the OnScreenNotification on mouse over. Test Plan: Added auto test and manual test Reviewers: #kwin, #plasma_on_wayland Subscribers: plasma-devel, kwin Tags: #plasma_on_wayland, #kwin Differential Revision: https://phabricator.kde.org/D3928 --- autotests/integration/internal_window.cpp | 24 +++++++++++++++++++++++ shell_client.cpp | 2 ++ 2 files changed, 26 insertions(+) diff --git a/autotests/integration/internal_window.cpp b/autotests/integration/internal_window.cpp index 6c2a670d02..b1b2072311 100644 --- a/autotests/integration/internal_window.cpp +++ b/autotests/integration/internal_window.cpp @@ -57,6 +57,7 @@ private Q_SLOTS: void testKeyboardShowWithoutActivating(); void testKeyboardTriggersLeave(); void testTouch(); + void testOpacity(); }; class HelperWindow : public QRasterWindow @@ -494,6 +495,29 @@ void InternalWindowTest::testTouch() QCOMPARE(win.pressedButtons(), Qt::MouseButtons()); } +void InternalWindowTest::testOpacity() +{ + // this test verifies that opacity is properly synced from QWindow to ShellClient + QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); + QVERIFY(clientAddedSpy.isValid()); + HelperWindow win; + win.setOpacity(0.5); + win.setGeometry(0, 0, 100, 100); + win.show(); + QVERIFY(clientAddedSpy.wait()); + QCOMPARE(clientAddedSpy.count(), 1); + auto internalClient = clientAddedSpy.first().first().value(); + QVERIFY(internalClient); + QVERIFY(internalClient->isInternal()); + QCOMPARE(internalClient->opacity(), 0.5); + + QSignalSpy opacityChangedSpy(internalClient, &ShellClient::opacityChanged); + QVERIFY(opacityChangedSpy.isValid()); + win.setOpacity(0.75); + QCOMPARE(opacityChangedSpy.count(), 1); + QCOMPARE(internalClient->opacity(), 0.75); +} + } WAYLANDTEST_MAIN(KWin::InternalWindowTest) diff --git a/shell_client.cpp b/shell_client.cpp index 85ecfffa9f..56ea20a6dc 100644 --- a/shell_client.cpp +++ b/shell_client.cpp @@ -931,6 +931,7 @@ void ShellClient::findInternalWindow() connect(m_internalWindow, &QWindow::xChanged, this, &ShellClient::updateInternalWindowGeometry); connect(m_internalWindow, &QWindow::yChanged, this, &ShellClient::updateInternalWindowGeometry); connect(m_internalWindow, &QWindow::destroyed, this, [this] { m_internalWindow = nullptr; }); + connect(m_internalWindow, &QWindow::opacityChanged, this, &ShellClient::setOpacity); // Try reading the window type from the QWindow. PlasmaCore.Dialog provides a dynamic type property // let's check whether it exists, if it does it's our window type @@ -938,6 +939,7 @@ void ShellClient::findInternalWindow() if (!windowType.isNull()) { m_windowType = static_cast(windowType.toInt()); } + setOpacity(m_internalWindow->opacity()); return; } }