
$FreeBSD$

--- gdk/x11/gdkdisplay-x11.c.orig
+++ gdk/x11/gdkdisplay-x11.c
@@ -1974,11 +1974,23 @@
 				      Window      xrootwin)
 {
   GdkScreen *screen = gdk_display_get_default_screen (display);
+  XWindowAttributes attrs;
+  gboolean result;
+  GdkX11Display *display_x11;
 
   if (GDK_SCREEN_XROOTWIN (screen) == xrootwin)
     return screen;
 
-  return NULL;
+  display_x11 = GDK_X11_DISPLAY (display);
+
+  gdk_x11_display_error_trap_push (display);
+  result = XGetWindowAttributes (display_x11->xdisplay, xrootwin, &attrs);
+  if (gdk_x11_display_error_trap_pop (display) || !result)
+	  return NULL;
+
+  screen = _gdk_x11_screen_new (display, XScreenNumberOfScreen(attrs.screen));
+
+  return screen;
 }
 
 /**
