src/video/x11/SDL_x11dyn.c
author Bob Pendleton <bob@pendleton.com>
Tue, 13 Jan 2009 19:31:06 +0000
changeset 3036 76a1692fcec5
parent 3025 54fac87e1f34
child 3697 f7b03b6838cb
permissions -rw-r--r--
Added #ifndef SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS NULL #endif so that the X code would compile. It looked like it was needed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1950
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     1
/*
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     2
    SDL - Simple DirectMedia Layer
2859
99210400e8b9 Updated copyright date
Sam Lantinga <slouken@libsdl.org>
parents: 2763
diff changeset
     3
    Copyright (C) 1997-2009 Sam Lantinga
1950
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     4
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     5
    This library is free software; you can redistribute it and/or
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     6
    modify it under the terms of the GNU Library General Public
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     7
    License as published by the Free Software Foundation; either
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     8
    version 2 of the License, or (at your option) any later version.
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     9
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    10
    This library is distributed in the hope that it will be useful,
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    13
    Library General Public License for more details.
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    14
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    15
    You should have received a copy of the GNU Library General Public
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    16
    License along with this library; if not, write to the Free
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    17
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    18
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    19
    Sam Lantinga
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    20
    slouken@libsdl.org
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    21
*/
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    22
#include "SDL_config.h"
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    23
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    24
#define DEBUG_DYNAMIC_X11 0
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    25
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    26
#include "SDL_x11dyn.h"
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    27
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    28
#if DEBUG_DYNAMIC_X11
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    29
#include <stdio.h>
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    30
#endif
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    31
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    32
#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    33
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    34
#include "SDL_name.h"
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    35
#include "SDL_loadso.h"
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    36
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    37
typedef struct
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    38
{
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    39
    void *lib;
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    40
    const char *libname;
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    41
} x11dynlib;
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    42
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    43
#ifndef SDL_VIDEO_DRIVER_X11_DYNAMIC
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    44
#define SDL_VIDEO_DRIVER_X11_DYNAMIC NULL
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    45
#endif
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    46
#ifndef SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    47
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT NULL
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    48
#endif
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    49
#ifndef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    50
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER NULL
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    51
#endif
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    52
#ifndef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    53
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR NULL
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    54
#endif
2763
6fc50bdd88c0 Some cleanups on the new XInput code.
Ryan C. Gordon <icculus@icculus.org>
parents: 2325
diff changeset
    55
#ifndef SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT
6fc50bdd88c0 Some cleanups on the new XInput code.
Ryan C. Gordon <icculus@icculus.org>
parents: 2325
diff changeset
    56
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT NULL
6fc50bdd88c0 Some cleanups on the new XInput code.
Ryan C. Gordon <icculus@icculus.org>
parents: 2325
diff changeset
    57
#endif
3036
Bob Pendleton <bob@pendleton.com>
parents: 3025
diff changeset
    58
#ifndef SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS
Bob Pendleton <bob@pendleton.com>
parents: 3025
diff changeset
    59
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS NULL
Bob Pendleton <bob@pendleton.com>
parents: 3025
diff changeset
    60
