[mutter/wayland] Revert "compositor: fix focusing the stage window"



commit f860df4b2dbd43006d65cdcf87886f2d4ebe4d63
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Sun Feb 23 12:28:51 2014 -0500

    Revert "compositor: fix focusing the stage window"
    
    This reverts commit 876f81db12d122ce2be69395c809d9835eebea39.
    
    This doesn't quite work properly, and is overcomplicated.

 src/compositor/compositor.c |   34 ++++++++++--------------
 src/core/display-private.h  |   18 +++----------
 src/core/display.c          |   60 +++++++++++-------------------------------
 3 files changed, 34 insertions(+), 78 deletions(-)
---
diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c
index 88b525f..a93d6c6 100644
--- a/src/compositor/compositor.c
+++ b/src/compositor/compositor.c
@@ -316,39 +316,33 @@ meta_focus_stage_window (MetaScreen *screen,
   if (!stage)
     return;
 
-  if (!meta_is_wayland_compositor ())
-    {
-      window = clutter_x11_get_stage_window (stage);
+  window = clutter_x11_get_stage_window (stage);
 
-      if (window == None)
-        return;
+  if (window == None)
+    return;
 
-      meta_display_set_input_focus_xwindow (screen->display,
-                                            screen,
-                                            META_FOCUS_STAGE,
-                                            window,
-                                            timestamp);
-    }
-  else
-    {
-      meta_display_set_input_focus_xwindow (screen->display,
-                                            screen,
-                                            META_FOCUS_STAGE,
-                                            None,
-                                            timestamp);
-    }
+  meta_display_set_input_focus_xwindow (screen->display,
+                                        screen,
+                                        window,
+                                        timestamp);
 }
 
 gboolean
 meta_stage_is_focused (MetaScreen *screen)
 {
   ClutterStage *stage;
+  Window window;
 
   stage = CLUTTER_STAGE (meta_get_stage_for_screen (screen));
   if (!stage)
     return FALSE;
 
-  return (screen->display->focus_type == META_FOCUS_STAGE);
+  window = clutter_x11_get_stage_window (stage);
+
+  if (window == None)
+    return FALSE;
+
+  return (screen->display->focus_xwindow == window);
 }
 
 static gboolean
diff --git a/src/core/display-private.h b/src/core/display-private.h
index 11b3a60..4bd95cb 100644
--- a/src/core/display-private.h
+++ b/src/core/display-private.h
@@ -84,14 +84,6 @@ typedef enum {
   META_TILE_MAXIMIZED
 } MetaTileMode;
 
