comparison src/video/x11/SDL_x11modes.c @ 242:4bcb29d3769c

Added support for Xi Graphics XME fullscreen extension
author Sam Lantinga <slouken@libsdl.org>
date Thu, 22 Nov 2001 04:55:38 +0000
parents 275a934573a7
children e8157fcb3114
comparison
equal deleted inserted replaced
241:b6084de9431a 242:4bcb29d3769c
89 return -1; 89 return -1;
90 return b->vdisplay - a->vdisplay; 90 return b->vdisplay - a->vdisplay;
91 } 91 }
92 #endif 92 #endif
93 93
94 static void get_real_resolution(_THIS, int* w, int* h);
95
94 static void set_best_resolution(_THIS, int width, int height) 96 static void set_best_resolution(_THIS, int width, int height)
95 { 97 {
96 #ifdef XFREE86_VM 98 #ifdef XFREE86_VM
97 if ( use_vidmode ) { 99 if ( use_vidmode ) {
98 XF86VidModeModeLine mode; 100 XF86VidModeModeLine mode;
121 } 123 }
122 XFree(modes); 124 XFree(modes);
123 } 125 }
124 } 126 }
125 #endif /* XFREE86_VM */ 127 #endif /* XFREE86_VM */
128
129 /* XiG */
130 #ifdef HAVE_XIGXME
131 #ifdef XIG_DEBUG
132 fprintf(stderr, "XME: set_best_resolution(): w = %d, h = %d\n",
133 width, height);
134 #endif
135 if ( SDL_modelist ) {
136 int i;
137
138 for ( i=0; SDL_modelist[i]; ++i ) {
139 if ( (SDL_modelist[i]->w >= width) &&
140 (SDL_modelist[i]->h >= height) ) {
141 break;
142 }
143 }
144
145 if ( SDL_modelist[i] ) { /* found one, lets try it */
146 int w, h;
147
148 /* check current mode so we can avoid uneccessary mode changes */
149 get_real_resolution(this, &w, &h);
150
151 if ( (SDL_modelist[i]->w != w) || (SDL_modelist[i]->h != h) ) {
152 # ifdef XIG_DEBUG
153 fprintf(stderr, "XME: set_best_resolution: "
154 "XiGMiscChangeResolution: %d %d\n",
155 SDL_modelist[s]->w, SDL_modelist[s]->h);
156 # endif
157 XiGMiscChangeResolution(SDL_Display,
158 SDL_Screen,
159 0, /* view */
160 SDL_modelist[i]->w,
161 SDL_modelist[i]->h,
162 0);
163 XSync(SDL_Display, False);
164 }
165 }
166 }
167 #endif /* HAVE_XIGXME */
168
126 } 169 }
127 170
128 static void get_real_resolution(_THIS, int* w, int* h) 171 static void get_real_resolution(_THIS, int* w, int* h)
129 { 172 {
130 #ifdef XFREE86_VM 173 #ifdef XFREE86_VM
137 *h = mode.vdisplay; 180 *h = mode.vdisplay;
138 return; 181 return;
139 } 182 }
140 } 183 }
141 #endif 184 #endif
185
186 #ifdef HAVE_XIGXME
187 if ( use_xme ) {
188 int ractive;
189 XiGMiscResolutionInfo *modelist;
190
191 XiGMiscQueryResolutions(SDL_Display, SDL_Screen,
192 0, /* view */
193 &ractive, &modelist);
194 *w = modelist[ractive].width;
195 *h = modelist[ractive].height;
196 #ifdef XIG_DEBUG
197 fprintf(stderr, "XME: get_real_resolution: w = %d h = %d\n", *w, *h);
198 #endif
199 XFree(modelist);
200 return;
201 }
202 #endif /* XIG_XME */
203
142 *w = DisplayWidth(SDL_Display, SDL_Screen); 204 *w = DisplayWidth(SDL_Display, SDL_Screen);
143 *h = DisplayHeight(SDL_Display, SDL_Screen); 205 *h = DisplayHeight(SDL_Display, SDL_Screen);
144 } 206 }
145 207
146 /* Called after mapping a window - waits until the window is mapped */ 208 /* Called after mapping a window - waits until the window is mapped */
205 #ifdef XFREE86_VM 267 #ifdef XFREE86_VM
206 int buggy_X11; 268 int buggy_X11;
207 int vm_major, vm_minor; 269 int vm_major, vm_minor;
208 int nmodes; 270 int nmodes;
209 XF86VidModeModeInfo **modes; 271 XF86VidModeModeInfo **modes;
272 #endif
273 #ifdef HAVE_XIGXME
274 int xme_major, xme_minor;
275 int ractive, nummodes;
276 XiGMiscResolutionInfo *modelist;
210 #endif 277 #endif
211 int i, n; 278 int i, n;
212 int screen_w; 279 int screen_w;
213 int screen_h; 280 int screen_h;
214 281
307 374
308 use_vidmode = vm_major * 100 + vm_minor; 375 use_vidmode = vm_major * 100 + vm_minor;
309 save_mode(this); 376 save_mode(this);
310 } 377 }
311 #endif /* XFREE86_VM */ 378 #endif /* XFREE86_VM */
379
380 /* XiG */
381 #ifdef HAVE_XIGXME
382 /* first lets make sure we have the extension, and it's at least v2.0 */
383 if (XiGMiscQueryVersion(SDL_Display, &xme_major, &xme_minor)) {
384 #ifdef XIG_DEBUG
385 fprintf(stderr, "XME: XiGMiscQueryVersion: V%d.%d\n",
386 xme_major, xme_minor);
387 #endif
388 /* work around a XiGMisc bogosity in our version of libXext */
389 if (xme_major == 0 && xme_major == 0) {
390 /* Ideally libxme would spit this out, but the problem is that
391 the right Query func will never be called if using the bogus
392 libXext version.
393 */
394 fprintf(stderr,
395 "XME: If you are using Xi Graphics CDE and a Summit server, you need to\n"
396 "XME: get the libXext update from our ftp site before fullscreen switching\n"
397 "XME: will work. Fullscreen switching is only supported on Summit Servers\n");
398 }
399 } else {
400 /* not there. Bummer. */
401 xme_major = xme_minor = 0;
402 }
403
404 modelist = NULL;
405 if (xme_major >= 2 && (nummodes = XiGMiscQueryResolutions(SDL_Display,
406 SDL_Screen,
407 0, /* view */
408 &ractive,
409 &modelist)) > 1)
410 { /* then we actually have some */
411 int j;
412
413 #ifdef XIG_DEBUG
414 fprintf(stderr, "XME: nummodes = %d, active mode = %d\n",
415 nummodes, ractive);
416 #endif
417
418 SDL_modelist = (SDL_Rect **)malloc((nummodes+1)*sizeof(SDL_Rect *));
419
420 /* we get the list already sorted in */
421 /* descending order. We'll copy it in */
422 /* reverse order so SDL is happy */
423 if (SDL_modelist) {
424 for ( i=0, j=nummodes-1; j>=0; i++, j-- ) {
425 if ((SDL_modelist[i] =
426 (SDL_Rect *)malloc(sizeof(SDL_Rect))) == NULL)
427 break;
428 #ifdef XIG_DEBUG
429 fprintf(stderr, "XME: mode = %4d, w = %4d, h = %4d\n",
430 i, modelist[i].width, modelist[i].height);
431 #endif
432
433 SDL_modelist[i]->x = 0;
434 SDL_modelist[i]->y = 0;
435 SDL_modelist[i]->w = modelist[j].width;
436 SDL_modelist[i]->h = modelist[j].height;
437
438 }
439 SDL_modelist[i] = NULL; /* terminator */
440 }
441 use_xme = 1;
442 saved_res = modelist[ractive]; /* save the current resolution */
443 } else {
444 use_xme = 0;
445 }
446 if ( modelist ) {
447 XFree(modelist);
448 }
449 #endif /* HAVE_XIGXME */
312 450
313 { 451 {
314 static int depth_list[] = { 32, 24, 16, 15, 8 }; 452 static int depth_list[] = { 32, 24, 16, 15, 8 };
315 int j, np; 453 int j, np;
316 int use_directcolor = 1; 454 int use_directcolor = 1;
367 } 505 }
368 SDL_modelist[n] = NULL; 506 SDL_modelist[n] = NULL;
369 } 507 }
370 } 508 }
371 509
372 #ifdef XFREE86_DEBUG 510 #if defined(XFREE86_DEBUG) || defined(XIG_DEBUG)
373 if ( use_vidmode ) { 511 if ( use_vidmode ) {
374 printf("XFree86 VidMode is enabled\n"); 512 printf("XFree86 VidMode is enabled\n");
375 } 513 }
514
515 #ifdef HAVE_XIGXME
516 if ( use_xme )
517 printf("Xi Graphics XME fullscreen is enabled\n");
518 else
519 printf("Xi Graphics XME fullscreen is not available\n");
520 #endif
521
376 if ( SDL_modelist ) { 522 if ( SDL_modelist ) {
377 printf("X11 video mode list:\n"); 523 printf("X11 video mode list:\n");
378 for ( i=0; SDL_modelist[i]; ++i ) { 524 for ( i=0; SDL_modelist[i]; ++i ) {
379 printf("\t%dx%d\n", SDL_modelist[i]->w, SDL_modelist[i]->h); 525 printf("\t%dx%d\n", SDL_modelist[i]->w, SDL_modelist[i]->h);
380 } 526 }
381 } 527 }
382 #endif /* XFREE86_DEBUG */ 528 #endif /* XFREE86_DEBUG || XIG_DEBUG */
383 529
384 /* The default X/Y fullscreen offset is 0/0 */ 530 /* The default X/Y fullscreen offset is 0/0 */
385 xinerama_x = 0; 531 xinerama_x = 0;
386 xinerama_y = 0; 532 xinerama_y = 0;
387 533
595 if ( use_vidmode ) { 741 if ( use_vidmode ) {
596 restore_mode(this); 742 restore_mode(this);
597 XVidMode(LockModeSwitch, (SDL_Display, SDL_Screen, False)); 743 XVidMode(LockModeSwitch, (SDL_Display, SDL_Screen, False));
598 } 744 }
599 #endif 745 #endif
746
747 #ifdef HAVE_XIGXME
748 if ( use_xme ) {
749 int rw, rh;
750
751 /* check current mode so we can avoid uneccessary mode changes */
752 get_real_resolution(this, &rw, &rh);
753
754 if (rw != saved_res.width || rh != saved_res.height) {
755 XiGMiscChangeResolution(SDL_Display,
756 SDL_Screen,
757 0, /* view */
758 saved_res.width,
759 saved_res.height,
760 0);
761 XSync(SDL_Display, False);
762 }
763 }
764 #endif
765
600 XUnmapWindow(SDL_Display, FSwindow); 766 XUnmapWindow(SDL_Display, FSwindow);
601 X11_WaitUnmapped(this, FSwindow); 767 X11_WaitUnmapped(this, FSwindow);
602 XSync(SDL_Display, True); /* Flush spurious mode change events */ 768 XSync(SDL_Display, True); /* Flush spurious mode change events */
603 currently_fullscreen = 0; 769 currently_fullscreen = 0;
604 } 770 }