[mutter] frames: Remove all other uses of meta_core_get



commit 4496fb4447c1b8541469cb58c88cd46d09c9e8c7
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Thu Jan 1 11:50:57 2015 -0800

    frames: Remove all other uses of meta_core_get
    
    RIP.

 src/core/core.c |   72 -------------------------------------------------------
 src/core/core.h |   50 --------------------------------------
 src/ui/frames.c |   52 +++++++++++----------------------------
 3 files changed, 15 insertions(+), 159 deletions(-)
---
diff --git a/src/core/core.c b/src/core/core.c
index b1440b1..d7bc73b 100644
--- a/src/core/core.c
+++ b/src/core/core.c
@@ -63,78 +63,6 @@ get_window (Display *xdisplay,
 }
 
 void
-meta_core_get (Display *xdisplay,
-    Window xwindow,
-    ...)
-{
-  va_list args;
-  MetaCoreGetType request;
-
-  MetaDisplay *display = meta_display_for_x_display (xdisplay);
-  MetaWindow *window = meta_display_lookup_x_window (display, xwindow);
-  MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
-  MetaWindowX11Private *priv = window_x11->priv;
-
-  va_start (args, xwindow);
-
-  request = va_arg (args, MetaCoreGetType);
-
-  /* Now, we special-case the first request slightly. Mostly, requests
-   * for information on windows which have no frame are errors.
-   * But sometimes we may want to know *whether* a window has a frame.
-   * In this case, pass the key META_CORE_WINDOW_HAS_FRAME
-   * as the *first* request, with a pointer to a boolean; if the window
-   * has no frame, this will be set to False and meta_core_get will
-   * exit immediately (so the values of any other requests will be
-   * undefined). Otherwise it will be set to True and meta_core_get will
-   * continue happily on its way.
-   */
-
-  if (request != META_CORE_WINDOW_HAS_FRAME &&
-      (window == NULL || window->frame == NULL))
-    {
-      meta_bug ("No such frame window 0x%lx!\n", xwindow);
-      goto out;
-    }
-
-  while (request != META_CORE_GET_END)
-    {
-      gpointer answer = va_arg (args, gpointer);
-
-      switch (request)
-        {
-        case META_CORE_WINDOW_HAS_FRAME:
-          *((gboolean*)answer) = window != NULL && window->frame != NULL;
-          if (!*((gboolean*)answer)) goto out; /* see above */
-          break;
-        case META_CORE_GET_CLIENT_WIDTH:
-          *((gint*)answer) = priv->client_rect.width;
-          break;
-        case META_CORE_GET_CLIENT_HEIGHT:
-          *((gint*)answer) = priv->client_rect.height;
-          break;
-        case META_CORE_GET_MINI_ICON:
-          *((cairo_surface_t**)answer) = window->mini_icon;
-          break;
-        case META_CORE_GET_FRAME_RECT:
-          meta_window_get_frame_rect (window, ((MetaRectangle*)answer));
-          break;
-        case META_CORE_GET_THEME_VARIANT:
-          *((char**)answer) = window->gtk_theme_variant;
-          break;
-
-        default:
-          meta_warning("Unknown window information request: %d\n", request);
-        }
-
-      request = va_arg (args, MetaCoreGetType);
-    }
-
- out:
-  va_end (args);
-}
-
-void
 meta_core_queue_frame_resize (Display *xdisplay,
                               Window   frame_xwindow)
 {
diff --git a/src/core/core.h b/src/core/core.h
index f5e64d6..ab1a773 100644
--- a/src/core/core.h
+++ b/src/core/core.h
@@ -28,56 +28,6 @@
 #include <meta/common.h>
 #include <meta/boxes.h>
 
-typedef enum
-{
-  META_CORE_GET_END = 0,
-  META_CORE_WINDOW_HAS_FRAME,
-  META_CORE_GET_CLIENT_WIDTH,
-  META_CORE_GET_CLIENT_HEIGHT,
-  META_CORE_GET_MINI_ICON,
-  META_CORE_GET_FRAME_RECT,
-  META_CORE_GET_THEME_VARIANT,
-} MetaCoreGetType;
-
-/* General information function about the given window. Pass in a sequence of
- * pairs of MetaCoreGetTypes and pointers to variables; the variables will be
- * filled with the requested values. End the list with META_CORE_GET_END.
- * For example:
- *
- *   meta_core_get (my_display, my_window,
- *                  META_CORE_GET_FRAME_RECT, &rect,
- *                  META_CORE_GET_END);
- *
- * If the window doesn't have a frame, this will raise a meta_bug. To suppress
- * this behaviour, ask META_CORE_WINDOW_HAS_FRAME as the *first* question in
- * the list. If the window has no frame, the answer to this question will be
- * False, and anything else you asked will be undefined. Otherwise, the answer
- * will be True. The answer will necessarily be True if you ask the question
- * in any other position. The positions of all other questions don't matter.
- *
- * The reason for this function is that some parts of the program don't know
- * about MetaWindows. But they *can* see core.h. So we used to have a whole
- * load of functions which took a display and an X window, looked up the
- * relevant MetaWindow, and returned information about it. The trouble with
- * that is that looking up the MetaWindow is a nontrivial operation, and
- * consolidating the calls in this way makes (for example) frame exposes
- * 33% faster, according to valgrind.
- *
- * This function would perhaps be slightly better if the questions were
- * represented by pointers, perhaps gchar*s, because then we could take
- * advantage of gcc's automatic sentinel checking. On the other hand, this
- * immediately suggests string comparison, and that's slow.
- *
- * Another possible improvement is that core.h still has a bunch of
- * functions which can't be described by the formula "give a display and
- * an X window, get a single value" (meta_core_user_move, for example), but
- * which could theoretically be handled by this function if we relaxed the
- * requirement that all questions should have exactly one argument.
- */
-void meta_core_get (Display *xdisplay,
-                    Window window,
-                    ...);
-
 void meta_core_queue_frame_resize (Display *xdisplay,
                                    Window frame_xwindow);
 
diff --git a/src/ui/frames.c b/src/ui/frames.c
index 4f2d922..7237cf9 100644
--- a/src/ui/frames.c
+++ b/src/ui/frames.c
@@ -34,6 +34,8 @@
 
 #include "core/window-private.h"
 #include "core/frame.h"
+#include "x11/window-x11.h"
+#include "x11/window-x11-private.h"
 
 #include <cairo-xlib.h>
 
@@ -432,15 +434,11 @@ static void
 meta_ui_frame_calc_geometry (MetaUIFrame       *frame,
                              MetaFrameGeometry *fgeom)
 {
-  int width, height;
   MetaFrameFlags flags;
   MetaFrameType type;
   MetaButtonLayout button_layout;
-
-  meta_core_get (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), frame->xwindow,
-                 META_CORE_GET_CLIENT_WIDTH, &width,
-                 META_CORE_GET_CLIENT_HEIGHT, &height,
-                 META_CORE_GET_END);
+  MetaWindowX11 *window_x11 = META_WINDOW_X11 (frame->meta_window);
+  MetaWindowX11Private *priv = window_x11->priv;
 
   flags = meta_frame_get_flags (frame->meta_window->frame);
   type = meta_window_get_window_type (frame->meta_window);
@@ -454,7 +452,8 @@ meta_ui_frame_calc_geometry (MetaUIFrame       *frame,
                             type,
                             frame->text_height,
                             flags,
-                            width, height,
+                            priv->client_rect.width,
+                            priv->client_rect.height,
                             &button_layout,
                             fgeom);
 }
