[mutter/wayland] Remove meta_window_new_with_attrs



commit 384a34c27d3f65a7be209ebf65178752ba4ded85
Author: Daniel Drake <drake endlessm com>
Date:   Thu Dec 19 10:51:49 2013 -0600

    Remove meta_window_new_with_attrs
    
    The compositor code used to handle X windows that didn't have a
    corresponding MetaWindow (see commit d538690b), which is why the
    attribute query is separated.
    
    As that doesn't happen any more, we can clean up. No functional changes.
    
    Suggested by Owen Taylor.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=721345

 src/core/display.c        |    4 +-
 src/core/screen.c         |   70 +++++---------------------
 src/core/window-private.h |    8 +--
 src/core/window.c         |  122 +++++++++++++++++++--------------------------
 4 files changed, 67 insertions(+), 137 deletions(-)
---
diff --git a/src/core/display.c b/src/core/display.c
index 455db31..ce33923 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -2806,14 +2806,14 @@ handle_other_xevent (MetaDisplay *display,
           && meta_display_screen_for_root (display, event->xmap.event))
         {
           window = meta_window_new (display, event->xmap.window,
-                                    FALSE);
+                                    FALSE, META_COMP_EFFECT_CREATE);
         }
       break;
     case MapRequest:
       if (window == NULL)
         {
           window = meta_window_new (display, event->xmaprequest.window,
-                                    FALSE);
+                                    FALSE, META_COMP_EFFECT_CREATE);
         }
       /* if frame was receiver it's some malicious send event or something */
       else if (!frame_was_receiver && window)
diff --git a/src/core/screen.c b/src/core/screen.c
index 90083ec..d006b43 100644
--- a/src/core/screen.c
+++ b/src/core/screen.c
@@ -880,82 +880,36 @@ meta_screen_free (MetaScreen *screen,
   meta_display_ungrab (display);
 }
 
-typedef struct
-{
-  Window               xwindow;
-  XWindowAttributes    attrs;
-} WindowInfo;
-
-static GList *
-list_windows (MetaScreen *screen)
+void
+meta_screen_manage_all_windows (MetaScreen *screen)
 {
   Window ignored1, ignored2;
   Window *children;
   guint n_children, i;
-  GList *result;
+
+  meta_display_grab (screen->display);
+
+  if (screen->guard_window == None)
+    screen->guard_window =
+      meta_screen_create_guard_window (screen->display->xdisplay, screen);
+
+  meta_stack_freeze (screen->stack);
 
   XQueryTree (screen->display->xdisplay,
               screen->xroot,
               &ignored1, &ignored2, &children, &n_children);
 
-  result = NULL;
   for (i = 0; i < n_children; ++i)
     {
-      WindowInfo *info = g_new0 (WindowInfo, 1);
-
-      meta_error_trap_push_with_return (screen->display);
-      
-      XGetWindowAttributes (screen->display->xdisplay,
-                            children[i], &info->attrs);
-
-      if (meta_error_trap_pop_with_return (screen->display))
-       {
-          meta_verbose ("Failed to get attributes for window 0x%lx\n",
-                        children[i]);
-         g_free (info);
-        }
-      else
-        {
-         info->xwindow = children[i];
-       }
-
-      result = g_list_prepend (result, info);
+      meta_window_new (screen->display, children[i], TRUE,
+                       META_COMP_EFFECT_NONE);
     }
 
   if (children)
     XFree (children);
 
-  return g_list_reverse (result);
-}
-
-void
-meta_screen_manage_all_windows (MetaScreen *screen)
-{
-  GList *windows;
-  GList *list;
-
-  meta_display_grab (screen->display);
-
-  if (screen->guard_window == None)
-    screen->guard_window =
-      meta_screen_create_guard_window (screen->display->xdisplay, screen);
-
-  windows = list_windows (screen);
-
-  meta_stack_freeze (screen->stack);
-  for (list = windows; list != NULL; list = list->next)
-    {
-      WindowInfo *info = list->data;
-
-      meta_window_new_with_attrs (screen->display, info->xwindow, TRUE,
-                                  META_COMP_EFFECT_NONE,
-                                  &info->attrs);
-    }
   meta_stack_thaw (screen->stack);
 
-  g_list_foreach (windows, (GFunc)g_free, NULL);
-  g_list_free (windows);
-
   meta_display_ungrab (screen->display);
 }
 
