From 8c3f2a8e0378ff5d649ce831b995669874fd1056 Mon Sep 17 00:00:00 2001
From: Tomas Janousek <tomi@nomi.cz>
Date: Mon, 9 Jul 2007 16:45:47 +0200
Subject: Deal with XineramaQueryScreens failure.

The call to XineramaQueryScreens may return NULL in some cases. This patch
tries to deal with that somehow.

Signed-off-by: Tomas Janousek <tomi@nomi.cz>
---
 src/Screen.cc | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/Screen.cc b/src/Screen.cc
index 2e8c265..c6379a0 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -1955,6 +1955,7 @@ void BScreen::initXinerama() {
     Display *display = FbTk::App::instance()->display();
 
     if (!XineramaIsActive(display)) {
+notactive:
 #ifdef DEBUG
         cerr<<"BScreen::initXinerama(): dont have Xinerama"<<endl;
 #endif // DEBUG
@@ -1973,6 +1974,17 @@ void BScreen::initXinerama() {
     XineramaScreenInfo *screen_info;
     int number;
     screen_info = XineramaQueryScreens(display, &number);
+
+    /* The call may have actually failed. If this is the first time we init
+     * Xinerama, fall back to turning it off. If not, pretend nothing
+     * happened -- another event will tell us and it will work then. */
+    if (!screen_info) {
+        if (m_xinerama_headinfo)
+            return;
+        else
+            goto notactive;
+    }
+
     if (m_xinerama_headinfo)
         delete [] m_xinerama_headinfo;
     m_xinerama_headinfo = new XineramaHeadInfo[number];
-- 
cgit v0.11.2