- if (head > screen_num_monitors)
- return NULL;
- if (desktop >= screen_num_desktops) {
- if (desktop == DESKTOP_ALL)
- return &area[screen_num_desktops][head];
- return NULL;
+ Rect *a;
+ GSList *it;
+ gint l, r, t, b;
+
+ g_assert(head < screen_num_monitors);
+
+ /* get the base area for the monitor */
+ a = g_new(Rect, 1);
+ *a = monitor_area[head];
+
+ /* remove any struts which will be affecting the search area */
+ l = t = r = b = 0;
+ for (it = struts_left; it; it = g_slist_next(it)) {
+ StrutPartial *s = it->data;
+ if (!search ||
+ RANGE_INTERSECT(search->y, search->height,
+ s->left_start, s->left_end - s->left_start + 1))
+ l = MAX(l, s->left);
+ }
+ for (it = struts_right; it; it = g_slist_next(it)) {
+ StrutPartial *s = it->data;
+ if (!search == 0 ||
+ RANGE_INTERSECT(search->y, search->height,
+ s->right_start, s->right_end - s->right_start + 1))
+ r = MAX(r, s->right);
+ }
+ for (it = struts_top; it; it = g_slist_next(it)) {
+ StrutPartial *s = it->data;
+ if (!search == 0 ||
+ RANGE_INTERSECT(search->x, search->width,
+ s->top_start, s->top_end - s->top_start + 1))
+ t = MAX(t, s->top);
+ }
+ for (it = struts_bottom; it; it = g_slist_next(it)) {
+ StrutPartial *s = it->data;
+ if (search->width == 0 ||
+ RANGE_INTERSECT(search->x, search->width,
+ s->bottom_start,
+ s->bottom_end - s->bottom_start + 1))
+ b = MAX(b, s->bottom);