kwo pushed a commit to branch master.

http://git.enlightenment.org/e16/e16.git/commit/?id=ebe82a7bbba9acd29375e7afb271275b8e26706f

commit ebe82a7bbba9acd29375e7afb271275b8e26706f
Author: Kim Woelders <k...@woelders.dk>
Date:   Sun Mar 14 18:38:29 2021 +0100

    Focus: Fix pointer focus on new windows if pointer is in window
    
    In certain situations new windows would not be focused.
---
 src/focus.c | 73 ++++++++++++++++++++++++++++++++++++-------------------------
 1 file changed, 43 insertions(+), 30 deletions(-)

diff --git a/src/focus.c b/src/focus.c
index 658dc63f..04885d2c 100644
--- a/src/focus.c
+++ b/src/focus.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various 
contributors
- * Copyright (C) 2004-2020 Kim Woelders
+ * Copyright (C) 2004-2021 Kim Woelders
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to
@@ -109,6 +109,42 @@ FocusEwinValid(EWin * ewin, int want_on_screen, int click, 
int want_visible)
    return ok;
 }
 
+/*
+ * Return !0 if new ewin should be focused.
+ */
+static int
+FocusEwinValidNew(EWin * ewin)
+{
+   int                 ok = 0;
+
+   if (Conf.focus.all_new_windows_get_focus)
+      ok = 1;
+
+   else if (Conf.focus.new_windows_get_focus_if_group_focused &&
+           Mode.focuswin &&
+           EwinGetWindowGroup(ewin) == EwinGetWindowGroup(Mode.focuswin))
+      ok = 1;
+
+   else if (EwinIsTransient(ewin))
+     {
+       if (Conf.focus.new_transients_get_focus)
+         {
+            ok = 1;
+         }
+       else if (Conf.focus.new_transients_get_focus_if_group_focused &&
+                Mode.focuswin)
+         {
+            if ((EwinGetTransientFor(ewin) ==
+                 EwinGetClientXwin(Mode.focuswin)) ||
+                (EwinGetWindowGroup(ewin) ==
+                 EwinGetWindowGroup(Mode.focuswin)))
+               ok = 1;
+         }
+     }
+
+   return ok;
+}
+
 /*
  * Return the ewin to focus after entering area or losing focused window.
  */
@@ -309,7 +345,6 @@ ClickGrabsUpdate(void)
 static void
 doFocusToEwin(EWin * ewin, int why)
 {
-   int                 do_focus = 0;
    int                 do_raise = 0, do_warp = 0;
 
    if (focus_inhibit)
@@ -374,39 +409,15 @@ doFocusToEwin(EWin * ewin, int why)
        if (ewin->props.focus_when_mapped)
           goto check_focus_new;
 
-       if (Conf.focus.all_new_windows_get_focus)
-          goto check_focus_new;
-
-       if (Conf.focus.new_windows_get_focus_if_group_focused &&
-           Mode.focuswin &&
-           EwinGetWindowGroup(ewin) == EwinGetWindowGroup(Mode.focuswin))
-          goto check_focus_new;
-
-       if (Conf.focus.mode != MODE_FOCUS_CLICK && ewin == Mode.mouse_over_ewin)
-          goto check_focus_new;
-
-       if (EwinIsTransient(ewin))
+       if (FocusEwinValidNew(ewin))
          {
-            if (Conf.focus.new_transients_get_focus)
-              {
-                 do_focus = 1;
-              }
-            else if (Conf.focus.new_transients_get_focus_if_group_focused &&
-                     Mode.focuswin)
-              {
-                 if ((EwinGetTransientFor(ewin) ==
-                      EwinGetClientXwin(Mode.focuswin)) ||
-                     (EwinGetWindowGroup(ewin) ==
-                      EwinGetWindowGroup(Mode.focuswin)))
-                    do_focus = 1;
-              }
-
-            if (!do_focus)
-               return;
             DeskGotoByEwin(ewin, 0);
             goto check_focus_new;
          }
 
+       if (Conf.focus.mode != MODE_FOCUS_CLICK && ewin == Mode.mouse_over_ewin)
+          goto check_focus_new;
+
        return;
 
       check_focus_new:
@@ -503,6 +514,8 @@ FocusToEWin(EWin * ewin, int why)
    switch (why)
      {
      case FOCUS_EWIN_NEW:
+       if (!FocusEwinValidNew(ewin))
+          break;
        if (!FocusEwinValid(ewin, 0, 0, 0))
           break;
        focus_pending_new = ewin;

-- 


Reply via email to