[mutter] Remove meta_window_new_with_attrs



commit c7725ddf2a00cba75beb394f8726c22b86b0d7e6
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         |  160 +++++++++++++++++++-------------------------
 4 files changed, 85 insertions(+), 157 deletions(-)
---
diff --git a/src/core/display.c b/src/core/display.c
index a938515..e4a2163 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -2775,14 +2775,14 @@ event_callback (XEvent   *event,
               && 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 fc0c3ae..89c1846 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 = 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 = 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 774b6ab..31f029a 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -490,12 +490,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);
 void        meta_window_unmanage           (MetaWindow  *window,
                                             guint32      timestamp);
 void        meta_window_calc_showing       (MetaWindow  *window);
diff --git a/src/core/window.c b/src/core/window.c
index 7d8948e..2515ff6 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -659,53 +659,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
@@ -816,12 +769,12 @@ meta_window_should_attach_to_parent (MetaWindow *window)
 }
 
 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;
   MetaWindow *window;
   GSList *tmp;
   MetaWorkspace *space;
@@ -830,8 +783,6 @@ meta_window_new_with_attrs (MetaDisplay       *display,
   MetaMoveResizeFlags flags;
   MetaScreen *screen;
 
-  g_assert (attrs != NULL);
-
   meta_verbose ("Attempting to manage 0x%lx\n", xwindow);
 
   if (meta_display_xwindow_is_a_no_focus_window (display, xwindow))
@@ -841,12 +792,41 @@ 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;
+   }
+
   screen = 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;
@@ -856,14 +836,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 &&
@@ -873,34 +853,32 @@ 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_window (display, xwindow, must_be_viewable, attrs))
+  if (maybe_filter_window (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
-                                   */
-
-  meta_verbose ("must_be_viewable = %d attrs->map_state = %d (%s)\n",
+  meta_verbose ("must_be_viewable = %d attrs.map_state = %d (%s)\n",
                 must_be_viewable,
-                attrs->map_state,
-                (attrs->map_state == IsUnmapped) ?
+                attrs.map_state,
+                (attrs.map_state == IsUnmapped) ?
                 "IsUnmapped" :
-                (attrs->map_state == IsViewable) ?
+                (attrs.map_state == IsViewable) ?
                 "IsViewable" :
-                (attrs->map_state == IsUnviewable) ?
+                (attrs.map_state == IsUnviewable) ?
                 "IsUnviewable" :
                 "(unknown)");
 
   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;
@@ -938,14 +916,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 };
@@ -967,11 +945,11 @@ meta_window_new_with_attrs (MetaDisplay       *display,
 #endif
 
   /* 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;
 
@@ -1018,22 +996,22 @@ meta_window_new_with_attrs (MetaDisplay       *display,
 
   window->desc = g_strdup_printf ("0x%lx", window->xwindow);
 
-  window->override_redirect = attrs->override_redirect;
+  window->override_redirect = attrs.override_redirect;
 
   /* avoid tons of stack updates */
   meta_stack_freeze (window->screen->stack);
 
-  window->rect.x = attrs->x;
-  window->rect.y = attrs->y;
-  window->rect.width = attrs->width;
-  window->rect.height = attrs->height;
+  window->rect.x = attrs.x;
+  window->rect.y = attrs.y;
+  window->rect.width = attrs.width;
+  window->rect.height = attrs.height;
 
   /* And border width, size_hints are the "request" */
-  window->border_width = attrs->border_width;
-  window->size_hints.x = attrs->x;
-  window->size_hints.y = attrs->y;
-  window->size_hints.width = attrs->width;
-  window->size_hints.height = attrs->height;
+  window->border_width = attrs.border_width;
+  window->size_hints.x = attrs.x;
+  window->size_hints.y = attrs.y;
+  window->size_hints.width = attrs.width;
+  window->size_hints.height = attrs.height;
   /* initialize the remaining size_hints as if size_hints.flags were zero */
   meta_set_normal_hints (window, NULL);
 
@@ -1041,9 +1019,9 @@ meta_window_new_with_attrs (MetaDisplay       *display,
   window->saved_rect = window->rect;
   window->user_rect = window->rect;
 
-  window->depth = attrs->depth;
-  window->xvisual = attrs->visual;
-  window->colormap = attrs->colormap;
+  window->depth = attrs.depth;
+  window->xvisual = attrs.visual;
+  window->colormap = attrs.colormap;
 
   window->title = NULL;
   window->icon_name = NULL;
@@ -1078,7 +1056,7 @@ meta_window_new_with_attrs (MetaDisplay       *display,
   window->minimized = FALSE;
   window->tab_unminimized = FALSE;
   window->iconic = FALSE;
-  window->mapped = attrs->map_state != IsUnmapped;
+  window->mapped = attrs.map_state != IsUnmapped;
   window->hidden = FALSE;
   window->visible_to_compositor = FALSE;
   window->pending_compositor_effect = effect;


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