1
0
Fork 0

boxes: Add rectangle init macro

META_RECTANGLE_INIT() works like e.g. GRAPHENE_RECT_INIT() and similar
macros.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
This commit is contained in:
Jonas Ådahl 2021-06-22 16:10:05 +02:00 committed by Marge Bot
parent de06d5d9e7
commit 990267026a
2 changed files with 21 additions and 0 deletions

View file

@ -54,6 +54,14 @@ typedef struct _MetaRectangle MetaRectangle;
typedef cairo_rectangle_int_t MetaRectangle;
#endif
#define META_RECTANGLE_INIT(_x, _y, _width, _height) \
(MetaRectangle) { \
.x = (_x), \
.y = (_y), \
.width = (_width), \
.height = (_height) \
}
/**
* MetaStrut:
* @rect: #MetaRectangle the #MetaStrut is on

View file

@ -103,6 +103,18 @@ new_monitor_edge (int x, int y, int width, int height, int side_type)
return temporary;
}
static void
test_init_rect (void)
{
MetaRectangle rect;
rect = META_RECTANGLE_INIT (1, 2, 3, 4);
g_assert_cmpint (rect.x, ==, 1);
g_assert_cmpint (rect.y, ==, 2);
g_assert_cmpint (rect.width, ==, 3);
g_assert_cmpint (rect.height, ==, 4);
}
static void
test_area (void)
{
@ -1364,6 +1376,7 @@ init_boxes_tests (void)
{
init_random_ness ();
g_test_add_func ("/util/boxes/init", test_init_rect);
g_test_add_func ("/util/boxes/area", test_area);
g_test_add_func ("/util/boxes/intersect", test_intersect);
g_test_add_func ("/util/boxes/equal", test_equal);