diff --git a/autotests/integration/internal_window.cpp b/autotests/integration/internal_window.cpp --- a/autotests/integration/internal_window.cpp +++ b/autotests/integration/internal_window.cpp @@ -57,6 +57,7 @@ void testKeyboardShowWithoutActivating(); void testKeyboardTriggersLeave(); void testTouch(); + void testOpacity(); }; class HelperWindow : public QRasterWindow @@ -494,6 +495,29 @@ 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 --- a/shell_client.cpp +++ b/shell_client.cpp @@ -931,13 +931,15 @@ 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 const QVariant windowType = m_internalWindow->property("type"); if (!windowType.isNull()) { m_windowType = static_cast(windowType.toInt()); } + setOpacity(m_internalWindow->opacity()); return; } }