comparison src/video/x11/SDL_x11dyn.c @ 1589:34cca785be57

Xrandr support in the X11 target. Fixes Bugzilla #109, and as a bonus, Bugzilla #145, too!
author Ryan C. Gordon <icculus@icculus.org>
date Wed, 22 Mar 2006 11:13:58 +0000
parents 7fd9fc1f2be5
children 5115439d67b1
comparison
equal deleted inserted replaced
1588:e20dcef5647c 1589:34cca785be57
19 Sam Lantinga 19 Sam Lantinga
20 slouken@libsdl.org 20 slouken@libsdl.org
21 */ 21 */
22 #include "SDL_config.h" 22 #include "SDL_config.h"
23 23
24 #if 0 24 #define DEBUG_DYNAMIC_X11 0
25 #define DEBUG_DYNAMIC_X11 1
26 #endif
27 25
28 #include "SDL_x11dyn.h" 26 #include "SDL_x11dyn.h"
29 27
30 #ifdef DEBUG_DYNAMIC_X11 28 #if DEBUG_DYNAMIC_X11
31 #include <stdio.h> 29 #include <stdio.h>
32 #endif 30 #endif
33 31
34 #ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC 32 #ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC
35 #include <dlfcn.h> 33 #include <dlfcn.h>
37 #include "SDL_loadso.h" 35 #include "SDL_loadso.h"
38 static const char *x11_library = SDL_VIDEO_DRIVER_X11_DYNAMIC; 36 static const char *x11_library = SDL_VIDEO_DRIVER_X11_DYNAMIC;
39 static void *x11_handle = NULL; 37 static void *x11_handle = NULL;
40 static const char *x11ext_library = SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT; 38 static const char *x11ext_library = SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT;
41 static void *x11ext_handle = NULL; 39 static void *x11ext_handle = NULL;
40 static const char *xrender_library = SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER;
41 static void *xrender_handle = NULL;
42 static const char *xrandr_library = SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR;
43 static void *xrandr_handle = NULL;
42 44
43 typedef struct 45 typedef struct
44 { 46 {
45 void *lib; 47 void *lib;
46 const char *libname; 48 const char *libname;
52 void *fn = NULL; 54 void *fn = NULL;
53 const x11libitem libs[] = 55 const x11libitem libs[] =
54 { 56 {
55 { x11_handle, "libX11" }, 57 { x11_handle, "libX11" },
56 { x11ext_handle, "libX11ext" }, 58 { x11ext_handle, "libX11ext" },
59 { xrender_handle, "libXrender" },
60 { xrandr_handle, "libXrandr" },
57 }; 61 };
58 62
59 for (i = 0; i < (sizeof (libs) / sizeof (libs[0])); i++) 63 for (i = 0; i < (sizeof (libs) / sizeof (libs[0])); i++)
60 { 64 {
61 if (libs[i].lib != NULL) 65 if (libs[i].lib != NULL)
128 } 132 }
129 if (x11ext_handle != NULL) { 133 if (x11ext_handle != NULL) {
130 SDL_UnloadObject(x11ext_handle); 134 SDL_UnloadObject(x11ext_handle);
131 x11ext_handle = NULL; 135 x11ext_handle = NULL;
132 } 136 }
137 if (xrender_handle != NULL) {
138 SDL_UnloadObject(xrender_handle);
139 xrender_handle = NULL;
140 }
141 if (xrandr_handle != NULL) {
142 SDL_UnloadObject(xrandr_handle);
143 xrandr_handle = NULL;
144 }
133 } 145 }
134 } 146 }
135 #endif 147 #endif
136 } 148 }
137 149
144 /* deal with multiple modules (dga, x11, etc) needing these symbols... */ 156 /* deal with multiple modules (dga, x11, etc) needing these symbols... */
145 if (x11_load_refcount++ == 0) { 157 if (x11_load_refcount++ == 0) {
146 int *thismod = NULL; 158 int *thismod = NULL;
147 x11_handle = SDL_LoadObject(x11_library); 159 x11_handle = SDL_LoadObject(x11_library);
148 x11ext_handle = SDL_LoadObject(x11ext_library); 160 x11ext_handle = SDL_LoadObject(x11ext_library);
161 xrender_handle = SDL_LoadObject(xrender_library);
162 xrandr_handle = SDL_LoadObject(xrandr_library);
149 #define SDL_X11_MODULE(modname) thismod = &SDL_X11_HAVE_##modname; 163 #define SDL_X11_MODULE(modname) thismod = &SDL_X11_HAVE_##modname;
150 #define SDL_X11_SYM(a,fn,x,y,z) p##fn = X11_GetSym(#fn,thismod); 164 #define SDL_X11_SYM(a,fn,x,y,z) p##fn = X11_GetSym(#fn,thismod);
151 #include "SDL_x11sym.h" 165 #include "SDL_x11sym.h"
152 #undef SDL_X11_MODULE 166 #undef SDL_X11_MODULE
153 #undef SDL_X11_SYM 167 #undef SDL_X11_SYM