diff --git a/src/core/window-private.h b/src/core/window-private.h
index 0e0631a..ef4c83d 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -510,12 +510,8 @@ struct _MetaWindowClass
 
 MetaWindow* meta_window_new                (MetaDisplay *display,
                                             Window       xwindow,
-                                            gboolean     must_be_viewable);
-MetaWindow* meta_window_new_with_attrs     (MetaDisplay       *display,
-                                            Window             xwindow,
-                                            gboolean           must_be_viewable,
-                                            MetaCompEffect     effect,
-                                            XWindowAttributes *attrs);
+                                            gboolean     must_be_viewable,
+                                            MetaCompEffect     effect);
 MetaWindow *meta_window_new_for_wayland    (MetaDisplay        *display,
                                             MetaWaylandSurface *surface);
 void        meta_window_unmanage           (MetaWindow  *window,
diff --git a/src/core/window.c b/src/core/window.c
index 6152d51..45fdb8c 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -685,53 +685,6 @@ maybe_leave_show_desktop_mode (MetaWindow *window)
     }
 }
 
-MetaWindow*
-meta_window_new (MetaDisplay *display,
-                 Window       xwindow,
-                 gboolean     must_be_viewable)
-{
-  XWindowAttributes attrs;
-  MetaWindow *window;
-
-  meta_display_grab (display);
-  meta_error_trap_push (display); /* Push a trap over all of window
-                                   * creation, to reduce XSync() calls
-                                   */
-
-  meta_error_trap_push_with_return (display);
-
-  if (XGetWindowAttributes (display->xdisplay,xwindow, &attrs))
-   {
-      if(meta_error_trap_pop_with_return (display) != Success)
-       {
-          meta_verbose ("Failed to get attributes for window 0x%lx\n",
-                        xwindow);
-          meta_error_trap_pop (display);
-          meta_display_ungrab (display);
-          return NULL;
-       }
-      window = meta_window_new_with_attrs (display, xwindow,
-                                           must_be_viewable,
-                                           META_COMP_EFFECT_CREATE,
-                                           &attrs);
-   }
-  else
-   {
-         meta_error_trap_pop_with_return (display);
-         meta_verbose ("Failed to get attributes for window 0x%lx\n",
-                        xwindow);
-         meta_error_trap_pop (display);
-         meta_display_ungrab (display);
-         return NULL;
-   }
-
-
-  meta_error_trap_pop (display);
-  meta_display_ungrab (display);
-
-  return window;
-}
-
 /* The MUTTER_WM_CLASS_FILTER environment variable is designed for
  * performance and regression testing environments where we want to do
  * tests with only a limited set of windows and ignore all other windows
@@ -1460,12 +1413,12 @@ meta_window_new_for_wayland (MetaDisplay        *display,
 }
 
 MetaWindow*
-meta_window_new_with_attrs (MetaDisplay       *display,
-                            Window             xwindow,
-                            gboolean           must_be_viewable,
-                            MetaCompEffect     effect,
-                            XWindowAttributes *attrs)
+meta_window_new (MetaDisplay       *display,
+                 Window             xwindow,
+                 gboolean           must_be_viewable,
+                 MetaCompEffect     effect)
 {
+  XWindowAttributes attrs;
   MetaScreen *screen = NULL;
   GSList *tmp;
   gulong existing_wm_state;
@@ -1481,11 +1434,40 @@ meta_window_new_with_attrs (MetaDisplay       *display,
       return NULL;
     }
 
+  /* Grab server */
+  meta_display_grab (display);
+  meta_error_trap_push (display); /* Push a trap over all of window
+                                   * creation, to reduce XSync() calls
+                                   */
+
+  meta_error_trap_push_with_return (display);
+
+  if (XGetWindowAttributes (display->xdisplay, xwindow, &attrs))
+   {
+      if(meta_error_trap_pop_with_return (display) != Success)
+       {
+          meta_verbose ("Failed to get attributes for window 0x%lx\n",
+                        xwindow);
+          meta_error_trap_pop (display);
+          meta_display_ungrab (display);
+          return NULL;
+       }
+   }
+  else
+   {
+         meta_error_trap_pop_with_return (display);
+         meta_verbose ("Failed to get attributes for window 0x%lx\n",
+                        xwindow);
+         meta_error_trap_pop (display);
+         meta_display_ungrab (display);
+         return NULL;
+   }
+
   for (tmp = display->screens; tmp != NULL; tmp = tmp->next)
     {
       MetaScreen *scr = tmp->data;
 
-      if (scr->xroot == attrs->root)
+      if (scr->xroot == attrs.root)
         {
           screen = tmp->data;
           break;
@@ -1495,14 +1477,14 @@ meta_window_new_with_attrs (MetaDisplay       *display,
   g_assert (screen);
 
   /* A black list of override redirect windows that we don't need to manage: */
-  if (attrs->override_redirect &&
+  if (attrs.override_redirect &&
       (xwindow == screen->no_focus_window ||
        xwindow == screen->flash_window ||
        xwindow == screen->wm_sn_selection_window ||
-       attrs->class == InputOnly ||
+       attrs.class == InputOnly ||
        /* any windows created via meta_create_offscreen_window: */
-       (attrs->x == -100 && attrs->y == -100
-       && attrs->width == 1 && attrs->height == 1) ||
+       (attrs.x == -100 && attrs.y == -100
+       && attrs.width == 1 && attrs.height == 1) ||
        xwindow == screen->wm_cm_selection_window ||
        xwindow == screen->guard_window ||
        (display->compositor &&
@@ -1512,23 +1494,21 @@ meta_window_new_with_attrs (MetaDisplay       *display,
       )
      ) {
     meta_verbose ("Not managing our own windows\n");
+    meta_error_trap_pop (display);
+    meta_display_ungrab (display);
     return NULL;
   }
 
-  if (maybe_filter_xwindow (display, xwindow, must_be_viewable, attrs))
+  if (maybe_filter_xwindow (display, xwindow, must_be_viewable, &attrs))
     {
       meta_verbose ("Not managing filtered window\n");
+      meta_error_trap_pop (display);
+      meta_display_ungrab (display);
       return NULL;
     }
 
-  /* Grab server */
-  meta_display_grab (display);
-  meta_error_trap_push (display); /* Push a trap over all of window
-                                   * creation, to reduce XSync() calls
-                                   */
-
   existing_wm_state = WithdrawnState;
-  if (must_be_viewable && attrs->map_state != IsViewable)
+  if (must_be_viewable && attrs.map_state != IsViewable)
     {
       /* Only manage if WM_STATE is IconicState or NormalState */
       gulong state;
@@ -1567,14 +1547,14 @@ meta_window_new_with_attrs (MetaDisplay       *display,
   meta_error_trap_pop_with_return (display);
 
   event_mask = PropertyChangeMask | ColormapChangeMask;
-  if (attrs->override_redirect)
+  if (attrs.override_redirect)
     event_mask |= StructureNotifyMask;
 
   /* If the window is from this client (a menu, say) we need to augment
    * the event mask, not replace it. For windows from other clients,
-   * attrs->your_event_mask will be empty at this point.
+   * attrs.your_event_mask will be empty at this point.
    */
-  XSelectInput (display->xdisplay, xwindow, attrs->your_event_mask | event_mask);
+  XSelectInput (display->xdisplay, xwindow, attrs.your_event_mask | event_mask);
 
     {
       unsigned char mask_bits[XIMaskLen (XI_LASTEVENT)] = { 0 };
@@ -1591,11 +1571,11 @@ meta_window_new_with_attrs (MetaDisplay       *display,
     }
 
   /* Get rid of any borders */
-  if (attrs->border_width != 0)
+  if (attrs.border_width != 0)
     XSetWindowBorderWidth (display->xdisplay, xwindow, 0);
 
   /* Get rid of weird gravities */
-  if (attrs->win_gravity != NorthWestGravity)
+  if (attrs.win_gravity != NorthWestGravity)
     {
       XSetWindowAttributes set_attrs;
 
@@ -1624,7 +1604,7 @@ meta_window_new_with_attrs (MetaDisplay       *display,
                                    TRUE,
                                    existing_wm_state,
                                    effect,
-                                   attrs);
+                                   &attrs);
 
   meta_error_trap_pop (display); /* pop the XSync()-reducing trap */
   meta_display_ungrab (display);


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