static void make_grid(const Rect* client_rects, int n_client_rects, const Rect* monitor, int* x_edges, int* y_edges, int max_edges) { int i; int n_edges = 0; for (i = 0; i < n_client_rects; ++i) { if (!RECT_INTERSECTS_RECT(client_rects[i], *monitor)) continue; x_edges[n_edges] = client_rects[i].x; y_edges[n_edges++] = client_rects[i].y; x_edges[n_edges] = client_rects[i].x + client_rects[i].width; y_edges[n_edges++] = client_rects[i].y + client_rects[i].height; } x_edges[n_edges] = monitor->x; y_edges[n_edges++] = monitor->y; x_edges[n_edges] = monitor->x + monitor->width; y_edges[n_edges++] = monitor->y + monitor->height; for (i = n_edges; i < max_edges; ++i) x_edges[i] = y_edges[i] = G_MAXINT; qsort(x_edges, n_edges, sizeof(int), compare_ints); uniquify(x_edges, n_edges); qsort(y_edges, n_edges, sizeof(int), compare_ints); uniquify(y_edges, n_edges); }
static gboolean stacking_occludes(struct wm_client *client, struct wm_client *sibling) { GList *it; gboolean occludes = FALSE; if(sibling && client->layer != sibling->layer) return occludes; for(it = g_list_next(g_list_find(stacking_list, client)); it; it = g_list_next(it)) if(WINDOW_IS_CLIENT(it->data)) { struct wm_client *c = it->data; if((c->desktop == DESKTOP_ALL || client->desktop == DESKTOP_ALL || c->desktop == client->desktop) && !client_search_transient(c, client)) { if(RECT_INTERSECTS_RECT(c->frame->area, client->frame->area)) { if(sibling != NULL) { if(c == sibling) { occludes = TRUE; break; } } else if(c->layer == client->layer) { occludes = TRUE; break; } else if(c->layer < client->layer) break; } } } return occludes; }
static int total_overlap(const Rect* client_rects, int n_client_rects, const Rect* proposed_rect) { int overlap = 0; int i; for (i = 0; i < n_client_rects; ++i) { if (!RECT_INTERSECTS_RECT(*proposed_rect, client_rects[i])) continue; Rect rtemp; RECT_SET_INTERSECTION(rtemp, *proposed_rect, client_rects[i]); overlap += RECT_AREA(rtemp); } return overlap; }