mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 01:20:42 -05:00
mtk: Move Rectangle.area from Meta
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
This commit is contained in:
parent
af7c7befd8
commit
db77759938
@ -63,6 +63,19 @@ mtk_rectangle_new (int x,
|
||||
return rect;
|
||||
}
|
||||
|
||||
/**
|
||||
* mtk_rectangle_area:
|
||||
* @rect: A rectangle
|
||||
*
|
||||
* Returns: The area of the rectangle
|
||||
*/
|
||||
int
|
||||
mtk_rectangle_area (const MtkRectangle *rect)
|
||||
{
|
||||
g_return_val_if_fail (rect != NULL, 0);
|
||||
return rect->width * rect->height;
|
||||
}
|
||||
|
||||
/**
|
||||
* mtk_rectangle_equal:
|
||||
* @src1: The first rectangle
|
||||
|
@ -79,6 +79,10 @@ MtkRectangle * mtk_rectangle_new (int x,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
/* Basic comparison functions */
|
||||
MTK_EXPORT
|
||||
int mtk_rectangle_area (const MtkRectangle *rect);
|
||||
|
||||
MTK_EXPORT
|
||||
gboolean mtk_rectangle_equal (const MtkRectangle *src1,
|
||||
const MtkRectangle *src2);
|
||||
|
@ -3374,7 +3374,7 @@ meta_monitor_manager_get_logical_monitor_from_rect (MetaMonitorManager *manager,
|
||||
&intersection))
|
||||
continue;
|
||||
|
||||
intersection_area = meta_rectangle_area (&intersection);
|
||||
intersection_area = mtk_rectangle_area (&intersection);
|
||||
|
||||
if (intersection_area > best_logical_monitor_area)
|
||||
{
|
||||
|
@ -133,14 +133,6 @@ meta_rectangle_edge_list_to_string (GList *edge_list,
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
int
|
||||
meta_rectangle_area (const MetaRectangle *rect)
|
||||
{
|
||||
g_return_val_if_fail (rect != NULL, 0);
|
||||
return rect->width * rect->height;
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_rectangle_overlap (const MetaRectangle *rect1,
|
||||
const MetaRectangle *rect2)
|
||||
@ -402,8 +394,8 @@ compare_rect_areas (gconstpointer a, gconstpointer b)
|
||||
const MetaRectangle *a_rect = (gconstpointer) a;
|
||||
const MetaRectangle *b_rect = (gconstpointer) b;
|
||||
|
||||
int a_area = meta_rectangle_area (a_rect);
|
||||
int b_area = meta_rectangle_area (b_rect);
|
||||
int a_area = mtk_rectangle_area (a_rect);
|
||||
int b_area = mtk_rectangle_area (b_rect);
|
||||
|
||||
return b_area - a_area; /* positive ret value denotes b > a, ... */
|
||||
}
|
||||
@ -890,7 +882,7 @@ meta_rectangle_clip_to_region (const GList *spanning_rects,
|
||||
|
||||
/* Determine maximal overlap amount */
|
||||
mtk_rectangle_intersect (rect, compare_rect, &overlap);
|
||||
maximal_overlap_amount_for_compare = meta_rectangle_area (&overlap);
|
||||
maximal_overlap_amount_for_compare = mtk_rectangle_area (&overlap);
|
||||
|
||||
/* See if this is the best rect so far */
|
||||
if (maximal_overlap_amount_for_compare > best_overlap)
|
||||
|
@ -101,10 +101,6 @@ MetaRectangle *meta_rectangle_copy (const MetaRectangle *rect);
|
||||
META_EXPORT
|
||||
void meta_rectangle_free (MetaRectangle *rect);
|
||||
|
||||
/* Basic comparison functions */
|
||||
META_EXPORT
|
||||
int meta_rectangle_area (const MetaRectangle *rect);
|
||||
|
||||
/* overlap is similar to intersect but doesn't provide location of
|
||||
* intersection information.
|
||||
*/
|
||||
|
@ -110,11 +110,11 @@ test_area (void)
|
||||
for (i = 0; i < NUM_RANDOM_RUNS; i++)
|
||||
{
|
||||
get_random_rect (&temp);
|
||||
g_assert (meta_rectangle_area (&temp) == temp.width * temp.height);
|
||||
g_assert (mtk_rectangle_area (&temp) == temp.width * temp.height);
|
||||
}
|
||||
|
||||
temp = MTK_RECTANGLE_INIT (0, 0, 5, 7);
|
||||
g_assert (meta_rectangle_area (&temp) == 35);
|
||||
g_assert (mtk_rectangle_area (&temp) == 35);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -131,13 +131,13 @@ test_intersect (void)
|
||||
mtk_rectangle_intersect (&a, &b, &temp);
|
||||
temp2 = MTK_RECTANGLE_INIT (100, 200, 10, 2);
|
||||
g_assert (mtk_rectangle_equal (&temp, &temp2));
|
||||
g_assert (meta_rectangle_area (&temp) == 20);
|
||||
g_assert (mtk_rectangle_area (&temp) == 20);
|
||||
|
||||
mtk_rectangle_intersect (&a, &c, &temp);
|
||||
g_assert (meta_rectangle_area (&temp) == 0);
|
||||
g_assert (mtk_rectangle_area (&temp) == 0);
|
||||
|
||||
mtk_rectangle_intersect (&a, &d, &temp);
|
||||
g_assert (meta_rectangle_area (&temp) == 0);
|
||||
g_assert (mtk_rectangle_area (&temp) == 0);
|
||||
|
||||
mtk_rectangle_intersect (&b, &d, &b);
|
||||
g_assert (mtk_rectangle_equal (&b, &b_intersect_d));
|
||||
|
Loading…
Reference in New Issue
Block a user