[mutter] window-x11: Move take_focus to MetaWindowX11Private



commit 6c3b0cfc36f471b0879a1efe130e3546626ca634
Author: Marco Trevisan (Treviño) <mail 3v1n0 net>
Date:   Wed Jan 30 20:19:41 2019 +0100

    window-x11: Move take_focus to MetaWindowX11Private
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/421

 src/core/window-private.h    |  7 +++----
 src/core/window.c            |  5 ++---
 src/x11/window-props.c       |  4 ++--
 src/x11/window-x11-private.h |  1 +
 src/x11/window-x11.c         | 22 ++++++++++++++++++++--
 src/x11/window-x11.h         |  2 ++
 6 files changed, 30 insertions(+), 11 deletions(-)
---
diff --git a/src/core/window-private.h b/src/core/window-private.h
index 170d230ce..4bee88fe6 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -327,7 +327,6 @@ struct _MetaWindow
   guint icon_geometry_set : 1;
 
   /* These are the flags from WM_PROTOCOLS */
-  guint take_focus : 1;
   guint delete_window : 1;
   guint can_ping : 1;
   /* Globally active / No input */
@@ -699,11 +698,11 @@ gboolean meta_window_same_application (MetaWindow *window,
 #define META_WINDOW_IN_NORMAL_TAB_CHAIN_TYPE(w) \
   ((w)->type != META_WINDOW_DOCK && (w)->type != META_WINDOW_DESKTOP)
 #define META_WINDOW_IN_NORMAL_TAB_CHAIN(w) \
-  (((w)->input || (w)->take_focus ) && META_WINDOW_IN_NORMAL_TAB_CHAIN_TYPE (w) && (!(w)->skip_taskbar))
+  (meta_window_is_focusable (w) && META_WINDOW_IN_NORMAL_TAB_CHAIN_TYPE (w) && (!(w)->skip_taskbar))
 #define META_WINDOW_IN_DOCK_TAB_CHAIN(w) \
-  (((w)->input || (w)->take_focus) && (! META_WINDOW_IN_NORMAL_TAB_CHAIN_TYPE (w) || (w)->skip_taskbar))
+  (meta_window_is_focusable (w) && (! META_WINDOW_IN_NORMAL_TAB_CHAIN_TYPE (w) || (w)->skip_taskbar))
 #define META_WINDOW_IN_GROUP_TAB_CHAIN(w, g) \
-  (((w)->input || (w)->take_focus) && (!g || meta_window_get_group(w)==g))
+  (meta_window_is_focusable (w) && (!g || meta_window_get_group(w)==g))
 
 void meta_window_free_delete_dialog (MetaWindow *window);
 
diff --git a/src/core/window.c b/src/core/window.c
index 4fcae7598..af0423f8d 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -1079,7 +1079,6 @@ _meta_window_shared_new (MetaDisplay         *display,
   window->initial_timestamp_set = FALSE;
   window->net_wm_user_time_set = FALSE;
   window->user_time_window = None;
-  window->take_focus = FALSE;
   window->delete_window = FALSE;
   window->can_ping = FALSE;
   window->input = TRUE;
@@ -4689,8 +4688,8 @@ meta_window_focus (MetaWindow  *window,
   window->restore_focus_on_map = FALSE;
 
   meta_topic (META_DEBUG_FOCUS,
-              "Setting input focus to window %s, input: %d take_focus: %d\n",
-              window->desc, window->input, window->take_focus);
+              "Setting input focus to window %s, input: %d focusable: %d\n",
+              window->desc, window->input, meta_window_is_focusable (window));
 
   if (window->display->grab_window &&
       window->display->grab_window != window &&
diff --git a/src/x11/window-props.c b/src/x11/window-props.c
index 65b77cd7e..6ad7905f4 100644
--- a/src/x11/window-props.c
+++ b/src/x11/window-props.c
@@ -1531,9 +1531,9 @@ reload_wm_protocols (MetaWindow    *window,
 {
   int i;
 
-  window->take_focus = FALSE;
   window->delete_window = FALSE;
   window->can_ping = FALSE;
+  meta_window_x11_set_wm_take_focus (window, FALSE);
 
   if (value->type == META_PROP_VALUE_INVALID)
     return;
@@ -1543,7 +1543,7 @@ reload_wm_protocols (MetaWindow    *window,
     {
       if (value->v.atom_list.atoms[i] ==
           window->display->x11_display->atom_WM_TAKE_FOCUS)
-        window->take_focus = TRUE;
+        meta_window_x11_set_wm_take_focus (window, TRUE);
       else if (value->v.atom_list.atoms[i] ==
                window->display->x11_display->atom_WM_DELETE_WINDOW)
         window->delete_window = TRUE;
diff --git a/src/x11/window-x11-private.h b/src/x11/window-x11-private.h
index 268f8bdcf..9f0ada728 100644
--- a/src/x11/window-x11-private.h
+++ b/src/x11/window-x11-private.h
@@ -47,6 +47,7 @@ struct _MetaWindowX11Private
   /* TRUE if the client forced these on */
   guint wm_state_skip_taskbar : 1;
   guint wm_state_skip_pager : 1;
+  guint wm_take_focus : 1;
 
   /* Weird "_NET_WM_STATE_MODAL" flag */
   guint wm_state_modal : 1;
diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c
index 7e3d66dcc..af5df998b 100644
--- a/src/x11/window-x11.c
+++ b/src/x11/window-x11.c
@@ -745,6 +745,9 @@ static void
 meta_window_x11_focus (MetaWindow *window,
                        guint32     timestamp)
 {
+  MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
+  MetaWindowX11Private *priv =
+    meta_window_x11_get_instance_private (window_x11);
   /* For output-only or shaded windows, focus the frame.
    * This seems to result in the client window getting key events
    * though, so I don't know if it's icccm-compliant.
@@ -774,7 +777,7 @@ meta_window_x11_focus (MetaWindow *window,
                                                    timestamp);
         }
 
-      if (window->take_focus)
+      if (priv->wm_take_focus)
         {
           meta_topic (META_DEBUG_FOCUS,
                       "Sending WM_TAKE_FOCUS to %s since take_focus = true\n",
@@ -1628,10 +1631,25 @@ meta_window_x11_shortcuts_inhibited (MetaWindow         *window,
   return FALSE;
 }
 
+void
+meta_window_x11_set_wm_take_focus (MetaWindow *window,
+                                   gboolean    take_focus)
+{
+  MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
+  MetaWindowX11Private *priv =
+    meta_window_x11_get_instance_private (window_x11);
+
+  priv->wm_take_focus = take_focus;
+}
+
 static gboolean
 meta_window_x11_is_focusable (MetaWindow *window)
 {
-  return window->input || window->take_focus;
+  MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
+  MetaWindowX11Private *priv =
+    meta_window_x11_get_instance_private (window_x11);
+
+  return window->input || priv->wm_take_focus;
 }
 
 static gboolean
diff --git a/src/x11/window-x11.h b/src/x11/window-x11.h
index 383a52129..a28d9dc0e 100644
--- a/src/x11/window-x11.h
+++ b/src/x11/window-x11.h
@@ -51,6 +51,8 @@ MetaWindow * meta_window_x11_new           (MetaDisplay        *display,
 
 void meta_window_x11_set_net_wm_state            (MetaWindow *window);
 void meta_window_x11_set_wm_state                (MetaWindow *window);
+void meta_window_x11_set_wm_take_focus           (MetaWindow *window,
+                                                  gboolean    take_focus);
 void meta_window_x11_set_allowed_actions_hint    (MetaWindow *window);
 
 void meta_window_x11_create_sync_request_alarm   (MetaWindow *window);


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