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
This commit is contained in:
parent
5ab7b7e41e
commit
0a042dad69
2 changed files with 26 additions and 0 deletions
|
@ -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<ShellClient*>();
|
||||
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)
|
||||
|
|
|
@ -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<NET::WindowType>(windowType.toInt());
|
||||
}
|
||||
setOpacity(m_internalWindow->opacity());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue