Mercurial > sdl-ios-xcode
comparison src/video/x11/SDL_x11modes.c @ 292:eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Incorporated XFree86 extension libraries into the source
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 05 Mar 2002 19:55:32 +0000 |
parents | e8157fcb3114 |
children | f6ffac90895c |
comparison
equal
deleted
inserted
replaced
291:68a8a8237c09 | 292:eadc0746dfaf |
---|---|
38 #include "SDL_x11wm_c.h" | 38 #include "SDL_x11wm_c.h" |
39 #include "SDL_x11modes_c.h" | 39 #include "SDL_x11modes_c.h" |
40 #include "SDL_x11image_c.h" | 40 #include "SDL_x11image_c.h" |
41 | 41 |
42 #ifdef HAVE_XINERAMA | 42 #ifdef HAVE_XINERAMA |
43 #include <X11/extensions/Xinerama.h> | 43 #include <XFree86/extensions/Xinerama.h> |
44 #endif | 44 #endif |
45 | 45 |
46 #define MAX(a, b) (a > b ? a : b) | 46 #define MAX(a, b) (a > b ? a : b) |
47 | 47 |
48 #ifdef XFREE86_VM | 48 #ifdef XFREE86_VM |
49 Bool XVidMode(GetModeInfo, (Display *dpy, int scr, XF86VidModeModeInfo *info)) | 49 Bool SDL_NAME(XF86VidModeGetModeInfo)(Display *dpy, int scr, SDL_NAME(XF86VidModeModeInfo) *info) |
50 { | 50 { |
51 XF86VidModeModeLine *l = (XF86VidModeModeLine*)((char*)info + sizeof info->dotclock); | 51 SDL_NAME(XF86VidModeModeLine) *l = (SDL_NAME(XF86VidModeModeLine)*)((char*)info + sizeof info->dotclock); |
52 return XVidMode(GetModeLine, (dpy, scr, &info->dotclock, l)); | 52 return SDL_NAME(XF86VidModeGetModeLine)(dpy, scr, &info->dotclock, l); |
53 } | 53 } |
54 #endif /* XFREE86_VM */ | 54 #endif /* XFREE86_VM */ |
55 | 55 |
56 #ifdef XFREE86_VM | 56 #ifdef XFREE86_VM |
57 static void save_mode(_THIS) | 57 static void save_mode(_THIS) |
58 { | 58 { |
59 memset(&saved_mode, 0, sizeof(saved_mode)); | 59 memset(&saved_mode, 0, sizeof(saved_mode)); |
60 XVidMode(GetModeInfo, (SDL_Display,SDL_Screen,&saved_mode)); | 60 SDL_NAME(XF86VidModeGetModeInfo)(SDL_Display,SDL_Screen,&saved_mode); |
61 XVidMode(GetViewPort, (SDL_Display,SDL_Screen,&saved_view.x,&saved_view.y)); | 61 SDL_NAME(XF86VidModeGetViewPort)(SDL_Display,SDL_Screen,&saved_view.x,&saved_view.y); |
62 } | 62 } |
63 #endif | 63 #endif |
64 | 64 |
65 #ifdef XFREE86_VM | 65 #ifdef XFREE86_VM |
66 static void restore_mode(_THIS) | 66 static void restore_mode(_THIS) |
67 { | 67 { |
68 XF86VidModeModeLine mode; | 68 SDL_NAME(XF86VidModeModeLine) mode; |
69 int unused; | 69 int unused; |
70 | 70 |
71 if ( XVidMode(GetModeLine, (SDL_Display, SDL_Screen, &unused, &mode)) ) { | 71 if ( SDL_NAME(XF86VidModeGetModeLine)(SDL_Display, SDL_Screen, &unused, &mode) ) { |
72 if ( (saved_mode.hdisplay != mode.hdisplay) || | 72 if ( (saved_mode.hdisplay != mode.hdisplay) || |
73 (saved_mode.vdisplay != mode.vdisplay) ) { | 73 (saved_mode.vdisplay != mode.vdisplay) ) { |
74 XVidMode(SwitchToMode, (SDL_Display, SDL_Screen, &saved_mode)); | 74 SDL_NAME(XF86VidModeSwitchToMode)(SDL_Display, SDL_Screen, &saved_mode); |
75 } | 75 } |
76 } | 76 } |
77 if ( (saved_view.x != 0) || (saved_view.y != 0) ) { | 77 if ( (saved_view.x != 0) || (saved_view.y != 0) ) { |
78 XVidMode(SetViewPort, (SDL_Display, SDL_Screen, saved_view.x, saved_view.y)); | 78 SDL_NAME(XF86VidModeSetViewPort)(SDL_Display, SDL_Screen, saved_view.x, saved_view.y); |
79 } | 79 } |
80 } | 80 } |
81 #endif | 81 #endif |
82 | 82 |
83 #ifdef XFREE86_VM | 83 #ifdef XFREE86_VM |
84 static int cmpmodes(const void *va, const void *vb) | 84 static int cmpmodes(const void *va, const void *vb) |
85 { | 85 { |
86 const XF86VidModeModeInfo *a = *(const XF86VidModeModeInfo**)va; | 86 const SDL_NAME(XF86VidModeModeInfo) *a = *(const SDL_NAME(XF86VidModeModeInfo)**)va; |
87 const XF86VidModeModeInfo *b = *(const XF86VidModeModeInfo**)vb; | 87 const SDL_NAME(XF86VidModeModeInfo) *b = *(const SDL_NAME(XF86VidModeModeInfo)**)vb; |
88 if(a->hdisplay > b->hdisplay) | 88 if(a->hdisplay > b->hdisplay) |
89 return -1; | 89 return -1; |
90 return b->vdisplay - a->vdisplay; | 90 return b->vdisplay - a->vdisplay; |
91 } | 91 } |
92 #endif | 92 #endif |
95 | 95 |
96 static void set_best_resolution(_THIS, int width, int height) | 96 static void set_best_resolution(_THIS, int width, int height) |
97 { | 97 { |
98 #ifdef XFREE86_VM | 98 #ifdef XFREE86_VM |
99 if ( use_vidmode ) { | 99 if ( use_vidmode ) { |
100 XF86VidModeModeLine mode; | 100 SDL_NAME(XF86VidModeModeLine) mode; |
101 XF86VidModeModeInfo **modes; | 101 SDL_NAME(XF86VidModeModeInfo) **modes; |
102 int i; | 102 int i; |
103 int nmodes; | 103 int nmodes; |
104 | 104 |
105 if ( XVidMode(GetModeLine, (SDL_Display, SDL_Screen, &i, &mode)) && | 105 if ( SDL_NAME(XF86VidModeGetModeLine)(SDL_Display, SDL_Screen, &i, &mode) && |
106 XVidMode(GetAllModeLines, (SDL_Display,SDL_Screen,&nmodes,&modes))){ | 106 SDL_NAME(XF86VidModeGetAllModeLines)(SDL_Display,SDL_Screen,&nmodes,&modes)){ |
107 qsort(modes, nmodes, sizeof *modes, cmpmodes); | 107 qsort(modes, nmodes, sizeof *modes, cmpmodes); |
108 #ifdef XFREE86_DEBUG | 108 #ifdef XFREE86_DEBUG |
109 printf("Available modes:\n"); | 109 printf("Available modes:\n"); |
110 for ( i = 0; i < nmodes; ++i ) { | 110 for ( i = 0; i < nmodes; ++i ) { |
111 printf("Mode %d: %dx%d\n", i, | 111 printf("Mode %d: %dx%d\n", i, |
117 (modes[i]->vdisplay >= height) ) | 117 (modes[i]->vdisplay >= height) ) |
118 break; | 118 break; |
119 } | 119 } |
120 if ( (modes[i]->hdisplay != mode.hdisplay) || | 120 if ( (modes[i]->hdisplay != mode.hdisplay) || |
121 (modes[i]->vdisplay != mode.vdisplay) ) { | 121 (modes[i]->vdisplay != mode.vdisplay) ) { |
122 XVidMode(SwitchToMode, (SDL_Display, SDL_Screen, modes[i])); | 122 SDL_NAME(XF86VidModeSwitchToMode)(SDL_Display, SDL_Screen, modes[i]); |
123 } | 123 } |
124 XFree(modes); | 124 XFree(modes); |
125 } | 125 } |
126 } | 126 } |
127 #endif /* XFREE86_VM */ | 127 #endif /* XFREE86_VM */ |
170 | 170 |
171 static void get_real_resolution(_THIS, int* w, int* h) | 171 static void get_real_resolution(_THIS, int* w, int* h) |
172 { | 172 { |
173 #ifdef XFREE86_VM | 173 #ifdef XFREE86_VM |
174 if ( use_vidmode ) { | 174 if ( use_vidmode ) { |
175 XF86VidModeModeLine mode; | 175 SDL_NAME(XF86VidModeModeLine) mode; |
176 int unused; | 176 int unused; |
177 | 177 |
178 if ( XVidMode(GetModeLine, (SDL_Display, SDL_Screen, &unused, &mode)) ) { | 178 if ( SDL_NAME(XF86VidModeGetModeLine)(SDL_Display, SDL_Screen, &unused, &mode) ) { |
179 *w = mode.hdisplay; | 179 *w = mode.hdisplay; |
180 *h = mode.vdisplay; | 180 *h = mode.vdisplay; |
181 return; | 181 return; |
182 } | 182 } |
183 } | 183 } |
266 { | 266 { |
267 #ifdef XFREE86_VM | 267 #ifdef XFREE86_VM |
268 int buggy_X11; | 268 int buggy_X11; |
269 int vm_major, vm_minor; | 269 int vm_major, vm_minor; |
270 int nmodes; | 270 int nmodes; |
271 XF86VidModeModeInfo **modes; | 271 SDL_NAME(XF86VidModeModeInfo) **modes; |
272 #endif | 272 #endif |
273 #ifdef HAVE_XIGXME | 273 #ifdef HAVE_XIGXME |
274 int xme_major, xme_minor; | 274 int xme_major, xme_minor; |
275 int ractive, nummodes; | 275 int ractive, nummodes; |
276 XiGMiscResolutionInfo *modelist; | 276 XiGMiscResolutionInfo *modelist; |
308 /* The alpha and PPC XFree86 servers are also buggy */ | 308 /* The alpha and PPC XFree86 servers are also buggy */ |
309 buggy_X11 = 1; | 309 buggy_X11 = 1; |
310 #endif | 310 #endif |
311 /* Enumerate the available fullscreen modes */ | 311 /* Enumerate the available fullscreen modes */ |
312 if ( ! buggy_X11 ) { | 312 if ( ! buggy_X11 ) { |
313 if ( XVidMode(QueryExtension, (SDL_Display, &vm_event, &vm_error)) && | 313 if ( SDL_NAME(XF86VidModeQueryExtension)(SDL_Display, &vm_event, &vm_error) && |
314 XVidMode(QueryVersion, (SDL_Display, &vm_major, &vm_minor)) ) { | 314 SDL_NAME(XF86VidModeQueryVersion)(SDL_Display, &vm_major, &vm_minor) ) { |
315 #ifdef BROKEN_XFREE86_4001 | 315 #ifdef BROKEN_XFREE86_4001 |
316 #ifdef X_XF86VidModeGetDotClocks /* Compiled under XFree86 4.0 */ | 316 #ifdef X_XF86VidModeGetDotClocks /* Compiled under XFree86 4.0 */ |
317 /* Earlier X servers hang when doing vidmode */ | 317 /* Earlier X servers hang when doing vidmode */ |
318 if ( vm_major < 2 ) { | 318 if ( vm_major < 2 ) { |
319 #ifdef XFREE86_DEBUG | 319 #ifdef XFREE86_DEBUG |
328 } else { | 328 } else { |
329 buggy_X11 = 1; | 329 buggy_X11 = 1; |
330 } | 330 } |
331 } | 331 } |
332 if ( ! buggy_X11 && | 332 if ( ! buggy_X11 && |
333 XVidMode(GetAllModeLines, (SDL_Display, SDL_Screen,&nmodes,&modes)) ) { | 333 SDL_NAME(XF86VidModeGetAllModeLines)(SDL_Display, SDL_Screen,&nmodes,&modes) ) { |
334 | 334 |
335 qsort(modes, nmodes, sizeof *modes, cmpmodes); | 335 qsort(modes, nmodes, sizeof *modes, cmpmodes); |
336 SDL_modelist = (SDL_Rect **)malloc((nmodes+2)*sizeof(SDL_Rect *)); | 336 SDL_modelist = (SDL_Rect **)malloc((nmodes+2)*sizeof(SDL_Rect *)); |
337 if ( SDL_modelist ) { | 337 if ( SDL_modelist ) { |
338 n = 0; | 338 n = 0; |
531 xinerama_x = 0; | 531 xinerama_x = 0; |
532 xinerama_y = 0; | 532 xinerama_y = 0; |
533 | 533 |
534 #ifdef HAVE_XINERAMA | 534 #ifdef HAVE_XINERAMA |
535 /* Query Xinerama extention */ | 535 /* Query Xinerama extention */ |
536 if ( XineramaQueryExtension(SDL_Display, &i, &i) && | 536 if ( SDL_NAME(XineramaQueryExtension)(SDL_Display, &i, &i) && |
537 XineramaIsActive(SDL_Display) ) { | 537 SDL_NAME(XineramaIsActive)(SDL_Display) ) { |
538 /* Find out which screen is the zero'th one */ | 538 /* Find out which screen is the zero'th one */ |
539 int screens; | 539 int screens; |
540 XineramaScreenInfo *xinerama; | 540 SDL_NAME(XineramaScreenInfo) *xinerama; |
541 | 541 |
542 #ifdef XINERAMA_DEBUG | 542 #ifdef XINERAMA_DEBUG |
543 printf("X11 detected Xinerama:\n"); | 543 printf("X11 detected Xinerama:\n"); |
544 #endif | 544 #endif |
545 xinerama = XineramaQueryScreens(SDL_Display, &screens); | 545 xinerama = SDL_NAME(XineramaQueryScreens)(SDL_Display, &screens); |
546 for ( i = 0; i < screens; i++ ) { | 546 for ( i = 0; i < screens; i++ ) { |
547 #ifdef XINERAMA_DEBUG | 547 #ifdef XINERAMA_DEBUG |
548 printf("xinerama %d: %dx%d+%d+%d\n", | 548 printf("xinerama %d: %dx%d+%d+%d\n", |
549 xinerama[i].screen_number, | 549 xinerama[i].screen_number, |
550 xinerama[i].width, xinerama[i].height, | 550 xinerama[i].width, xinerama[i].height, |
701 #endif | 701 #endif |
702 | 702 |
703 #ifdef XFREE86_VM | 703 #ifdef XFREE86_VM |
704 /* Save the current video mode */ | 704 /* Save the current video mode */ |
705 if ( use_vidmode ) { | 705 if ( use_vidmode ) { |
706 XVidMode(LockModeSwitch, (SDL_Display, SDL_Screen, True)); | 706 SDL_NAME(XF86VidModeLockModeSwitch)(SDL_Display, SDL_Screen, True); |
707 } | 707 } |
708 #endif | 708 #endif |
709 currently_fullscreen = 1; | 709 currently_fullscreen = 1; |
710 | 710 |
711 /* Set the new resolution */ | 711 /* Set the new resolution */ |
738 if ( currently_fullscreen ) { | 738 if ( currently_fullscreen ) { |
739 XReparentWindow(SDL_Display, SDL_Window, WMwindow, 0, 0); | 739 XReparentWindow(SDL_Display, SDL_Window, WMwindow, 0, 0); |
740 #ifdef XFREE86_VM | 740 #ifdef XFREE86_VM |
741 if ( use_vidmode ) { | 741 if ( use_vidmode ) { |
742 restore_mode(this); | 742 restore_mode(this); |
743 XVidMode(LockModeSwitch, (SDL_Display, SDL_Screen, False)); | 743 SDL_NAME(XF86VidModeLockModeSwitch)(SDL_Display, SDL_Screen, False); |
744 } | 744 } |
745 #endif | 745 #endif |
746 | 746 |
747 #ifdef HAVE_XIGXME | 747 #ifdef HAVE_XIGXME |
748 if ( use_xme ) { | 748 if ( use_xme ) { |