diff --git a/src/meta/boxes.h b/src/meta/boxes.h index 7585e1312..40683bb1f 100644 --- a/src/meta/boxes.h +++ b/src/meta/boxes.h @@ -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 diff --git a/src/tests/boxes-tests.c b/src/tests/boxes-tests.c index ea33b5544..8886a294c 100644 --- a/src/tests/boxes-tests.c +++ b/src/tests/boxes-tests.c @@ -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);