Introduce get_output_from_rect

This commit is contained in:
Orestis Floros 2018-03-17 20:42:54 +02:00
parent e09861f73f
commit 8a3ef3a81b
2 changed files with 22 additions and 0 deletions

View File

@ -88,6 +88,14 @@ Output *get_output_by_name(const char *name, const bool require_active);
*/
Output *get_output_containing(unsigned int x, unsigned int y);
/**
* Returns the active output which contains the midpoint of the given rect. If
* such an output doesn't exist, returns the output which contains most of the
* rectangle or NULL if there is no output which intersects with it.
*
*/
Output *get_output_from_rect(Rect rect);
/**
* Returns the active output which spans exactly the area specified by
* rect or NULL if there is no output like this.

View File

@ -114,6 +114,20 @@ Output *get_output_containing(unsigned int x, unsigned int y) {
return NULL;
}
/*
* Returns the active output which contains the midpoint of the given rect. If
* such an output doesn't exist, returns the output which contains most of the
* rectangle or NULL if there is no output which intersects with it.
*
*/
Output *get_output_from_rect(Rect rect) {
unsigned int mid_x = rect.x + rect.width / 2;
unsigned int mid_y = rect.y + rect.height / 2;
Output *output = get_output_containing(mid_x, mid_y);
return output ? output : output_containing_rect(rect);
}
/*
* Returns the active output which spans exactly the area specified by
* rect or NULL if there is no output like this.