Added an aborted try at making fullscreen work on Xinerama screen != 0
authorSam Lantinga <slouken@libsdl.org>
Mon, 30 Sep 2002 00:35:25 +0000
changeset 499f480ecd70499
parent 498 4b8ff8ac2c07
child 500 c335456c421d
Added an aborted try at making fullscreen work on Xinerama screen != 0
src/video/x11/SDL_x11modes.c
src/video/x11/SDL_x11video.c
     1.1 --- a/src/video/x11/SDL_x11modes.c	Mon Sep 16 18:38:09 2002 +0000
     1.2 +++ b/src/video/x11/SDL_x11modes.c	Mon Sep 30 00:35:25 2002 +0000
     1.3 @@ -43,7 +43,7 @@
     1.4  #include <XFree86/extensions/Xinerama.h>
     1.5  #endif 
     1.6  
     1.7 -#define MAX(a, b)	(a > b ? a : b)
     1.8 +#define MAX(a, b)        (a > b ? a : b)
     1.9  
    1.10  #ifdef XFREE86_VM
    1.11  Bool SDL_NAME(XF86VidModeGetModeInfo)(Display *dpy, int scr, SDL_NAME(XF86VidModeModeInfo) *info)
    1.12 @@ -126,41 +126,41 @@
    1.13      }
    1.14  #endif /* XFREE86_VM */
    1.15  
    1.16 -				/* XiG */
    1.17 +                                /* XiG */
    1.18  #ifdef HAVE_XIGXME
    1.19  #ifdef XIG_DEBUG
    1.20      fprintf(stderr, "XME: set_best_resolution(): w = %d, h = %d\n",
    1.21 -	    width, height);
    1.22 +            width, height);
    1.23  #endif
    1.24      if ( SDL_modelist ) {
    1.25 -	int i;
    1.26 +        int i;
    1.27  
    1.28          for ( i=0; SDL_modelist[i]; ++i ) {
    1.29 -	    if ( (SDL_modelist[i]->w >= width) &&
    1.30 +            if ( (SDL_modelist[i]->w >= width) &&
    1.31                   (SDL_modelist[i]->h >= height) ) {
    1.32 -		break;
    1.33 -	    }
    1.34 +                break;
    1.35 +            }
    1.36          }
    1.37 -	
    1.38 -	if ( SDL_modelist[i] ) { /* found one, lets try it */
    1.39 -	    int w, h;	
    1.40 +        
    1.41 +        if ( SDL_modelist[i] ) { /* found one, lets try it */
    1.42 +            int w, h;        
    1.43  
    1.44              /* check current mode so we can avoid uneccessary mode changes */
    1.45 -	    get_real_resolution(this, &w, &h);
    1.46 +            get_real_resolution(this, &w, &h);
    1.47  
    1.48 -	    if ( (SDL_modelist[i]->w != w) || (SDL_modelist[i]->h != h) ) {
    1.49 +            if ( (SDL_modelist[i]->w != w) || (SDL_modelist[i]->h != h) ) {
    1.50  # ifdef XIG_DEBUG
    1.51 -		fprintf(stderr, "XME: set_best_resolution: "
    1.52 -			"XiGMiscChangeResolution: %d %d\n",
    1.53 -			SDL_modelist[s]->w, SDL_modelist[s]->h);
    1.54 +                fprintf(stderr, "XME: set_best_resolution: "
    1.55 +                        "XiGMiscChangeResolution: %d %d\n",
    1.56 +                        SDL_modelist[s]->w, SDL_modelist[s]->h);
    1.57  # endif
    1.58 -		XiGMiscChangeResolution(SDL_Display, 
    1.59 -					SDL_Screen,
    1.60 -					0, /* view */
    1.61 -					SDL_modelist[i]->w, 
    1.62 -					SDL_modelist[i]->h, 
    1.63 -					0);
    1.64 -		XSync(SDL_Display, False);
    1.65 +                XiGMiscChangeResolution(SDL_Display, 
    1.66 +                                        SDL_Screen,
    1.67 +                                        0, /* view */
    1.68 +                                        SDL_modelist[i]->w, 
    1.69 +                                        SDL_modelist[i]->h, 
    1.70 +                                        0);
    1.71 +                XSync(SDL_Display, False);
    1.72              }
    1.73          }
    1.74      }
    1.75 @@ -189,8 +189,8 @@
    1.76          XiGMiscResolutionInfo *modelist;
    1.77  
    1.78          XiGMiscQueryResolutions(SDL_Display, SDL_Screen,
    1.79 -			        0, /* view */
    1.80 -			        &ractive, &modelist);
    1.81 +                                0, /* view */
    1.82 +                                &ractive, &modelist);
    1.83          *w = modelist[ractive].width;
    1.84          *h = modelist[ractive].height;
    1.85  #ifdef XIG_DEBUG
    1.86 @@ -232,10 +232,10 @@
    1.87  {
    1.88      XVisualInfo vi;
    1.89      if(XMatchVisualInfo(SDL_Display, SDL_Screen, depth, class, &vi)) {
    1.90 -	int n = this->hidden->nvisuals;
    1.91 -	this->hidden->visuals[n].depth = vi.depth;
    1.92 -	this->hidden->visuals[n].visual = vi.visual;
    1.93 -	this->hidden->nvisuals++;
    1.94 +        int n = this->hidden->nvisuals;
    1.95 +        this->hidden->visuals[n].depth = vi.depth;
    1.96 +        this->hidden->visuals[n].visual = vi.visual;
    1.97 +        this->hidden->nvisuals++;
    1.98      }
    1.99      return(this->hidden->nvisuals);
   1.100  }
   1.101 @@ -249,10 +249,10 @@
   1.102          template.visualid = strtol(visual_id, NULL, 0);
   1.103          vi = XGetVisualInfo(SDL_Display, VisualIDMask, &template, &nvis);
   1.104          if ( vi ) {
   1.105 -	    int n = this->hidden->nvisuals;
   1.106 -	    this->hidden->visuals[n].depth = vi->depth;
   1.107 -	    this->hidden->visuals[n].visual = vi->visual;
   1.108 -	    this->hidden->nvisuals++;
   1.109 +            int n = this->hidden->nvisuals;
   1.110 +            this->hidden->visuals[n].depth = vi->depth;
   1.111 +            this->hidden->visuals[n].visual = vi->visual;
   1.112 +            this->hidden->nvisuals++;
   1.113              XFree(vi);
   1.114          }
   1.115      }
   1.116 @@ -315,14 +315,14 @@
   1.117  #ifdef BROKEN_XFREE86_4001
   1.118  #ifdef X_XF86VidModeGetDotClocks  /* Compiled under XFree86 4.0 */
   1.119                  /* Earlier X servers hang when doing vidmode */
   1.120 -		if ( vm_major < 2 ) {
   1.121 +                if ( vm_major < 2 ) {
   1.122  #ifdef XFREE86_DEBUG
   1.123                      printf("Compiled under XFree86 4.0, server is XFree86 3.X\n");
   1.124  #endif
   1.125                      buggy_X11 = 1;
   1.126                  }
   1.127  #else
   1.128 -		/* XFree86 3.X code works with XFree86 4.0 servers */;
   1.129 +                /* XFree86 3.X code works with XFree86 4.0 servers */;
   1.130  #endif /* XFree86 4.0 */
   1.131  #endif /* XFree86 4.02 and newer are fixed wrt backwards compatibility */
   1.132          } else {
   1.133 @@ -377,69 +377,69 @@
   1.134      }
   1.135  #endif /* XFREE86_VM */
   1.136  
   1.137 -				/* XiG */
   1.138 +                                /* XiG */
   1.139  #ifdef HAVE_XIGXME
   1.140      /* first lets make sure we have the extension, and it's at least v2.0 */
   1.141      if (XiGMiscQueryVersion(SDL_Display, &xme_major, &xme_minor)) {
   1.142  #ifdef XIG_DEBUG
   1.143 -	fprintf(stderr, "XME: XiGMiscQueryVersion: V%d.%d\n",
   1.144 -		xme_major, xme_minor);
   1.145 +        fprintf(stderr, "XME: XiGMiscQueryVersion: V%d.%d\n",
   1.146 +                xme_major, xme_minor);
   1.147  #endif
   1.148 -	/* work around a XiGMisc bogosity in our version of libXext */
   1.149 -	if (xme_major == 0 && xme_major == 0) {
   1.150 -	    /* Ideally libxme would spit this out, but the problem is that
   1.151 -	       the right Query func will never be called if using the bogus
   1.152 -	       libXext version.
   1.153 -	     */
   1.154 -	    fprintf(stderr, 
   1.155 +        /* work around a XiGMisc bogosity in our version of libXext */
   1.156 +        if (xme_major == 0 && xme_major == 0) {
   1.157 +            /* Ideally libxme would spit this out, but the problem is that
   1.158 +               the right Query func will never be called if using the bogus
   1.159 +               libXext version.
   1.160 +             */
   1.161 +            fprintf(stderr, 
   1.162  "XME: If you are using Xi Graphics CDE and a Summit server, you need to\n"
   1.163  "XME: get the libXext update from our ftp site before fullscreen switching\n"
   1.164  "XME: will work.  Fullscreen switching is only supported on Summit Servers\n");
   1.165 -	  }
   1.166 +          }
   1.167      } else {
   1.168          /* not there. Bummer. */
   1.169 -	xme_major = xme_minor = 0;
   1.170 +        xme_major = xme_minor = 0;
   1.171      }
   1.172  
   1.173      modelist = NULL;
   1.174      if (xme_major >= 2 && (nummodes = XiGMiscQueryResolutions(SDL_Display, 
   1.175 -					    SDL_Screen,
   1.176 -					    0, /* view */
   1.177 -					    &ractive, 
   1.178 -					    &modelist)) > 1)
   1.179 -    {				/* then we actually have some */
   1.180 -	int j;
   1.181 +                                            SDL_Screen,
   1.182 +                                            0, /* view */
   1.183 +                                            &ractive, 
   1.184 +                                            &modelist)) > 1)
   1.185 +    {                                /* then we actually have some */
   1.186 +        int j;
   1.187  
   1.188  #ifdef XIG_DEBUG
   1.189 -	fprintf(stderr, "XME: nummodes = %d, active mode = %d\n",
   1.190 -		nummodes, ractive);
   1.191 +        fprintf(stderr, "XME: nummodes = %d, active mode = %d\n",
   1.192 +                nummodes, ractive);
   1.193  #endif
   1.194  
   1.195 -	SDL_modelist = (SDL_Rect **)malloc((nummodes+1)*sizeof(SDL_Rect *));
   1.196 +        SDL_modelist = (SDL_Rect **)malloc((nummodes+1)*sizeof(SDL_Rect *));
   1.197  
   1.198 -				/* we get the list already sorted in */
   1.199 -				/* descending order.  We'll copy it in */
   1.200 -				/* reverse order so SDL is happy */
   1.201 -	if (SDL_modelist) {
   1.202 -	    for ( i=0, j=nummodes-1; j>=0; i++, j-- ) {
   1.203 -		if ((SDL_modelist[i] = 
   1.204 -		     (SDL_Rect *)malloc(sizeof(SDL_Rect))) == NULL)
   1.205 -		  break;
   1.206 +                                /* we get the list already sorted in */
   1.207 +                                /* descending order.  We'll copy it in */
   1.208 +                                /* reverse order so SDL is happy */
   1.209 +        if (SDL_modelist) {
   1.210 +            for ( i=0, j=nummodes-1; j>=0; i++, j-- ) {
   1.211 +                if ((SDL_modelist[i] = 
   1.212 +                     (SDL_Rect *)malloc(sizeof(SDL_Rect))) == NULL)
   1.213 +                  break;
   1.214  #ifdef XIG_DEBUG
   1.215 -		fprintf(stderr, "XME: mode = %4d, w = %4d, h = %4d\n",
   1.216 -		       i, modelist[i].width, modelist[i].height);
   1.217 +                fprintf(stderr, "XME: mode = %4d, w = %4d, h = %4d\n",
   1.218 +                       i, modelist[i].width, modelist[i].height);
   1.219  #endif
   1.220 -		
   1.221 -		SDL_modelist[i]->x = 0;
   1.222 -		SDL_modelist[i]->y = 0;
   1.223 -		SDL_modelist[i]->w = modelist[j].width;
   1.224 -		SDL_modelist[i]->h = modelist[j].height;
   1.225 -		
   1.226 -	    }
   1.227 +                
   1.228 +                SDL_modelist[i]->x = 0;
   1.229 +                SDL_modelist[i]->y = 0;
   1.230 +                SDL_modelist[i]->w = modelist[j].width;
   1.231 +                SDL_modelist[i]->h = modelist[j].height;
   1.232 +                
   1.233 +            }
   1.234              SDL_modelist[i] = NULL; /* terminator */
   1.235 -	}
   1.236 -	use_xme = 1;
   1.237 -	saved_res = modelist[ractive]; /* save the current resolution */
   1.238 +        }
   1.239 +        use_xme = 1;
   1.240 +        saved_res = modelist[ractive]; /* save the current resolution */
   1.241      } else {
   1.242          use_xme = 0;
   1.243      }
   1.244 @@ -449,46 +449,46 @@
   1.245  #endif /* HAVE_XIGXME */
   1.246  
   1.247      {
   1.248 -	static int depth_list[] = { 32, 24, 16, 15, 8 };
   1.249 -	int j, np;
   1.250 -	int use_directcolor = 1;
   1.251 -	XPixmapFormatValues *pf;
   1.252 +        static int depth_list[] = { 32, 24, 16, 15, 8 };
   1.253 +        int j, np;
   1.254 +        int use_directcolor = 1;
   1.255 +        XPixmapFormatValues *pf;
   1.256  
   1.257 -	/* Search for the visuals in deepest-first order, so that the first
   1.258 -	   will be the richest one */
   1.259 -	if ( getenv("SDL_VIDEO_X11_NODIRECTCOLOR") ) {
   1.260 -		use_directcolor = 0;
   1.261 -	}
   1.262 -	this->hidden->nvisuals = 0;
   1.263 -	if ( ! add_visual_byid(this, getenv("SDL_VIDEO_X11_VISUALID")) ) {
   1.264 -		for ( i=0; i<SDL_TABLESIZE(depth_list); ++i ) {
   1.265 -			if ( depth_list[i] > 8 ) {
   1.266 -				if ( use_directcolor ) {
   1.267 -					add_visual(this, depth_list[i], DirectColor);
   1.268 -				}
   1.269 -				add_visual(this, depth_list[i], TrueColor);
   1.270 -			} else {
   1.271 -				add_visual(this, depth_list[i], PseudoColor);
   1.272 -				add_visual(this, depth_list[i], StaticColor);
   1.273 -			}
   1.274 -		}
   1.275 -	}
   1.276 -	if ( this->hidden->nvisuals == 0 ) {
   1.277 -	    SDL_SetError("Found no sufficiently capable X11 visuals");
   1.278 -	    return -1;
   1.279 -	}
   1.280 -	    
   1.281 -	/* look up the pixel quantum for each depth */
   1.282 -	pf = XListPixmapFormats(SDL_Display, &np);
   1.283 -	for(i = 0; i < this->hidden->nvisuals; i++) {
   1.284 -	    int d = this->hidden->visuals[i].depth;
   1.285 -	    for(j = 0; j < np; j++)
   1.286 -		if(pf[j].depth == d)
   1.287 -		    break;
   1.288 -	    this->hidden->visuals[i].bpp = j < np ? pf[j].bits_per_pixel : d;
   1.289 -	}
   1.290 +        /* Search for the visuals in deepest-first order, so that the first
   1.291 +           will be the richest one */
   1.292 +        if ( getenv("SDL_VIDEO_X11_NODIRECTCOLOR") ) {
   1.293 +                use_directcolor = 0;
   1.294 +        }
   1.295 +        this->hidden->nvisuals = 0;
   1.296 +        if ( ! add_visual_byid(this, getenv("SDL_VIDEO_X11_VISUALID")) ) {
   1.297 +                for ( i=0; i<SDL_TABLESIZE(depth_list); ++i ) {
   1.298 +                        if ( depth_list[i] > 8 ) {
   1.299 +                                if ( use_directcolor ) {
   1.300 +                                        add_visual(this, depth_list[i], DirectColor);
   1.301 +                                }
   1.302 +                                add_visual(this, depth_list[i], TrueColor);
   1.303 +                        } else {
   1.304 +                                add_visual(this, depth_list[i], PseudoColor);
   1.305 +                                add_visual(this, depth_list[i], StaticColor);
   1.306 +                        }
   1.307 +                }
   1.308 +        }
   1.309 +        if ( this->hidden->nvisuals == 0 ) {
   1.310 +            SDL_SetError("Found no sufficiently capable X11 visuals");
   1.311 +            return -1;
   1.312 +        }
   1.313 +            
   1.314 +        /* look up the pixel quantum for each depth */
   1.315 +        pf = XListPixmapFormats(SDL_Display, &np);
   1.316 +        for(i = 0; i < this->hidden->nvisuals; i++) {
   1.317 +            int d = this->hidden->visuals[i].depth;
   1.318 +            for(j = 0; j < np; j++)
   1.319 +                if(pf[j].depth == d)
   1.320 +                    break;
   1.321 +            this->hidden->visuals[i].bpp = j < np ? pf[j].bits_per_pixel : d;
   1.322 +        }
   1.323  
   1.324 -	XFree(pf);
   1.325 +        XFree(pf);
   1.326      }
   1.327  
   1.328      if ( SDL_modelist == NULL ) {
   1.329 @@ -535,13 +535,20 @@
   1.330      /* Query Xinerama extention */
   1.331      if ( SDL_NAME(XineramaQueryExtension)(SDL_Display, &i, &i) &&
   1.332           SDL_NAME(XineramaIsActive)(SDL_Display) ) {
   1.333 -        /* Find out which screen is the zero'th one */
   1.334 +        /* Find out which screen is the desired one */
   1.335 +        int desired = 0;
   1.336          int screens;
   1.337          SDL_NAME(XineramaScreenInfo) *xinerama;
   1.338  
   1.339  #ifdef XINERAMA_DEBUG
   1.340          printf("X11 detected Xinerama:\n");
   1.341  #endif
   1.342 +#if 0 /* Apparently the vidmode extension doesn't work with Xinerama */
   1.343 +        const char *variable = getenv("SDL_VIDEO_X11_XINERAMA_SCREEN");
   1.344 +        if ( variable ) {
   1.345 +                desired = atoi(variable);
   1.346 +        }
   1.347 +#endif
   1.348          xinerama = SDL_NAME(XineramaQueryScreens)(SDL_Display, &screens);
   1.349          for ( i = 0; i < screens; i++ ) {
   1.350  #ifdef XINERAMA_DEBUG
   1.351 @@ -550,7 +557,7 @@
   1.352                  xinerama[i].width, xinerama[i].height,
   1.353                  xinerama[i].x_org, xinerama[i].y_org);
   1.354  #endif
   1.355 -            if ( xinerama[i].screen_number == 0 ) {
   1.356 +            if ( xinerama[i].screen_number == desired ) {
   1.357                  xinerama_x = xinerama[i].x_org;
   1.358                  xinerama_y = xinerama[i].y_org;
   1.359              }
   1.360 @@ -566,8 +573,8 @@
   1.361  {
   1.362      int i;
   1.363      for(i = 0; i < this->hidden->nvisuals; i++)
   1.364 -	if(this->hidden->visuals[i].bpp == format->BitsPerPixel)
   1.365 -	    return 1;
   1.366 +        if(this->hidden->visuals[i].bpp == format->BitsPerPixel)
   1.367 +            return 1;
   1.368      return 0;
   1.369  }
   1.370  
   1.371 @@ -672,7 +679,8 @@
   1.372      if ( current_h > real_h ) {
   1.373          real_h = MAX(real_h, screen_h);
   1.374      }
   1.375 -    XMoveResizeWindow(SDL_Display, FSwindow, 0, 0, real_w, real_h);
   1.376 +    XMoveResizeWindow(SDL_Display, FSwindow,
   1.377 +                      xinerama_x, xinerama_y, real_w, real_h);
   1.378      XMapRaised(SDL_Display, FSwindow);
   1.379      X11_WaitMapped(this, FSwindow);
   1.380  
   1.381 @@ -745,22 +753,22 @@
   1.382  #endif
   1.383  
   1.384  #ifdef HAVE_XIGXME
   1.385 -	if ( use_xme ) {
   1.386 -	    int rw, rh;	
   1.387 -	    
   1.388 +        if ( use_xme ) {
   1.389 +            int rw, rh;        
   1.390 +            
   1.391              /* check current mode so we can avoid uneccessary mode changes */
   1.392 -	    get_real_resolution(this, &rw, &rh);
   1.393 +            get_real_resolution(this, &rw, &rh);
   1.394  
   1.395 -	    if (rw != saved_res.width || rh != saved_res.height) {
   1.396 -		XiGMiscChangeResolution(SDL_Display, 
   1.397 -					SDL_Screen,
   1.398 -					0, /* view */
   1.399 -					saved_res.width, 
   1.400 -					saved_res.height,
   1.401 -					0);
   1.402 -		XSync(SDL_Display, False);
   1.403 -	    }
   1.404 -	}
   1.405 +            if (rw != saved_res.width || rh != saved_res.height) {
   1.406 +                XiGMiscChangeResolution(SDL_Display, 
   1.407 +                                        SDL_Screen,
   1.408 +                                        0, /* view */
   1.409 +                                        saved_res.width, 
   1.410 +                                        saved_res.height,
   1.411 +                                        0);
   1.412 +                XSync(SDL_Display, False);
   1.413 +            }
   1.414 +        }
   1.415  #endif
   1.416  
   1.417          XUnmapWindow(SDL_Display, FSwindow);
     2.1 --- a/src/video/x11/SDL_x11video.c	Mon Sep 16 18:38:09 2002 +0000
     2.2 +++ b/src/video/x11/SDL_x11video.c	Mon Sep 30 00:35:25 2002 +0000
     2.3 @@ -282,7 +282,8 @@
     2.4      xattr.border_pixel = 0;
     2.5      xattr.colormap = SDL_XColorMap;
     2.6  
     2.7 -    FSwindow = XCreateWindow(SDL_Display, SDL_Root, 0, 0, 32, 32, 0,
     2.8 +    FSwindow = XCreateWindow(SDL_Display, SDL_Root,
     2.9 +                             xinerama_x, xinerama_y, 32, 32, 0,
    2.10  			     this->hidden->depth, InputOutput, SDL_Visual,
    2.11  			     CWOverrideRedirect | CWBackPixel | CWBorderPixel
    2.12  			     | CWColormap,