diff --git a/autotests/client/test_plasmashell.cpp b/autotests/client/test_plasmashell.cpp --- a/autotests/client/test_plasmashell.cpp +++ b/autotests/client/test_plasmashell.cpp @@ -438,23 +438,30 @@ { // 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 s(m_compositor->createSurface()); QScopedPointer ps(m_plasmaShell->createSurface(s.data())); ps->setRole(PlasmaShellSurface::Role::Panel); QVERIFY(plasmaSurfaceCreatedSpy.wait()); QCOMPARE(plasmaSurfaceCreatedSpy.count(), 1); auto sps = plasmaSurfaceCreatedSpy.first().first().value(); + 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() diff --git a/src/server/plasmashell_interface.h b/src/server/plasmashell_interface.h --- a/src/server/plasmashell_interface.h +++ b/src/server/plasmashell_interface.h @@ -234,6 +234,13 @@ **/ 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); diff --git a/src/server/plasmashell_interface.cpp b/src/server/plasmashell_interface.cpp --- a/src/server/plasmashell_interface.cpp +++ b/src/server/plasmashell_interface.cpp @@ -317,7 +317,11 @@ { auto s = cast(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)