[plasma/kwin] src: Reapply "Handle "Globally Active" input model more gracefully"

Vlad Zahorodnii <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 5c2f04469d0640054e0f2e34e1adf8b62c79a508 by Vlad Zahorodnii.
Committed on 19/08/2026 at 10:36.
Pushed by vladz into branch 'master'.

Reapply "Handle "Globally Active" input model more gracefully"

This reverts commit def002a9c5f736d08f1260a9e025b64bada15143.

M  +3    -1    src/activation.cpp
M  +5    -0    src/window.cpp
M  +1    -0    src/window.h
M  +5    -0    src/x11window.cpp
M  +1    -0    src/x11window.h

https://invent.kde.org/plasma/kwin/-/commit/5c2f04469d0640054e0f2e34e1adf8b62c79a508

diff --git a/src/activation.cpp b/src/activation.cpp
index c587bb06e8c..e78050c95d0 100644
--- a/src/activation.cpp
+++ b/src/activation.cpp
@@ -396,7 +396,9 @@ bool Workspace::requestFocus(Window *window, bool force)
     }
 
     window->takeFocus();
-    setActiveWindow(window);
+    if (!window->takesAsyncFocus()) {
+        setActiveWindow(window);
+    }
 
     return true;
 }
diff --git a/src/window.cpp b/src/window.cpp
index a4460a9ecb0..fdb7c62038b 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -667,6 +667,11 @@ void Window::takeFocus()
 {
 }
 
+bool Window::takesAsyncFocus() const
+{
+    return false;
+}
+
 bool Window::isSpecialWindow() const
 {
     // TODO
diff --git a/src/window.h b/src/window.h
index bf2c61d7c7b..796b5454ed3 100644
--- a/src/window.h
+++ b/src/window.h
@@ -1115,6 +1115,7 @@ public:
 
     bool wantsTabFocus() const;
     virtual void takeFocus();
+    virtual bool takesAsyncFocus() const;
     virtual bool wantsInput() const = 0;
     void checkWorkspacePosition(RectF oldGeometry = RectF(), LogicalOutput *oldOutput = nullptr);
 #if KWIN_BUILD_X11
diff --git a/src/x11window.cpp b/src/x11window.cpp
index ba55ac83dc6..3f477e2cb1f 100644
--- a/src/x11window.cpp
+++ b/src/x11window.cpp
@@ -1659,6 +1659,11 @@ void X11Window::takeFocus()
     }
 }
 
+bool X11Window::takesAsyncFocus() const
+{
+    return !acceptsFocus() && info->supportsProtocol(NET::TakeFocusProtocol);
+}
+
 /**
  * Returns whether the window provides context help or not. If it does,
  * you should show a help menu item or a help button like '?' and call
diff --git a/src/x11window.h b/src/x11window.h
index 67cf57bf81f..fc13023600d 100644
--- a/src/x11window.h
+++ b/src/x11window.h
@@ -148,6 +148,7 @@ public:
     bool isCloseable() const override; ///< May be closed by the user (May have a close button)
 
     void takeFocus() override;
+    bool takesAsyncFocus() const override;
 
     void invalidateDecoration() override;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.