core: Add a in-tree copy of GtkBorder

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2407>
This commit is contained in:
Bilal Elmoussaoui 2022-05-09 11:24:23 +02:00
parent b0b21e8274
commit 64ee8d02f7
6 changed files with 30 additions and 15 deletions

View File

@ -345,7 +345,7 @@ meta_frame_query_borders (MetaFrame *frame,
if (res == Success && nitems == 4) if (res == Success && nitems == 4)
{ {
borders->invisible = (GtkBorder) { borders->invisible = (MetaFrameBorder) {
((long *) data)[0], ((long *) data)[0],
((long *) data)[1], ((long *) data)[1],
((long *) data)[2], ((long *) data)[2],
@ -371,7 +371,7 @@ meta_frame_query_borders (MetaFrame *frame,
if (res == Success && nitems == 4) if (res == Success && nitems == 4)
{ {
borders->visible = (GtkBorder) { borders->visible = (MetaFrameBorder) {
((long *) data)[0], ((long *) data)[0],
((long *) data)[1], ((long *) data)[1],
((long *) data)[2], ((long *) data)[2],
@ -381,7 +381,7 @@ meta_frame_query_borders (MetaFrame *frame,
g_clear_pointer (&data, XFree); g_clear_pointer (&data, XFree);
borders->total = (GtkBorder) { borders->total = (MetaFrameBorder) {
borders->invisible.left + frame->cached_borders.visible.left, borders->invisible.left + frame->cached_borders.visible.left,
borders->invisible.right + frame->cached_borders.visible.right, borders->invisible.right + frame->cached_borders.visible.right,
borders->invisible.top + frame->cached_borders.visible.top, borders->invisible.top + frame->cached_borders.visible.top,

View File

@ -278,7 +278,7 @@ struct _MetaWindow
Window user_time_window; Window user_time_window;
gboolean has_custom_frame_extents; gboolean has_custom_frame_extents;
GtkBorder custom_frame_extents; MetaFrameBorder custom_frame_extents;
/* The rectangles here are in "frame rect" coordinates. See the /* The rectangles here are in "frame rect" coordinates. See the
* comment at the top of meta_window_move_resize_internal() for more * comment at the top of meta_window_move_resize_internal() for more

View File

@ -4354,7 +4354,7 @@ meta_window_client_rect_to_frame_rect (MetaWindow *window,
} }
else else
{ {
const GtkBorder *extents = &window->custom_frame_extents; const MetaFrameBorder *extents = &window->custom_frame_extents;
frame_rect->x += extents->left; frame_rect->x += extents->left;
frame_rect->y += extents->top; frame_rect->y += extents->top;
if (frame_rect->width != G_MAXINT) if (frame_rect->width != G_MAXINT)
@ -4395,7 +4395,7 @@ meta_window_frame_rect_to_client_rect (MetaWindow *window,
} }
else else
{ {
const GtkBorder *extents = &window->custom_frame_extents; const MetaFrameBorder *extents = &window->custom_frame_extents;
client_rect->x -= extents->left; client_rect->x -= extents->left;
client_rect->y -= extents->top; client_rect->y -= extents->top;
client_rect->width += extents->left + extents->right; client_rect->width += extents->left + extents->right;

View File

@ -70,6 +70,21 @@ struct _MetaButtonLayout
gboolean right_buttons_has_spacer[MAX_BUTTONS_PER_CORNER]; gboolean right_buttons_has_spacer[MAX_BUTTONS_PER_CORNER];
}; };
/**
* MetaFrameBorder:
* @left: left border
* @right: right border
* @top: top border
* @bottom: bottom border
*/
typedef struct _MetaFrameBorder
{
int16_t left;
int16_t right;
int16_t top;
int16_t bottom;
} MetaFrameBorder;
/** /**
* MetaFrameBorders: * MetaFrameBorders:
* @visible: inner visible portion of frame border * @visible: inner visible portion of frame border
@ -82,12 +97,12 @@ struct _MetaFrameBorders
/* The frame border is made up of two pieces - an inner visible portion /* The frame border is made up of two pieces - an inner visible portion
* and an outer portion that is invisible but responds to events. * and an outer portion that is invisible but responds to events.
*/ */
GtkBorder visible; MetaFrameBorder visible;
GtkBorder invisible; MetaFrameBorder invisible;
/* For convenience, we have a "total" border which is equal to the sum /* For convenience, we have a "total" border which is equal to the sum
* of the two borders above. */ * of the two borders above. */
GtkBorder total; MetaFrameBorder total;
}; };
/* sets all dimensions to zero */ /* sets all dimensions to zero */

View File

@ -1163,7 +1163,7 @@ meta_window_wayland_finish_move_resize (MetaWindow *window,
} }
else else
{ {
window->custom_frame_extents = (GtkBorder) { 0 }; window->custom_frame_extents = (MetaFrameBorder) { 0 };
} }
flags = META_MOVE_RESIZE_WAYLAND_FINISH_MOVE_RESIZE; flags = META_MOVE_RESIZE_WAYLAND_FINISH_MOVE_RESIZE;

View File

@ -347,14 +347,14 @@ reload_icon_geometry (MetaWindow *window,
} }
static void static void
meta_window_set_custom_frame_extents (MetaWindow *window, meta_window_set_custom_frame_extents (MetaWindow *window,
GtkBorder *extents, MetaFrameBorder *extents,
gboolean is_initial) gboolean is_initial)
{ {
if (extents) if (extents)
{ {
if (window->has_custom_frame_extents && if (window->has_custom_frame_extents &&
memcmp (&window->custom_frame_extents, extents, sizeof (GtkBorder)) == 0) memcmp (&window->custom_frame_extents, extents, sizeof (MetaFrameBorder)) == 0)
return; return;
window->has_custom_frame_extents = TRUE; window->has_custom_frame_extents = TRUE;
@ -397,7 +397,7 @@ reload_gtk_frame_extents (MetaWindow *window,
} }
else else
{ {
GtkBorder extents; MetaFrameBorder extents;
extents.left = (int)value->v.cardinal_list.cardinals[0]; extents.left = (int)value->v.cardinal_list.cardinals[0];
extents.right = (int)value->v.cardinal_list.cardinals[1]; extents.right = (int)value->v.cardinal_list.cardinals[1];
extents.top = (int)value->v.cardinal_list.cardinals[2]; extents.top = (int)value->v.cardinal_list.cardinals[2];