comparison src/video/x11/SDL_x11dyn.h @ 1575:3ba88cb7eb1b

Updated dynamic X11 code. See details in Bugzilla #170.
author Ryan C. Gordon <icculus@icculus.org>
date Wed, 22 Mar 2006 05:00:59 +0000
parents 1f4f09641645
children 34cca785be57
comparison
equal deleted inserted replaced
1574:0fd72308659e 1575:3ba88cb7eb1b
37 #include <sys/shm.h> 37 #include <sys/shm.h>
38 #include <X11/extensions/XShm.h> 38 #include <X11/extensions/XShm.h>
39 #endif 39 #endif
40 40
41 /* 41 /*
42 * Never reference Xlib directly...we might load it dynamically at runtime. 42 * When using the "dynamic X11" functionality, we duplicate all the Xlib
43 * Even if we don't, for readability, we still use the function pointers 43 * symbols that would be referenced by SDL inside of SDL itself.
44 * (although the symbol resolution will be done by the loader in that case). 44 * These duplicated symbols just serve as passthroughs to the functions
45 * in Xlib, that was dynamically loaded.
45 * 46 *
46 * We define SDL_X11_SYM and include SDL_x11sym.h to accomplish various 47 * This allows us to use Xlib as-is when linking against it directly, but
47 * goals, without having to duplicate those function signatures. 48 * also handles all the strange cases where there was code in the Xlib
49 * headers that may or may not exist or vary on a given platform.
48 */ 50 */
49 #ifdef __cplusplus 51 #ifdef __cplusplus
50 extern "C" { 52 extern "C" {
51 #endif
52
53 #ifdef __osf__
54 extern int _XData32(Display *,register long *,unsigned);
55 extern void _XRead32(Display *,register long *,long);
56 extern void _SmtBufferOverflow(Display *,register smtDisplayPtr);
57 extern void _SmtIpError(Display *,register smtDisplayPtr, int);
58 extern int ipAllocateData(ChannelPtr, IPCard, IPDataPtr *);
59 extern int ipUnallocateAndSendData(ChannelPtr, IPCard);
60 #endif 53 #endif
61 54
62 /* evil function signatures... */ 55 /* evil function signatures... */
63 typedef Bool (*SDL_X11_XESetWireToEventRetType)(Display*,XEvent*,xEvent*); 56 typedef Bool (*SDL_X11_XESetWireToEventRetType)(Display*,XEvent*,xEvent*);
64 typedef int (*SDL_X11_XSynchronizeRetType)(Display*); 57 typedef int (*SDL_X11_XSynchronizeRetType)(Display*);
65 typedef Status (*SDL_X11_XESetEventToWireRetType)(Display*,XEvent*,xEvent*); 58 typedef Status (*SDL_X11_XESetEventToWireRetType)(Display*,XEvent*,xEvent*);
66 typedef int (*SDL_X11_XSetExtensionErrorHandlerType)(Display *,char *,char *); 59 typedef int (*SDL_X11_XSetExtensionErrorHandlerType)(Display *,char *,char *);
67 60
68 #define SDL_X11_SYM(req,ret,fn,params) extern ret (*p##fn) params; 61 int SDL_X11_LoadSymbols(void);
62 void SDL_X11_UnloadSymbols(void);
63
64 /* That's really annoying...make this a function pointer no matter what. */
65 #ifdef X_HAVE_UTF8_STRING
66 extern XIC (*pXCreateIC)(XIM,...);
67 #endif
68
69 /* These SDL_X11_HAVE_* flags are here whether you have dynamic X11 or not. */
70 #define SDL_X11_MODULE(modname) extern int SDL_X11_HAVE_##modname;
71 #define SDL_X11_SYM(rc,fn,params,args,ret)
69 #include "SDL_x11sym.h" 72 #include "SDL_x11sym.h"
73 #undef SDL_X11_MODULE
70 #undef SDL_X11_SYM 74 #undef SDL_X11_SYM
71 75
72 /* Macro in the xlib headers, not an actual symbol... */
73 #define pXDestroyImage XDestroyImage
74
75 /* Workaround code in headers... */
76 #if !__SDL_NO_REDEFINE_X11_HEADER_SYMS
77 #define _XFlush p_XFlush
78 #define _XFlushGCCache p_XFlushGCCache
79 #define _XReply p_XReply
80 #define _XSend p_XSend
81 #define XFree pXFree
82 #define _XData32 p_XData32
83
84 #if defined(__osf__)
85 #define _SmtBufferOverflow p_SmtBufferOverflow
86 #define _SmtIpError p_SmtIpError
87 #define ipAllocateData pipAllocateData
88 #define ipUnallocateAndSendData pipUnallocateAndSendData
89 #endif
90
91 #endif /* !__SDL_NO_REDEFINE_X11_HEADER_SYMS */
92
93 int SDL_X11_LoadSymbols(void);
94 void SDL_X11_UnloadSymbols(void);
95 76
96 #ifdef __cplusplus 77 #ifdef __cplusplus
97 } 78 }
98 #endif 79 #endif
99 80