mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 11:32:04 +00:00
changed all tabs to spaces. Removed and replaced with meta_core_get(). New
2007-06-06 Thomas Thurman <thomas@thurman.org.uk> * frames.c, core.[ch]: changed all tabs to spaces. * core.[ch] (meta_core_get_client_size, meta_core_window_has_frame, meta_core_titlebar_is_onscreen, meta_core_get_client_xwindow, meta_core_get_frame_flags, meta_core_get_frame_type, meta_core_get_mini_icon, meta_core_get_icon, meta_core_get_position, meta_core_get_size, meta_core_get_frame_workspace, meta_core_get_frame_extents, meta_core_get_screen_size): Removed and replaced with meta_core_get(). * core.[ch] (meta_core_get): New function. * core.h (MetaCoreGetType): New enum. * frames.c (meta_frames_ensure_layout, meta_frames_calc_geometry, meta_frames_get_geometry, meta_frames_apply_shapes, meta_frame_titlebar_event, meta_frames_button_press_event, populate_cache, clip_to_screen, meta_frames_paint_to_drawable, meta_frames_set_window_background, get_control): Replace use of removed functions in ui.c with meta_core_get(). All this should make things a little faster. Closes #377495. svn path=/trunk/; revision=3233
This commit is contained in:
parent
98791271e1
commit
ff33209e1f
21
ChangeLog
21
ChangeLog
@ -1,3 +1,24 @@
|
||||
2007-06-06 Thomas Thurman <thomas@thurman.org.uk>
|
||||
|
||||
* frames.c, core.[ch]: changed all tabs to spaces.
|
||||
* core.[ch] (meta_core_get_client_size, meta_core_window_has_frame,
|
||||
meta_core_titlebar_is_onscreen, meta_core_get_client_xwindow,
|
||||
meta_core_get_frame_flags, meta_core_get_frame_type,
|
||||
meta_core_get_mini_icon, meta_core_get_icon, meta_core_get_position,
|
||||
meta_core_get_size, meta_core_get_frame_workspace,
|
||||
meta_core_get_frame_extents, meta_core_get_screen_size): Removed
|
||||
and replaced with meta_core_get().
|
||||
* core.[ch] (meta_core_get): New function.
|
||||
* core.h (MetaCoreGetType): New enum.
|
||||
* frames.c (meta_frames_ensure_layout, meta_frames_calc_geometry,
|
||||
meta_frames_get_geometry, meta_frames_apply_shapes,
|
||||
meta_frame_titlebar_event, meta_frames_button_press_event,
|
||||
populate_cache, clip_to_screen, meta_frames_paint_to_drawable,
|
||||
meta_frames_set_window_background, get_control): Replace use of
|
||||
removed functions in ui.c with meta_core_get().
|
||||
|
||||
All this should make things a little faster. Closes #377495.
|
||||
|
||||
2007-06-04 Thomas Thurman <thomas@thurman.org.uk>
|
||||
|
||||
* NEWS: Added translators' names from 2.19.8 (sorry, folks:
|
||||
|
311
src/core.c
311
src/core.c
@ -42,7 +42,7 @@
|
||||
*/
|
||||
static MetaWindow *
|
||||
get_window (Display *xdisplay,
|
||||
Window frame_xwindow)
|
||||
Window frame_xwindow)
|
||||
{
|
||||
MetaDisplay *display;
|
||||
MetaWindow *window;
|
||||
@ -60,125 +60,156 @@ get_window (Display *xdisplay,
|
||||
}
|
||||
|
||||
void
|
||||
meta_core_get_client_size (Display *xdisplay,
|
||||
Window frame_xwindow,
|
||||
int *width,
|
||||
int *height)
|
||||
meta_core_get (Display *xdisplay,
|
||||
Window xwindow,
|
||||
...)
|
||||
{
|
||||
MetaWindow *window = get_window (xdisplay, frame_xwindow);
|
||||
|
||||
if (width)
|
||||
*width = window->rect.width;
|
||||
if (height)
|
||||
*height = window->rect.height;
|
||||
}
|
||||
va_list args;
|
||||
MetaCoreGetType request;
|
||||
|
||||
gboolean
|
||||
meta_core_window_has_frame (Display *xdisplay,
|
||||
Window frame_xwindow)
|
||||
{
|
||||
MetaDisplay *display;
|
||||
MetaWindow *window;
|
||||
|
||||
display = meta_display_for_x_display (xdisplay);
|
||||
window = meta_display_lookup_x_window (display, frame_xwindow);
|
||||
MetaDisplay *display = meta_display_for_x_display (xdisplay);
|
||||
MetaWindow *window = meta_display_lookup_x_window (display, xwindow);
|
||||
|
||||
return window != NULL && window->frame != NULL;
|
||||
}
|
||||
va_start (args, xwindow);
|
||||
|
||||
gboolean
|
||||
meta_core_titlebar_is_onscreen (Display *xdisplay,
|
||||
Window frame_xwindow)
|
||||
{
|
||||
MetaWindow *window = get_window (xdisplay, frame_xwindow);
|
||||
request = va_arg (args, MetaCoreGetType);
|
||||
|
||||
return meta_window_titlebar_is_onscreen (window);
|
||||
}
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
Window
|
||||
meta_core_get_client_xwindow (Display *xdisplay,
|
||||
Window frame_xwindow)
|
||||
{
|
||||
MetaWindow *window = get_window (xdisplay, frame_xwindow);
|
||||
if (request != META_CORE_WINDOW_HAS_FRAME &&
|
||||
(window == NULL || window->frame == NULL)) {
|
||||
meta_bug ("No such frame window 0x%lx!\n", xwindow);
|
||||
return;
|
||||
}
|
||||
|
||||
return window->xwindow;
|
||||
}
|
||||
while (request != META_CORE_GET_END) {
|
||||
|
||||
gpointer answer = va_arg (args, gpointer);
|
||||
|
||||
MetaFrameFlags
|
||||
meta_core_get_frame_flags (Display *xdisplay,
|
||||
Window frame_xwindow)
|
||||
{
|
||||
MetaWindow *window = get_window (xdisplay, frame_xwindow);
|
||||
|
||||
return meta_frame_get_flags (window->frame);
|
||||
}
|
||||
switch (request) {
|
||||
case META_CORE_WINDOW_HAS_FRAME:
|
||||
*((gboolean*)answer) = window != NULL && window->frame != NULL;
|
||||
if (!*((gboolean*)answer)) return; /* see above */
|
||||
break;
|
||||
case META_CORE_GET_CLIENT_WIDTH:
|
||||
*((gint*)answer) = window->rect.width;
|
||||
break;
|
||||
case META_CORE_GET_CLIENT_HEIGHT:
|
||||
*((gint*)answer) = window->rect.height;
|
||||
break;
|
||||
case META_CORE_IS_TITLEBAR_ONSCREEN:
|
||||
*((gboolean*)answer) = meta_window_titlebar_is_onscreen (window);
|
||||
break;
|
||||
case META_CORE_GET_CLIENT_XWINDOW:
|
||||
*((Window*)answer) = window->xwindow;
|
||||
break;
|
||||
case META_CORE_GET_FRAME_FLAGS:
|
||||
*((MetaFrameFlags*)answer) = meta_frame_get_flags (window->frame);
|
||||
break;
|
||||
case META_CORE_GET_FRAME_TYPE:
|
||||
{
|
||||
MetaFrameType base_type = META_FRAME_TYPE_LAST;
|
||||
|
||||
MetaFrameType
|
||||
meta_core_get_frame_type (Display *xdisplay,
|
||||
Window frame_xwindow)
|
||||
{
|
||||
MetaWindow *window;
|
||||
MetaFrameType base_type;
|
||||
switch (window->type)
|
||||
{
|
||||
case META_WINDOW_NORMAL:
|
||||
base_type = META_FRAME_TYPE_NORMAL;
|
||||
break;
|
||||
|
||||
window = get_window (xdisplay, frame_xwindow);
|
||||
case META_WINDOW_DIALOG:
|
||||
base_type = META_FRAME_TYPE_DIALOG;
|
||||
break;
|
||||
|
||||
base_type = META_FRAME_TYPE_LAST;
|
||||
|
||||
switch (window->type)
|
||||
{
|
||||
case META_WINDOW_NORMAL:
|
||||
base_type = META_FRAME_TYPE_NORMAL;
|
||||
break;
|
||||
|
||||
case META_WINDOW_DIALOG:
|
||||
base_type = META_FRAME_TYPE_DIALOG;
|
||||
break;
|
||||
|
||||
case META_WINDOW_MODAL_DIALOG:
|
||||
base_type = META_FRAME_TYPE_MODAL_DIALOG;
|
||||
break;
|
||||
|
||||
case META_WINDOW_MENU:
|
||||
base_type = META_FRAME_TYPE_MENU;
|
||||
break;
|
||||
case META_WINDOW_MODAL_DIALOG:
|
||||
base_type = META_FRAME_TYPE_MODAL_DIALOG;
|
||||
break;
|
||||
|
||||
case META_WINDOW_UTILITY:
|
||||
base_type = META_FRAME_TYPE_UTILITY;
|
||||
break;
|
||||
|
||||
case META_WINDOW_DESKTOP:
|
||||
case META_WINDOW_DOCK:
|
||||
case META_WINDOW_TOOLBAR:
|
||||
case META_WINDOW_SPLASHSCREEN:
|
||||
/* No frame */
|
||||
base_type = META_FRAME_TYPE_LAST;
|
||||
break;
|
||||
case META_WINDOW_MENU:
|
||||
base_type = META_FRAME_TYPE_MENU;
|
||||
break;
|
||||
|
||||
case META_WINDOW_UTILITY:
|
||||
base_type = META_FRAME_TYPE_UTILITY;
|
||||
break;
|
||||
|
||||
case META_WINDOW_DESKTOP:
|
||||
case META_WINDOW_DOCK:
|
||||
case META_WINDOW_TOOLBAR:
|
||||
case META_WINDOW_SPLASHSCREEN:
|
||||
/* No frame */
|
||||
base_type = META_FRAME_TYPE_LAST;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if (base_type == META_FRAME_TYPE_LAST)
|
||||
{
|
||||
/* can't add border if undecorated */
|
||||
*((MetaFrameType*)answer) = META_FRAME_TYPE_LAST;
|
||||
}
|
||||
else if (window->border_only)
|
||||
{
|
||||
/* override base frame type */
|
||||
*((MetaFrameType*)answer) = META_FRAME_TYPE_BORDER;
|
||||
}
|
||||
else
|
||||
{
|
||||
*((MetaFrameType*)answer) = base_type;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case META_CORE_GET_MINI_ICON:
|
||||
*((GdkPixbuf**)answer) = window->mini_icon;
|
||||
break;
|
||||
case META_CORE_GET_ICON:
|
||||
*((GdkPixbuf**)answer) = window->icon;
|
||||
break;
|
||||
case META_CORE_GET_X:
|
||||
meta_window_get_position (window, (int*)answer, NULL);
|
||||
break;
|
||||
case META_CORE_GET_Y:
|
||||
meta_window_get_position (window, NULL, (int*)answer);
|
||||
break;
|
||||
case META_CORE_GET_FRAME_WORKSPACE:
|
||||
*((gint*)answer) = meta_window_get_net_wm_desktop (window);
|
||||
break;
|
||||
case META_CORE_GET_FRAME_X:
|
||||
*((gint*)answer) = window->frame->rect.x;
|
||||
break;
|
||||
case META_CORE_GET_FRAME_Y:
|
||||
*((gint*)answer) = window->frame->rect.y;
|
||||
break;
|
||||
case META_CORE_GET_FRAME_WIDTH:
|
||||
*((gint*)answer) = window->frame->rect.width;
|
||||
break;
|
||||
case META_CORE_GET_FRAME_HEIGHT:
|
||||
*((gint*)answer) = window->frame->rect.height;
|
||||
break;
|
||||
case META_CORE_GET_SCREEN_WIDTH:
|
||||
*((gint*)answer) = window->screen->rect.width;
|
||||
break;
|
||||
case META_CORE_GET_SCREEN_HEIGHT:
|
||||
*((gint*)answer) = window->screen->rect.height;
|
||||
break;
|
||||
|
||||
default:
|
||||
meta_warning(_("Unknown window information request: %d"), request);
|
||||
}
|
||||
|
||||
if (base_type == META_FRAME_TYPE_LAST)
|
||||
return META_FRAME_TYPE_LAST; /* can't add border if undecorated */
|
||||
else if (window->border_only)
|
||||
return META_FRAME_TYPE_BORDER; /* override base frame type */
|
||||
else
|
||||
return base_type;
|
||||
}
|
||||
request = va_arg (args, MetaCoreGetType);
|
||||
}
|
||||
|
||||
GdkPixbuf*
|
||||
meta_core_get_mini_icon (Display *xdisplay,
|
||||
Window frame_xwindow)
|
||||
{
|
||||
MetaWindow *window = get_window (xdisplay, frame_xwindow);
|
||||
|
||||
return window->mini_icon;
|
||||
}
|
||||
|
||||
GdkPixbuf*
|
||||
meta_core_get_icon (Display *xdisplay,
|
||||
Window frame_xwindow)
|
||||
{
|
||||
MetaWindow *window = get_window (xdisplay, frame_xwindow);
|
||||
|
||||
return window->icon;
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
void
|
||||
@ -275,32 +306,6 @@ meta_core_user_focus (Display *xdisplay,
|
||||
meta_window_focus (window, timestamp);
|
||||
}
|
||||
|
||||
void
|
||||
meta_core_get_position (Display *xdisplay,
|
||||
Window frame_xwindow,
|
||||
int *x,
|
||||
int *y)
|
||||
{
|
||||
MetaWindow *window = get_window (xdisplay, frame_xwindow);
|
||||
|
||||
meta_window_get_position (window, x, y);
|
||||
}
|
||||
|
||||
void
|
||||
meta_core_get_size (Display *xdisplay,
|
||||
Window frame_xwindow,
|
||||
int *width,
|
||||
int *height)
|
||||
{
|
||||
MetaWindow *window = get_window (xdisplay, frame_xwindow);
|
||||
|
||||
if (width)
|
||||
*width = window->rect.width;
|
||||
if (height)
|
||||
*height = window->rect.height;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
meta_core_minimize (Display *xdisplay,
|
||||
Window frame_xwindow)
|
||||
@ -451,36 +456,6 @@ meta_core_get_active_workspace (Screen *xscreen)
|
||||
return meta_workspace_index (screen->active_workspace);
|
||||
}
|
||||
|
||||
int
|
||||
meta_core_get_frame_workspace (Display *xdisplay,
|
||||
Window frame_xwindow)
|
||||
{
|
||||
MetaWindow *window = get_window (xdisplay, frame_xwindow);
|
||||
|
||||
return meta_window_get_net_wm_desktop (window);
|
||||
}
|
||||
|
||||
void
|
||||
meta_core_get_frame_extents (Display *xdisplay,
|
||||
Window frame_xwindow,
|
||||
int *x,
|
||||
int *y,
|
||||
int *width,
|
||||
int *height)
|
||||
{
|
||||
MetaWindow *window = get_window (xdisplay, frame_xwindow);
|
||||
|
||||
if (x)
|
||||
*x = window->frame->rect.x;
|
||||
if (y)
|
||||
*y = window->frame->rect.y;
|
||||
if (width)
|
||||
*width = window->frame->rect.width;
|
||||
if (height)
|
||||
*height = window->frame->rect.height;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
meta_core_show_window_menu (Display *xdisplay,
|
||||
Window frame_xwindow,
|
||||
@ -730,20 +705,6 @@ meta_core_set_screen_cursor (Display *xdisplay,
|
||||
meta_frame_set_screen_cursor (window->frame, cursor);
|
||||
}
|
||||
|
||||
void
|
||||
meta_core_get_screen_size (Display *xdisplay,
|
||||
Window frame_on_screen,
|
||||
int *width,
|
||||
int *height)
|
||||
{
|
||||
MetaWindow *window = get_window (xdisplay, frame_on_screen);
|
||||
|
||||
if (width)
|
||||
*width = window->screen->rect.width;
|
||||
if (height)
|
||||
*height = window->screen->rect.height;
|
||||
}
|
||||
|
||||
void
|
||||
meta_core_increment_event_serial (Display *xdisplay)
|
||||
{
|
||||
|
108
src/core.h
108
src/core.h
@ -29,30 +29,68 @@
|
||||
#include <gdk/gdkx.h>
|
||||
#include "common.h"
|
||||
|
||||
void meta_core_get_client_size (Display *xdisplay,
|
||||
Window frame_xwindow,
|
||||
int *width,
|
||||
int *height);
|
||||
typedef enum
|
||||
{
|
||||
META_CORE_GET_END = 0,
|
||||
META_CORE_WINDOW_HAS_FRAME,
|
||||
META_CORE_GET_CLIENT_WIDTH,
|
||||
META_CORE_GET_CLIENT_HEIGHT,
|
||||
META_CORE_IS_TITLEBAR_ONSCREEN,
|
||||
META_CORE_GET_CLIENT_XWINDOW,
|
||||
META_CORE_GET_FRAME_FLAGS,
|
||||
META_CORE_GET_FRAME_TYPE,
|
||||
META_CORE_GET_MINI_ICON,
|
||||
META_CORE_GET_ICON,
|
||||
META_CORE_GET_X,
|
||||
META_CORE_GET_Y,
|
||||
META_CORE_GET_FRAME_WORKSPACE,
|
||||
META_CORE_GET_FRAME_X,
|
||||
META_CORE_GET_FRAME_Y,
|
||||
META_CORE_GET_FRAME_WIDTH,
|
||||
META_CORE_GET_FRAME_HEIGHT,
|
||||
META_CORE_GET_SCREEN_WIDTH,
|
||||
META_CORE_GET_SCREEN_HEIGHT,
|
||||
} MetaCoreGetType;
|
||||
|
||||
gboolean meta_core_titlebar_is_onscreen (Display *xdisplay,
|
||||
Window frame_xwindow);
|
||||
|
||||
gboolean meta_core_window_has_frame (Display *xdisplay,
|
||||
Window frame_xwindow);
|
||||
|
||||
|
||||
Window meta_core_get_client_xwindow (Display *xdisplay,
|
||||
Window frame_xwindow);
|
||||
|
||||
MetaFrameFlags meta_core_get_frame_flags (Display *xdisplay,
|
||||
Window frame_xwindow);
|
||||
MetaFrameType meta_core_get_frame_type (Display *xdisplay,
|
||||
Window frame_xwindow);
|
||||
|
||||
GdkPixbuf* meta_core_get_mini_icon (Display *xdisplay,
|
||||
Window frame_xwindow);
|
||||
GdkPixbuf* meta_core_get_icon (Display *xdisplay,
|
||||
Window frame_xwindow);
|
||||
/* 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_X, &x,
|
||||
* META_CORE_GET_Y, &y,
|
||||
* 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);
|
||||
@ -78,17 +116,6 @@ void meta_core_user_focus (Display *xdisplay,
|
||||
Window frame_xwindow,
|
||||
guint32 timestamp);
|
||||
|
||||
/* get position of client, same coord space expected by move */
|
||||
void meta_core_get_position (Display *xdisplay,
|
||||
Window frame_xwindow,
|
||||
int *x,
|
||||
int *y);
|
||||
|
||||
void meta_core_get_size (Display *xdisplay,
|
||||
Window frame_xwindow,
|
||||
int *width,
|
||||
int *height);
|
||||
|
||||
void meta_core_minimize (Display *xdisplay,
|
||||
Window frame_xwindow);
|
||||
void meta_core_toggle_maximize (Display *xdisplay,
|
||||
@ -126,14 +153,6 @@ const char* meta_core_get_workspace_name_with_index (Display *xdisplay,
|
||||
Window xroot,
|
||||
int index);
|
||||
|
||||
void meta_core_get_frame_extents (Display *xdisplay,
|
||||
Window frame_xwindow,
|
||||
int *x,
|
||||
int *y,
|
||||
int *width,
|
||||
int *height);
|
||||
|
||||
|
||||
void meta_core_show_window_menu (Display *xdisplay,
|
||||
Window frame_xwindow,
|
||||
int root_x,
|
||||
@ -170,11 +189,6 @@ void meta_core_set_screen_cursor (Display *xdisplay,
|
||||
Window frame_on_screen,
|
||||
MetaCursor cursor);
|
||||
|
||||
void meta_core_get_screen_size (Display *xdisplay,
|
||||
Window frame_on_screen,
|
||||
int *width,
|
||||
int *height);
|
||||
|
||||
/* Used because we ignore EnterNotify when a window is unmapped that
|
||||
* really shouldn't cause focus changes, by comparing the event serial
|
||||
* of the EnterNotify and the UnmapNotify.
|
||||
|
222
src/frames.c
222
src/frames.c
@ -73,8 +73,8 @@ static void meta_frames_paint_to_drawable (MetaFrames *frames,
|
||||
MetaUIFrame *frame,
|
||||
GdkDrawable *drawable,
|
||||
GdkRegion *region,
|
||||
int x_offset,
|
||||
int y_offset);
|
||||
int x_offset,
|
||||
int y_offset);
|
||||
|
||||
static void meta_frames_set_window_background (MetaFrames *frames,
|
||||
MetaUIFrame *frame);
|
||||
@ -102,7 +102,7 @@ static MetaFrameControl get_control (MetaFrames *frames,
|
||||
static void clear_tip (MetaFrames *frames);
|
||||
static void invalidate_all_caches (MetaFrames *frames);
|
||||
static void invalidate_whole_window (MetaFrames *frames,
|
||||
MetaUIFrame *frame);
|
||||
MetaUIFrame *frame);
|
||||
|
||||
static GtkWidgetClass *parent_class = NULL;
|
||||
|
||||
@ -115,12 +115,12 @@ meta_frames_get_type (void)
|
||||
{
|
||||
static const GtkTypeInfo frames_info =
|
||||
{
|
||||
"MetaFrames",
|
||||
sizeof (MetaFrames),
|
||||
sizeof (MetaFramesClass),
|
||||
(GtkClassInitFunc) meta_frames_class_init,
|
||||
(GtkObjectInitFunc) meta_frames_init,
|
||||
/* reserved_1 */ NULL,
|
||||
"MetaFrames",
|
||||
sizeof (MetaFrames),
|
||||
sizeof (MetaFramesClass),
|
||||
(GtkClassInitFunc) meta_frames_class_init,
|
||||
(GtkObjectInitFunc) meta_frames_init,
|
||||
/* reserved_1 */ NULL,
|
||||
/* reserved_2 */ NULL,
|
||||
(GtkClassInitFunc) NULL,
|
||||
};
|
||||
@ -295,7 +295,7 @@ typedef struct
|
||||
|
||||
static CachedPixels *
|
||||
get_cache (MetaFrames *frames,
|
||||
MetaUIFrame *frame)
|
||||
MetaUIFrame *frame)
|
||||
{
|
||||
CachedPixels *pixels;
|
||||
|
||||
@ -312,7 +312,7 @@ get_cache (MetaFrames *frames,
|
||||
|
||||
static void
|
||||
invalidate_cache (MetaFrames *frames,
|
||||
MetaUIFrame *frame)
|
||||
MetaUIFrame *frame)
|
||||
{
|
||||
CachedPixels *pixels = get_cache (frames, frame);
|
||||
int i;
|
||||
@ -447,8 +447,10 @@ meta_frames_ensure_layout (MetaFrames *frames,
|
||||
|
||||
widget = GTK_WIDGET (frames);
|
||||
|
||||
flags = meta_core_get_frame_flags (gdk_display, frame->xwindow);
|
||||
type = meta_core_get_frame_type (gdk_display, frame->xwindow);
|
||||
meta_core_get (gdk_display, frame->xwindow,
|
||||
META_CORE_GET_FRAME_FLAGS, &flags,
|
||||
META_CORE_GET_FRAME_TYPE, &type,
|
||||
META_CORE_GET_END);
|
||||
|
||||
style = meta_theme_get_frame_style (meta_theme_get_current (),
|
||||
type, flags);
|
||||
@ -485,7 +487,7 @@ meta_frames_ensure_layout (MetaFrames *frames,
|
||||
pango_layout_set_auto_dir (frame->layout, FALSE);
|
||||
|
||||
font_desc = meta_gtk_widget_get_font_desc (widget, scale,
|
||||
meta_prefs_get_titlebar_font ());
|
||||
meta_prefs_get_titlebar_font ());
|
||||
|
||||
size = pango_font_description_get_size (font_desc);
|
||||
|
||||
@ -507,7 +509,7 @@ meta_frames_ensure_layout (MetaFrames *frames,
|
||||
}
|
||||
|
||||
pango_layout_set_font_description (frame->layout,
|
||||
font_desc);
|
||||
font_desc);
|
||||
|
||||
pango_font_description_free (font_desc);
|
||||
|
||||
@ -527,11 +529,12 @@ meta_frames_calc_geometry (MetaFrames *frames,
|
||||
MetaFrameType type;
|
||||
MetaButtonLayout button_layout;
|
||||
|
||||
meta_core_get_client_size (gdk_display, frame->xwindow,
|
||||
&width, &height);
|
||||
|
||||
flags = meta_core_get_frame_flags (gdk_display, frame->xwindow);
|
||||
type = meta_core_get_frame_type (gdk_display, frame->xwindow);
|
||||
meta_core_get (gdk_display, frame->xwindow,
|
||||
META_CORE_GET_CLIENT_WIDTH, &width,
|
||||
META_CORE_GET_CLIENT_HEIGHT, &height,
|
||||
META_CORE_GET_FRAME_FLAGS, &flags,
|
||||
META_CORE_GET_FRAME_TYPE, &type,
|
||||
META_CORE_GET_END);
|
||||
|
||||
meta_frames_ensure_layout (frames, frame);
|
||||
|
||||
@ -552,17 +555,17 @@ meta_frames_new (int screen_number)
|
||||
GdkScreen *screen;
|
||||
|
||||
screen = gdk_display_get_screen (gdk_display_get_default (),
|
||||
screen_number);
|
||||
screen_number);
|
||||
|
||||
return g_object_new (META_TYPE_FRAMES,
|
||||
"screen", screen,
|
||||
NULL);
|
||||
"screen", screen,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void
|
||||
meta_frames_manage_window (MetaFrames *frames,
|
||||
Window xwindow,
|
||||
GdkWindow *window)
|
||||
GdkWindow *window)
|
||||
{
|
||||
MetaUIFrame *frame;
|
||||
|
||||
@ -614,8 +617,8 @@ meta_frames_unmanage_window (MetaFrames *frames,
|
||||
|
||||
/* restore the cursor */
|
||||
meta_core_set_screen_cursor (gdk_display,
|
||||
frame->xwindow,
|
||||
META_CURSOR_DEFAULT);
|
||||
frame->xwindow,
|
||||
META_CURSOR_DEFAULT);
|
||||
|
||||
gdk_window_set_user_data (frame->window, NULL);
|
||||
|
||||
@ -678,8 +681,10 @@ meta_frames_get_geometry (MetaFrames *frames,
|
||||
if (frame == NULL)
|
||||
meta_bug ("No such frame 0x%lx\n", xwindow);
|
||||
|
||||
flags = meta_core_get_frame_flags (gdk_display, frame->xwindow);
|
||||
type = meta_core_get_frame_type (gdk_display, frame->xwindow);
|
||||
meta_core_get (gdk_display, frame->xwindow,
|
||||
META_CORE_GET_FRAME_FLAGS, &flags,
|
||||
META_CORE_GET_FRAME_TYPE, &type,
|
||||
META_CORE_GET_END);
|
||||
|
||||
g_return_if_fail (type < META_FRAME_TYPE_LAST);
|
||||
|
||||
@ -914,8 +919,9 @@ meta_frames_apply_shapes (MetaFrames *frames,
|
||||
&attrs);
|
||||
|
||||
/* Copy the client's shape to the temporary shape_window */
|
||||
client_window = meta_core_get_client_xwindow (gdk_display,
|
||||
frame->xwindow);
|
||||
meta_core_get (gdk_display, frame->xwindow,
|
||||
META_CORE_GET_CLIENT_XWINDOW, &client_window,
|
||||
META_CORE_GET_END);
|
||||
|
||||
XShapeCombineShape (gdk_display, shape_window, ShapeBounding,
|
||||
fgeom.left_width,
|
||||
@ -972,11 +978,11 @@ meta_frames_apply_shapes (MetaFrames *frames,
|
||||
|
||||
void
|
||||
meta_frames_move_resize_frame (MetaFrames *frames,
|
||||
Window xwindow,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height)
|
||||
Window xwindow,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
MetaUIFrame *frame = meta_frames_lookup_window (frames, xwindow);
|
||||
int old_x, old_y, old_width, old_height;
|
||||
@ -1145,7 +1151,7 @@ show_tip_now (MetaFrames *frames)
|
||||
screen_number = gdk_screen_get_number (gtk_widget_get_screen (GTK_WIDGET (frames)));
|
||||
|
||||
meta_fixed_tip_show (gdk_display,
|
||||
screen_number,
|
||||
screen_number,
|
||||
rect->x + dx,
|
||||
rect->y + rect->height + 2 + dy,
|
||||
tiptext);
|
||||
@ -1213,7 +1219,9 @@ meta_frame_titlebar_event (MetaUIFrame *frame,
|
||||
{
|
||||
case META_ACTION_TITLEBAR_TOGGLE_SHADE:
|
||||
{
|
||||
flags = meta_core_get_frame_flags (gdk_display, frame->xwindow);
|
||||
meta_core_get (gdk_display, frame->xwindow,
|
||||
META_CORE_GET_FRAME_FLAGS, &flags,
|
||||
META_CORE_GET_END);
|
||||
|
||||
if (flags & META_FRAME_ALLOWS_SHADE)
|
||||
{
|
||||
@ -1231,7 +1239,9 @@ meta_frame_titlebar_event (MetaUIFrame *frame,
|
||||
|
||||
case META_ACTION_TITLEBAR_TOGGLE_MAXIMIZE:
|
||||
{
|
||||
flags = meta_core_get_frame_flags (gdk_display, frame->xwindow);
|
||||
meta_core_get (gdk_display, frame->xwindow,
|
||||
META_CORE_GET_FRAME_FLAGS, &flags,
|
||||
META_CORE_GET_END);
|
||||
|
||||
if (flags & META_FRAME_ALLOWS_MAXIMIZE)
|
||||
{
|
||||
@ -1242,7 +1252,9 @@ meta_frame_titlebar_event (MetaUIFrame *frame,
|
||||
|
||||
case META_ACTION_TITLEBAR_MINIMIZE:
|
||||
{
|
||||
flags = meta_core_get_frame_flags (gdk_display, frame->xwindow);
|
||||
meta_core_get (gdk_display, frame->xwindow,
|
||||
META_CORE_GET_FRAME_FLAGS, &flags,
|
||||
META_CORE_GET_END);
|
||||
|
||||
if (flags & META_FRAME_ALLOWS_MINIMIZE)
|
||||
{
|
||||
@ -1440,9 +1452,9 @@ meta_frames_button_press_event (GtkWidget *widget,
|
||||
dx = event->x_root - event->x;
|
||||
dy = event->y_root - event->y;
|
||||
|
||||
/* Align to the right end of the menu rectangle if RTL */
|
||||
if (meta_ui_get_direction() == META_UI_DIRECTION_RTL)
|
||||
dx += rect->width;
|
||||
/* Align to the right end of the menu rectangle if RTL */
|
||||
if (meta_ui_get_direction() == META_UI_DIRECTION_RTL)
|
||||
dx += rect->width;
|
||||
|
||||
meta_core_show_window_menu (gdk_display,
|
||||
frame->xwindow,
|
||||
@ -1463,6 +1475,7 @@ meta_frames_button_press_event (GtkWidget *widget,
|
||||
control == META_FRAME_CONTROL_RESIZE_W))
|
||||
{
|
||||
MetaGrabOp op;
|
||||
gboolean titlebar_is_onscreen;
|
||||
|
||||
op = META_GRAB_OP_NONE;
|
||||
|
||||
@ -1497,8 +1510,11 @@ meta_frames_button_press_event (GtkWidget *widget,
|
||||
break;
|
||||
}
|
||||
|
||||
if (!meta_core_titlebar_is_onscreen (gdk_display,
|
||||
frame->xwindow))
|
||||
meta_core_get (gdk_display, frame->xwindow,
|
||||
META_CORE_IS_TITLEBAR_ONSCREEN, &titlebar_is_onscreen,
|
||||
META_CORE_GET_END);
|
||||
|
||||
if (!titlebar_is_onscreen)
|
||||
meta_core_show_window_menu (gdk_display,
|
||||
frame->xwindow,
|
||||
event->x_root,
|
||||
@ -1521,9 +1537,11 @@ meta_frames_button_press_event (GtkWidget *widget,
|
||||
event->button == 1)
|
||||
{
|
||||
MetaFrameFlags flags;
|
||||
|
||||
flags = meta_core_get_frame_flags (gdk_display, frame->xwindow);
|
||||
|
||||
|
||||
meta_core_get (gdk_display, frame->xwindow,
|
||||
META_CORE_GET_FRAME_FLAGS, &flags,
|
||||
META_CORE_GET_END);
|
||||
|
||||
if (flags & META_FRAME_ALLOWS_MOVE)
|
||||
{
|
||||
meta_core_begin_grab_op (gdk_display,
|
||||
@ -1701,8 +1719,8 @@ meta_frames_button_release_event (GtkWidget *widget,
|
||||
|
||||
static void
|
||||
meta_frames_update_prelit_control (MetaFrames *frames,
|
||||
MetaUIFrame *frame,
|
||||
MetaFrameControl control)
|
||||
MetaUIFrame *frame,
|
||||
MetaFrameControl control)
|
||||
{
|
||||
MetaFrameControl old_control;
|
||||
MetaCursor cursor;
|
||||
@ -1875,7 +1893,7 @@ meta_frames_motion_notify_event (GtkWidget *widget,
|
||||
control = META_FRAME_CONTROL_NONE;
|
||||
|
||||
/* Update prelit control and cursor */
|
||||
meta_frames_update_prelit_control (frames, frame, control);
|
||||
meta_frames_update_prelit_control (frames, frame, control);
|
||||
|
||||
/* No tooltip while in the process of clicking */
|
||||
}
|
||||
@ -1890,7 +1908,7 @@ meta_frames_motion_notify_event (GtkWidget *widget,
|
||||
control = get_control (frames, frame, x, y);
|
||||
|
||||
/* Update prelit control and cursor */
|
||||
meta_frames_update_prelit_control (frames, frame, control);
|
||||
meta_frames_update_prelit_control (frames, frame, control);
|
||||
|
||||
queue_tip (frames);
|
||||
}
|
||||
@ -1930,8 +1948,8 @@ get_bg_gc (GdkWindow *window, int x_offset, int y_offset)
|
||||
if (private->bg_pixmap == GDK_PARENT_RELATIVE_BG && private->parent)
|
||||
{
|
||||
return get_bg_gc (GDK_WINDOW (private->parent),
|
||||
x_offset + private->x,
|
||||
y_offset + private->y);
|
||||
x_offset + private->x,
|
||||
y_offset + private->y);
|
||||
}
|
||||
else if (private->bg_pixmap &&
|
||||
private->bg_pixmap != GDK_PARENT_RELATIVE_BG &&
|
||||
@ -1958,13 +1976,13 @@ get_bg_gc (GdkWindow *window, int x_offset, int y_offset)
|
||||
|
||||
static void
|
||||
clear_backing (GdkPixmap *pixmap,
|
||||
GdkWindow *window,
|
||||
int xoffset, int yoffset)
|
||||
GdkWindow *window,
|
||||
int xoffset, int yoffset)
|
||||
{
|
||||
GdkGC *tmp_gc = get_bg_gc (window, xoffset, yoffset);
|
||||
|
||||
gdk_draw_rectangle (pixmap, tmp_gc, TRUE,
|
||||
0, 0, -1, -1);
|
||||
0, 0, -1, -1);
|
||||
|
||||
g_object_unref (tmp_gc);
|
||||
}
|
||||
@ -1974,7 +1992,7 @@ clear_backing (GdkPixmap *pixmap,
|
||||
|
||||
static GdkPixmap *
|
||||
generate_pixmap (MetaFrames *frames,
|
||||
MetaUIFrame *frame,
|
||||
MetaUIFrame *frame,
|
||||
MetaRectangle rect)
|
||||
{
|
||||
GdkRectangle rectangle;
|
||||
@ -1994,7 +2012,7 @@ generate_pixmap (MetaFrames *frames,
|
||||
region = gdk_region_rectangle (&rectangle);
|
||||
|
||||
meta_frames_paint_to_drawable (frames, frame, result, region,
|
||||
- rectangle.x, - rectangle.y);
|
||||
-rectangle.x, -rectangle.y);
|
||||
|
||||
gdk_region_destroy (region);
|
||||
|
||||
@ -2004,22 +2022,26 @@ generate_pixmap (MetaFrames *frames,
|
||||
|
||||
static void
|
||||
populate_cache (MetaFrames *frames,
|
||||
MetaUIFrame *frame)
|
||||
MetaUIFrame *frame)
|
||||
{
|
||||
int top, bottom, left, right;
|
||||
int width, height;
|
||||
int frame_width, frame_height, screen_width, screen_height;
|
||||
CachedPixels *pixels;
|
||||
MetaFrameType frame_type;
|
||||
MetaFrameFlags frame_flags;
|
||||
int i;
|
||||
|
||||
meta_core_get_frame_extents (gdk_display,
|
||||
frame->xwindow,
|
||||
NULL, NULL,
|
||||
&frame_width, &frame_height);
|
||||
|
||||
meta_core_get_screen_size (gdk_display,
|
||||
frame->xwindow,
|
||||
&screen_width, &screen_height);
|
||||
meta_core_get (gdk_display, frame->xwindow,
|
||||
META_CORE_GET_FRAME_WIDTH, &frame_width,
|
||||
META_CORE_GET_FRAME_HEIGHT, &frame_height,
|
||||
META_CORE_GET_SCREEN_WIDTH, &screen_width,
|
||||
META_CORE_GET_SCREEN_HEIGHT, &screen_height,
|
||||
META_CORE_GET_CLIENT_WIDTH, &width,
|
||||
META_CORE_GET_CLIENT_HEIGHT, &height,
|
||||
META_CORE_GET_FRAME_TYPE, &frame_type,
|
||||
META_CORE_GET_FRAME_FLAGS, &frame_flags,
|
||||
META_CORE_GET_END);
|
||||
|
||||
/* don't cache extremely large windows */
|
||||
if (frame_width > 2 * screen_width ||
|
||||
@ -2029,13 +2051,11 @@ populate_cache (MetaFrames *frames,
|
||||
}
|
||||
|
||||
meta_theme_get_frame_borders (meta_theme_get_current (),
|
||||
meta_core_get_frame_type (gdk_display, frame->xwindow),
|
||||
frame->text_height,
|
||||
meta_core_get_frame_flags (gdk_display, frame->xwindow),
|
||||
frame_type,
|
||||
frame->text_height,
|
||||
frame_flags,
|
||||
&top, &bottom, &left, &right);
|
||||
|
||||
meta_core_get_client_size (gdk_display, frame->xwindow, &width, &height);
|
||||
|
||||
pixels = get_cache (frames, frame);
|
||||
|
||||
/* Setup the rectangles for the four frame borders. First top, then
|
||||
@ -2088,14 +2108,14 @@ clip_to_screen (GdkRegion *region, MetaUIFrame *frame)
|
||||
* is crucial to handle huge client windows,
|
||||
* like "xterm -geometry 1000x1000"
|
||||
*/
|
||||
meta_core_get_frame_extents (gdk_display,
|
||||
frame->xwindow,
|
||||
&frame_area.x, &frame_area.y,
|
||||
&frame_area.width, &frame_area.height);
|
||||
|
||||
meta_core_get_screen_size (gdk_display,
|
||||
frame->xwindow,
|
||||
&screen_area.width, &screen_area.height);
|
||||
meta_core_get (gdk_display, frame->xwindow,
|
||||
META_CORE_GET_FRAME_X, &frame_area.x,
|
||||
META_CORE_GET_FRAME_Y, &frame_area.y,
|
||||
META_CORE_GET_FRAME_WIDTH, &frame_area.width,
|
||||
META_CORE_GET_FRAME_HEIGHT, &frame_area.height,
|
||||
META_CORE_GET_SCREEN_WIDTH, &screen_area.height,
|
||||
META_CORE_GET_SCREEN_HEIGHT, &screen_area.height,
|
||||
META_CORE_GET_END);
|
||||
|
||||
gdk_region_offset (region, frame_area.x, frame_area.y);
|
||||
|
||||
@ -2108,7 +2128,7 @@ clip_to_screen (GdkRegion *region, MetaUIFrame *frame)
|
||||
|
||||
static void
|
||||
subtract_from_region (GdkRegion *region, GdkDrawable *drawable,
|
||||
gint x, gint y)
|
||||
gint x, gint y)
|
||||
{
|
||||
GdkRectangle rect;
|
||||
GdkRegion *reg_rect;
|
||||
@ -2199,8 +2219,8 @@ meta_frames_paint_to_drawable (MetaFrames *frames,
|
||||
MetaUIFrame *frame,
|
||||
GdkDrawable *drawable,
|
||||
GdkRegion *region,
|
||||
int x_offset,
|
||||
int y_offset)
|
||||
int x_offset,
|
||||
int y_offset)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
MetaFrameFlags flags;
|
||||
@ -2311,13 +2331,14 @@ meta_frames_paint_to_drawable (MetaFrames *frames,
|
||||
button_states[META_BUTTON_TYPE_RIGHT_RIGHT_BACKGROUND] =
|
||||
button_states[META_BUTTON_TYPE_CLOSE];
|
||||
|
||||
flags = meta_core_get_frame_flags (gdk_display, frame->xwindow);
|
||||
type = meta_core_get_frame_type (gdk_display, frame->xwindow);
|
||||
mini_icon = meta_core_get_mini_icon (gdk_display, frame->xwindow);
|
||||
icon = meta_core_get_icon (gdk_display, frame->xwindow);
|
||||
|
||||
meta_core_get_client_size (gdk_display, frame->xwindow,
|
||||
&w, &h);
|
||||
meta_core_get (gdk_display, frame->xwindow,
|
||||
META_CORE_GET_FRAME_FLAGS, &flags,
|
||||
META_CORE_GET_FRAME_TYPE, &type,
|
||||
META_CORE_GET_MINI_ICON, &mini_icon,
|
||||
META_CORE_GET_ICON, &icon,
|
||||
META_CORE_GET_CLIENT_WIDTH, &w,
|
||||
META_CORE_GET_CLIENT_HEIGHT, &h,
|
||||
META_CORE_GET_END);
|
||||
|
||||
meta_frames_ensure_layout (frames, frame);
|
||||
|
||||
@ -2339,9 +2360,10 @@ meta_frames_paint_to_drawable (MetaFrames *frames,
|
||||
type, frame->text_height, flags,
|
||||
&top, &bottom, &left, &right);
|
||||
|
||||
meta_core_get_screen_size (gdk_display,
|
||||
frame->xwindow,
|
||||
&screen_width, &screen_height);
|
||||
meta_core_get (gdk_display, frame->xwindow,
|
||||
META_CORE_GET_SCREEN_WIDTH, &screen_width,
|
||||
META_CORE_GET_SCREEN_HEIGHT, &screen_height,
|
||||
META_CORE_GET_END);
|
||||
|
||||
edges = gdk_region_copy (region);
|
||||
|
||||
@ -2432,12 +2454,14 @@ meta_frames_set_window_background (MetaFrames *frames,
|
||||
MetaFrameStyle *style;
|
||||
gboolean frame_exists;
|
||||
|
||||
frame_exists = meta_core_window_has_frame (gdk_display, frame->xwindow);
|
||||
meta_core_get (gdk_display, frame->xwindow,
|
||||
META_CORE_WINDOW_HAS_FRAME, &frame_exists,
|
||||
META_CORE_GET_FRAME_FLAGS, &flags,
|
||||
META_CORE_GET_FRAME_TYPE, &type,
|
||||
META_CORE_GET_END);
|
||||
|
||||
if (frame_exists)
|
||||
{
|
||||
flags = meta_core_get_frame_flags (gdk_display, frame->xwindow);
|
||||
type = meta_core_get_frame_type (gdk_display, frame->xwindow);
|
||||
style = meta_theme_get_frame_style (meta_theme_get_current (),
|
||||
type, flags);
|
||||
}
|
||||
@ -2613,7 +2637,9 @@ get_control (MetaFrames *frames,
|
||||
if (POINT_IN_RECT (x, y, fgeom.menu_rect.clickable))
|
||||
return META_FRAME_CONTROL_MENU;
|
||||
|
||||
flags = meta_core_get_frame_flags (gdk_display, frame->xwindow);
|
||||
meta_core_get (gdk_display, frame->xwindow,
|
||||
META_CORE_GET_FRAME_FLAGS, &flags,
|
||||
META_CORE_GET_END);
|
||||
|
||||
has_vert = (flags & META_FRAME_ALLOWS_VERTICAL_RESIZE) != 0;
|
||||
has_horiz = (flags & META_FRAME_ALLOWS_HORIZONTAL_RESIZE) != 0;
|
||||
@ -2783,7 +2809,7 @@ meta_frames_pop_delay_exposes (MetaFrames *frames)
|
||||
|
||||
static void
|
||||
invalidate_whole_window (MetaFrames *frames,
|
||||
MetaUIFrame *frame)
|
||||
MetaUIFrame *frame)
|
||||
{
|
||||
gdk_window_invalidate_rect (frame->window, NULL, FALSE);
|
||||
invalidate_cache (frames, frame);
|
||||
|
Loading…
Reference in New Issue
Block a user