[mutter/wip/exalm/focused-appearance: 5/5] window: Appear as focused while focusing



commit 03c85d56377968f010db8d530ff9eb7b751e7088
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Sun Oct 13 05:15:51 2019 +0500

    window: Appear as focused while focusing
    
    Prevent focused window from blinking after switching to another
    workspace on X11.

 src/core/window-private.h | 3 +++
 src/core/window.c         | 8 +++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)
---
diff --git a/src/core/window-private.h b/src/core/window-private.h
index 484140a27..5d63a6684 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -540,6 +540,9 @@ struct _MetaWindow
   int constrained_placement_rule_offset_y;
 
   guint unmanage_idle_id;
+
+  /* Prevent blinking when focusing */
+  gboolean focusing;
 };
 
 struct _MetaWindowClass
diff --git a/src/core/window.c b/src/core/window.c
index 4627e5f7b..804753e29 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -4780,7 +4780,13 @@ meta_window_focus (MetaWindow  *window,
       window = modal_transient;
     }
 
+  /* If the window was the default focused window on its workspace, and focus
+   * change happens because of switching to that workspace, the window will now
+   * briefly appear unfocused on X11, since has_focus is not yet set. Set a flag
+   * to prevent that. */
+  window->focusing = TRUE;
   meta_window_flush_calc_showing (window);
+  window->focusing = FALSE;
 
   if ((!window->mapped || window->hidden) && !window->shaded)
     {
@@ -7255,7 +7261,7 @@ meta_window_appears_focused (MetaWindow *window)
   if (workspace && workspace != workspace_manager->active_workspace)
     default_window = meta_workspace_get_default_focus_window (workspace);
 
-  return window->has_focus || (window->attached_focus_window != NULL) || (window == default_window);
+  return window->has_focus || window->focusing || (window->attached_focus_window != NULL) || (window == 
default_window);
 }
 
 gboolean


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]