#endif
1950
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    61
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    62
static x11dynlib x11libs[] = {
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    63
    {NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC},
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    64
    {NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT},
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    65
    {NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER},
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    66
    {NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR},
2763
6fc50bdd88c0 Some cleanups on the new XInput code.
Ryan C. Gordon <icculus@icculus.org>
parents: 2325
diff changeset
    67
    {NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT},
3025
54fac87e1f34 Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    68
    {NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS},
1950
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    69
};
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    70
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    71
static void
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    72
X11_GetSym(const char *fnname, int *rc, void **fn)
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    73
{
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    74
    int i;
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    75
    for (i = 0; i < SDL_TABLESIZE(x11libs); i++) {
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    76
        if (x11libs[i].lib != NULL) {
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    77
            *fn = SDL_LoadFunction(x11libs[i].lib, fnname);
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    78
            if (*fn != NULL)
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    79
                break;
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    80
        }
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    81
    }
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    82
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    83
#if DEBUG_DYNAMIC_X11
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    84
    if (*fn != NULL)
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    85
        printf("X11: Found '%s' in %s (%p)\n", fnname, x11libs[i].libname,
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    86
               *fn);
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    87
    else
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    88
        printf("X11: Symbol '%s' NOT FOUND!\n", fnname);
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    89
#endif
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    90
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    91
    if (*fn == NULL)
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    92
        *rc = 0;                /* kill this module. */
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    93
}
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    94
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    95
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    96
/* Define all the function pointers and wrappers... */
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    97
#define SDL_X11_MODULE(modname)
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    98
#define SDL_X11_SYM(rc,fn,params,args,ret) \
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    99
	static rc (*p##fn) params = NULL; \
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   100
	rc fn params { ret p##fn args ; }
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   101
#include "SDL_x11sym.h"
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   102
#undef SDL_X11_MODULE
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   103
#undef SDL_X11_SYM
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   104
#endif /* SDL_VIDEO_DRIVER_X11_DYNAMIC */
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   105
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   106
/* Annoying varargs entry point... */
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   107
#ifdef X_HAVE_UTF8_STRING
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   108
XIC(*pXCreateIC) (XIM,...) = NULL;
2325
c7bcf84ba1b9 Next version of internationalized input for X11. On my machine (famous last words :-) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents: 2120
diff changeset
   109
char *(*pXGetICValues) (XIC, ...) = NULL;
1950
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   110
#endif
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   111
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   112
/* These SDL_X11_HAVE_* flags are here whether you have dynamic X11 or not. */
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   113
#define SDL_X11_MODULE(modname) int SDL_X11_HAVE_##modname = 1;
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   114
#define SDL_X11_SYM(rc,fn,params,args,ret)
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   115
#include "SDL_x11sym.h"
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   116
#undef SDL_X11_MODULE
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   117
#undef SDL_X11_SYM
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   118
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   119
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   120
static int x11_load_refcount = 0;
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   121
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   122
void
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   123
SDL_X11_UnloadSymbols(void)
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   124
{
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   125
#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   126
    /* Don't actually unload if more than one module is using the libs... */
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   127
    if (x11_load_refcount > 0) {
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   128
        if (--x11_load_refcount == 0) {
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   129
            int i;
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   130
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   131
            /* set all the function pointers to NULL. */
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   132
#define SDL_X11_MODULE(modname) SDL_X11_HAVE_##modname = 1;
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   133
#define SDL_X11_SYM(rc,fn,params,args,ret) p##fn = NULL;
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   134
#include "SDL_x11sym.h"
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   135
#undef SDL_X11_MODULE
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   136
#undef SDL_X11_SYM
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   137
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   138
#ifdef X_HAVE_UTF8_STRING
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   139
            pXCreateIC = NULL;
2325
c7bcf84ba1b9 Next version of internationalized input for X11. On my machine (famous last words :-) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents: 2120
diff changeset
   140
            pXGetICValues = NULL;
1950
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   141
#endif
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   142
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   143
            for (i = 0; i < SDL_TABLESIZE(x11libs); i++) {
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   144
                if (x11libs[i].lib != NULL) {
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   145
                    SDL_UnloadObject(x11libs[i].lib);
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   146
                    x11libs[i].lib = NULL;
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   147
                }
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   148
            }
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   149
        }
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   150
    }
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   151
#endif
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   152
}
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   153
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   154
/* returns non-zero if all needed symbols were loaded. */
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   155
int
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   156
SDL_X11_LoadSymbols(void)
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   157
{
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   158
    int rc = 1;                 /* always succeed if not using Dynamic X11 stuff. */
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   159
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   160
#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   161
    /* deal with multiple modules (dga, x11, etc) needing these symbols... */
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   162
    if (x11_load_refcount++ == 0) {
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   163
        int i;
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   164
        int *thismod = NULL;
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   165
        for (i = 0; i < SDL_TABLESIZE(x11libs); i++) {
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   166
            if (x11libs[i].libname != NULL) {
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   167
                x11libs[i].lib = SDL_LoadObject(x11libs[i].libname);
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   168
            }
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   169
        }
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   170
#define SDL_X11_MODULE(modname) thismod = &SDL_X11_HAVE_##modname;
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   171
#define SDL_X11_SYM(a,fn,x,y,z) X11_GetSym(#fn,thismod,(void**)&p##fn);
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   172
#include "SDL_x11sym.h"
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   173
#undef SDL_X11_MODULE
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   174
#undef SDL_X11_SYM
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   175
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   176
#ifdef X_HAVE_UTF8_STRING
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   177
        X11_GetSym("XCreateIC", &SDL_X11_HAVE_UTF8, (void **) &pXCreateIC);
2325
c7bcf84ba1b9 Next version of internationalized input for X11. On my machine (famous last words :-) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents: 2120
diff changeset
   178
        X11_GetSym("XGetICValues", &SDL_X11_HAVE_UTF8,
c7bcf84ba1b9 Next version of internationalized input for X11. On my machine (famous last words :-) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents: 2120
diff changeset
   179
                   (void **) &pXGetICValues);
1950
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   180
#endif
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   181
2120
2c835d58faad make indent
Sam Lantinga <slouken@libsdl.org>
parents: 2118
diff changeset
   182
        if (SDL_X11_HAVE_BASEXLIB) {
2c835d58faad make indent
Sam Lantinga <slouken@libsdl.org>
parents: 2118
diff changeset
   183
            /* all required symbols loaded. */
2118
238db749017a Merged r3062:3063 from branches/SDL-1.2: clear inaccurate x11dyn error strings.
Ryan C. Gordon <icculus@icculus.org>
parents: 1950
diff changeset
   184
            SDL_ClearError();
238db749017a Merged r3062:3063 from branches/SDL-1.2: clear inaccurate x11dyn error strings.
Ryan C. Gordon <icculus@icculus.org>
parents: 1950
diff changeset
   185
        } else {
2120
2c835d58faad make indent
Sam Lantinga <slouken@libsdl.org>
parents: 2118
diff changeset
   186
            /* in case something got loaded... */
2c835d58faad make indent
Sam Lantinga <slouken@libsdl.org>
parents: 2118
diff changeset
   187
            SDL_X11_UnloadSymbols();
1950
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   188
            rc = 0;
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   189
        }
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   190
    }
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   191
#else
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   192
#ifdef X_HAVE_UTF8_STRING
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   193
    pXCreateIC = XCreateIC;
2325
c7bcf84ba1b9 Next version of internationalized input for X11. On my machine (famous last words :-) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents: 2120
diff changeset
   194
    pXGetICValues = XGetICValues;
1950
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   195
#endif
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   196
#endif
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   197
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   198
    return rc;
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   199
}
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   200
a344e42bce3b Started work on the new X11 driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   201
/* vi: set ts=4 sw=4 expandtab: */