From cfd49bdf68ef48fcd53a084c74626372fc169688 Mon Sep 17 00:00:00 2001 From: Victor Kareh Date: Fri, 12 Apr 2019 07:58:30 -0400 Subject: 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. --- src/ui/preview-widget.c | 47 ++++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 25 deletions(-) (limited to 'src/ui/preview-widget.c') diff --git a/src/ui/preview-widget.c b/src/ui/preview-widget.c index 6dc4691c..1db34950 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; @@ -268,7 +265,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)) @@ -304,7 +301,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)) @@ -349,11 +346,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); } } @@ -367,10 +364,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 -- cgit v1.2.1