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; } }