@@ -495,17 +494,12 @@ static void
 meta_ui_frame_attach_style (MetaUIFrame *frame)
 {
   MetaFrames *frames = frame->frames;
-  gboolean has_frame;
-  char *variant = NULL;
+  const char *variant;
 
   if (frame->style_info != NULL)
     meta_style_info_unref (frame->style_info);
 
-  meta_core_get (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
-                 frame->xwindow,
-                 META_CORE_WINDOW_HAS_FRAME, &has_frame,
-                 META_CORE_GET_THEME_VARIANT, &variant,
-                 META_CORE_GET_END);
+  variant = frame->meta_window->gtk_theme_variant;
 
   if (variant == NULL || strcmp(variant, "normal") == 0)
     frame->style_info = meta_style_info_ref (frames->normal_style);
@@ -1405,19 +1399,12 @@ meta_frames_destroy_event           (GtkWidget           *widget,
 static cairo_region_t *
 get_visible_frame_border_region (MetaUIFrame *frame)
 {
-  MetaRectangle frame_rect;
   cairo_rectangle_int_t area;
   cairo_region_t *frame_border;
   MetaFrameFlags flags;
   MetaFrameType type;
   MetaFrameBorders borders;
-  Display *display;
-
-  display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
-
-  meta_core_get (display, frame->xwindow,
-                 META_CORE_GET_FRAME_RECT, &frame_rect,
-                 META_CORE_GET_END);
+  MetaRectangle frame_rect = frame->meta_window->rect;
 
   flags = meta_frame_get_flags (frame->meta_window->frame);
   type = meta_window_get_window_type (frame->meta_window);
@@ -1473,10 +1460,7 @@ meta_ui_frame_get_mask (MetaUIFrame *frame,
   MetaFrameFlags flags;
   MetaRectangle frame_rect;
 
-  meta_core_get (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
-                 frame->xwindow,
-                 META_CORE_GET_FRAME_RECT, &frame_rect,
-                 META_CORE_GET_END);
+  meta_window_get_frame_rect (frame->meta_window, &frame_rect);
 
   flags = meta_frame_get_flags (frame->meta_window->frame);
 
@@ -1535,14 +1519,12 @@ meta_ui_frame_paint (MetaUIFrame  *frame,
   MetaFrameFlags flags;
   MetaFrameType type;
   cairo_surface_t *mini_icon;
-  int w, h;
   MetaButtonState button_states[META_BUTTON_TYPE_LAST];
   int i;
   int button_type = -1;
   MetaButtonLayout button_layout;
-  Display *display;
-
-  display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
+  MetaWindowX11 *window_x11 = META_WINDOW_X11 (frame->meta_window);
+  MetaWindowX11Private *priv = window_x11->priv;
 
   for (i = 0; i < META_BUTTON_TYPE_LAST; i++)
     button_states[i] = META_BUTTON_STATE_NORMAL;
@@ -1593,12 +1575,7 @@ meta_ui_frame_paint (MetaUIFrame  *frame,
   if (button_type > -1)
     button_states[button_type] = frame->button_state;
 
-  meta_core_get (display, frame->xwindow,
-                 META_CORE_GET_MINI_ICON, &mini_icon,
-                 META_CORE_GET_CLIENT_WIDTH, &w,
-                 META_CORE_GET_CLIENT_HEIGHT, &h,
-                 META_CORE_GET_END);
-
+  mini_icon = frame->meta_window->mini_icon;
   flags = meta_frame_get_flags (frame->meta_window->frame);
   type = meta_window_get_window_type (frame->meta_window);
 
@@ -1611,7 +1588,8 @@ meta_ui_frame_paint (MetaUIFrame  *frame,
                          cr,
                          type,
                          flags,
-                         w, h,
+                         priv->client_rect.width,
+                         priv->client_rect.height,
                          frame->text_layout,
                          frame->text_height,
                          &button_layout,


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