On Sat, May 21, 2005 at 07:43:43PM +0100, Roger Leigh wrote:

> Hi Bill, Yann,
> 
> What does `xdpyinfo | grep RANDR` show?  My X server (FBDev) has this
> enabled.  Perhaps your server doesn't, and gcompris isn't handling
> this gracefully?

Attached is a patch (against 6.5.3) that fixes up the code to properly
cope with X servers that don't provide XRANDR.  I've tested with both
FBDev and Xnest XFree86-4.3 X servers, with and without -x, and it
now autodetects XRANDR correctly.

I've not checked this with the sarge version.  If the code isn't
vastly different, the patch should be equally applicable.


Regards,
Roger

-- 
Roger Leigh
                Printing on GNU/Linux?  http://gimp-print.sourceforge.net/
                Debian GNU/Linux        http://www.debian.org/
                GPG Public Key: 0x25BFB848.  Please sign and encrypt your mail.
--- gc.orig/gcompris-6.5.3/src/gcompris/gcompris.c      2005-04-19 
22:12:30.000000000 +0100
+++ gc/gcompris-6.5.3/src/gcompris/gcompris.c   2005-05-21 22:38:28.183117256 
+0100
@@ -151,6 +151,7 @@
 static SizeID xr_previous_size;
 static XRANDRData   *xrandr;
 
+static void xrandr_init ( XRANDRData *data );
 static void xrandr_get_config ( XRANDRData *data );
 gboolean xrandr_set_config( XRANDRData  *grandr );
 #endif
@@ -288,31 +289,33 @@
   GtkWidget *vbox;
   int i;
 
+  screen_height = gdk_screen_height();
+  screen_width  = gdk_screen_width();
+
 #ifdef XRANDR
   /* Search the 800x600 Resolution */
   if(properties->fullscreen && !properties->noxrandr) {
     g_warning("XRANDR Is compiled in. Searching a good resolution");
 
     xrandr = g_new0 (XRANDRData, 1);
-    xrandr_get_config ( xrandr );
-    xr_previous_size = (SizeID)xrandr->xr_current_size;
+    xrandr_init ( xrandr );
 
-    for (i = 0; i < xrandr->xr_nsize; i++) {
-      if(xrandr->xr_sizes[i].width == BOARDWIDTH, xrandr->xr_sizes[i].height 
== BOARDHEIGHT+BARHEIGHT) {
-       xrandr->xr_current_size = (SizeID)i;
-       xrandr_set_config( xrandr );
-       break;
+    /* Check if XRANDR is available */
+    if (!properties->noxrandr) {
+      xrandr_get_config ( xrandr );
+      xr_previous_size = (SizeID)xrandr->xr_current_size;
+
+      for (i = 0; i < xrandr->xr_nsize; i++) {
+        if(xrandr->xr_sizes[i].width == BOARDWIDTH, xrandr->xr_sizes[i].height 
== BOARDHEIGHT+BARHEIGHT) {
+         xrandr->xr_current_size = (SizeID)i;
+         xrandr_set_config( xrandr );
+         break;
+       }
       }
+      screen_height = xrandr->xr_sizes[xrandr->xr_current_size].height;
+      screen_width  = xrandr->xr_sizes[xrandr->xr_current_size].width;
     }
-    screen_height = xrandr->xr_sizes[xrandr->xr_current_size].height;
-    screen_width  = xrandr->xr_sizes[xrandr->xr_current_size].width;
-  } else {
-  screen_height = gdk_screen_height();
-  screen_width  = gdk_screen_width();
   }
-#else
-  screen_height = gdk_screen_height();
-  screen_width  = gdk_screen_width();
 #endif
 
   yratio=screen_height/(float)(BOARDHEIGHT+BARHEIGHT);
@@ -623,7 +626,7 @@
 
 #ifdef XRANDR
   /* Set back the original screen size */
-  if(properties->fullscreen) {
+  if(properties->fullscreen && !properties->noxrandr) {
     xrandr_get_config ( xrandr );      /* Need to refresh our config or xrandr 
api will reject us */
     xrandr->xr_current_size = (SizeID)xr_previous_size;
     xrandr_set_config( xrandr );
@@ -756,9 +759,22 @@
  * ------------
  */
 static void
-xrandr_get_config ( XRANDRData *data )
+xrandr_init ( XRANDRData *data )
 {
   data->xr_screen_conf = XRRGetScreenInfo (GDK_DISPLAY(), GDK_ROOT_WINDOW());
+  if (data->xr_screen_conf == NULL)
+    {
+      g_warning("XRANDR not available");
+      properties->noxrandr = TRUE;
+    }
+  else
+      g_warning("XRANDR support enabled");
+}
+       
+static void
+xrandr_get_config ( XRANDRData *data )
+{
+  xrandr_init (data);
   
   data->xr_current_size = XRRConfigCurrentConfiguration (data->xr_screen_conf, 
                                                         
&data->xr_current_rotation);

Attachment: signature.asc
Description: Digital signature

Reply via email to