annotate 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
rev   line source
1168
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1 /*
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
3 Copyright (C) 1997-2004 Sam Lantinga
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
4
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
6 modify it under the terms of the GNU Library General Public
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
8 version 2 of the License, or (at your option) any later version.
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
9
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
13 Library General Public License for more details.
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
14
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
15 You should have received a copy of the GNU Library General Public
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
16 License along with this library; if not, write to the Free
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
18
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
19 Sam Lantinga
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
20 slouken@libsdl.org
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
21 */
1402
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
22 #include "SDL_config.h"
1168
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
23
1589
34cca785be57 Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1587
diff changeset
24 #define DEBUG_DYNAMIC_X11 0
1168
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
25
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
26 #include "SDL_x11dyn.h"
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
27
1589
34cca785be57 Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1587
diff changeset
28 #if DEBUG_DYNAMIC_X11
1168
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
29 #include <stdio.h>
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
30 #endif
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
31
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1245
diff changeset
32 #ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC
1168
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
33 #include <dlfcn.h>
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
34 #include "SDL_name.h"
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
35 #include "SDL_loadso.h"
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1245
diff changeset
36 static const char *x11_library = SDL_VIDEO_DRIVER_X11_DYNAMIC;
1168
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
37 static void *x11_handle = NULL;
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1245
diff changeset
38 static const char *x11ext_library = SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT;
1168
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
39 static void *x11ext_handle = NULL;
1589
34cca785be57 Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1587
diff changeset
40 static const char *xrender_library = SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER;
34cca785be57 Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1587
diff changeset
41 static void *xrender_handle = NULL;
34cca785be57 Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1587
diff changeset
42 static const char *xrandr_library = SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR;
34cca785be57 Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1587
diff changeset
43 static void *xrandr_handle = NULL;
1168
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
44
1575
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
45 typedef struct
1168
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
46 {
1575
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
47 void *lib;
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
48 const char *libname;
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
49 } x11libitem;
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
50
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
51 static void *X11_GetSym(const char *fnname, int *rc)
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
52 {
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
53 int i;
1168
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
54 void *fn = NULL;
1575
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
55 const x11libitem libs[] =
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
56 {
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
57 { x11_handle, "libX11" },
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
58 { x11ext_handle, "libX11ext" },
1589
34cca785be57 Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1587
diff changeset
59 { xrender_handle, "libXrender" },
34cca785be57 Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1587
diff changeset
60 { xrandr_handle, "libXrandr" },
1575
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
61 };
1168
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
62
1575
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
63 for (i = 0; i < (sizeof (libs) / sizeof (libs[0])); i++)
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
64 {
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
65 if (libs[i].lib != NULL)
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
66 {
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
67 fn = SDL_LoadFunction(libs[i].lib, fnname);
1168
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
68 if (fn != NULL)
1575
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
69 break;
1168
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
70 }
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
71 }
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
72
1575
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
73 #if DEBUG_DYNAMIC_X11
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
74 if (fn != NULL)
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
75 printf("X11: Found '%s' in %s (%p)\n", fnname, libs[i].libname, fn);
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
76 else
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
77 printf("X11: Symbol '%s' NOT FOUND!\n", fnname);
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
78 #endif
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
79
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
80 if (fn == NULL)
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
81 *rc = 0; /* kill this module. */
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
82
1168
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
83 return fn;
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
84 }
1575
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
85
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
86
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
87 /* Define all the function pointers and wrappers... */
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
88 #define SDL_X11_MODULE(modname)
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
89 #define SDL_X11_SYM(rc,fn,params,args,ret) \
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
90 static rc (*p##fn) params = NULL; \
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
91 rc fn params { ret p##fn args ; }
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
92 #include "SDL_x11sym.h"
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
93 #undef SDL_X11_MODULE
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
94 #undef SDL_X11_SYM
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1245
diff changeset
95 #endif /* SDL_VIDEO_DRIVER_X11_DYNAMIC */
1168
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
96
1575
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
97 /* Annoying varargs entry point... */
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
98 #ifdef X_HAVE_UTF8_STRING
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
99 XIC (*pXCreateIC)(XIM,...) = NULL;
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
100 #endif
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
101
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
102 /* These SDL_X11_HAVE_* flags are here whether you have dynamic X11 or not. */
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
103 #define SDL_X11_MODULE(modname) int SDL_X11_HAVE_##modname = 1;
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
104 #define SDL_X11_SYM(rc,fn,params,args,ret)
1168
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
105 #include "SDL_x11sym.h"
1575
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
106 #undef SDL_X11_MODULE
1168
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
107 #undef SDL_X11_SYM
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
108
1575
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
109
1168
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
110 static int x11_load_refcount = 0;
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
111
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
112 void SDL_X11_UnloadSymbols(void)
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
113 {
1575
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
114 #ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC
1168
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
115 /* Don't actually unload if more than one module is using the libs... */
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
116 if (x11_load_refcount > 0) {
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
117 if (--x11_load_refcount == 0) {
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
118 /* set all the function pointers to NULL. */
1575
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
119 #define SDL_X11_MODULE(modname) SDL_X11_HAVE_##modname = 1;
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
120 #define SDL_X11_SYM(rc,fn,params,args,ret) p##fn = NULL;
1168
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
121 #include "SDL_x11sym.h"
1575
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
122 #undef SDL_X11_MODULE
1168
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
123 #undef SDL_X11_SYM
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
124
1575
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
125 #ifdef X_HAVE_UTF8_STRING
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
126 pXCreateIC = NULL;
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
127 #endif
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
128
1168
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
129 if (x11_handle != NULL) {
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
130 SDL_UnloadObject(x11_handle);
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
131 x11_handle = NULL;
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
132 }
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
133 if (x11ext_handle != NULL) {
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
134 SDL_UnloadObject(x11ext_handle);
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
135 x11ext_handle = NULL;
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
136 }
1589
34cca785be57 Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1587
diff changeset
137 if (xrender_handle != NULL) {
34cca785be57 Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1587
diff changeset
138 SDL_UnloadObject(xrender_handle);
34cca785be57 Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1587
diff changeset
139 xrender_handle = NULL;
34cca785be57 Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1587
diff changeset
140 }
34cca785be57 Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1587
diff changeset
141 if (xrandr_handle != NULL) {
34cca785be57 Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1587
diff changeset
142 SDL_UnloadObject(xrandr_handle);
34cca785be57 Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1587
diff changeset
143 xrandr_handle = NULL;
34cca785be57 Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1587
diff changeset
144 }
1168
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
145 }
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
146 }
1575
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
147 #endif
1168
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
148 }
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
149
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
150 /* returns non-zero if all needed symbols were loaded. */
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
151 int SDL_X11_LoadSymbols(void)
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
152 {
1575
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
153 int rc = 1; /* always succeed if not using Dynamic X11 stuff. */
1168
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
154
1575
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
155 #ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
156 /* deal with multiple modules (dga, x11, etc) needing these symbols... */
1168
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
157 if (x11_load_refcount++ == 0) {
1575
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
158 int *thismod = NULL;
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
159 x11_handle = SDL_LoadObject(x11_library);
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
160 x11ext_handle = SDL_LoadObject(x11ext_library);
1589
34cca785be57 Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1587
diff changeset
161 xrender_handle = SDL_LoadObject(xrender_library);
34cca785be57 Xrandr support in the X11 target.
Ryan C. Gordon <icculus@icculus.org>
parents: 1587
diff changeset
162 xrandr_handle = SDL_LoadObject(xrandr_library);
1575
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
163 #define SDL_X11_MODULE(modname) thismod = &SDL_X11_HAVE_##modname;
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
164 #define SDL_X11_SYM(a,fn,x,y,z) p##fn = X11_GetSym(#fn,thismod);
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
165 #include "SDL_x11sym.h"
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
166 #undef SDL_X11_MODULE
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
167 #undef SDL_X11_SYM
1168
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
168
1575
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
169 #ifdef X_HAVE_UTF8_STRING
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
170 pXCreateIC = X11_GetSym("XCreateIC",&SDL_X11_HAVE_UTF8);
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
171 #endif
1168
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
172
1575
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
173 if (!SDL_X11_HAVE_BASEXLIB) { /* some required symbol didn't load. */
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
174 SDL_X11_UnloadSymbols(); /* in case something got loaded... */
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
175 }
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
176 }
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
177 #else
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
178 #ifdef X_HAVE_UTF8_STRING
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
179 pXCreateIC = XCreateIC;
1168
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
180 #endif
1575
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
181 #endif
1168
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
182
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
183 return rc;
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
184 }
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
185
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
186 /* end of SDL_x11dyn.c ... */
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
187