From 3b295beaedabd0bbacb3c4072738cd218b5f7eca Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Sun, 23 Mar 2008 17:58:10 +0000 Subject: [PATCH] Fix Xinerama detection --- common/xscreen.c | 24 ++++++++++++++++-------- common/xutil.c | 16 ---------------- common/xutil.h | 1 - 3 files changed, 16 insertions(+), 25 deletions(-) diff --git a/common/xscreen.c b/common/xscreen.c index 4b2c62390..2c0a4590f 100644 --- a/common/xscreen.c +++ b/common/xscreen.c @@ -78,15 +78,24 @@ screensinfo_new(xcb_connection_t *conn) int xinerama_screen_number, screen, screen_to_test; xcb_screen_t *s; bool drop; + xcb_xinerama_is_active_reply_t *r = NULL; si = p_new(ScreensInfo, 1); - xsq = xcb_xinerama_query_screens_reply(conn, - xcb_xinerama_query_screens_unchecked(conn), - NULL); - - if((si->xinerama_is_active = xinerama_is_active(conn)) && xsq) + /* Check for extension before checking for Xinerama */ + if(xcb_get_extension_data(conn, &xcb_xinerama_id)->present) { + r = xcb_xinerama_is_active_reply(conn, xcb_xinerama_is_active(conn), NULL); + si->xinerama_is_active = r->state; + p_delete(&r); + } + + if(si->xinerama_is_active) + { + xsq = xcb_xinerama_query_screens_reply(conn, + xcb_xinerama_query_screens_unchecked(conn), + NULL); + xsi = xcb_xinerama_query_screens_screen_info(xsq); xinerama_screen_number = xcb_xinerama_query_screens_screen_info_length(xsq); @@ -121,6 +130,8 @@ screensinfo_new(xcb_connection_t *conn) p_delete(&si->geometry); si->geometry = newgeometry; } + + p_delete(&xsq); } else { @@ -136,9 +147,6 @@ screensinfo_new(xcb_connection_t *conn) } } - if(xsq) - p_delete(&xsq); - return si; } diff --git a/common/xutil.c b/common/xutil.c index 2071056b9..426b003b4 100644 --- a/common/xutil.c +++ b/common/xutil.c @@ -132,22 +132,6 @@ x_get_transient_for_hint(xcb_connection_t *c, xcb_window_t win, return true; } -bool -xinerama_is_active(xcb_connection_t *c) -{ - bool ret; - xcb_xinerama_is_active_reply_t *r = NULL; - - r = xcb_xinerama_is_active_reply(c, xcb_xinerama_is_active(c), NULL); - if(!r) - return false; - - ret = r->state; - p_delete(&r); - - return ret; -} - xcb_window_t root_window(xcb_connection_t *c, int screen_number) { diff --git a/common/xutil.h b/common/xutil.h index 3f5ad99e6..bd6e28d3a 100644 --- a/common/xutil.h +++ b/common/xutil.h @@ -77,7 +77,6 @@ unsigned int xgetnumlockmask(xcb_connection_t *); /* Common function defined in Xlib but not in XCB */ bool x_get_transient_for_hint(xcb_connection_t *, xcb_window_t, xcb_window_t *); -bool xinerama_is_active(xcb_connection_t *); xcb_window_t root_window(xcb_connection_t *, int); typedef struct _class_hint_t