frames: Remove all other uses of meta_core_get

RIP.
This commit is contained in:
Jasper St. Pierre
2015-01-01 11:50:57 -08:00
parent 7e66d2a484
commit 4496fb4447
3 changed files with 15 additions and 159 deletions

View File

@ -62,78 +62,6 @@ get_window (Display *xdisplay,
return window;
}
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)

View File

@ -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);