diff --git a/abstract_client.h b/abstract_client.h --- a/abstract_client.h +++ b/abstract_client.h @@ -416,6 +416,18 @@ virtual const WindowRules* rules() const = 0; virtual void takeFocus() = 0; virtual bool wantsInput() const = 0; + /** + * Whether a dock window wants input. + * + * By default KWin doesn't pass focus to a dock window unless a force activate + * request is provided. + * + * This method allows to have dock windows take focus also through flags set on + * the window. + * + * The default implementation returns @c false. + **/ + virtual bool dockWantsInput() const; void checkWorkspacePosition(QRect oldGeometry = QRect(), int oldDesktop = -2, QRect oldClientGeometry = QRect()); virtual xcb_timestamp_t userTime() const; virtual void updateWindowRules(Rules::Types selection) = 0; diff --git a/abstract_client.cpp b/abstract_client.cpp --- a/abstract_client.cpp +++ b/abstract_client.cpp @@ -1634,4 +1634,9 @@ return Toplevel::inputGeometry(); } +bool AbstractClient::dockWantsInput() const +{ + return false; +} + } diff --git a/activation.cpp b/activation.cpp --- a/activation.cpp +++ b/activation.cpp @@ -371,8 +371,13 @@ } cancelDelayFocus(); } - if (!flags.testFlag(ActivityFocusForce) && (c->isDock() || c->isSplash())) - flags &= ~ActivityFocus; // toplevel menus and dock windows don't take focus if not forced + if (!flags.testFlag(ActivityFocusForce) && (c->isDock() || c->isSplash())) { + // toplevel menus and dock windows don't take focus if not forced + // and don't have a flag that they take focus + if (!c->dockWantsInput()) { + flags &= ~ActivityFocus; + } + } if (c->isShade()) { if (c->wantsInput() && (flags & ActivityFocus)) { // client cannot accept focus, but at least the window should be active (window menu, et. al. ) diff --git a/autotests/integration/plasma_surface_test.cpp b/autotests/integration/plasma_surface_test.cpp --- a/autotests/integration/plasma_surface_test.cpp +++ b/autotests/integration/plasma_surface_test.cpp @@ -59,6 +59,8 @@ void testOSDPlacement(); void testPanelTypeHasStrut_data(); void testPanelTypeHasStrut(); + void testPanelActivate_data(); + void testPanelActivate(); private: ConnectionThread *m_connection = nullptr; @@ -368,5 +370,36 @@ QCOMPARE(stackingOrder.last(), panel); } +void PlasmaSurfaceTest::testPanelActivate_data() +{ + QTest::addColumn("wantsFocus"); + QTest::addColumn("active"); + + QTest::newRow("no focus") << false << false; + QTest::newRow("focus") << true << true; +} + +void PlasmaSurfaceTest::testPanelActivate() +{ + QScopedPointer surface(Test::createSurface()); + QVERIFY(!surface.isNull()); + QScopedPointer shellSurface(Test::createShellSurface(Test::ShellSurfaceType::WlShell, surface.data())); + QVERIFY(!shellSurface.isNull()); + QScopedPointer plasmaSurface(m_plasmaShell->createSurface(surface.data())); + QVERIFY(!plasmaSurface.isNull()); + plasmaSurface->setRole(PlasmaShellSurface::Role::Panel); + QFETCH(bool, wantsFocus); + plasmaSurface->setPanelTakesFocus(wantsFocus); + + auto panel = Test::renderAndWaitForShown(surface.data(), QSize(100, 200), Qt::blue); + + QVERIFY(panel); + QCOMPARE(panel->windowType(), NET::Dock); + QVERIFY(panel->isDock()); + QFETCH(bool, active); + QCOMPARE(panel->dockWantsInput(), active); + QCOMPARE(panel->isActive(), active); +} + WAYLANDTEST_MAIN(PlasmaSurfaceTest) #include "plasma_surface_test.moc" diff --git a/shell_client.h b/shell_client.h --- a/shell_client.h +++ b/shell_client.h @@ -96,6 +96,7 @@ bool userCanSetFullScreen() const override; bool userCanSetNoBorder() const override; bool wantsInput() const override; + bool dockWantsInput() const override; using AbstractClient::resizeWithChecks; void resizeWithChecks(int w, int h, ForceGeometry_t force = NormalGeometrySet) override; using AbstractClient::setGeometry; diff --git a/shell_client.cpp b/shell_client.cpp --- a/shell_client.cpp +++ b/shell_client.cpp @@ -1373,4 +1373,14 @@ } } +bool ShellClient::dockWantsInput() const +{ + if (m_plasmaShellSurface) { + if (m_plasmaShellSurface->role() == PlasmaShellSurfaceInterface::Role::Panel) { + return m_plasmaShellSurface->panelTakesFocus(); + } + } + return false; +} + }