summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authorVictor Kareh <[email protected]>2019-04-12 07:58:30 -0400
committerVictor Kareh <[email protected]>2019-06-05 10:49:37 -0400
commitc66b32666e48996b97e691ed002f86b6ff18dec5 (patch)
tree3e5d1b07331ab708cac920fcfe62e504aa2481ad /src/ui
parent707eb409e7dfeec276f6dfa3e667a0140b3300aa (diff)
downloadmarco-c66b32666e48996b97e691ed002f86b6ff18dec5.tar.bz2
marco-c66b32666e48996b97e691ed002f86b6ff18dec5.tar.xz
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 upstream commit: https://gitlab.gnome.org/GNOME/metacity/commit/72224a165 NOTE: Patch copied from metacity and adapted for marco.
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/frames.c35
-rw-r--r--src/ui/frames.h7
-rw-r--r--src/ui/preview-widget.c47
-rw-r--r--src/ui/preview-widget.h6
-rw-r--r--src/ui/theme-viewer.c11
-rw-r--r--src/ui/theme.c83
-rw-r--r--src/ui/theme.h10
-rw-r--r--src/ui/ui.c30
8 files changed, 96 insertions, 133 deletions
diff --git a/src/ui/frames.c b/src/ui/frames.c
index 5d76f42a..1adb3ccf 100644
--- a/src/ui/frames.c
+++ b/src/ui/frames.c
@@ -668,10 +668,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;
@@ -702,14 +701,13 @@ meta_frames_get_geometry (MetaFrames *frames,
type,
frame->text_height,
flags,
- top_height, bottom_height,
- left_width, right_width);
+ borders);
/* Scale frame geometry to ensure proper frame position */
- *top_height *= scale;
- *bottom_height *= scale;
- *left_width *= scale;
- *right_width *= scale;
+ borders->visible.top *= scale;
+ borders->visible.bottom *= scale;
+ borders->visible.left *= scale;
+ borders->visible.right *= scale;
}
#ifdef HAVE_SHAPE
@@ -2060,6 +2058,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;
gint scale;
@@ -2090,7 +2089,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);
scale = gdk_window_get_scale_factor (frame->window);
@@ -2195,6 +2199,7 @@ subtract_client_area (cairo_region_t *region, MetaUIFrame *frame)
GdkRectangle area;
MetaFrameFlags flags;
MetaFrameType type;
+ MetaFrameBorders borders;
cairo_region_t *tmp_region;
Display *display;
gint scale;
@@ -2210,13 +2215,13 @@ subtract_client_area (cairo_region_t *region, MetaUIFrame *frame)
META_CORE_GET_END);
meta_theme_get_frame_borders (meta_theme_get_current (),
- type, frame->text_height, flags,
- &area.x, NULL, &area.y, NULL);
+ type, frame->text_height, flags,
+ &borders);
area.width /= scale;
area.height /= scale;
- area.x /= scale;
- area.y /= scale;
+ area.x = borders.visible.left / scale;
+ area.y = borders.visible.top / scale;
tmp_region = cairo_region_create_rectangle (&area);
cairo_region_subtract (region, tmp_region);
diff --git a/src/ui/frames.h b/src/ui/frames.h
index 736c37ca..1262f148 100644
--- a/src/ui/frames.h
+++ b/src/ui/frames.h
@@ -127,10 +127,9 @@ void meta_frames_set_title (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_apply_shapes (MetaFrames *frames,
Window xwindow,
diff --git a/src/ui/preview-widget.c b/src/ui/preview-widget.c
index 50f42b61..6c819707 100644
--- a/src/ui/preview-widget.c
+++ b/src/ui/preview-widget.c
@@ -98,10 +98,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*
@@ -172,7 +172,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)
{
@@ -180,17 +180,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;
}
}
}
@@ -223,8 +220,8 @@ meta_preview_draw (GtkWidget *widget,
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
gtk_widget_get_allocation (widget, &allocation);
- client_width = allocation.width - preview->left_width - preview->right_width - border_width * 2;
- client_height = allocation.height - preview->top_height - preview->bottom_height - border_width * 2;
+ client_width = allocation.width - preview->borders.visible.left - preview->borders.visible.right - border_width * 2;
+ client_height = allocation.height - preview->borders.visible.top - preview->borders.visible.bottom - border_width * 2;
if (client_width < 0)
client_width = 1;
@@ -266,7 +263,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))
@@ -302,7 +299,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))
@@ -347,11 +344,11 @@ meta_preview_size_allocate (GtkWidget *widget,
gtk_widget_get_visible (child))
{
gtk_widget_get_allocation (widget, &widget_allocation);
- child_allocation.x = widget_allocation.x + border_width + preview->left_width;
- child_allocation.y = widget_allocation.y + border_width + preview->top_height;
+ child_allocation.x = widget_allocation.x + border_width + preview->borders.visible.left;
+ child_allocation.y = widget_allocation.y + border_width + preview->borders.visible.top;
- child_allocation.width = MAX (1, widget_allocation.width - border_width * 2 - preview->left_width - preview->right_width);
- child_allocation.height = MAX (1, widget_allocation.height - border_width * 2 - preview->top_height - preview->bottom_height);
+ child_allocation.width = MAX (1, widget_allocation.width - border_width * 2 - preview->borders.visible.left - preview->borders.visible.right);
+ child_allocation.height = MAX (1, widget_allocation.height - border_width * 2 - preview->borders.visible.top - preview->borders.visible.bottom);
gtk_widget_size_allocate (gtk_bin_get_child (GTK_BIN (widget)), &child_allocation);
}
}
@@ -365,10 +362,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
diff --git a/src/ui/preview-widget.h b/src/ui/preview-widget.h
index 1bbd97e7..11818588 100644
--- a/src/ui/preview-widget.h
+++ b/src/ui/preview-widget.h
@@ -50,11 +50,7 @@ struct _MetaPreview
PangoLayout *layout;
int text_height;
- int left_width;
- int right_width;
- int top_height;
- int bottom_height;
-
+ MetaFrameBorders borders;
MetaButtonLayout button_layout;
};
diff --git a/src/ui/theme-viewer.c b/src/ui/theme-viewer.c
index d4331b8e..5903f990 100644
--- a/src/ui/theme-viewer.c
+++ b/src/ui/theme-viewer.c
@@ -1020,7 +1020,7 @@ run_theme_benchmark (void)
GtkWidget* widget;
cairo_surface_t *pixmap;
cairo_t *cr;
- int top_height, bottom_height, left_width, right_width;
+ MetaFrameBorders borders;
MetaButtonState button_states[META_BUTTON_TYPE_LAST] =
{
META_BUTTON_STATE_NORMAL,
@@ -1046,10 +1046,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);
@@ -1084,8 +1081,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);
meta_theme_draw_frame (global_theme,
diff --git a/src/ui/theme.c b/src/ui/theme.c
index d7932e67..37298e42 100644
--- a/src/ui/theme.c
+++ b/src/ui/theme.c
@@ -405,10 +405,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;
@@ -423,34 +420,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;
}
}
@@ -647,12 +630,16 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout *layout,
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;
@@ -5657,30 +5644,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;
@@ -5688,8 +5668,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
diff --git a/src/ui/theme.h b/src/ui/theme.h
index ef6af363..2e4a425c 100644
--- a/src/ui/theme.h
+++ b/src/ui/theme.h
@@ -877,10 +877,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,
@@ -1080,10 +1077,7 @@ 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,
diff --git a/src/ui/ui.c b/src/ui/ui.c
index 20e7546b..e7993625 100644
--- a/src/ui/ui.c
+++ b/src/ui/ui.c
@@ -295,14 +295,11 @@ 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);
}
static void
@@ -637,13 +634,10 @@ meta_ui_window_should_not_cause_focus (Display *xdisplay,
}
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)
+meta_ui_theme_get_frame_borders (MetaUI *ui,
+ MetaFrameType type,
+ MetaFrameFlags flags,
+ MetaFrameBorders *borders)
{
int text_height;
GtkStyleContext *style = NULL;
@@ -684,15 +678,17 @@ 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);
if (free_font_desc)
pango_font_description_free (free_font_desc);
}
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)