From a38f4f98d1f6bc62eec7ed7d4964e29930ea46b0 Mon Sep 17 00:00:00 2001
From: Olivier Fourdan <fourdan.olivier@wanadoo.fr>
Date: Fri, 22 Dec 2006 20:21:05 +0000
Subject: [PATCH] Focus the internal fallback window when focus is transfered
 to a window that doesn't have InputHint set but still use
 WM_PROTOCOLS_TAKE_FOCUS (ie, there is no way for the window manager to tell
 whether or not the client will accept focus in the end since focus is set by
 the client alone through the 'take focus' mechanism) - Fix bug #1853 without
 breaking #2410

(Old svn revision: 24169)
---
 src/client.h | 4 ----
 src/focus.c  | 6 ++++++
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/client.h b/src/client.h
index 30752e412..b1999b450 100644
--- a/src/client.h
+++ b/src/client.h
@@ -198,10 +198,6 @@
 #define CLIENT_CAN_STICK_WINDOW(c)      (!(c->transient_for) && \
                                          FLAG_TEST(c->xfwm_flags, XFWM_FLAG_HAS_STICK))
 
-#define HINTS_ACCEPT_INPUT(wmhints)     (!(wmhints) || \
-                                         ((wmhints) && !(wmhints->flags & InputHint)) || \
-                                         ((wmhints) && (wmhints->flags & InputHint) && (wmhints->input)))
-
 typedef enum
 {
     UNSET = 0,
diff --git a/src/focus.c b/src/focus.c
index f87552921..489654bd3 100644
--- a/src/focus.c
+++ b/src/focus.c
@@ -540,6 +540,12 @@ clientSetFocus (ScreenInfo *screen_info, Client * c, Time timestamp, unsigned sh
             }
             clientUpdateOpacity (screen_info, c);
         }
+        else if (!client_focus)
+        {
+            /* Hack to prevent loosing focus when all remaining windows won't accept focus, see bug #1853 */
+            XSetInputFocus (myScreenGetXDisplay (screen_info), screen_info->xfwm4_win, RevertToPointerRoot, timestamp);
+        }
+
         if (FLAG_TEST(c->wm_flags, WM_FLAG_TAKEFOCUS))
         {
             pending_focus = c;
-- 
GitLab