mtk: Move Rectangle.union from Meta
Similar to Rectangle.equal. The clutter helper was not used. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
This commit is contained in:
parent
9b2cba4e86
commit
6f66dd9944
@ -214,10 +214,6 @@ void _clutter_util_rectangle_offset (const MtkRectangle *src,
|
|||||||
int y,
|
int y,
|
||||||
MtkRectangle *dest);
|
MtkRectangle *dest);
|
||||||
|
|
||||||
void _clutter_util_rectangle_union (const MtkRectangle *src1,
|
|
||||||
const MtkRectangle *src2,
|
|
||||||
MtkRectangle *dest);
|
|
||||||
|
|
||||||
gboolean _clutter_util_rectangle_intersection (const MtkRectangle *src1,
|
gboolean _clutter_util_rectangle_intersection (const MtkRectangle *src1,
|
||||||
const MtkRectangle *src2,
|
const MtkRectangle *src2,
|
||||||
MtkRectangle *dest);
|
MtkRectangle *dest);
|
||||||
|
@ -163,37 +163,6 @@ _clutter_util_rectangle_offset (const MtkRectangle *src,
|
|||||||
dest->y += y;
|
dest->y += y;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*< private >
|
|
||||||
* _clutter_util_rectangle_union:
|
|
||||||
* @src1: first rectangle to union
|
|
||||||
* @src2: second rectangle to union
|
|
||||||
* @dest: (out): return location for the unioned rectangle
|
|
||||||
*
|
|
||||||
* Calculates the union of two rectangles.
|
|
||||||
*
|
|
||||||
* The union of rectangles @src1 and @src2 is the smallest rectangle which
|
|
||||||
* includes both @src1 and @src2 within it.
|
|
||||||
*
|
|
||||||
* It is allowed for @dest to be the same as either @src1 or @src2.
|
|
||||||
*
|
|
||||||
* This function should really be in Cairo.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
_clutter_util_rectangle_union (const MtkRectangle *src1,
|
|
||||||
const MtkRectangle *src2,
|
|
||||||
MtkRectangle *dest)
|
|
||||||
{
|
|
||||||
int dest_x, dest_y;
|
|
||||||
|
|
||||||
dest_x = MIN (src1->x, src2->x);
|
|
||||||
dest_y = MIN (src1->y, src2->y);
|
|
||||||
|
|
||||||
dest->width = MAX (src1->x + src1->width, src2->x + src2->width) - dest_x;
|
|
||||||
dest->height = MAX (src1->y + src1->height, src2->y + src2->height) - dest_y;
|
|
||||||
dest->x = dest_x;
|
|
||||||
dest->y = dest_y;
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
_clutter_util_rectangle_intersection (const MtkRectangle *src1,
|
_clutter_util_rectangle_intersection (const MtkRectangle *src1,
|
||||||
const MtkRectangle *src2,
|
const MtkRectangle *src2,
|
||||||
|
@ -55,3 +55,46 @@ mtk_rectangle_equal (const MtkRectangle *src1,
|
|||||||
(src1->width == src2->width) &&
|
(src1->width == src2->width) &&
|
||||||
(src1->height == src2->height));
|
(src1->height == src2->height));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mtk_rectangle_union:
|
||||||
|
* @rect1: a #MtkRectangle
|
||||||
|
* @rect2: another #MtkRectangle
|
||||||
|
* @dest: (out caller-allocates): an empty #MtkRectangle, to be filled
|
||||||
|
* with the coordinates of the bounding box.
|
||||||
|
*
|
||||||
|
* Computes the union of the two rectangles
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
mtk_rectangle_union (const MtkRectangle *rect1,
|
||||||
|
const MtkRectangle *rect2,
|
||||||
|
MtkRectangle *dest)
|
||||||
|
{
|
||||||
|
int dest_x, dest_y;
|
||||||
|
int dest_w, dest_h;
|
||||||
|
|
||||||
|
dest_x = rect1->x;
|
||||||
|
dest_y = rect1->y;
|
||||||
|
dest_w = rect1->width;
|
||||||
|
dest_h = rect1->height;
|
||||||
|
|
||||||
|
if (rect2->x < dest_x)
|
||||||
|
{
|
||||||
|
dest_w += dest_x - rect2->x;
|
||||||
|
dest_x = rect2->x;
|
||||||
|
}
|
||||||
|
if (rect2->y < dest_y)
|
||||||
|
{
|
||||||
|
dest_h += dest_y - rect2->y;
|
||||||
|
dest_y = rect2->y;
|
||||||
|
}
|
||||||
|
if (rect2->x + rect2->width > dest_x + dest_w)
|
||||||
|
dest_w = rect2->x + rect2->width - dest_x;
|
||||||
|
if (rect2->y + rect2->height > dest_y + dest_h)
|
||||||
|
dest_h = rect2->y + rect2->height - dest_y;
|
||||||
|
|
||||||
|
dest->x = dest_x;
|
||||||
|
dest->y = dest_y;
|
||||||
|
dest->width = dest_w;
|
||||||
|
dest->height = dest_h;
|
||||||
|
}
|
||||||
|
@ -68,3 +68,9 @@ MTK_EXPORT
|
|||||||
gboolean mtk_rectangle_equal (const MtkRectangle *src1,
|
gboolean mtk_rectangle_equal (const MtkRectangle *src1,
|
||||||
const MtkRectangle *src2);
|
const MtkRectangle *src2);
|
||||||
|
|
||||||
|
/* Find the bounding box of the union of two rectangles */
|
||||||
|
MTK_EXPORT
|
||||||
|
void mtk_rectangle_union (const MtkRectangle *rect1,
|
||||||
|
const MtkRectangle *rect2,
|
||||||
|
MtkRectangle *dest);
|
||||||
|
|
||||||
|
@ -200,47 +200,6 @@ meta_rectangle_intersect (const MetaRectangle *src1,
|
|||||||
return return_val;
|
return return_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* meta_rectangle_union:
|
|
||||||
* @rect1: a #MetaRectangle
|
|
||||||
* @rect2: another #MetaRectangle
|
|
||||||
* @dest: (out caller-allocates): an empty #MetaRectangle, to be filled
|
|
||||||
* with the coordinates of the bounding box.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
meta_rectangle_union (const MetaRectangle *rect1,
|
|
||||||
const MetaRectangle *rect2,
|
|
||||||
MetaRectangle *dest)
|
|
||||||
{
|
|
||||||
int dest_x, dest_y;
|
|
||||||
int dest_w, dest_h;
|
|
||||||
|
|
||||||
dest_x = rect1->x;
|
|
||||||
dest_y = rect1->y;
|
|
||||||
dest_w = rect1->width;
|
|
||||||
dest_h = rect1->height;
|
|
||||||
|
|
||||||
if (rect2->x < dest_x)
|
|
||||||
{
|
|
||||||
dest_w += dest_x - rect2->x;
|
|
||||||
dest_x = rect2->x;
|
|
||||||
}
|
|
||||||
if (rect2->y < dest_y)
|
|
||||||
{
|
|
||||||
dest_h += dest_y - rect2->y;
|
|
||||||
dest_y = rect2->y;
|
|
||||||
}
|
|
||||||
if (rect2->x + rect2->width > dest_x + dest_w)
|
|
||||||
dest_w = rect2->x + rect2->width - dest_x;
|
|
||||||
if (rect2->y + rect2->height > dest_y + dest_h)
|
|
||||||
dest_h = rect2->y + rect2->height - dest_y;
|
|
||||||
|
|
||||||
dest->x = dest_x;
|
|
||||||
dest->y = dest_y;
|
|
||||||
dest->width = dest_w;
|
|
||||||
dest->height = dest_h;
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
meta_rectangle_overlap (const MetaRectangle *rect1,
|
meta_rectangle_overlap (const MetaRectangle *rect1,
|
||||||
const MetaRectangle *rect2)
|
const MetaRectangle *rect2)
|
||||||
|
@ -458,15 +458,15 @@ setup_constraint_info (MetaBackend *backend,
|
|||||||
if (window->fullscreen && meta_window_has_fullscreen_monitors (window))
|
if (window->fullscreen && meta_window_has_fullscreen_monitors (window))
|
||||||
{
|
{
|
||||||
info->entire_monitor = window->fullscreen_monitors.top->rect;
|
info->entire_monitor = window->fullscreen_monitors.top->rect;
|
||||||
meta_rectangle_union (&info->entire_monitor,
|
mtk_rectangle_union (&info->entire_monitor,
|
||||||
&window->fullscreen_monitors.bottom->rect,
|
&window->fullscreen_monitors.bottom->rect,
|
||||||
&info->entire_monitor);
|
&info->entire_monitor);
|
||||||
meta_rectangle_union (&info->entire_monitor,
|
mtk_rectangle_union (&info->entire_monitor,
|
||||||
&window->fullscreen_monitors.left->rect,
|
&window->fullscreen_monitors.left->rect,
|
||||||
&info->entire_monitor);
|
&info->entire_monitor);
|
||||||
meta_rectangle_union (&info->entire_monitor,
|
mtk_rectangle_union (&info->entire_monitor,
|
||||||
&window->fullscreen_monitors.right->rect,
|
&window->fullscreen_monitors.right->rect,
|
||||||
&info->entire_monitor);
|
&info->entire_monitor);
|
||||||
if (window->fullscreen_monitors.top == logical_monitor &&
|
if (window->fullscreen_monitors.top == logical_monitor &&
|
||||||
window->fullscreen_monitors.bottom == logical_monitor &&
|
window->fullscreen_monitors.bottom == logical_monitor &&
|
||||||
window->fullscreen_monitors.left == logical_monitor &&
|
window->fullscreen_monitors.left == logical_monitor &&
|
||||||
|
@ -122,12 +122,6 @@ gboolean meta_rectangle_intersect (const MetaRectangle *src1,
|
|||||||
const MetaRectangle *src2,
|
const MetaRectangle *src2,
|
||||||
MetaRectangle *dest);
|
MetaRectangle *dest);
|
||||||
|
|
||||||
/* Find the bounding box of the union of two rectangles */
|
|
||||||
META_EXPORT
|
|
||||||
void meta_rectangle_union (const MetaRectangle *rect1,
|
|
||||||
const MetaRectangle *rect2,
|
|
||||||
MetaRectangle *dest);
|
|
||||||
|
|
||||||
/* overlap is similar to intersect but doesn't provide location of
|
/* overlap is similar to intersect but doesn't provide location of
|
||||||
* intersection information.
|
* intersection information.
|
||||||
*/
|
*/
|
||||||
|
@ -127,7 +127,7 @@ meta_wayland_subsurface_union_geometry (MetaWaylandSubsurface *subsurface,
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (surface->buffer)
|
if (surface->buffer)
|
||||||
meta_rectangle_union (out_geometry, &geometry, out_geometry);
|
mtk_rectangle_union (out_geometry, &geometry, out_geometry);
|
||||||
|
|
||||||
META_WAYLAND_SURFACE_FOREACH_SUBSURFACE (&surface->output_state,
|
META_WAYLAND_SURFACE_FOREACH_SUBSURFACE (&surface->output_state,
|
||||||
subsurface_surface)
|
subsurface_surface)
|
||||||
|
Loading…
Reference in New Issue
Block a user