I had a quick look in RandR's Xinerama implementation and noticed it
doesn't seem to treat having no monitors as a cause for concern at all,
which supports my guess that it's a transitional state that the driver
will go through when it's shut down both outputs and not yet brought them
back up.

Here's a patch which I believe should do something more useful. If
Xinerama says we have no monitors, it uses the default non-Xinerama
behaviour, which I believe treats the screen like a single monitor
the size of the virtual screen, or something (this seems like a
tolerable fallback - just keeping the old configuration for the moment would
be another possibility). When the CRTC comes back up, RandR hopefully emits
another "screen size changed" event, GDK notices and re-enables Xinerama-ish
behaviour, and all is well with the world.

It seems to work for me, anyway, but it's 4am here so please review it
carefully!

Hope this helps,
        Simon
--- gtk+2.0-2.10.11.orig/gdk/x11/gdkscreen-x11.c
+++ gtk+2.0-2.10.11/gdk/x11/gdkscreen-x11.c
@@ -600,16 +601,20 @@
       GdkScreenX11 *screen_x11 = GDK_SCREEN_X11 (screen);
       XineramaScreenInfo *monitors = XineramaQueryScreens (GDK_SCREEN_XDISPLAY (screen),
 							   &screen_x11->num_monitors);
-      if (screen_x11->num_monitors <= 0)
+      if (screen_x11->num_monitors <= 0 || monitors == NULL)
 	{
-	  /* FIXME: We need to trap errors, since XINERAMA isn't always XINERAMA.
-	   *        I don't think the num_monitors <= 0 check has any validity.
-	   */ 
-	  g_error ("error while retrieving Xinerama information");
+	  /* If Xinerama doesn't think we have any monitors, try acting as
+	   * though we had no Xinerama. If the "no monitors" condition
+	   * is because XRandR 1.2 is currently switching between CRTCs,
+	   * we'll be notified again when we have our monitor back,
+	   * and can go back into Xinerama-ish mode at that point. */
+	  if (monitors)
+	    XFree (monitors);
+	  return FALSE;
 	}
       else
 	{
 	  int i;
 	  screen_x11->monitors = g_new0 (GdkRectangle, screen_x11->num_monitors);
 	  
 	  for (i = 0; i < screen_x11->num_monitors; i++)

Attachment: signature.asc
Description: Digital signature

Reply via email to