Commit b7b6e2fc authored by Marco Trevisan's avatar Marco Trevisan 🎺

boxes: Add function to check if a rectangle has a neighbor

A similar function is implemented for monitor, but it can be a generic operation
parent f181de3e
...@@ -284,4 +284,8 @@ void meta_rectangle_crop_and_scale (const MetaRectangle *rect, ...@@ -284,4 +284,8 @@ void meta_rectangle_crop_and_scale (const MetaRectangle *rect,
int dst_height, int dst_height,
MetaRectangle *dest); MetaRectangle *dest);
gboolean meta_rectangle_has_neighbor (const MetaRectangle *rect,
const MetaRectangle *neighbor,
MetaSide neighbor_side);
#endif /* META_BOXES_PRIVATE_H */ #endif /* META_BOXES_PRIVATE_H */
...@@ -2201,3 +2201,35 @@ meta_rectangle_crop_and_scale (const MetaRectangle *rect, ...@@ -2201,3 +2201,35 @@ meta_rectangle_crop_and_scale (const MetaRectangle *rect,
meta_rectangle_from_clutter_rect (&tmp, META_ROUNDING_STRATEGY_GROW, dest); meta_rectangle_from_clutter_rect (&tmp, META_ROUNDING_STRATEGY_GROW, dest);
} }
gboolean
meta_rectangle_has_neighbor (const MetaRectangle *rect,
const MetaRectangle *neighbor,
MetaSide neighbor_side)
{
switch (neighbor_side)
{
case META_SIDE_RIGHT:
if (neighbor->x == (rect->x + rect->width) &&
meta_rectangle_vert_overlap (neighbor, rect))
return TRUE;
break;
case META_SIDE_LEFT:
if (rect->x == (neighbor->x + neighbor->width) &&
meta_rectangle_vert_overlap (neighbor, rect))
return TRUE;
break;
case META_SIDE_TOP:
if (rect->y == (neighbor->y + neighbor->height) &&
meta_rectangle_horiz_overlap (neighbor, rect))
return TRUE;
break;
case META_SIDE_BOTTOM:
if (neighbor->y == (rect->y + rect->height) &&
meta_rectangle_horiz_overlap (neighbor, rect))
return TRUE;
break;
}
return FALSE;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment