Added support for Xi Graphics XME fullscreen extension
authorSam Lantinga <slouken@libsdl.org>
Thu, 22 Nov 2001 04:55:38 +0000
changeset 2424bcb29d3769c
parent 241 b6084de9431a
child 243 cf4944faad96
Added support for Xi Graphics XME fullscreen extension
configure.in
docs.html
include/SDL_opengl.h
src/video/x11/SDL_x11modes.c
src/video/x11/SDL_x11video.h
     1.1 --- a/configure.in	Thu Nov 22 03:47:16 2001 +0000
     1.2 +++ b/configure.in	Thu Nov 22 04:55:38 2001 +0000
     1.3 @@ -622,6 +622,26 @@
     1.4                      SYSTEM_LIBS="$SYSTEM_LIBS -lXinerama"
     1.5                  fi
     1.6              fi
     1.7 +            AC_ARG_ENABLE(video-x11-xme,
     1.8 +[  --enable-video-x11-xme  enable Xi Graphics XME for fullscreen [default=yes]],
     1.9 +                            , enable_video_x11_xme=yes)
    1.10 +            if test x$enable_video_x11_xme = xyes; then
    1.11 +                AC_MSG_CHECKING(for Xi Graphics XiGMiscExtension support)
    1.12 +                video_x11_xme=no
    1.13 +                AC_TRY_COMPILE([
    1.14 +                 #include <X11/Xlib.h>
    1.15 +                 #include <X11/extensions/xme.h>
    1.16 +                ],[
    1.17 +                 XiGMiscResolutionInfo *resolutions;
    1.18 +                ],[
    1.19 +                video_x11_xme=yes
    1.20 +                ])
    1.21 +                AC_MSG_RESULT($video_x11_xme)
    1.22 +                if test x$video_x11_xme = xyes; then
    1.23 +                    CFLAGS="$CFLAGS -DHAVE_XIGXME"
    1.24 +                    SYSTEM_LIBS="$SYSTEM_LIBS -lxme"
    1.25 +                fi
    1.26 +            fi
    1.27          fi
    1.28      fi
    1.29  }
     2.1 --- a/docs.html	Thu Nov 22 03:47:16 2001 +0000
     2.2 +++ b/docs.html	Thu Nov 22 04:55:38 2001 +0000
     2.3 @@ -16,6 +16,7 @@
     2.4  Major changes since SDL 1.0.0:
     2.5  </H2>
     2.6  <UL>
     2.7 +	<LI> 1.2.4: Added support for Xi Graphics XME fullscreen extension
     2.8  	<LI> 1.2.3: Added X11 Xinerama support - fullscreen starts on screen 0
     2.9  	<LI> 1.2.3: Added platform independent OpenGL header - SDL_opengl.h
    2.10  	<LI> 1.2.3: Fixed flashing the screen when creating a window on BeOS
     3.1 --- a/include/SDL_opengl.h	Thu Nov 22 03:47:16 2001 +0000
     3.2 +++ b/include/SDL_opengl.h	Thu Nov 22 04:55:38 2001 +0000
     3.3 @@ -50,7 +50,7 @@
     3.4     If you don't want this version included, simply define "NO_SDL_GLEXT"
     3.5   */
     3.6  #ifndef NO_SDL_GLEXT
     3.7 -#ifndef __glext_h_
     3.8 +#if !defined(__glext_h_) && !defined(GL_GLEXT_LEGACY)
     3.9  #define __glext_h_
    3.10  
    3.11  #ifdef __cplusplus
     4.1 --- a/src/video/x11/SDL_x11modes.c	Thu Nov 22 03:47:16 2001 +0000
     4.2 +++ b/src/video/x11/SDL_x11modes.c	Thu Nov 22 04:55:38 2001 +0000
     4.3 @@ -91,6 +91,8 @@
     4.4  }
     4.5  #endif
     4.6  
     4.7 +static void get_real_resolution(_THIS, int* w, int* h);
     4.8 +
     4.9  static void set_best_resolution(_THIS, int width, int height)
    4.10  {
    4.11  #ifdef XFREE86_VM
    4.12 @@ -123,6 +125,47 @@
    4.13          }
    4.14      }
    4.15  #endif /* XFREE86_VM */
    4.16 +
    4.17 +				/* XiG */
    4.18 +#ifdef HAVE_XIGXME
    4.19 +#ifdef XIG_DEBUG
    4.20 +    fprintf(stderr, "XME: set_best_resolution(): w = %d, h = %d\n",
    4.21 +	    width, height);
    4.22 +#endif
    4.23 +    if ( SDL_modelist ) {
    4.24 +	int i;
    4.25 +
    4.26 +        for ( i=0; SDL_modelist[i]; ++i ) {
    4.27 +	    if ( (SDL_modelist[i]->w >= width) &&
    4.28 +                 (SDL_modelist[i]->h >= height) ) {
    4.29 +		break;
    4.30 +	    }
    4.31 +        }
    4.32 +	
    4.33 +	if ( SDL_modelist[i] ) { /* found one, lets try it */
    4.34 +	    int w, h;	
    4.35 +
    4.36 +            /* check current mode so we can avoid uneccessary mode changes */
    4.37 +	    get_real_resolution(this, &w, &h);
    4.38 +
    4.39 +	    if ( (SDL_modelist[i]->w != w) || (SDL_modelist[i]->h != h) ) {
    4.40 +# ifdef XIG_DEBUG
    4.41 +		fprintf(stderr, "XME: set_best_resolution: "
    4.42 +			"XiGMiscChangeResolution: %d %d\n",
    4.43 +			SDL_modelist[s]->w, SDL_modelist[s]->h);
    4.44 +# endif
    4.45 +		XiGMiscChangeResolution(SDL_Display, 
    4.46 +					SDL_Screen,
    4.47 +					0, /* view */
    4.48 +					SDL_modelist[i]->w, 
    4.49 +					SDL_modelist[i]->h, 
    4.50 +					0);
    4.51 +		XSync(SDL_Display, False);
    4.52 +            }
    4.53 +        }
    4.54 +    }
    4.55 +#endif /* HAVE_XIGXME */
    4.56 +
    4.57  }
    4.58  
    4.59  static void get_real_resolution(_THIS, int* w, int* h)
    4.60 @@ -139,6 +182,25 @@
    4.61          }
    4.62      }
    4.63  #endif
    4.64 +
    4.65 +#ifdef HAVE_XIGXME
    4.66 +    if ( use_xme ) {
    4.67 +        int ractive;
    4.68 +        XiGMiscResolutionInfo *modelist;
    4.69 +
    4.70 +        XiGMiscQueryResolutions(SDL_Display, SDL_Screen,
    4.71 +			        0, /* view */
    4.72 +			        &ractive, &modelist);
    4.73 +        *w = modelist[ractive].width;
    4.74 +        *h = modelist[ractive].height;
    4.75 +#ifdef XIG_DEBUG
    4.76 +        fprintf(stderr, "XME: get_real_resolution: w = %d h = %d\n", *w, *h);
    4.77 +#endif
    4.78 +        XFree(modelist);
    4.79 +        return;
    4.80 +    }
    4.81 +#endif /* XIG_XME */
    4.82 +
    4.83      *w = DisplayWidth(SDL_Display, SDL_Screen);
    4.84      *h = DisplayHeight(SDL_Display, SDL_Screen);
    4.85  }
    4.86 @@ -208,6 +270,11 @@
    4.87      int nmodes;
    4.88      XF86VidModeModeInfo **modes;
    4.89  #endif
    4.90 +#ifdef HAVE_XIGXME
    4.91 +    int xme_major, xme_minor;
    4.92 +    int ractive, nummodes;
    4.93 +    XiGMiscResolutionInfo *modelist;
    4.94 +#endif
    4.95      int i, n;
    4.96      int screen_w;
    4.97      int screen_h;
    4.98 @@ -310,6 +377,77 @@
    4.99      }
   4.100  #endif /* XFREE86_VM */
   4.101  
   4.102 +				/* XiG */
   4.103 +#ifdef HAVE_XIGXME
   4.104 +    /* first lets make sure we have the extension, and it's at least v2.0 */
   4.105 +    if (XiGMiscQueryVersion(SDL_Display, &xme_major, &xme_minor)) {
   4.106 +#ifdef XIG_DEBUG
   4.107 +	fprintf(stderr, "XME: XiGMiscQueryVersion: V%d.%d\n",
   4.108 +		xme_major, xme_minor);
   4.109 +#endif
   4.110 +	/* work around a XiGMisc bogosity in our version of libXext */
   4.111 +	if (xme_major == 0 && xme_major == 0) {
   4.112 +	    /* Ideally libxme would spit this out, but the problem is that
   4.113 +	       the right Query func will never be called if using the bogus
   4.114 +	       libXext version.
   4.115 +	     */
   4.116 +	    fprintf(stderr, 
   4.117 +"XME: If you are using Xi Graphics CDE and a Summit server, you need to\n"
   4.118 +"XME: get the libXext update from our ftp site before fullscreen switching\n"
   4.119 +"XME: will work.  Fullscreen switching is only supported on Summit Servers\n");
   4.120 +	  }
   4.121 +    } else {
   4.122 +        /* not there. Bummer. */
   4.123 +	xme_major = xme_minor = 0;
   4.124 +    }
   4.125 +
   4.126 +    modelist = NULL;
   4.127 +    if (xme_major >= 2 && (nummodes = XiGMiscQueryResolutions(SDL_Display, 
   4.128 +					    SDL_Screen,
   4.129 +					    0, /* view */
   4.130 +					    &ractive, 
   4.131 +					    &modelist)) > 1)
   4.132 +    {				/* then we actually have some */
   4.133 +	int j;
   4.134 +
   4.135 +#ifdef XIG_DEBUG
   4.136 +	fprintf(stderr, "XME: nummodes = %d, active mode = %d\n",
   4.137 +		nummodes, ractive);
   4.138 +#endif
   4.139 +
   4.140 +	SDL_modelist = (SDL_Rect **)malloc((nummodes+1)*sizeof(SDL_Rect *));
   4.141 +
   4.142 +				/* we get the list already sorted in */
   4.143 +				/* descending order.  We'll copy it in */
   4.144 +				/* reverse order so SDL is happy */
   4.145 +	if (SDL_modelist) {
   4.146 +	    for ( i=0, j=nummodes-1; j>=0; i++, j-- ) {
   4.147 +		if ((SDL_modelist[i] = 
   4.148 +		     (SDL_Rect *)malloc(sizeof(SDL_Rect))) == NULL)
   4.149 +		  break;
   4.150 +#ifdef XIG_DEBUG
   4.151 +		fprintf(stderr, "XME: mode = %4d, w = %4d, h = %4d\n",
   4.152 +		       i, modelist[i].width, modelist[i].height);
   4.153 +#endif
   4.154 +		
   4.155 +		SDL_modelist[i]->x = 0;
   4.156 +		SDL_modelist[i]->y = 0;
   4.157 +		SDL_modelist[i]->w = modelist[j].width;
   4.158 +		SDL_modelist[i]->h = modelist[j].height;
   4.159 +		
   4.160 +	    }
   4.161 +            SDL_modelist[i] = NULL; /* terminator */
   4.162 +	}
   4.163 +	use_xme = 1;
   4.164 +	saved_res = modelist[ractive]; /* save the current resolution */
   4.165 +    } else {
   4.166 +        use_xme = 0;
   4.167 +    }
   4.168 +    if ( modelist ) {
   4.169 +        XFree(modelist);
   4.170 +    }
   4.171 +#endif /* HAVE_XIGXME */
   4.172 +
   4.173      {
   4.174  	static int depth_list[] = { 32, 24, 16, 15, 8 };
   4.175  	int j, np;
   4.176 @@ -369,17 +507,25 @@
   4.177          }
   4.178      }
   4.179  
   4.180 -#ifdef XFREE86_DEBUG
   4.181 +#if defined(XFREE86_DEBUG) || defined(XIG_DEBUG)
   4.182      if ( use_vidmode ) {
   4.183          printf("XFree86 VidMode is enabled\n");
   4.184      }
   4.185 +
   4.186 +#ifdef HAVE_XIGXME
   4.187 +    if ( use_xme )
   4.188 +      printf("Xi Graphics XME fullscreen is enabled\n");
   4.189 +    else
   4.190 +      printf("Xi Graphics XME fullscreen is not available\n");
   4.191 +#endif 
   4.192 +
   4.193      if ( SDL_modelist ) {
   4.194          printf("X11 video mode list:\n");
   4.195          for ( i=0; SDL_modelist[i]; ++i ) {
   4.196              printf("\t%dx%d\n", SDL_modelist[i]->w, SDL_modelist[i]->h);
   4.197          }
   4.198      }
   4.199 -#endif /* XFREE86_DEBUG */
   4.200 +#endif /* XFREE86_DEBUG || XIG_DEBUG */
   4.201  
   4.202      /* The default X/Y fullscreen offset is 0/0 */
   4.203      xinerama_x = 0;
   4.204 @@ -597,6 +743,26 @@
   4.205              XVidMode(LockModeSwitch, (SDL_Display, SDL_Screen, False));
   4.206          }
   4.207  #endif
   4.208 +
   4.209 +#ifdef HAVE_XIGXME
   4.210 +	if ( use_xme ) {
   4.211 +	    int rw, rh;	
   4.212 +	    
   4.213 +            /* check current mode so we can avoid uneccessary mode changes */
   4.214 +	    get_real_resolution(this, &rw, &rh);
   4.215 +
   4.216 +	    if (rw != saved_res.width || rh != saved_res.height) {
   4.217 +		XiGMiscChangeResolution(SDL_Display, 
   4.218 +					SDL_Screen,
   4.219 +					0, /* view */
   4.220 +					saved_res.width, 
   4.221 +					saved_res.height,
   4.222 +					0);
   4.223 +		XSync(SDL_Display, False);
   4.224 +	    }
   4.225 +	}
   4.226 +#endif
   4.227 +
   4.228          XUnmapWindow(SDL_Display, FSwindow);
   4.229          X11_WaitUnmapped(this, FSwindow);
   4.230          XSync(SDL_Display, True);   /* Flush spurious mode change events */
     5.1 --- a/src/video/x11/SDL_x11video.h	Thu Nov 22 03:47:16 2001 +0000
     5.2 +++ b/src/video/x11/SDL_x11video.h	Thu Nov 22 04:55:38 2001 +0000
     5.3 @@ -47,6 +47,9 @@
     5.4  #define XVidMode(func, args)	XF86VidMode##func args
     5.5  #endif
     5.6  #endif /* XFREE86_VM */
     5.7 +#ifdef HAVE_XIGXME
     5.8 +#include <X11/extensions/xme.h>
     5.9 +#endif
    5.10  
    5.11  #include <string.h>
    5.12  
    5.13 @@ -121,6 +124,11 @@
    5.14          int x, y;
    5.15      } saved_view;
    5.16  #endif
    5.17 +#ifdef HAVE_XIGXME /* XiG XME fullscreen */
    5.18 +    int use_xme;
    5.19 +    XiGMiscResolutionInfo saved_res;
    5.20 +#endif
    5.21 +
    5.22      int xinerama_x;
    5.23      int xinerama_y;
    5.24      int use_vidmode;
    5.25 @@ -172,6 +180,8 @@
    5.26  #define SDL_modelist		(this->hidden->modelist)
    5.27  #define saved_mode		(this->hidden->saved_mode)
    5.28  #define saved_view		(this->hidden->saved_view)
    5.29 +#define use_xme			(this->hidden->use_xme)
    5.30 +#define saved_res		(this->hidden->saved_res)
    5.31  #define xinerama_x		(this->hidden->xinerama_x)
    5.32  #define xinerama_y		(this->hidden->xinerama_y)
    5.33  #define use_vidmode		(this->hidden->use_vidmode)