+ Strut *struts;
+ gint l, r, t, b;
+
+ struts = g_new0(Strut, screen_num_monitors);
+
+ /* calc the xinerama areas */
+ for (x = 0; x < screen_num_monitors; ++x) {
+ area[i][x] = monitor_area[x];
+ if (x == 0) {
+ l = monitor_area[x].x;
+ t = monitor_area[x].y;
+ r = monitor_area[x].x + monitor_area[x].width - 1;
+ b = monitor_area[x].y + monitor_area[x].height - 1;
+ } else {
+ l = MIN(l, monitor_area[x].x);
+ t = MIN(t, monitor_area[x].y);
+ r = MAX(r, monitor_area[x].x + monitor_area[x].width - 1);
+ b = MAX(b, monitor_area[x].y + monitor_area[x].height - 1);
+ }
+ }
+ RECT_SET(area[i][x], l, t, r - l + 1, b - t + 1);
+
+ /* apply the struts */
+
+ /* find the left-most xin heads, i do this in 2 loops :| */
+ o = area[i][0].x;
+ for (x = 1; x < screen_num_monitors; ++x)
+ o = MIN(o, area[i][x].x);
+
+ for (x = 0; x < screen_num_monitors; ++x) {
+ for (it = client_list; it; it = g_list_next(it)) {
+ ObClient *c = it->data;
+ screen_area_add_strut_left(&c->strut,
+ &monitor_area[x],
+ o + c->strut.left - area[i][x].x,
+ &struts[x]);
+ }
+ screen_area_add_strut_left(&dock_strut,
+ &monitor_area[x],
+ o + dock_strut.left - area[i][x].x,
+ &struts[x]);
+
+ area[i][x].x += struts[x].left;
+ area[i][x].width -= struts[x].left;
+ }
+
+ /* find the top-most xin heads, i do this in 2 loops :| */
+ o = area[i][0].y;
+ for (x = 1; x < screen_num_monitors; ++x)
+ o = MIN(o, area[i][x].y);
+
+ for (x = 0; x < screen_num_monitors; ++x) {
+ for (it = client_list; it; it = g_list_next(it)) {
+ ObClient *c = it->data;
+ screen_area_add_strut_top(&c->strut,
+ &monitor_area[x],
+ o + c->strut.top - area[i][x].y,
+ &struts[x]);
+ }
+ screen_area_add_strut_top(&dock_strut,
+ &monitor_area[x],
+ o + dock_strut.top - area[i][x].y,
+ &struts[x]);
+
+ area[i][x].y += struts[x].top;
+ area[i][x].height -= struts[x].top;
+ }
+
+ /* find the right-most xin heads, i do this in 2 loops :| */
+ o = area[i][0].x + area[i][0].width - 1;
+ for (x = 1; x < screen_num_monitors; ++x)
+ o = MAX(o, area[i][x].x + area[i][x].width - 1);
+
+ for (x = 0; x < screen_num_monitors; ++x) {
+ for (it = client_list; it; it = g_list_next(it)) {
+ ObClient *c = it->data;
+ screen_area_add_strut_right(&c->strut,
+ &monitor_area[x],
+ (area[i][x].x +
+ area[i][x].width - 1) -
+ (o - c->strut.right),
+ &struts[x]);
+ }
+ screen_area_add_strut_right(&dock_strut,
+ &monitor_area[x],
+ (area[i][x].x +
+ area[i][x].width - 1) -
+ (o - dock_strut.right),
+ &struts[x]);
+
+ area[i][x].width -= struts[x].right;
+ }
+
+ /* find the bottom-most xin heads, i do this in 2 loops :| */
+ o = area[i][0].y + area[i][0].height - 1;
+ for (x = 1; x < screen_num_monitors; ++x)
+ o = MAX(o, area[i][x].y + area[i][x].height - 1);
+
+ for (x = 0; x < screen_num_monitors; ++x) {
+ for (it = client_list; it; it = g_list_next(it)) {
+ ObClient *c = it->data;
+ screen_area_add_strut_bottom(&c->strut,
+ &monitor_area[x],
+ (area[i][x].y +
+ area[i][x].height - 1) - \
+ (o - c->strut.bottom),
+ &struts[x]);
+ }
+ screen_area_add_strut_bottom(&dock_strut,
+ &monitor_area[x],
+ (area[i][x].y +
+ area[i][x].height - 1) - \
+ (o - dock_strut.bottom),
+ &struts[x]);
+
+ area[i][x].height -= struts[x].bottom;
+ }
+
+ l = RECT_LEFT(area[i][0]);
+ t = RECT_TOP(area[i][0]);
+ r = RECT_RIGHT(area[i][0]);
+ b = RECT_BOTTOM(area[i][0]);
+ for (x = 1; x < screen_num_monitors; ++x) {
+ l = MIN(l, RECT_LEFT(area[i][x]));
+ t = MIN(l, RECT_TOP(area[i][x]));
+ r = MAX(r, RECT_RIGHT(area[i][x]));
+ b = MAX(b, RECT_BOTTOM(area[i][x]));
+ }
+ RECT_SET(area[i][screen_num_monitors], l, t,
+ r - l + 1, b - t + 1);
+
+ /* XXX optimize when this is run? */
+
+ /* the area has changed, adjust all the maximized
+ windows */
+ for (it = client_list; it; it = g_list_next(it)) {
+ ObClient *c = it->data;
+ if (i < screen_num_desktops) {
+ if (c->desktop == i)
+ client_reconfigure(c);
+ } else if (c->desktop == DESKTOP_ALL)
+ client_reconfigure(c);
+ }
+ if (i < screen_num_desktops) {
+ /* don't set these for the 'all desktops' area */
+ dims[(i * 4) + 0] = area[i][screen_num_monitors].x;
+ dims[(i * 4) + 1] = area[i][screen_num_monitors].y;
+ dims[(i * 4) + 2] = area[i][screen_num_monitors].width;
+ dims[(i * 4) + 3] = area[i][screen_num_monitors].height;
+ }
+
+ g_free(struts);
+ }
+
+ PROP_SETA32(RootWindow(ob_display, ob_screen), net_workarea, cardinal,
+ dims, 4 * screen_num_desktops);