From 32a92abf7578ea93d85741b7c89a0958082aa9ee Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Mon, 23 Jul 2007 21:32:31 -0400 Subject: [PATCH] move the code for tracking what extensions are available on the display into the libobt --- Makefile.am | 28 ++++----- obt/display.c | 70 ++++++++++++++++++++--- obt/display.h | 37 ++++++++++-- obt/obt.h | 25 -------- openbox/client.c | 7 +-- openbox/event.c | 21 ++++--- openbox/extensions.c | 133 ------------------------------------------- openbox/extensions.h | 74 ------------------------ openbox/frame.c | 2 +- openbox/grab.c | 4 +- openbox/moveresize.c | 8 +-- openbox/openbox.c | 3 - openbox/screen.c | 56 ++++++++++++++++-- 13 files changed, 180 insertions(+), 288 deletions(-) delete mode 100644 obt/obt.h delete mode 100644 openbox/extensions.c delete mode 100644 openbox/extensions.h diff --git a/Makefile.am b/Makefile.am index 6c2140ef..389042fb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -113,8 +113,12 @@ parser_libobparser_la_SOURCES = \ ## obt ## obt_libobt_la_CPPFLAGS = \ + $(XINERAMA_CFLAGS) \ + $(XKB_CFLAGS) \ + $(XRANDR_CFLAGS) \ + $(XSHAPE_CFLAGS) \ + $(XSYNC_CFLAGS) \ $(GLIB_CFLAGS) \ - $(XML_CFLAGS) \ -DG_LOG_DOMAIN=\"Obt\" \ -DLOCALEDIR=\"$(localedir)\" \ -DDATADIR=\"$(datadir)\" \ @@ -122,10 +126,13 @@ obt_libobt_la_CPPFLAGS = \ obt_libobt_la_LDFLAGS = \ -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) obt_libobt_la_LIBADD = \ - $(GLIB_LIBS) \ - $(XML_LIBS) + $(XINERAMA_LIBS) \ + $(XKB_LIBS) \ + $(XRANDR_LIBS) \ + $(XSHAPE_LIBS) \ + $(XSYNC_LIBS) \ + $(GLIB_LIBS) obt_libobt_la_SOURCES = \ - obt/obt.h \ obt/display.h \ obt/display.c \ obt/mainloop.h \ @@ -136,11 +143,6 @@ obt_libobt_la_SOURCES = \ openbox_openbox_CPPFLAGS = \ $(SM_CFLAGS) \ - $(XINERAMA_CFLAGS) \ - $(XKB_CFLAGS) \ - $(XRANDR_CFLAGS) \ - $(XSHAPE_CFLAGS) \ - $(XSYNC_CFLAGS) \ $(X_CFLAGS) \ $(XCURSOR_CFLAGS) \ $(SM_CFLAGS) \ @@ -154,11 +156,6 @@ openbox_openbox_CPPFLAGS = \ -DG_LOG_DOMAIN=\"Openbox\" openbox_openbox_LDADD = \ $(SM_LIBS) \ - $(XINERAMA_LIBS) \ - $(XKB_LIBS) \ - $(XRANDR_LIBS) \ - $(XSHAPE_LIBS) \ - $(XSYNC_LIBS) \ $(GLIB_LIBS) \ $(X_LIBS) \ $(XCURSOR_LIBS) \ @@ -228,8 +225,6 @@ openbox_openbox_SOURCES = \ openbox/dock.h \ openbox/event.c \ openbox/event.h \ - openbox/extensions.c \ - openbox/extensions.h \ openbox/focus.c \ openbox/focus.h \ openbox/focus_cycle.c \ @@ -399,7 +394,6 @@ pubinclude_HEADERS = \ render/render.h \ render/theme.h \ parser/parse.h \ - obt/obt.h \ obt/display.h \ obt/mainloop.h \ obt/util.h diff --git a/obt/display.c b/obt/display.c index b638f9cd..d9966780 100644 --- a/obt/display.c +++ b/obt/display.c @@ -28,10 +28,22 @@ # include #endif +gboolean obt_display_error_occured = FALSE; + +gboolean obt_display_extension_xkb = FALSE; +gint obt_display_extension_xkb_basep; +gboolean obt_display_extension_shape = FALSE; +gint obt_display_extension_shape_basep; +gboolean obt_display_extension_xinerama = FALSE; +gint obt_display_extension_xinerama_basep; +gboolean obt_display_extension_randr = FALSE; +gint obt_display_extension_randr_basep; +gboolean obt_display_extension_sync = FALSE; +gint obt_display_extension_sync_basep; + static gint xerror_handler(Display *d, XErrorEvent *e); static gboolean xerror_ignore = FALSE; -static gboolean xerror_occured = FALSE; Display* obt_display_open(const char *display_name) { @@ -41,9 +53,56 @@ Display* obt_display_open(const char *display_name) n = display_name ? g_strdup(display_name) : NULL; d = XOpenDisplay(n); if (d) { + gint junk; + (void)junk; + if (fcntl(ConnectionNumber(d), F_SETFD, 1) == -1) g_message("Failed to set display as close-on-exec"); XSetErrorHandler(xerror_handler); + + /* read what extensions are present */ +#ifdef XKB + obt_display_extension_xkb = + XkbQueryExtension(d, &junk, + &obt_display_extension_xkb_basep, &junk, + NULL, NULL); + if (!obt_display_extension_xkb) + g_message("XKB extension is not present on the server"); +#endif + +#ifdef SHAPE + obt_display_extension_shape = + XShapeQueryExtension(d, &obt_display_extension_shape_basep, + &junk); + if (!obt_display_extension_shape) + g_message("X Shape extension is not present on the server"); +#endif + +#ifdef XINERAMA + obt_display_extension_xinerama = + XineramaQueryExtension(d, + &obt_display_extension_xinerama_basep, + &junk) && XineramaIsActive(d); + if (!obt_display_extension_xinerama) + g_message("Xinerama extension is not present on the server"); +#endif + +#ifdef XRANDR + obt_display_extension_randr = + XRRQueryExtension(d, &obt_display_extension_randr_basep, + &junk); + if (!obt_display_extension_randr) + g_message("XRandR extension is not present on the server"); +#endif + +#ifdef SYNC + obt_display_extension_sync = + XSyncQueryExtension(d, &obt_display_extension_sync_basep, + &junk) && XSyncInitialize(d, &junk, &junk); + if (!obt_display_extension_sync) + g_message("X Sync extension is not present on the server or is an " + "incompatible version"); +#endif } g_free(n); @@ -72,7 +131,7 @@ static gint xerror_handler(Display *d, XErrorEvent *e) (void)d; (void)e; #endif - xerror_occured = TRUE; + obt_display_error_occured = TRUE; return 0; } @@ -80,10 +139,5 @@ void obt_display_ignore_errors(Display *d, gboolean ignore) { XSync(d, FALSE); xerror_ignore = ignore; - if (ignore) xerror_occured = FALSE; -} - -gboolean obt_display_error_occured() -{ - return xerror_occured; + if (ignore) obt_display_error_occured = FALSE; } diff --git a/obt/display.h b/obt/display.h index aafa0fcd..b4a13c7c 100644 --- a/obt/display.h +++ b/obt/display.h @@ -16,20 +16,49 @@ See the COPYING file for a copy of the GNU General Public License. */ -#ifndef __obt_instance_h -#define __obt_instance_h +#ifndef __obt_display_h +#define __obt_display_h #include #include +#include /* shape.h uses Region which is in here */ +#ifdef XKB +#include +#endif +#ifdef SHAPE +#include +#endif +#ifdef XINERAMA +#include +#endif +#ifdef XRANDR +#include +#endif +#ifdef SYNC +#include +#endif + G_BEGIN_DECLS +extern gboolean obt_display_error_occured; + +extern gboolean obt_display_extension_xkb; +extern gint obt_display_extension_xkb_basep; +extern gboolean obt_display_extension_shape; +extern gint obt_display_extension_shape_basep; +extern gboolean obt_display_extension_xinerama; +extern gint obt_display_extension_xinerama_basep; +extern gboolean obt_display_extension_randr; +extern gint obt_display_extension_randr_basep; +extern gboolean obt_display_extension_sync; +extern gint obt_display_extension_sync_basep; + Display* obt_display_open(const char *display_name); void obt_display_close(Display *d); void obt_display_ignore_errors(Display *d, gboolean ignore); -gboolean obt_display_error_occured(); G_END_DECLS -#endif /*__obt_instance_h*/ +#endif /*__obt_display_h*/ diff --git a/obt/obt.h b/obt/obt.h deleted file mode 100644 index 0343a6a7..00000000 --- a/obt/obt.h +++ /dev/null @@ -1,25 +0,0 @@ -/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*- - - obt.h for the Openbox window manager - Copyright (c) 2007 Dana Jansens - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - See the COPYING file for a copy of the GNU General Public License. -*/ - -#ifndef __obt_h -#define __obt_h - -#include "obt/instance.h" -#include "obt/util.h" - -#endif /*__obt_h*/ diff --git a/openbox/client.c b/openbox/client.c index 025dd129..20ccfe3d 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -26,7 +26,6 @@ #include "ping.h" #include "place.h" #include "prop.h" -#include "extensions.h" #include "frame.h" #include "session.h" #include "event.h" @@ -1262,7 +1261,7 @@ static void client_get_shaped(ObClient *self) { self->shaped = FALSE; #ifdef SHAPE - if (extensions_shape) { + if (obt_display_extension_shape) { gint foo; guint ufoo; gint s; @@ -3639,8 +3638,8 @@ gboolean client_focus(ObClient *self) obt_display_ignore_errors(ob_display, FALSE); ob_debug_type(OB_DEBUG_FOCUS, "Error focusing? %d\n", - obt_display_error_occured()); - return !obt_display_error_occured(); + obt_display_error_occured); + return !obt_display_error_occured; } static void client_present(ObClient *self, gboolean here, gboolean raise, diff --git a/openbox/event.c b/openbox/event.c index 5aa73921..63e27df6 100644 --- a/openbox/event.c +++ b/openbox/event.c @@ -39,7 +39,6 @@ #include "moveresize.h" #include "group.h" #include "stacking.h" -#include "extensions.h" #include "translate.h" #include "ping.h" #include "obt/display.h" @@ -180,7 +179,9 @@ static Window event_get_window(XEvent *e) break; default: #ifdef XKB - if (extensions_xkb && e->type == extensions_xkb_event_basep) { + if (obt_display_extension_xkb && + e->type == obt_display_extension_xkb_basep) + { switch (((XkbAnyEvent*)e)->xkb_type) { case XkbBellNotify: window = ((XkbBellNotifyEvent*)e)->window; @@ -190,8 +191,8 @@ static Window event_get_window(XEvent *e) } else #endif #ifdef SYNC - if (extensions_sync && - e->type == extensions_sync_event_basep + XSyncAlarmNotify) + if (obt_display_extension_sync && + e->type == obt_display_extension_sync_basep + XSyncAlarmNotify) { window = None; } else @@ -229,8 +230,8 @@ static void event_set_curtime(XEvent *e) break; default: #ifdef SYNC - if (extensions_sync && - e->type == extensions_sync_event_basep + XSyncAlarmNotify) + if (obt_display_extension_sync && + e->type == obt_display_extension_sync_basep + XSyncAlarmNotify) { t = ((XSyncAlarmNotifyEvent*)e)->time; } @@ -690,8 +691,8 @@ static void event_process(const XEvent *ec, gpointer data) obt_display_ignore_errors(ob_display, FALSE); } #ifdef SYNC - else if (extensions_sync && - e->type == extensions_sync_event_basep + XSyncAlarmNotify) + else if (obt_display_extension_sync && + e->type == obt_display_extension_sync_basep + XSyncAlarmNotify) { XSyncAlarmNotifyEvent *se = (XSyncAlarmNotifyEvent*)e; if (se->alarm == moveresize_alarm && moveresize_in_progress) @@ -1585,7 +1586,9 @@ static void event_handle_client(ObClient *client, XEvent *e) default: ; #ifdef SHAPE - if (extensions_shape && e->type == extensions_shape_event_basep) { + if (obt_display_extension_shape && + e->type == obt_display_extension_shape_basep) + { client->shaped = ((XShapeEvent*)e)->shaped; frame_adjust_shape(client->frame); } diff --git a/openbox/extensions.c b/openbox/extensions.c deleted file mode 100644 index d1088361..00000000 --- a/openbox/extensions.c +++ /dev/null @@ -1,133 +0,0 @@ -/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*- - - extensions.c for the Openbox window manager - Copyright (c) 2006 Mikael Magnusson - Copyright (c) 2003-2007 Dana Jansens - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - See the COPYING file for a copy of the GNU General Public License. -*/ - -#include "openbox.h" -#include "geom.h" -#include "extensions.h" -#include "screen.h" -#include "debug.h" - -gboolean extensions_xkb = FALSE; -gint extensions_xkb_event_basep; -gboolean extensions_shape = FALSE; -gint extensions_shape_event_basep; -gboolean extensions_xinerama = FALSE; -gint extensions_xinerama_event_basep; -gboolean extensions_randr = FALSE; -gint extensions_randr_event_basep; -gboolean extensions_sync = FALSE; -gint extensions_sync_event_basep; - -void extensions_query_all(void) -{ - gint junk; - (void)junk; - -#ifdef XKB - extensions_xkb = - XkbQueryExtension(ob_display, &junk, &extensions_xkb_event_basep, - &junk, NULL, NULL); - if (!extensions_xkb) - ob_debug("XKB extension is not present on the server\n"); -#endif - -#ifdef SHAPE - extensions_shape = - XShapeQueryExtension(ob_display, &extensions_shape_event_basep, - &junk); - if (!extensions_shape) - ob_debug("X Shape extension is not present on the server\n"); -#endif - -#ifdef XINERAMA - extensions_xinerama = - XineramaQueryExtension(ob_display, &extensions_xinerama_event_basep, - &junk) && XineramaIsActive(ob_display); - if (!extensions_xinerama) - ob_debug("Xinerama extension is not present on the server\n"); -#endif - -#ifdef XRANDR - extensions_randr = - XRRQueryExtension(ob_display, &extensions_randr_event_basep, - &junk); - if (!extensions_randr) - ob_debug("XRandR extension is not present on the server\n"); -#endif - -#ifdef SYNC - extensions_sync = - XSyncQueryExtension(ob_display, &extensions_sync_event_basep, - &junk) && - XSyncInitialize(ob_display, &junk, &junk); - if (!extensions_sync) - ob_debug("X Sync extension is not present on the server or is an " - "incompatible version\n"); -#endif -} - -void extensions_xinerama_screens(Rect **xin_areas, guint *nxin) -{ - guint i; - gint l, r, t, b; - if (ob_debug_xinerama) { - g_print("Using fake xinerama !\n"); - gint w = WidthOfScreen(ScreenOfDisplay(ob_display, ob_screen)); - gint h = HeightOfScreen(ScreenOfDisplay(ob_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); - } - else -#ifdef XINERAMA - if (extensions_xinerama) { - guint i; - gint n; - XineramaScreenInfo *info = XineramaQueryScreens(ob_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); - } - else -#endif - { - *nxin = 1; - *xin_areas = g_new(Rect, *nxin + 1); - RECT_SET((*xin_areas)[0], 0, 0, - WidthOfScreen(ScreenOfDisplay(ob_display, ob_screen)), - HeightOfScreen(ScreenOfDisplay(ob_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); -} diff --git a/openbox/extensions.h b/openbox/extensions.h deleted file mode 100644 index 31558740..00000000 --- a/openbox/extensions.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*- - - extensions.h for the Openbox window manager - Copyright (c) 2006 Mikael Magnusson - Copyright (c) 2003-2007 Dana Jansens - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - See the COPYING file for a copy of the GNU General Public License. -*/ - -#ifndef __extensions_h -#define __extensions_h - -#include "geom.h" - -#include -#include /* shape.h uses Region which is in here */ -#ifdef XKB -#include -#endif -#ifdef SHAPE -#include -#endif -#ifdef XINERAMA -#include -#endif -#ifdef XRANDR -#include -#endif -#ifdef SYNC -#include -#endif - -#include - -/*! Does the display have the XKB extension? */ -extern gboolean extensions_xkb; -/*! Base for events for the XKB extension */ -extern gint extensions_xkb_event_basep; - -/*! Does the display have the Shape extension? */ -extern gboolean extensions_shape; -/*! Base for events for the Shape extension */ -extern gint extensions_shape_event_basep; - -/*! Does the display have the Xinerama extension? */ -extern gboolean extensions_xinerama; -/*! Base for events for the Xinerama extension */ -extern gint extensions_xinerama_event_basep; - -/*! Does the display have the RandR extension? */ -extern gboolean extensions_randr; -/*! Base for events for the Randr extension */ -extern gint extensions_randr_event_basep; - -/*! Does the display have the Sync extension? */ -extern gboolean extensions_sync; -/*! Base for events for the Sync extension */ -extern gint extensions_sync_event_basep; - -void extensions_query_all(); - -void extensions_xinerama_screens(Rect **areas, guint *nxin); - -#endif diff --git a/openbox/frame.c b/openbox/frame.c index 2952b6c7..be8230c0 100644 --- a/openbox/frame.c +++ b/openbox/frame.c @@ -20,7 +20,6 @@ #include "frame.h" #include "client.h" #include "openbox.h" -#include "extensions.h" #include "prop.h" #include "grab.h" #include "config.h" @@ -30,6 +29,7 @@ #include "moveresize.h" #include "screen.h" #include "render/theme.h" +#include "obt/display.h" #define FRAME_EVENTMASK (EnterWindowMask | LeaveWindowMask | \ ButtonPressMask | ButtonReleaseMask | \ diff --git a/openbox/grab.c b/openbox/grab.c index d84ef94f..cfbbbe1a 100644 --- a/openbox/grab.c +++ b/openbox/grab.c @@ -180,7 +180,7 @@ void grab_button_full(guint button, guint state, Window win, guint mask, XGrabButton(ob_display, button, state | mask_list[i], win, False, mask, pointer_mode, GrabModeAsync, None, ob_cursor(cur)); obt_display_ignore_errors(ob_display, FALSE); - if (obt_display_error_occured()) + if (obt_display_error_occured) ob_debug("Failed to grab button %d modifiers %d", button, state); } @@ -202,7 +202,7 @@ void grab_key(guint keycode, guint state, Window win, gint keyboard_mode) XGrabKey(ob_display, keycode, state | mask_list[i], win, FALSE, GrabModeAsync, keyboard_mode); obt_display_ignore_errors(ob_display, FALSE); - if (obt_display_error_occured()) + if (obt_display_error_occured) ob_debug("Failed to grab keycode %d modifiers %d", keycode, state); } diff --git a/openbox/moveresize.c b/openbox/moveresize.c index 4349f748..ed70899c 100644 --- a/openbox/moveresize.c +++ b/openbox/moveresize.c @@ -31,9 +31,9 @@ #include "config.h" #include "event.h" #include "debug.h" -#include "extensions.h" #include "render/render.h" #include "render/theme.h" +#include "obt/display.h" #include #include @@ -250,7 +250,7 @@ void moveresize_start(ObClient *c, gint x, gint y, guint b, guint32 cnr) moveresize_in_progress = TRUE; #ifdef SYNC - if (config_resize_redraw && !moving && extensions_sync && + if (config_resize_redraw && !moving && obt_display_extension_sync && moveresize_client->sync_request && moveresize_client->sync_counter) { /* Initialize values for the resize syncing, and create an alarm for @@ -365,7 +365,7 @@ static void do_resize(void) } #ifdef SYNC - if (config_resize_redraw && extensions_sync && + if (config_resize_redraw && obt_display_extension_sync && moveresize_client->sync_request && moveresize_client->sync_counter) { XEvent ce; @@ -923,7 +923,7 @@ gboolean moveresize_event(XEvent *e) } } #ifdef SYNC - else if (e->type == extensions_sync_event_basep + XSyncAlarmNotify) + else if (e->type == obt_display_extension_sync_basep + XSyncAlarmNotify) { waiting_for_sync = FALSE; /* we got our sync... */ do_resize(); /* ...so try resize if there is more change pending */ diff --git a/openbox/openbox.c b/openbox/openbox.c index f00cd2bd..ec283d5c 100644 --- a/openbox/openbox.c +++ b/openbox/openbox.c @@ -37,7 +37,6 @@ #include "frame.h" #include "keyboard.h" #include "mouse.h" -#include "extensions.h" #include "menuframe.h" #include "grab.h" #include "group.h" @@ -207,9 +206,7 @@ gint main(gint argc, gchar **argv) cursors[OB_CURSOR_NORTHWEST] = load_cursor("top_left_corner", XC_top_left_corner); - prop_startup(); /* get atoms values for the display */ - extensions_query_all(); /* find which extensions are present */ if (screen_annex()) { /* it will be ours! */ do { diff --git a/openbox/screen.c b/openbox/screen.c index d287c9fc..0d891630 100644 --- a/openbox/screen.c +++ b/openbox/screen.c @@ -33,7 +33,6 @@ #include "event.h" #include "focus.h" #include "popup.h" -#include "extensions.h" #include "render/render.h" #include "gettext.h" #include "obt/display.h" @@ -110,7 +109,7 @@ static gboolean replace_wm(void) XSync(ob_display, FALSE); obt_display_ignore_errors(ob_display, FALSE); - if (obt_display_error_occured()) + if (obt_display_error_occured) current_wm_sn_owner = None; } @@ -184,7 +183,7 @@ gboolean screen_annex(void) XSelectInput(ob_display, RootWindow(ob_display, ob_screen), ROOT_EVENTMASK); obt_display_ignore_errors(ob_display, FALSE); - if (obt_display_error_occured()) { + if (obt_display_error_occured) { g_message(_("A window manager is already running on screen %d"), ob_screen); @@ -1291,6 +1290,55 @@ typedef struct { } \ } +static void get_xinerama_screens(Rect **xin_areas, guint *nxin) +{ + guint i; + gint l, r, t, b; + + if (ob_debug_xinerama) { + g_print("Using fake xinerama !\n"); + gint w = WidthOfScreen(ScreenOfDisplay(ob_display, ob_screen)); + gint h = HeightOfScreen(ScreenOfDisplay(ob_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) { + guint i; + gint n; + XineramaScreenInfo *info = XineramaQueryScreens(ob_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(ob_display, ob_screen)), + HeightOfScreen(ScreenOfDisplay(ob_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; @@ -1299,7 +1347,7 @@ void screen_update_areas(void) GSList *sit; g_free(monitor_area); - extensions_xinerama_screens(&monitor_area, &screen_num_monitors); + get_xinerama_screens(&monitor_area, &screen_num_monitors); /* set up the user-specified margins */ config_margins.top_start = RECT_LEFT(monitor_area[screen_num_monitors]);