Mercurial > sdl-ios-xcode
comparison src/video/x11/SDL_x11modes.c @ 1361:19418e4422cb
New configure-based build system. Still work in progress, but much improved
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 16 Feb 2006 10:11:48 +0000 |
parents | c71e05b4dc2e |
children | c0a74f199ecf |
comparison
equal
deleted
inserted
replaced
1360:70a9cfb4cf1b | 1361:19418e4422cb |
---|---|
24 | 24 |
25 #include <stdio.h> | 25 #include <stdio.h> |
26 | 26 |
27 #include "SDL_timer.h" | 27 #include "SDL_timer.h" |
28 #include "SDL_events.h" | 28 #include "SDL_events.h" |
29 #include "SDL_events_c.h" | 29 #include "../../events/SDL_events_c.h" |
30 #include "SDL_x11video.h" | 30 #include "SDL_x11video.h" |
31 #include "SDL_x11wm_c.h" | 31 #include "SDL_x11wm_c.h" |
32 #include "SDL_x11modes_c.h" | 32 #include "SDL_x11modes_c.h" |
33 #include "SDL_x11image_c.h" | 33 #include "SDL_x11image_c.h" |
34 | 34 |
35 #ifdef HAVE_XINERAMA | 35 #if SDL_VIDEO_DRIVER_X11_XINERAMA |
36 #include <Xext/extensions/Xinerama.h> | 36 #include "../Xext/extensions/Xinerama.h" |
37 #endif | 37 #endif |
38 | 38 |
39 #define MAX(a, b) (a > b ? a : b) | 39 #define MAX(a, b) (a > b ? a : b) |
40 | 40 |
41 #ifdef XFREE86_VM | 41 #if SDL_VIDEO_DRIVER_X11_VIDMODE |
42 Bool SDL_NAME(XF86VidModeGetModeInfo)(Display *dpy, int scr, SDL_NAME(XF86VidModeModeInfo) *info) | 42 Bool SDL_NAME(XF86VidModeGetModeInfo)(Display *dpy, int scr, SDL_NAME(XF86VidModeModeInfo) *info) |
43 { | 43 { |
44 SDL_NAME(XF86VidModeModeLine) *l = (SDL_NAME(XF86VidModeModeLine)*)((char*)info + sizeof info->dotclock); | 44 SDL_NAME(XF86VidModeModeLine) *l = (SDL_NAME(XF86VidModeModeLine)*)((char*)info + sizeof info->dotclock); |
45 return SDL_NAME(XF86VidModeGetModeLine)(dpy, scr, (int*)&info->dotclock, l); | 45 return SDL_NAME(XF86VidModeGetModeLine)(dpy, scr, (int*)&info->dotclock, l); |
46 } | 46 } |
47 #endif /* XFREE86_VM */ | 47 #endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */ |
48 | 48 |
49 #ifdef XFREE86_VM | 49 #if SDL_VIDEO_DRIVER_X11_VIDMODE |
50 static void save_mode(_THIS) | 50 static void save_mode(_THIS) |
51 { | 51 { |
52 SDL_memset(&saved_mode, 0, sizeof(saved_mode)); | 52 SDL_memset(&saved_mode, 0, sizeof(saved_mode)); |
53 SDL_NAME(XF86VidModeGetModeInfo)(SDL_Display,SDL_Screen,&saved_mode); | 53 SDL_NAME(XF86VidModeGetModeInfo)(SDL_Display,SDL_Screen,&saved_mode); |
54 SDL_NAME(XF86VidModeGetViewPort)(SDL_Display,SDL_Screen,&saved_view.x,&saved_view.y); | 54 SDL_NAME(XF86VidModeGetViewPort)(SDL_Display,SDL_Screen,&saved_view.x,&saved_view.y); |
55 } | 55 } |
56 #endif | 56 #endif |
57 | 57 |
58 #ifdef XFREE86_VM | 58 #if SDL_VIDEO_DRIVER_X11_VIDMODE |
59 static void restore_mode(_THIS) | 59 static void restore_mode(_THIS) |
60 { | 60 { |
61 SDL_NAME(XF86VidModeModeLine) mode; | 61 SDL_NAME(XF86VidModeModeLine) mode; |
62 int unused; | 62 int unused; |
63 | 63 |
71 SDL_NAME(XF86VidModeSetViewPort)(SDL_Display, SDL_Screen, saved_view.x, saved_view.y); | 71 SDL_NAME(XF86VidModeSetViewPort)(SDL_Display, SDL_Screen, saved_view.x, saved_view.y); |
72 } | 72 } |
73 } | 73 } |
74 #endif | 74 #endif |
75 | 75 |
76 #ifdef XFREE86_VM | 76 #if SDL_VIDEO_DRIVER_X11_VIDMODE |
77 static int cmpmodes(const void *va, const void *vb) | 77 static int cmpmodes(const void *va, const void *vb) |
78 { | 78 { |
79 const SDL_NAME(XF86VidModeModeInfo) *a = *(const SDL_NAME(XF86VidModeModeInfo)**)va; | 79 const SDL_NAME(XF86VidModeModeInfo) *a = *(const SDL_NAME(XF86VidModeModeInfo)**)va; |
80 const SDL_NAME(XF86VidModeModeInfo) *b = *(const SDL_NAME(XF86VidModeModeInfo)**)vb; | 80 const SDL_NAME(XF86VidModeModeInfo) *b = *(const SDL_NAME(XF86VidModeModeInfo)**)vb; |
81 if ( a->hdisplay == b->hdisplay ) | 81 if ( a->hdisplay == b->hdisplay ) |
87 | 87 |
88 static void get_real_resolution(_THIS, int* w, int* h); | 88 static void get_real_resolution(_THIS, int* w, int* h); |
89 | 89 |
90 static void set_best_resolution(_THIS, int width, int height) | 90 static void set_best_resolution(_THIS, int width, int height) |
91 { | 91 { |
92 #ifdef XFREE86_VM | 92 #if SDL_VIDEO_DRIVER_X11_VIDMODE |
93 if ( use_vidmode ) { | 93 if ( use_vidmode ) { |
94 SDL_NAME(XF86VidModeModeLine) mode; | 94 SDL_NAME(XF86VidModeModeLine) mode; |
95 SDL_NAME(XF86VidModeModeInfo) **modes; | 95 SDL_NAME(XF86VidModeModeInfo) **modes; |
96 int i; | 96 int i; |
97 int best_width = 0, best_height = 0; | 97 int best_width = 0, best_height = 0; |
135 SDL_NAME(XF86VidModeSwitchToMode)(SDL_Display, SDL_Screen, modes[i]); | 135 SDL_NAME(XF86VidModeSwitchToMode)(SDL_Display, SDL_Screen, modes[i]); |
136 } | 136 } |
137 pXFree(modes); | 137 pXFree(modes); |
138 } | 138 } |
139 } | 139 } |
140 #endif /* XFREE86_VM */ | 140 #endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */ |
141 | 141 |
142 /* XiG */ | 142 /* XiG */ |
143 #ifdef HAVE_XIGXME | 143 #if SDL_VIDEO_DRIVER_X11_XME |
144 #ifdef XIG_DEBUG | 144 #ifdef XIG_DEBUG |
145 fprintf(stderr, "XME: set_best_resolution(): w = %d, h = %d\n", | 145 fprintf(stderr, "XME: set_best_resolution(): w = %d, h = %d\n", |
146 width, height); | 146 width, height); |
147 #endif | 147 #endif |
148 if ( SDL_modelist ) { | 148 if ( SDL_modelist ) { |
175 0); | 175 0); |
176 pXSync(SDL_Display, False); | 176 pXSync(SDL_Display, False); |
177 } | 177 } |
178 } | 178 } |
179 } | 179 } |
180 #endif /* HAVE_XIGXME */ | 180 #endif /* SDL_VIDEO_DRIVER_X11_XME */ |
181 | 181 |
182 } | 182 } |
183 | 183 |
184 static void get_real_resolution(_THIS, int* w, int* h) | 184 static void get_real_resolution(_THIS, int* w, int* h) |
185 { | 185 { |
186 #ifdef XFREE86_VM | 186 #if SDL_VIDEO_DRIVER_X11_VIDMODE |
187 if ( use_vidmode ) { | 187 if ( use_vidmode ) { |
188 SDL_NAME(XF86VidModeModeLine) mode; | 188 SDL_NAME(XF86VidModeModeLine) mode; |
189 int unused; | 189 int unused; |
190 | 190 |
191 if ( SDL_NAME(XF86VidModeGetModeLine)(SDL_Display, SDL_Screen, &unused, &mode) ) { | 191 if ( SDL_NAME(XF86VidModeGetModeLine)(SDL_Display, SDL_Screen, &unused, &mode) ) { |
194 return; | 194 return; |
195 } | 195 } |
196 } | 196 } |
197 #endif | 197 #endif |
198 | 198 |
199 #ifdef HAVE_XIGXME | 199 #if SDL_VIDEO_DRIVER_X11_XME |
200 if ( use_xme ) { | 200 if ( use_xme ) { |
201 int ractive; | 201 int ractive; |
202 XiGMiscResolutionInfo *modelist; | 202 XiGMiscResolutionInfo *modelist; |
203 | 203 |
204 XiGMiscQueryResolutions(SDL_Display, SDL_Screen, | 204 XiGMiscQueryResolutions(SDL_Display, SDL_Screen, |
275 /* Global for the error handler */ | 275 /* Global for the error handler */ |
276 int vm_event, vm_error = -1; | 276 int vm_event, vm_error = -1; |
277 | 277 |
278 int X11_GetVideoModes(_THIS) | 278 int X11_GetVideoModes(_THIS) |
279 { | 279 { |
280 #ifdef XFREE86_VM | 280 #if SDL_VIDEO_DRIVER_X11_VIDMODE |
281 int buggy_X11; | 281 int buggy_X11; |
282 int vm_major, vm_minor; | 282 int vm_major, vm_minor; |
283 int nmodes; | 283 int nmodes; |
284 SDL_NAME(XF86VidModeModeInfo) **modes; | 284 SDL_NAME(XF86VidModeModeInfo) **modes; |
285 #endif | 285 #endif |
286 #ifdef HAVE_XIGXME | 286 #if SDL_VIDEO_DRIVER_X11_XME |
287 int xme_major, xme_minor; | 287 int xme_major, xme_minor; |
288 int ractive, nummodes; | 288 int ractive, nummodes; |
289 XiGMiscResolutionInfo *modelist; | 289 XiGMiscResolutionInfo *modelist; |
290 #endif | 290 #endif |
291 int i, n; | 291 int i, n; |
295 vm_error = -1; | 295 vm_error = -1; |
296 use_vidmode = 0; | 296 use_vidmode = 0; |
297 screen_w = DisplayWidth(SDL_Display, SDL_Screen); | 297 screen_w = DisplayWidth(SDL_Display, SDL_Screen); |
298 screen_h = DisplayHeight(SDL_Display, SDL_Screen); | 298 screen_h = DisplayHeight(SDL_Display, SDL_Screen); |
299 | 299 |
300 #ifdef XFREE86_VM | 300 #if SDL_VIDEO_DRIVER_X11_VIDMODE |
301 /* Metro-X 4.3.0 and earlier has a broken implementation of | 301 /* Metro-X 4.3.0 and earlier has a broken implementation of |
302 XF86VidModeGetAllModeLines() - it hangs the client. | 302 XF86VidModeGetAllModeLines() - it hangs the client. |
303 */ | 303 */ |
304 buggy_X11 = 0; | 304 buggy_X11 = 0; |
305 if ( SDL_strcmp(ServerVendor(SDL_Display), "Metro Link Incorporated") == 0 ) { | 305 if ( SDL_strcmp(ServerVendor(SDL_Display), "Metro Link Incorporated") == 0 ) { |
405 pXFree(modes); | 405 pXFree(modes); |
406 | 406 |
407 use_vidmode = vm_major * 100 + vm_minor; | 407 use_vidmode = vm_major * 100 + vm_minor; |
408 save_mode(this); | 408 save_mode(this); |
409 } | 409 } |
410 #endif /* XFREE86_VM */ | 410 #endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */ |
411 | 411 |
412 /* XiG */ | 412 /* XiG */ |
413 #ifdef HAVE_XIGXME | 413 #if SDL_VIDEO_DRIVER_X11_XME |
414 /* first lets make sure we have the extension, and it's at least v2.0 */ | 414 /* first lets make sure we have the extension, and it's at least v2.0 */ |
415 if (XiGMiscQueryVersion(SDL_Display, &xme_major, &xme_minor)) { | 415 if (XiGMiscQueryVersion(SDL_Display, &xme_major, &xme_minor)) { |
416 #ifdef XIG_DEBUG | 416 #ifdef XIG_DEBUG |
417 fprintf(stderr, "XME: XiGMiscQueryVersion: V%d.%d\n", | 417 fprintf(stderr, "XME: XiGMiscQueryVersion: V%d.%d\n", |
418 xme_major, xme_minor); | 418 xme_major, xme_minor); |
476 use_xme = 0; | 476 use_xme = 0; |
477 } | 477 } |
478 if ( modelist ) { | 478 if ( modelist ) { |
479 pXFree(modelist); | 479 pXFree(modelist); |
480 } | 480 } |
481 #endif /* HAVE_XIGXME */ | 481 #endif /* SDL_VIDEO_DRIVER_X11_XME */ |
482 | 482 |
483 { | 483 { |
484 static int depth_list[] = { 32, 24, 16, 15, 8 }; | 484 static int depth_list[] = { 32, 24, 16, 15, 8 }; |
485 int j, np; | 485 int j, np; |
486 int use_directcolor = 1; | 486 int use_directcolor = 1; |
542 #if defined(XFREE86_DEBUG) || defined(XIG_DEBUG) | 542 #if defined(XFREE86_DEBUG) || defined(XIG_DEBUG) |
543 if ( use_vidmode ) { | 543 if ( use_vidmode ) { |
544 printf("XFree86 VidMode is enabled\n"); | 544 printf("XFree86 VidMode is enabled\n"); |
545 } | 545 } |
546 | 546 |
547 #ifdef HAVE_XIGXME | 547 #if SDL_VIDEO_DRIVER_X11_XME |
548 if ( use_xme ) | 548 if ( use_xme ) |
549 printf("Xi Graphics XME fullscreen is enabled\n"); | 549 printf("Xi Graphics XME fullscreen is enabled\n"); |
550 else | 550 else |
551 printf("Xi Graphics XME fullscreen is not available\n"); | 551 printf("Xi Graphics XME fullscreen is not available\n"); |
552 #endif | 552 #endif |
561 | 561 |
562 /* The default X/Y fullscreen offset is 0/0 */ | 562 /* The default X/Y fullscreen offset is 0/0 */ |
563 xinerama_x = 0; | 563 xinerama_x = 0; |
564 xinerama_y = 0; | 564 xinerama_y = 0; |
565 | 565 |
566 #ifdef HAVE_XINERAMA | 566 #if SDL_VIDEO_DRIVER_X11_XINERAMA |
567 /* Query Xinerama extention */ | 567 /* Query Xinerama extention */ |
568 if ( SDL_NAME(XineramaQueryExtension)(SDL_Display, &i, &i) && | 568 if ( SDL_NAME(XineramaQueryExtension)(SDL_Display, &i, &i) && |
569 SDL_NAME(XineramaIsActive)(SDL_Display) ) { | 569 SDL_NAME(XineramaIsActive)(SDL_Display) ) { |
570 /* Find out which screen is the desired one */ | 570 /* Find out which screen is the desired one */ |
571 int desired = 0; | 571 int desired = 0; |
594 xinerama_y = xinerama[i].y_org; | 594 xinerama_y = xinerama[i].y_org; |
595 } | 595 } |
596 } | 596 } |
597 pXFree(xinerama); | 597 pXFree(xinerama); |
598 } | 598 } |
599 #endif /* HAVE_XINERAMA */ | 599 #endif /* SDL_VIDEO_DRIVER_X11_XINERAMA */ |
600 | 600 |
601 return 0; | 601 return 0; |
602 } | 602 } |
603 | 603 |
604 int X11_SupportedVisual(_THIS, SDL_PixelFormat *format) | 604 int X11_SupportedVisual(_THIS, SDL_PixelFormat *format) |
738 } | 738 } |
739 #else | 739 #else |
740 pXRaiseWindow(SDL_Display, FSwindow); | 740 pXRaiseWindow(SDL_Display, FSwindow); |
741 #endif | 741 #endif |
742 | 742 |
743 #ifdef XFREE86_VM | 743 #if SDL_VIDEO_DRIVER_X11_VIDMODE |
744 /* Save the current video mode */ | 744 /* Save the current video mode */ |
745 if ( use_vidmode ) { | 745 if ( use_vidmode ) { |
746 SDL_NAME(XF86VidModeLockModeSwitch)(SDL_Display, SDL_Screen, True); | 746 SDL_NAME(XF86VidModeLockModeSwitch)(SDL_Display, SDL_Screen, True); |
747 } | 747 } |
748 #endif | 748 #endif |
775 | 775 |
776 int X11_LeaveFullScreen(_THIS) | 776 int X11_LeaveFullScreen(_THIS) |
777 { | 777 { |
778 if ( currently_fullscreen ) { | 778 if ( currently_fullscreen ) { |
779 pXReparentWindow(SDL_Display, SDL_Window, WMwindow, 0, 0); | 779 pXReparentWindow(SDL_Display, SDL_Window, WMwindow, 0, 0); |
780 #ifdef XFREE86_VM | 780 #if SDL_VIDEO_DRIVER_X11_VIDMODE |
781 if ( use_vidmode ) { | 781 if ( use_vidmode ) { |
782 restore_mode(this); | 782 restore_mode(this); |
783 SDL_NAME(XF86VidModeLockModeSwitch)(SDL_Display, SDL_Screen, False); | 783 SDL_NAME(XF86VidModeLockModeSwitch)(SDL_Display, SDL_Screen, False); |
784 } | 784 } |
785 #endif | 785 #endif |
786 | 786 |
787 #ifdef HAVE_XIGXME | 787 #if SDL_VIDEO_DRIVER_X11_XME |
788 if ( use_xme ) { | 788 if ( use_xme ) { |
789 int rw, rh; | 789 int rw, rh; |
790 | 790 |
791 /* check current mode so we can avoid uneccessary mode changes */ | 791 /* check current mode so we can avoid uneccessary mode changes */ |
792 get_real_resolution(this, &rw, &rh); | 792 get_real_resolution(this, &rw, &rh); |