} \
}
+static void get_xinerama_screens(Rect **xin_areas, guint *nxin)
+{
+ guint i;
+ gint n, l, r, t, b;
+#ifdef XINERAMA
+ XineramaScreenInfo *info;
+#endif
+
+ if (ob_debug_xinerama) {
+ gint w = WidthOfScreen(ScreenOfDisplay(obt_display, ob_screen));
+ gint h = HeightOfScreen(ScreenOfDisplay(obt_display, ob_screen));
+ *nxin = 2;
+ *xin_areas = g_new(Rect, *nxin + 1);
+ RECT_SET((*xin_areas)[0], 0, 0, w/2, h);
+ RECT_SET((*xin_areas)[1], w/2, 0, w-(w/2), h);
+ }
+#ifdef XINERAMA
+ else if (obt_display_extension_xinerama &&
+ (info = XineramaQueryScreens(obt_display, &n))) {
+ *nxin = n;
+ *xin_areas = g_new(Rect, *nxin + 1);
+ for (i = 0; i < *nxin; ++i)
+ RECT_SET((*xin_areas)[i], info[i].x_org, info[i].y_org,
+ info[i].width, info[i].height);
+ XFree(info);
+ }
+#endif
+ else {
+ *nxin = 1;
+ *xin_areas = g_new(Rect, *nxin + 1);
+ RECT_SET((*xin_areas)[0], 0, 0,
+ WidthOfScreen(ScreenOfDisplay(obt_display, ob_screen)),
+ HeightOfScreen(ScreenOfDisplay(obt_display, ob_screen)));
+ }
+
+ /* returns one extra with the total area in it */
+ l = (*xin_areas)[0].x;
+ t = (*xin_areas)[0].y;
+ r = (*xin_areas)[0].x + (*xin_areas)[0].width - 1;
+ b = (*xin_areas)[0].y + (*xin_areas)[0].height - 1;
+ for (i = 1; i < *nxin; ++i) {
+ l = MIN(l, (*xin_areas)[i].x);
+ t = MIN(l, (*xin_areas)[i].y);
+ r = MAX(r, (*xin_areas)[i].x + (*xin_areas)[i].width - 1);
+ b = MAX(b, (*xin_areas)[i].y + (*xin_areas)[i].height - 1);
+ }
+ RECT_SET((*xin_areas)[*nxin], l, t, r - l + 1, b - t + 1);
+}
+
void screen_update_areas(void)
{
- guint i, j;
+ guint i, j, onum;
gulong *dims;
GList *it;
GSList *sit;
+ onum = screen_num_monitors;
+
g_free(monitor_area);
- extensions_xinerama_screens(&monitor_area, &screen_num_monitors);
+ get_xinerama_screens(&monitor_area, &screen_num_monitors);
- if (!desktop_popup) {
- desktop_popup = g_new(ObPagerPopup*, screen_num_monitors);
- for (i = 0; i < screen_num_monitors; i++) {
+ if (screen_num_monitors < onum) {
+ /* free some of the pager popups */
+ for (i = screen_num_monitors; i < onum; ++i)
+ pager_popup_free(desktop_popup[i]);
+ desktop_popup = g_renew(ObPagerPopup*, desktop_popup,
+ screen_num_monitors);
+ }
+ else {
+ /* add some more pager popups */
+ desktop_popup = g_renew(ObPagerPopup*, desktop_popup,
+ screen_num_monitors);
+ for (i = onum; i < screen_num_monitors; ++i) {
desktop_popup[i] = pager_popup_new();
pager_popup_height(desktop_popup[i], POPUP_HEIGHT);
-
- if (screen_desktop_names)
- /* update the pager popup's width */
+ if (screen_desktop_names) /* the areas are initialized before the
+ desktop names */
pager_popup_text_width_to_strings(desktop_popup[i],
screen_desktop_names,
screen_num_desktops);