mirror of
https://github.com/brl/mutter.git
synced 2025-08-04 07:34:53 +00:00
Replace public MetaFrameGeometry with MetaFrameBorders
There were actually *two* MetaFrameGeometry structs: one in theme-private.h, one in frame.h. The latter public struct was populated by a mix of (void*) casting and int pointers, usually pulling directly from the data in the private struct. Remove the public struct, replace it with MetaFrameBorders and scrap all the pointer hacks to populate it, instead relying on both structs being used in common code. This commit should be relatively straightforward, and it should not do any tricky logic at all, just a sophisticated find and replace. https://bugzilla.gnome.org/show_bug.cgi?id=644930
This commit is contained in:
@@ -790,10 +790,9 @@ meta_frames_lookup_window (MetaFrames *frames,
|
||||
}
|
||||
|
||||
void
|
||||
meta_frames_get_geometry (MetaFrames *frames,
|
||||
Window xwindow,
|
||||
int *top_height, int *bottom_height,
|
||||
int *left_width, int *right_width)
|
||||
meta_frames_get_borders (MetaFrames *frames,
|
||||
Window xwindow,
|
||||
MetaFrameBorders *borders)
|
||||
{
|
||||
MetaFrameFlags flags;
|
||||
MetaUIFrame *frame;
|
||||
@@ -822,8 +821,7 @@ meta_frames_get_geometry (MetaFrames *frames,
|
||||
type,
|
||||
frame->text_height,
|
||||
flags,
|
||||
top_height, bottom_height,
|
||||
left_width, right_width);
|
||||
borders);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2051,6 +2049,7 @@ populate_cache (MetaFrames *frames,
|
||||
MetaUIFrame *frame)
|
||||
{
|
||||
int top, bottom, left, right;
|
||||
MetaFrameBorders borders;
|
||||
int width, height;
|
||||
int frame_width, frame_height, screen_width, screen_height;
|
||||
CachedPixels *pixels;
|
||||
@@ -2081,7 +2080,12 @@ populate_cache (MetaFrames *frames,
|
||||
frame_type,
|
||||
frame->text_height,
|
||||
frame_flags,
|
||||
&top, &bottom, &left, &right);
|
||||
&borders);
|
||||
|
||||
top = borders.visible.top;
|
||||
left = borders.visible.left;
|
||||
right = borders.visible.right;
|
||||
bottom = borders.visible.bottom;
|
||||
|
||||
pixels = get_cache (frames, frame);
|
||||
|
||||
@@ -2168,6 +2172,7 @@ subtract_client_area (cairo_region_t *region,
|
||||
cairo_rectangle_int_t area;
|
||||
MetaFrameFlags flags;
|
||||
MetaFrameType type;
|
||||
MetaFrameBorders borders;
|
||||
cairo_region_t *tmp_region;
|
||||
Display *display;
|
||||
|
||||
@@ -2180,8 +2185,11 @@ subtract_client_area (cairo_region_t *region,
|
||||
META_CORE_GET_CLIENT_HEIGHT, &area.height,
|
||||
META_CORE_GET_END);
|
||||
meta_theme_get_frame_borders (meta_theme_get_current (),
|
||||
type, frame->text_height, flags,
|
||||
&area.y, NULL, &area.x, NULL);
|
||||
type, frame->text_height, flags,
|
||||
&borders);
|
||||
|
||||
area.x = borders.visible.left;
|
||||
area.y = borders.visible.top;
|
||||
|
||||
tmp_region = cairo_region_create_rectangle (&area);
|
||||
cairo_region_subtract (region, tmp_region);
|
||||
|
@@ -133,10 +133,9 @@ void meta_frames_update_frame_style (MetaFrames *frames,
|
||||
void meta_frames_repaint_frame (MetaFrames *frames,
|
||||
Window xwindow);
|
||||
|
||||
void meta_frames_get_geometry (MetaFrames *frames,
|
||||
Window xwindow,
|
||||
int *top_height, int *bottom_height,
|
||||
int *left_width, int *right_width);
|
||||
void meta_frames_get_borders (MetaFrames *frames,
|
||||
Window xwindow,
|
||||
MetaFrameBorders *borders);
|
||||
|
||||
void meta_frames_reset_bg (MetaFrames *frames,
|
||||
Window xwindow);
|
||||
|
@@ -94,10 +94,10 @@ meta_preview_init (MetaPreview *preview)
|
||||
META_FRAME_ALLOWS_SHADE |
|
||||
META_FRAME_ALLOWS_MOVE;
|
||||
|
||||
preview->left_width = -1;
|
||||
preview->right_width = -1;
|
||||
preview->top_height = -1;
|
||||
preview->bottom_height = -1;
|
||||
preview->borders.visible.left = -1;
|
||||
preview->borders.visible.right = -1;
|
||||
preview->borders.visible.top = -1;
|
||||
preview->borders.visible.bottom = -1;
|
||||
}
|
||||
|
||||
GtkWidget*
|
||||
@@ -168,7 +168,7 @@ ensure_info (MetaPreview *preview)
|
||||
pango_font_description_free (font_desc);
|
||||
}
|
||||
|
||||
if (preview->top_height < 0)
|
||||
if (preview->borders.visible.top < 0)
|
||||
{
|
||||
if (preview->theme)
|
||||
{
|
||||
@@ -176,17 +176,14 @@ ensure_info (MetaPreview *preview)
|
||||
preview->type,
|
||||
preview->text_height,
|
||||
preview->flags,
|
||||
&preview->top_height,
|
||||
&preview->bottom_height,
|
||||
&preview->left_width,
|
||||
&preview->right_width);
|
||||
&preview->borders);
|
||||
}
|
||||
else
|
||||
{
|
||||
preview->top_height = 0;
|
||||
preview->bottom_height = 0;
|
||||
preview->left_width = 0;
|
||||
preview->right_width = 0;
|
||||
preview->borders.visible.top = 0;
|
||||
preview->borders.visible.bottom = 0;
|
||||
preview->borders.visible.left = 0;
|
||||
preview->borders.visible.right = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -215,8 +212,8 @@ meta_preview_draw (GtkWidget *widget,
|
||||
ensure_info (preview);
|
||||
cairo_save (cr);
|
||||
|
||||
client_width = allocation.width - preview->left_width - preview->right_width;
|
||||
client_height = allocation.height - preview->top_height - preview->bottom_height;
|
||||
client_width = allocation.width - preview->borders.visible.left - preview->borders.visible.right;
|
||||
client_height = allocation.height - preview->borders.visible.top - preview->borders.visible.bottom;
|
||||
|
||||
if (client_width < 0)
|
||||
client_width = 1;
|
||||
@@ -258,7 +255,7 @@ meta_preview_get_preferred_width (GtkWidget *widget,
|
||||
|
||||
ensure_info (preview);
|
||||
|
||||
*minimum = *natural = preview->left_width + preview->right_width;
|
||||
*minimum = *natural = preview->borders.visible.left + preview->borders.visible.right;
|
||||
|
||||
child = gtk_bin_get_child (GTK_BIN (preview));
|
||||
if (child && gtk_widget_get_visible (child))
|
||||
@@ -289,7 +286,7 @@ meta_preview_get_preferred_height (GtkWidget *widget,
|
||||
|
||||
ensure_info (preview);
|
||||
|
||||
*minimum = *natural = preview->top_height + preview->bottom_height;
|
||||
*minimum = *natural = preview->borders.visible.top + preview->borders.visible.bottom;
|
||||
|
||||
child = gtk_bin_get_child (GTK_BIN (preview));
|
||||
if (child && gtk_widget_get_visible (child))
|
||||
@@ -326,11 +323,11 @@ meta_preview_size_allocate (GtkWidget *widget,
|
||||
if (child && gtk_widget_get_visible (child))
|
||||
{
|
||||
gtk_widget_get_allocation (widget, &widget_allocation);
|
||||
child_allocation.x = widget_allocation.x + preview->left_width;
|
||||
child_allocation.y = widget_allocation.y + preview->top_height;
|
||||
|
||||
child_allocation.width = MAX (1, widget_allocation.width - preview->left_width - preview->right_width);
|
||||
child_allocation.height = MAX (1, widget_allocation.height - preview->top_height - preview->bottom_height);
|
||||
child_allocation.x = widget_allocation.x + preview->borders.visible.left;
|
||||
child_allocation.y = widget_allocation.y + preview->borders.visible.top;
|
||||
|
||||
child_allocation.width = MAX (1, widget_allocation.width - preview->borders.visible.left - preview->borders.visible.right);
|
||||
child_allocation.height = MAX (1, widget_allocation.height - preview->borders.visible.top - preview->borders.visible.bottom);
|
||||
|
||||
gtk_widget_size_allocate (child, &child_allocation);
|
||||
}
|
||||
@@ -345,10 +342,10 @@ clear_cache (MetaPreview *preview)
|
||||
preview->layout = NULL;
|
||||
}
|
||||
|
||||
preview->left_width = -1;
|
||||
preview->right_width = -1;
|
||||
preview->top_height = -1;
|
||||
preview->bottom_height = -1;
|
||||
preview->borders.visible.left = -1;
|
||||
preview->borders.visible.right = -1;
|
||||
preview->borders.visible.top = -1;
|
||||
preview->borders.visible.bottom = -1;
|
||||
}
|
||||
|
||||
void
|
||||
|
@@ -928,10 +928,7 @@ void meta_frame_layout_unref (MetaFrameLayout *layout)
|
||||
void meta_frame_layout_get_borders (const MetaFrameLayout *layout,
|
||||
int text_height,
|
||||
MetaFrameFlags flags,
|
||||
int *top_height,
|
||||
int *bottom_height,
|
||||
int *left_width,
|
||||
int *right_width);
|
||||
MetaFrameBorders *borders);
|
||||
void meta_frame_layout_calc_geometry (const MetaFrameLayout *layout,
|
||||
int text_height,
|
||||
MetaFrameFlags flags,
|
||||
@@ -1124,10 +1121,8 @@ void meta_theme_get_frame_borders (MetaTheme *theme,
|
||||
MetaFrameType type,
|
||||
int text_height,
|
||||
MetaFrameFlags flags,
|
||||
int *top_height,
|
||||
int *bottom_height,
|
||||
int *left_width,
|
||||
int *right_width);
|
||||
MetaFrameBorders *borders);
|
||||
|
||||
void meta_theme_calc_geometry (MetaTheme *theme,
|
||||
MetaFrameType type,
|
||||
int text_height,
|
||||
@@ -1136,7 +1131,7 @@ void meta_theme_calc_geometry (MetaTheme *theme,
|
||||
int client_height,
|
||||
const MetaButtonLayout *button_layout,
|
||||
MetaFrameGeometry *fgeom);
|
||||
|
||||
|
||||
MetaFrameLayout* meta_theme_lookup_layout (MetaTheme *theme,
|
||||
const char *name);
|
||||
void meta_theme_insert_layout (MetaTheme *theme,
|
||||
|
@@ -959,7 +959,7 @@ run_theme_benchmark (void)
|
||||
{
|
||||
GtkWidget* widget;
|
||||
cairo_surface_t *pixmap;
|
||||
int top_height, bottom_height, left_width, right_width;
|
||||
MetaFrameBorders borders;
|
||||
MetaButtonState button_states[META_BUTTON_TYPE_LAST] =
|
||||
{
|
||||
META_BUTTON_STATE_NORMAL,
|
||||
@@ -986,10 +986,7 @@ run_theme_benchmark (void)
|
||||
META_FRAME_TYPE_NORMAL,
|
||||
get_text_height (widget),
|
||||
get_flags (widget),
|
||||
&top_height,
|
||||
&bottom_height,
|
||||
&left_width,
|
||||
&right_width);
|
||||
&borders);
|
||||
|
||||
layout = create_title_layout (widget);
|
||||
|
||||
@@ -1024,8 +1021,8 @@ run_theme_benchmark (void)
|
||||
*/
|
||||
pixmap = gdk_window_create_similar_surface (gtk_widget_get_window (widget),
|
||||
CAIRO_CONTENT_COLOR,
|
||||
client_width + left_width + right_width,
|
||||
client_height + top_height + bottom_height);
|
||||
client_width + borders.visible.left + borders.visible.right,
|
||||
client_height + borders.visible.top + borders.visible.bottom);
|
||||
|
||||
cr = cairo_create (pixmap);
|
||||
|
||||
|
@@ -400,10 +400,7 @@ void
|
||||
meta_frame_layout_get_borders (const MetaFrameLayout *layout,
|
||||
int text_height,
|
||||
MetaFrameFlags flags,
|
||||
int *top_height,
|
||||
int *bottom_height,
|
||||
int *left_width,
|
||||
int *right_width)
|
||||
MetaFrameBorders *borders)
|
||||
{
|
||||
int buttons_height, title_height;
|
||||
|
||||
@@ -418,34 +415,20 @@ meta_frame_layout_get_borders (const MetaFrameLayout *layout,
|
||||
layout->title_vertical_pad +
|
||||
layout->title_border.top + layout->title_border.bottom;
|
||||
|
||||
if (top_height)
|
||||
{
|
||||
*top_height = MAX (buttons_height, title_height);
|
||||
}
|
||||
|
||||
if (left_width)
|
||||
*left_width = layout->left_width;
|
||||
if (right_width)
|
||||
*right_width = layout->right_width;
|
||||
|
||||
if (bottom_height)
|
||||
{
|
||||
if (flags & META_FRAME_SHADED)
|
||||
*bottom_height = 0;
|
||||
else
|
||||
*bottom_height = layout->bottom_height;
|
||||
}
|
||||
borders->visible.top = MAX (buttons_height, title_height);
|
||||
borders->visible.left = layout->left_width;
|
||||
borders->visible.right = layout->right_width;
|
||||
if (flags & META_FRAME_SHADED)
|
||||
borders->visible.bottom = 0;
|
||||
else
|
||||
borders->visible.bottom = layout->bottom_height;
|
||||
|
||||
if (flags & META_FRAME_FULLSCREEN)
|
||||
{
|
||||
if (top_height)
|
||||
*top_height = 0;
|
||||
if (bottom_height)
|
||||
*bottom_height = 0;
|
||||
if (left_width)
|
||||
*left_width = 0;
|
||||
if (right_width)
|
||||
*right_width = 0;
|
||||
borders->visible.top = 0;
|
||||
borders->visible.bottom = 0;
|
||||
borders->visible.left = 0;
|
||||
borders->visible.right = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -634,13 +617,18 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout *layout,
|
||||
gboolean left_buttons_has_spacer[MAX_BUTTONS_PER_CORNER];
|
||||
GdkRectangle *right_bg_rects[MAX_BUTTONS_PER_CORNER];
|
||||
gboolean right_buttons_has_spacer[MAX_BUTTONS_PER_CORNER];
|
||||
|
||||
MetaFrameBorders borders;
|
||||
|
||||
meta_frame_layout_get_borders (layout, text_height,
|
||||
flags,
|
||||
&fgeom->top_height,
|
||||
&fgeom->bottom_height,
|
||||
&fgeom->left_width,
|
||||
&fgeom->right_width);
|
||||
&borders);
|
||||
|
||||
|
||||
fgeom->left_width = borders.visible.left;
|
||||
fgeom->right_width = borders.visible.right;
|
||||
fgeom->top_height = borders.visible.top;
|
||||
fgeom->bottom_height = borders.visible.bottom;
|
||||
|
||||
width = client_width + fgeom->left_width + fgeom->right_width;
|
||||
|
||||
@@ -5585,30 +5573,23 @@ meta_theme_draw_frame_by_name (MetaTheme *theme,
|
||||
}
|
||||
|
||||
void
|
||||
meta_theme_get_frame_borders (MetaTheme *theme,
|
||||
MetaFrameType type,
|
||||
int text_height,
|
||||
MetaFrameFlags flags,
|
||||
int *top_height,
|
||||
int *bottom_height,
|
||||
int *left_width,
|
||||
int *right_width)
|
||||
meta_theme_get_frame_borders (MetaTheme *theme,
|
||||
MetaFrameType type,
|
||||
int text_height,
|
||||
MetaFrameFlags flags,
|
||||
MetaFrameBorders *borders)
|
||||
{
|
||||
MetaFrameStyle *style;
|
||||
|
||||
g_return_if_fail (type < META_FRAME_TYPE_LAST);
|
||||
|
||||
if (top_height)
|
||||
*top_height = 0;
|
||||
if (bottom_height)
|
||||
*bottom_height = 0;
|
||||
if (left_width)
|
||||
*left_width = 0;
|
||||
if (right_width)
|
||||
*right_width = 0;
|
||||
|
||||
|
||||
style = theme_get_style (theme, type, flags);
|
||||
|
||||
|
||||
borders->visible.top = 0;
|
||||
borders->visible.left = 0;
|
||||
borders->visible.right = 0;
|
||||
borders->visible.bottom = 0;
|
||||
|
||||
/* Parser is not supposed to allow this currently */
|
||||
if (style == NULL)
|
||||
return;
|
||||
@@ -5616,8 +5597,7 @@ meta_theme_get_frame_borders (MetaTheme *theme,
|
||||
meta_frame_layout_get_borders (style->layout,
|
||||
text_height,
|
||||
flags,
|
||||
top_height, bottom_height,
|
||||
left_width, right_width);
|
||||
borders);
|
||||
}
|
||||
|
||||
void
|
||||
|
25
src/ui/ui.c
25
src/ui/ui.c
@@ -306,14 +306,12 @@ meta_ui_free (MetaUI *ui)
|
||||
}
|
||||
|
||||
void
|
||||
meta_ui_get_frame_geometry (MetaUI *ui,
|
||||
Window frame_xwindow,
|
||||
int *top_height, int *bottom_height,
|
||||
int *left_width, int *right_width)
|
||||
meta_ui_get_frame_borders (MetaUI *ui,
|
||||
Window frame_xwindow,
|
||||
MetaFrameBorders *borders)
|
||||
{
|
||||
meta_frames_get_geometry (ui->frames, frame_xwindow,
|
||||
top_height, bottom_height,
|
||||
left_width, right_width);
|
||||
meta_frames_get_borders (ui->frames, frame_xwindow,
|
||||
borders);
|
||||
}
|
||||
|
||||
Window
|
||||
@@ -712,10 +710,7 @@ void
|
||||
meta_ui_theme_get_frame_borders (MetaUI *ui,
|
||||
MetaFrameType type,
|
||||
MetaFrameFlags flags,
|
||||
int *top_height,
|
||||
int *bottom_height,
|
||||
int *left_width,
|
||||
int *right_width)
|
||||
MetaFrameBorders *borders)
|
||||
{
|
||||
int text_height;
|
||||
GtkStyleContext *style = NULL;
|
||||
@@ -737,12 +732,14 @@ meta_ui_theme_get_frame_borders (MetaUI *ui,
|
||||
|
||||
meta_theme_get_frame_borders (meta_theme_get_current (),
|
||||
type, text_height, flags,
|
||||
top_height, bottom_height,
|
||||
left_width, right_width);
|
||||
borders);
|
||||
}
|
||||
else
|
||||
{
|
||||
*top_height = *bottom_height = *left_width = *right_width = 0;
|
||||
borders->visible.top = 0;
|
||||
borders->visible.bottom = 0;
|
||||
borders->visible.left = 0;
|
||||
borders->visible.right = 0;
|
||||
}
|
||||
|
||||
if (style != NULL)
|
||||
|
12
src/ui/ui.h
12
src/ui/ui.h
@@ -60,14 +60,10 @@ void meta_ui_free (MetaUI *ui);
|
||||
void meta_ui_theme_get_frame_borders (MetaUI *ui,
|
||||
MetaFrameType type,
|
||||
MetaFrameFlags flags,
|
||||
int *top_height,
|
||||
int *bottom_height,
|
||||
int *left_width,
|
||||
int *right_width);
|
||||
void meta_ui_get_frame_geometry (MetaUI *ui,
|
||||
Window frame_xwindow,
|
||||
int *top_height, int *bottom_height,
|
||||
int *left_width, int *right_width);
|
||||
MetaFrameBorders *borders);
|
||||
void meta_ui_get_frame_borders (MetaUI *ui,
|
||||
Window frame_xwindow,
|
||||
MetaFrameBorders *borders);
|
||||
Window meta_ui_create_frame_window (MetaUI *ui,
|
||||
Display *xdisplay,
|
||||
Visual *xvisual,
|
||||
|
Reference in New Issue
Block a user