-typedef enum {
-  META_FOCUS_NONE = 0,
-  META_FOCUS_X_CLIENT = 1,
-  META_FOCUS_WAYLAND_CLIENT = 2,
-  META_FOCUS_NO_FOCUS_WINDOW = 3,
-  META_FOCUS_STAGE = 4
-} MetaFocusType;
-
 struct _MetaDisplay
 {
   GObject parent_instance;
@@ -125,7 +117,6 @@ struct _MetaDisplay
    * like the no_focus_window or the stage X window. */
   Window focus_xwindow;
   gulong focus_serial;
-  MetaFocusType focus_type;
 
   /* last timestamp passed to XSetInputFocus */
   guint32 last_focus_time;
@@ -493,10 +484,9 @@ gboolean meta_display_process_barrier_event (MetaDisplay *display,
                                              XIEvent     *event);
 #endif /* HAVE_XI23 */
 
-void meta_display_set_input_focus_xwindow (MetaDisplay   *display,
-                                           MetaScreen    *screen,
-                                           MetaFocusType  type,
-                                           Window         window,
-                                           guint32        timestamp);
+void meta_display_set_input_focus_xwindow (MetaDisplay *display,
+                                           MetaScreen  *screen,
+                                           Window       window,
+                                           guint32      timestamp);
 
 #endif
diff --git a/src/core/display.c b/src/core/display.c
index d3a03bd..1ea1cc7 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -1746,12 +1746,11 @@ get_input_event (MetaDisplay *display,
 }
 
 static void
-update_focus_window (MetaDisplay   *display,
-                     MetaFocusType  type,
-                     MetaWindow    *window,
-                     Window         xwindow,
-                     gulong         serial,
-                     gboolean       focused_by_us)
+update_focus_window (MetaDisplay *display,
+                     MetaWindow  *window,
+                     Window       xwindow,
+                     gulong       serial,
+                     gboolean     focused_by_us)
 {
   MetaWaylandCompositor *compositor;
 
@@ -1759,7 +1758,6 @@ update_focus_window (MetaDisplay   *display,
   display->focused_by_us = focused_by_us;
 
   if (display->focus_xwindow == xwindow &&
-      display->focus_type == type &&
       display->focus_window == window)
     return;
 
@@ -1782,7 +1780,6 @@ update_focus_window (MetaDisplay   *display,
       meta_window_set_focused_internal (previous, FALSE);
     }
 
-  display->focus_type = type;
   display->focus_window = window;
   display->focus_xwindow = xwindow;
 
@@ -1809,8 +1806,7 @@ update_focus_window (MetaDisplay   *display,
     {
       compositor = meta_wayland_compositor_get_default ();
 
-      if (display->focus_type == META_FOCUS_NO_FOCUS_WINDOW ||
-          display->focus_type == META_FOCUS_STAGE)
+      if (meta_display_xwindow_is_a_no_focus_window (display, xwindow))
         meta_wayland_compositor_set_input_focus (compositor, NULL);
       else if (window && window->surface)
         meta_wayland_compositor_set_input_focus (compositor, window);
@@ -1852,12 +1848,11 @@ timestamp_too_old (MetaDisplay *display,
 }
 
 static void
-request_xserver_input_focus_change (MetaDisplay   *display,
-                                    MetaScreen    *screen,
-                                    MetaFocusType  type,
-                                    MetaWindow    *meta_window,
-                                    Window         xwindow,
-                                    guint32        timestamp)
+request_xserver_input_focus_change (MetaDisplay *display,
+                                    MetaScreen  *screen,
+                                    MetaWindow  *meta_window,
+                                    Window       xwindow,
+                                    guint32      timestamp)
 {
   gulong serial;
 
@@ -1890,7 +1885,6 @@ request_xserver_input_focus_change (MetaDisplay   *display,
   meta_display_ungrab (display);
 
   update_focus_window (display,
-                       type,
                        meta_window,
                        xwindow,
                        serial,
@@ -1912,12 +1906,9 @@ handle_window_focus_event (MetaDisplay  *display,
                            unsigned long serial)
 {
   MetaWindow *focus_window;
-  MetaFocusType type;
 #ifdef WITH_VERBOSE_MODE
   const char *window_type;
 
-  type = META_FOCUS_NONE;
-
   /* Note the event can be on either the window or the frame,
    * we focus the frame for shaded windows
    */
@@ -1929,26 +1920,14 @@ handle_window_focus_event (MetaDisplay  *display,
         window_type = "frame window";
       else
         window_type = "unknown client window";
-
-      if (window->client_type == META_WINDOW_CLIENT_TYPE_WAYLAND)
-        type = META_FOCUS_WAYLAND_CLIENT;
-      else
-        type = META_FOCUS_X_CLIENT;
     }
   else if (meta_display_xwindow_is_a_no_focus_window (display, event->event))
-    {
-      window_type = "no_focus_window";
-      type = META_FOCUS_NO_FOCUS_WINDOW;
-    }
+    window_type = "no_focus_window";
   else if (meta_display_screen_for_root (display, event->event))
     window_type = "root window";
   else
     window_type = "unknown window";
 
-  /* Don't change type if we don't know the new window */
-  if (type == META_FOCUS_NONE)
-    type = display->focus_type;
-
   meta_topic (META_DEBUG_FOCUS,
               "Focus %s event received on %s 0x%lx (%s) "
               "mode %s detail %s serial %lu\n",
@@ -2033,7 +2012,6 @@ handle_window_focus_event (MetaDisplay  *display,
        display->server_focus_serial == display->focus_serial))
     {
       update_focus_window (display,
-                           type,
                            focus_window,
                            focus_window ? focus_window->xwindow : None,
                            display->server_focus_serial,
@@ -3282,7 +3260,6 @@ meta_display_handle_xevent (MetaDisplay *display,
       meta_topic (META_DEBUG_FOCUS, "Earlier attempt to focus %s failed\n",
                   display->focus_window->desc);
       update_focus_window (display,
-                           META_FOCUS_NONE,
                            meta_display_lookup_x_window (display, display->server_focus_window),
                            display->server_focus_window,
                            display->server_focus_serial,
@@ -5951,8 +5928,6 @@ meta_display_set_input_focus_window (MetaDisplay *display,
 {
   request_xserver_input_focus_change (display,
                                       window->screen,
-                                      window->client_type == META_WINDOW_CLIENT_TYPE_WAYLAND ?
-                                      META_FOCUS_WAYLAND_CLIENT : META_FOCUS_X_CLIENT,
                                       window,
                                       focus_frame ? window->frame->xwindow : window->xwindow,
                                       timestamp);
@@ -5975,15 +5950,13 @@ meta_display_request_take_focus (MetaDisplay *display,
 }
 
 void
-meta_display_set_input_focus_xwindow (MetaDisplay   *display,
-                                      MetaScreen    *screen,
-                                      MetaFocusType  type,
-                                      Window         window,
-                                      guint32        timestamp)
+meta_display_set_input_focus_xwindow (MetaDisplay *display,
+                                      MetaScreen  *screen,
+                                      Window       window,
+                                      guint32      timestamp)
 {
   request_xserver_input_focus_change (display,
                                       screen,
-                                      type,
                                       NULL,
                                       window,
                                       timestamp);
@@ -5996,7 +5969,6 @@ meta_display_focus_the_no_focus_window (MetaDisplay *display,
 {
   request_xserver_input_focus_change (display,
                                       screen,
-                                      META_FOCUS_NO_FOCUS_WINDOW,
                                       NULL,
                                       screen->no_focus_window,
                                       timestamp);


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