Commit c25377a4 authored by David Edmundson's avatar David Edmundson
Browse files

[plasmashell] Add signal for panelTakesFocus changing

Test Plan: Attached unit test

Reviewers: apol

Reviewed By: apol

Subscribers: apol, kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D25965
parent 123ebd5b
......@@ -438,6 +438,7 @@ void TestPlasmaShell::testPanelTakesFocus()
{
// this test verifies that whether a panel wants to take focus is passed through correctly
QSignalSpy plasmaSurfaceCreatedSpy(m_plasmaShellInterface, &PlasmaShellInterface::surfaceCreated);
QVERIFY(plasmaSurfaceCreatedSpy.isValid());
QScopedPointer<Surface> s(m_compositor->createSurface());
QScopedPointer<PlasmaShellSurface> ps(m_plasmaShell->createSurface(s.data()));
......@@ -445,16 +446,22 @@ void TestPlasmaShell::testPanelTakesFocus()
QVERIFY(plasmaSurfaceCreatedSpy.wait());
QCOMPARE(plasmaSurfaceCreatedSpy.count(), 1);
auto sps = plasmaSurfaceCreatedSpy.first().first().value<PlasmaShellSurfaceInterface*>();
QSignalSpy plasmaSurfaceTakesFocusSpy(sps, &PlasmaShellSurfaceInterface::panelTakesFocusChanged);
QVERIFY(sps);
QCOMPARE(sps->role(), PlasmaShellSurfaceInterface::Role::Panel);
QCOMPARE(sps->panelTakesFocus(), false);
ps->setPanelTakesFocus(true);
m_connection->flush();
QTRY_COMPARE(sps->panelTakesFocus(), true);
QVERIFY(plasmaSurfaceTakesFocusSpy.wait());
QCOMPARE(plasmaSurfaceTakesFocusSpy.count(), 1);
QCOMPARE(sps->panelTakesFocus(), true);
ps->setPanelTakesFocus(false);
m_connection->flush();
QTRY_COMPARE(sps->panelTakesFocus(), false);
QVERIFY(plasmaSurfaceTakesFocusSpy.wait());
QCOMPARE(plasmaSurfaceTakesFocusSpy.count(), 2);
QCOMPARE(sps->panelTakesFocus(), false);
}
void TestPlasmaShell::testDisconnect()
......
......@@ -317,7 +317,11 @@ void PlasmaShellSurfaceInterface::Private::panelTakesFocusCallback(wl_client *cl
{
auto s = cast<Private>(resource);
Q_ASSERT(client == *s->client);
if (s->panelTakesFocus == takesFocus) {
return;
}
s->panelTakesFocus = takesFocus;
emit s->q_func()->panelTakesFocusChanged();
}
void PlasmaShellSurfaceInterface::Private::setPanelBehavior(org_kde_plasma_surface_panel_behavior behavior)
......
......@@ -234,6 +234,13 @@ Q_SIGNALS:
**/
void panelAutoHideShowRequested();
/*
* Emitted when panelTakesFocus changes
* @see panelTakesFocus
* @since 5.66
*/
void panelTakesFocusChanged();
private:
friend class PlasmaShellInterface;
explicit PlasmaShellSurfaceInterface(PlasmaShellInterface *shell, SurfaceInterface *parent, wl_resource *parentResource);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment