Dynamic loading support for Wayland
authorGabriel Jacobo <gabomdq@gmail.com>
Thu, 09 Jan 2014 13:56:21 -0300
changeset 81042e4f1bd21196
parent 8103 d4a88c49247e
child 8105 f74bf1bbe472
Dynamic loading support for Wayland
configure
configure.in
include/SDL_config.h.in
src/video/wayland/SDL_waylanddyn.c
src/video/wayland/SDL_waylanddyn.h
src/video/wayland/SDL_waylandevents.c
src/video/wayland/SDL_waylandevents_c.h
src/video/wayland/SDL_waylandmouse.c
src/video/wayland/SDL_waylandmouse.h
src/video/wayland/SDL_waylandopengles.c
src/video/wayland/SDL_waylandopengles.h
src/video/wayland/SDL_waylandsym.h
src/video/wayland/SDL_waylandtouch.c
src/video/wayland/SDL_waylandtouch.h
src/video/wayland/SDL_waylandvideo.c
src/video/wayland/SDL_waylandvideo.h
src/video/wayland/SDL_waylandwindow.c
src/video/wayland/SDL_waylandwindow.h
     1.1 --- a/configure	Wed Jan 08 14:53:08 2014 -0500
     1.2 +++ b/configure	Thu Jan 09 13:56:21 2014 -0300
     1.3 @@ -819,6 +819,7 @@
     1.4  enable_dummyaudio
     1.5  enable_video_wayland
     1.6  enable_video_wayland_qt_touch
     1.7 +enable_wayland_shared
     1.8  enable_video_x11
     1.9  with_x
    1.10  enable_x11_shared
    1.11 @@ -1538,6 +1539,7 @@
    1.12    --enable-video-wayland-qt-touch
    1.13                            QtWayland server support for Wayland video driver
    1.14                            [[default=yes]]
    1.15 +  --enable-wayland-shared dynamically load Wayland support [[default=maybe]]
    1.16    --enable-video-x11      use X11 video driver [[default=yes]]
    1.17    --enable-x11-shared     dynamically load X11 support [[default=maybe]]
    1.18    --enable-video-x11-xcursor
    1.19 @@ -18705,8 +18707,8 @@
    1.20          video_wayland=no
    1.21          if test x$PKG_CONFIG != xno; then
    1.22              if $PKG_CONFIG --exists wayland-client wayland-egl wayland-cursor egl xkbcommon ; then
    1.23 -                WAYLAND_CFLAGS=`$PKG_CONFIG --cflags wayland-client wayland-egl wayland-cursor egl xkbcommon`
    1.24 -                WAYLAND_LIBS=`$PKG_CONFIG --libs wayland-client wayland-egl wayland-cursor egl xkbcommon`
    1.25 +                WAYLAND_CFLAGS=`$PKG_CONFIG --cflags wayland-client wayland-egl wayland-cursor xkbcommon`
    1.26 +                WAYLAND_LIBS=`$PKG_CONFIG --libs wayland-client wayland-egl wayland-cursor xkbcommon`
    1.27                  video_wayland=yes
    1.28              fi
    1.29          fi
    1.30 @@ -18724,7 +18726,69 @@
    1.31              fi
    1.32              SOURCES="$SOURCES $srcdir/src/video/wayland/*.c"
    1.33              EXTRA_CFLAGS="$EXTRA_CFLAGS $WAYLAND_CFLAGS"
    1.34 -                        EXTRA_LDFLAGS="$EXTRA_LDFLAGS $WAYLAND_LIBS"
    1.35 +            # Check whether --enable-wayland-shared was given.
    1.36 +if test "${enable_wayland_shared+set}" = set; then :
    1.37 +  enableval=$enable_wayland_shared;
    1.38 +else
    1.39 +  enable_wayland_shared=maybe
    1.40 +fi
    1.41 +
    1.42 +
    1.43 +                        case "$host" in
    1.44 +                *)
    1.45 +                    wayland_client_lib=`find_lib "libwayland-client.so.*" "$WAYLAND_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`
    1.46 +                    wayland_egl_lib=`find_lib "libwayland-egl.so.*" "$WAYLAND_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`
    1.47 +                    if test x$wayland_egl_lib = x; then
    1.48 +                                                wayland_egl_lib=`find_lib "mesa-egl/libwayland-egl.so.*" "$WAYLAND_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`
    1.49 +                    fi
    1.50 +                    wayland_cursor_lib=`find_lib "libwayland-cursor.so.*" "$WAYLAND_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`
    1.51 +                    xkbcommon_lib=`find_lib "libxkbcommon.so.*" "$WAYLAND_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`
    1.52 +                    ;;
    1.53 +            esac
    1.54 +
    1.55 +            if test x$enable_wayland_shared = xmaybe; then
    1.56 +                enable_wayland_shared=yes
    1.57 +            fi
    1.58 +            if test x$have_loadso != xyes && \
    1.59 +               test x$enable_wayland_shared = xyes; then
    1.60 +                { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic WAYLAND loading" >&5
    1.61 +$as_echo "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic WAYLAND loading" >&2;}
    1.62 +                enable_wayland_shared=no
    1.63 +            fi
    1.64 +            if test x$have_loadso = xyes && \
    1.65 +               test x$enable_wayland_shared = xyes && \
    1.66 +               test x$wayland_client_lib != x && \
    1.67 +               test x$wayland_egl_lib != x && \
    1.68 +               test x$wayland_cursor_lib != x && \
    1.69 +               test x$xkbcommon_lib != x; then
    1.70 +                echo "-- dynamic libwayland-client -> $wayland_client_lib"
    1.71 +                echo "-- dynamic libwayland-egl -> $wayland_egl_lib"
    1.72 +                echo "-- dynamic libwayland-cursor -> $wayland_cursor_lib"
    1.73 +                echo "-- dynamic xkbcommon -> $xkbcommon_lib"
    1.74 +
    1.75 +cat >>confdefs.h <<_ACEOF
    1.76 +#define SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC "$wayland_client_lib"
    1.77 +_ACEOF
    1.78 +
    1.79 +
    1.80 +cat >>confdefs.h <<_ACEOF
    1.81 +#define SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL "$wayland_egl_lib"
    1.82 +_ACEOF
    1.83 +
    1.84 +
    1.85 +cat >>confdefs.h <<_ACEOF
    1.86 +#define SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR "$wayland_cursor_lib"
    1.87 +_ACEOF
    1.88 +
    1.89 +
    1.90 +cat >>confdefs.h <<_ACEOF
    1.91 +#define SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON "$xkbcommon_lib"
    1.92 +_ACEOF
    1.93 +
    1.94 +            else
    1.95 +                enable_wayland_shared=no
    1.96 +                EXTRA_LDFLAGS="$EXTRA_LDFLAGS $WAYLAND_LIBS"
    1.97 +            fi
    1.98              have_video=yes
    1.99          fi
   1.100      fi
     2.1 --- a/configure.in	Wed Jan 08 14:53:08 2014 -0500
     2.2 +++ b/configure.in	Thu Jan 09 13:56:21 2014 -0300
     2.3 @@ -1133,8 +1133,8 @@
     2.4          video_wayland=no
     2.5          if test x$PKG_CONFIG != xno; then
     2.6              if $PKG_CONFIG --exists wayland-client wayland-egl wayland-cursor egl xkbcommon ; then
     2.7 -                WAYLAND_CFLAGS=`$PKG_CONFIG --cflags wayland-client wayland-egl wayland-cursor egl xkbcommon`
     2.8 -                WAYLAND_LIBS=`$PKG_CONFIG --libs wayland-client wayland-egl wayland-cursor egl xkbcommon`
     2.9 +                WAYLAND_CFLAGS=`$PKG_CONFIG --cflags wayland-client wayland-egl wayland-cursor xkbcommon`
    2.10 +                WAYLAND_LIBS=`$PKG_CONFIG --libs wayland-client wayland-egl wayland-cursor xkbcommon`
    2.11                  video_wayland=yes
    2.12              fi
    2.13          fi
    2.14 @@ -1147,8 +1147,50 @@
    2.15              fi
    2.16              SOURCES="$SOURCES $srcdir/src/video/wayland/*.c"
    2.17              EXTRA_CFLAGS="$EXTRA_CFLAGS $WAYLAND_CFLAGS"
    2.18 -            dnl FIXME do dynamic loading code here.
    2.19 -            EXTRA_LDFLAGS="$EXTRA_LDFLAGS $WAYLAND_LIBS"
    2.20 +            AC_ARG_ENABLE(wayland-shared,
    2.21 +AC_HELP_STRING([--enable-wayland-shared], [dynamically load Wayland support [[default=maybe]]]),
    2.22 +                          , enable_wayland_shared=maybe)
    2.23 +
    2.24 +            dnl FIXME: Do BSD and OS X need special cases?
    2.25 +            case "$host" in
    2.26 +                *)
    2.27 +                    wayland_client_lib=[`find_lib "libwayland-client.so.*" "$WAYLAND_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
    2.28 +                    wayland_egl_lib=[`find_lib "libwayland-egl.so.*" "$WAYLAND_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
    2.29 +                    if test x$wayland_egl_lib = x; then
    2.30 +                        dnl This works in Ubuntu 13.10, maybe others
    2.31 +                        wayland_egl_lib=[`find_lib "mesa-egl/libwayland-egl.so.*" "$WAYLAND_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
    2.32 +                    fi
    2.33 +                    wayland_cursor_lib=[`find_lib "libwayland-cursor.so.*" "$WAYLAND_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
    2.34 +                    xkbcommon_lib=[`find_lib "libxkbcommon.so.*" "$WAYLAND_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
    2.35 +                    ;;
    2.36 +            esac
    2.37 +
    2.38 +            if test x$enable_wayland_shared = xmaybe; then
    2.39 +                enable_wayland_shared=yes
    2.40 +            fi
    2.41 +            if test x$have_loadso != xyes && \
    2.42 +               test x$enable_wayland_shared = xyes; then
    2.43 +                AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic WAYLAND loading])
    2.44 +                enable_wayland_shared=no
    2.45 +            fi
    2.46 +            if test x$have_loadso = xyes && \
    2.47 +               test x$enable_wayland_shared = xyes && \
    2.48 +               test x$wayland_client_lib != x && \
    2.49 +               test x$wayland_egl_lib != x && \
    2.50 +               test x$wayland_cursor_lib != x && \
    2.51 +               test x$xkbcommon_lib != x; then
    2.52 +                echo "-- dynamic libwayland-client -> $wayland_client_lib"
    2.53 +                echo "-- dynamic libwayland-egl -> $wayland_egl_lib"
    2.54 +                echo "-- dynamic libwayland-cursor -> $wayland_cursor_lib"
    2.55 +                echo "-- dynamic xkbcommon -> $xkbcommon_lib"
    2.56 +                AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC, "$wayland_client_lib", [ ])
    2.57 +                AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL, "$wayland_egl_lib", [ ])
    2.58 +                AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR, "$wayland_cursor_lib", [ ])
    2.59 +                AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON, "$xkbcommon_lib", [ ])
    2.60 +            else
    2.61 +                enable_wayland_shared=no
    2.62 +                EXTRA_LDFLAGS="$EXTRA_LDFLAGS $WAYLAND_LIBS"
    2.63 +            fi
    2.64              have_video=yes
    2.65          fi
    2.66      fi
     3.1 --- a/include/SDL_config.h.in	Wed Jan 08 14:53:08 2014 -0500
     3.2 +++ b/include/SDL_config.h.in	Thu Jan 09 13:56:21 2014 -0300
     3.3 @@ -263,6 +263,10 @@
     3.4  #undef SDL_VIDEO_DRIVER_WINDOWS
     3.5  #undef SDL_VIDEO_DRIVER_WAYLAND
     3.6  #undef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
     3.7 +#undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC
     3.8 +#undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL
     3.9 +#undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR
    3.10 +#undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON
    3.11  #undef SDL_VIDEO_DRIVER_X11
    3.12  #undef SDL_VIDEO_DRIVER_RPI
    3.13  #undef SDL_VIDEO_DRIVER_X11_DYNAMIC
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/src/video/wayland/SDL_waylanddyn.c	Thu Jan 09 13:56:21 2014 -0300
     4.3 @@ -0,0 +1,195 @@
     4.4 +/*
     4.5 +  Simple DirectMedia Layer
     4.6 +  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
     4.7 +
     4.8 +  This software is provided 'as-is', without any express or implied
     4.9 +  warranty.  In no event will the authors be held liable for any damages
    4.10 +  arising from the use of this software.
    4.11 +
    4.12 +  Permission is granted to anyone to use this software for any purpose,
    4.13 +  including commercial applications, and to alter it and redistribute it
    4.14 +  freely, subject to the following restrictions:
    4.15 +
    4.16 +  1. The origin of this software must not be misrepresented; you must not
    4.17 +     claim that you wrote the original software. If you use this software
    4.18 +     in a product, an acknowledgment in the product documentation would be
    4.19 +     appreciated but is not required.
    4.20 +  2. Altered source versions must be plainly marked as such, and must not be
    4.21 +     misrepresented as being the original software.
    4.22 +  3. This notice may not be removed or altered from any source distribution.
    4.23 +*/
    4.24 +#include "../../SDL_internal.h"
    4.25 +
    4.26 +#if SDL_VIDEO_DRIVER_WAYLAND
    4.27 +
    4.28 +#define DEBUG_DYNAMIC_WAYLAND 0
    4.29 +
    4.30 +#include "SDL_waylanddyn.h"
    4.31 +
    4.32 +#if DEBUG_DYNAMIC_WAYLAND
    4.33 +#include "SDL_log.h"
    4.34 +#endif
    4.35 +
    4.36 +#ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC
    4.37 +
    4.38 +#include "SDL_name.h"
    4.39 +#include "SDL_loadso.h"
    4.40 +
    4.41 +typedef struct
    4.42 +{
    4.43 +    void *lib;
    4.44 +    const char *libname;
    4.45 +} waylanddynlib;
    4.46 +
    4.47 +#ifndef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC
    4.48 +#define SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC NULL
    4.49 +#endif
    4.50 +#ifndef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL
    4.51 +#define SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL NULL
    4.52 +#endif
    4.53 +#ifndef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR
    4.54 +#define SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR NULL
    4.55 +#endif
    4.56 +#ifndef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON
    4.57 +#define SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON NULL
    4.58 +#endif
    4.59 +
    4.60 +static waylanddynlib waylandlibs[] = {
    4.61 +    {NULL, SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC},
    4.62 +    {NULL, SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL},
    4.63 +    {NULL, SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR},
    4.64 +    {NULL, SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON}
    4.65 +};
    4.66 +
    4.67 +static void *
    4.68 +WAYLAND_GetSym(const char *fnname, int *pHasModule)
    4.69 +{
    4.70 +    int i;
    4.71 +    void *fn = NULL;
    4.72 +    for (i = 0; i < SDL_TABLESIZE(waylandlibs); i++) {
    4.73 +        if (waylandlibs[i].lib != NULL) {
    4.74 +            fn = SDL_LoadFunction(waylandlibs[i].lib, fnname);
    4.75 +            if (fn != NULL)
    4.76 +                break;
    4.77 +        }
    4.78 +    }
    4.79 +
    4.80 +#if DEBUG_DYNAMIC_WAYLAND
    4.81 +    if (fn != NULL)
    4.82 +        SDL_Log("WAYLAND: Found '%s' in %s (%p)\n", fnname, waylandlibs[i].libname, fn);
    4.83 +    else
    4.84 +        SDL_Log("WAYLAND: Symbol '%s' NOT FOUND!\n", fnname);
    4.85 +#endif
    4.86 +
    4.87 +    if (fn == NULL)
    4.88 +        *pHasModule = 0;  /* kill this module. */
    4.89 +
    4.90 +    return fn;
    4.91 +}
    4.92 +
    4.93 +#endif /* SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC */
    4.94 +
    4.95 +/* Define all the function pointers and wrappers... */
    4.96 +#define SDL_WAYLAND_MODULE(modname) int SDL_WAYLAND_HAVE_##modname = 0;
    4.97 +#define SDL_WAYLAND_SYM(rc,fn,params) SDL_DYNWAYLANDFN_##fn WAYLAND_##fn = NULL;
    4.98 +#define SDL_WAYLAND_INTERFACE(iface) const struct wl_interface *WAYLAND_##iface = NULL;
    4.99 +#include "SDL_waylandsym.h"
   4.100 +#undef SDL_WAYLAND_MODULE
   4.101 +#undef SDL_WAYLAND_SYM
   4.102 +#undef SDL_WAYLAND_INTERFACE
   4.103 +
   4.104 +static int wayland_load_refcount = 0;
   4.105 +
   4.106 +void
   4.107 +SDL_WAYLAND_UnloadSymbols(void)
   4.108 +{
   4.109 +    /* Don't actually unload if more than one module is using the libs... */
   4.110 +    if (wayland_load_refcount > 0) {
   4.111 +        if (--wayland_load_refcount == 0) {
   4.112 +#ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC            
   4.113 +            int i;
   4.114 +#endif
   4.115 +            
   4.116 +            /* set all the function pointers to NULL. */
   4.117 +#define SDL_WAYLAND_MODULE(modname) SDL_WAYLAND_HAVE_##modname = 0;
   4.118 +#define SDL_WAYLAND_SYM(rc,fn,params) WAYLAND_##fn = NULL;
   4.119 +#define SDL_WAYLAND_INTERFACE(iface) WAYLAND_##iface = NULL;
   4.120 +#include "SDL_waylandsym.h"
   4.121 +#undef SDL_WAYLAND_MODULE
   4.122 +#undef SDL_WAYLAND_SYM
   4.123 +#undef SDL_WAYLAND_INTERFACE
   4.124 +
   4.125 +
   4.126 +#ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC
   4.127 +            for (i = 0; i < SDL_TABLESIZE(waylandlibs); i++) {
   4.128 +                if (waylandlibs[i].lib != NULL) {
   4.129 +                    SDL_UnloadObject(waylandlibs[i].lib);
   4.130 +                    waylandlibs[i].lib = NULL;
   4.131 +                }
   4.132 +            }
   4.133 +#endif
   4.134 +        }
   4.135 +    }
   4.136 +}
   4.137 +
   4.138 +/* returns non-zero if all needed symbols were loaded. */
   4.139 +int
   4.140 +SDL_WAYLAND_LoadSymbols(void)
   4.141 +{
   4.142 +    int rc = 1;                 /* always succeed if not using Dynamic WAYLAND stuff. */
   4.143 +
   4.144 +    /* deal with multiple modules (dga, wayland, etc) needing these symbols... */
   4.145 +    if (wayland_load_refcount++ == 0) {
   4.146 +#ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC
   4.147 +        int i;
   4.148 +        int *thismod = NULL;
   4.149 +        for (i = 0; i < SDL_TABLESIZE(waylandlibs); i++) {
   4.150 +            if (waylandlibs[i].libname != NULL) {
   4.151 +                waylandlibs[i].lib = SDL_LoadObject(waylandlibs[i].libname);
   4.152 +            }
   4.153 +        }
   4.154 +
   4.155 +#define SDL_WAYLAND_MODULE(modname) SDL_WAYLAND_HAVE_##modname = 1; /* default yes */
   4.156 +#define SDL_WAYLAND_SYM(rc,fn,params)
   4.157 +#define SDL_WAYLAND_INTERFACE(iface)
   4.158 +#include "SDL_waylandsym.h"
   4.159 +#undef SDL_WAYLAND_MODULE
   4.160 +#undef SDL_WAYLAND_SYM
   4.161 +#undef SDL_WAYLAND_INTERFACE
   4.162 +
   4.163 +#define SDL_WAYLAND_MODULE(modname) thismod = &SDL_WAYLAND_HAVE_##modname;
   4.164 +#define SDL_WAYLAND_SYM(rc,fn,params) WAYLAND_##fn = (SDL_DYNWAYLANDFN_##fn) WAYLAND_GetSym(#fn,thismod);
   4.165 +#define SDL_WAYLAND_INTERFACE(iface) WAYLAND_##iface = (struct wl_interface *) WAYLAND_GetSym(#iface,thismod);
   4.166 +#include "SDL_waylandsym.h"
   4.167 +#undef SDL_WAYLAND_MODULE
   4.168 +#undef SDL_WAYLAND_SYM
   4.169 +#undef SDL_WAYLAND_INTERFACE
   4.170 +
   4.171 +        if (SDL_WAYLAND_HAVE_WAYLAND_CLIENT) {
   4.172 +            /* all required symbols loaded. */
   4.173 +            SDL_ClearError();
   4.174 +        } else {
   4.175 +            /* in case something got loaded... */
   4.176 +            SDL_WAYLAND_UnloadSymbols();
   4.177 +            rc = 0;
   4.178 +        }
   4.179 +
   4.180 +#else  /* no dynamic WAYLAND */
   4.181 +
   4.182 +#define SDL_WAYLAND_MODULE(modname) SDL_WAYLAND_HAVE_##modname = 1; /* default yes */
   4.183 +#define SDL_WAYLAND_SYM(rc,fn,params) WAYLAND_##fn = fn;
   4.184 +#define SDL_WAYLAND_INTERFACE(iface) WAYLAND_##iface = &iface;
   4.185 +#include "SDL_waylandsym.h"
   4.186 +#undef SDL_WAYLAND_MODULE
   4.187 +#undef SDL_WAYLAND_SYM
   4.188 +#undef SDL_WAYLAND_INTERFACE
   4.189 +
   4.190 +#endif
   4.191 +    }
   4.192 +
   4.193 +    return rc;
   4.194 +}
   4.195 +
   4.196 +#endif /* SDL_VIDEO_DRIVER_WAYLAND */
   4.197 +
   4.198 +/* vi: set ts=4 sw=4 expandtab: */
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/src/video/wayland/SDL_waylanddyn.h	Thu Jan 09 13:56:21 2014 -0300
     5.3 @@ -0,0 +1,103 @@
     5.4 +/*
     5.5 +  Simple DirectMedia Layer
     5.6 +  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
     5.7 +
     5.8 +  This software is provided 'as-is', without any express or implied
     5.9 +  warranty.  In no event will the authors be held liable for any damages
    5.10 +  arising from the use of this software.
    5.11 +
    5.12 +  Permission is granted to anyone to use this software for any purpose,
    5.13 +  including commercial applications, and to alter it and redistribute it
    5.14 +  freely, subject to the following restrictions:
    5.15 +
    5.16 +  1. The origin of this software must not be misrepresented; you must not
    5.17 +     claim that you wrote the original software. If you use this software
    5.18 +     in a product, an acknowledgment in the product documentation would be
    5.19 +     appreciated but is not required.
    5.20 +  2. Altered source versions must be plainly marked as such, and must not be
    5.21 +     misrepresented as being the original software.
    5.22 +  3. This notice may not be removed or altered from any source distribution.
    5.23 +*/
    5.24 +
    5.25 +#ifndef _SDL_waylanddyn_h
    5.26 +#define _SDL_waylanddyn_h
    5.27 +
    5.28 +#include "../../SDL_internal.h"
    5.29 +
    5.30 +/* We can't include wayland-client.h here 
    5.31 + * but we need some structs from it
    5.32 + */
    5.33 +struct wl_interface;
    5.34 +struct wl_proxy;
    5.35 +struct wl_event_queue;
    5.36 +struct wl_display;
    5.37 +struct wl_surface;
    5.38 +struct wl_shm;
    5.39 +
    5.40 +#include <stdint.h>
    5.41 +#include "wayland-cursor.h"
    5.42 +#include "wayland-util.h"
    5.43 +#include "xkbcommon/xkbcommon.h"
    5.44 +
    5.45 +#ifdef __cplusplus
    5.46 +extern "C"
    5.47 +{
    5.48 +#endif
    5.49 +
    5.50 +int SDL_WAYLAND_LoadSymbols(void);
    5.51 +void SDL_WAYLAND_UnloadSymbols(void);
    5.52 +
    5.53 +#define SDL_WAYLAND_MODULE(modname) extern int SDL_WAYLAND_HAVE_##modname;
    5.54 +#define SDL_WAYLAND_SYM(rc,fn,params) \
    5.55 +    typedef rc (*SDL_DYNWAYLANDFN_##fn) params; \
    5.56 +    extern SDL_DYNWAYLANDFN_##fn WAYLAND_##fn;
    5.57 +#define SDL_WAYLAND_INTERFACE(iface) extern const struct wl_interface *WAYLAND_##iface;
    5.58 +#include "SDL_waylandsym.h"
    5.59 +#undef SDL_WAYLAND_MODULE
    5.60 +#undef SDL_WAYLAND_SYM
    5.61 +#undef SDL_WAYLAND_INTERFACE
    5.62 + 
    5.63 +
    5.64 +#ifdef __cplusplus
    5.65 +}
    5.66 +#endif
    5.67 +
    5.68 +#ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC
    5.69 +
    5.70 +#ifdef _WAYLAND_CLIENT_H
    5.71 +#error Do not include wayland-client ahead of SDL_waylanddyn.h in dynamic loading mode
    5.72 +#endif
    5.73 +
    5.74 +/* wayland-client-protocol.h included from wayland-client.h
    5.75 + * has inline functions that require these to be defined in dynamic loading mode
    5.76 + */
    5.77 +
    5.78 +#define wl_proxy_create (*WAYLAND_wl_proxy_create)
    5.79 +#define wl_proxy_destroy (*WAYLAND_wl_proxy_destroy)
    5.80 +#define wl_proxy_marshal (*WAYLAND_wl_proxy_marshal)
    5.81 +#define wl_proxy_set_user_data (*WAYLAND_wl_proxy_set_user_data)
    5.82 +#define wl_proxy_get_user_data (*WAYLAND_wl_proxy_get_user_data)
    5.83 +#define wl_proxy_add_listener (*WAYLAND_wl_proxy_add_listener)
    5.84 +
    5.85 +#define wl_seat_interface (*WAYLAND_wl_seat_interface)
    5.86 +#define wl_surface_interface (*WAYLAND_wl_surface_interface)
    5.87 +#define wl_shm_pool_interface (*WAYLAND_wl_shm_pool_interface)
    5.88 +#define wl_buffer_interface (*WAYLAND_wl_buffer_interface)
    5.89 +#define wl_registry_interface (*WAYLAND_wl_registry_interface)
    5.90 +#define wl_shell_surface_interface (*WAYLAND_wl_shell_surface_interface)
    5.91 +#define wl_region_interface (*WAYLAND_wl_region_interface)
    5.92 +#define wl_pointer_interface (*WAYLAND_wl_pointer_interface)
    5.93 +#define wl_keyboard_interface (*WAYLAND_wl_keyboard_interface)
    5.94 +#define wl_compositor_interface (*WAYLAND_wl_compositor_interface)
    5.95 +#define wl_output_interface (*WAYLAND_wl_output_interface)
    5.96 +#define wl_shell_interface (*WAYLAND_wl_shell_interface)
    5.97 +#define wl_shm_interface (*WAYLAND_wl_shm_interface)
    5.98 +
    5.99 +#endif /* SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC */
   5.100 +
   5.101 +#include "wayland-client.h"
   5.102 +#include "wayland-egl.h"
   5.103 +
   5.104 +#endif /* !defined _SDL_waylanddyn_h */
   5.105 +
   5.106 +/* vi: set ts=4 sw=4 expandtab: */
     6.1 --- a/src/video/wayland/SDL_waylandevents.c	Wed Jan 08 14:53:08 2014 -0500
     6.2 +++ b/src/video/wayland/SDL_waylandevents.c	Thu Jan 09 13:56:21 2014 -0300
     6.3 @@ -19,7 +19,7 @@
     6.4    3. This notice may not be removed or altered from any source distribution.
     6.5  */
     6.6  
     6.7 -#include "SDL_config.h"
     6.8 +#include "../../SDL_internal.h"
     6.9  
    6.10  #include "SDL_stdinc.h"
    6.11  #include "SDL_assert.h"
    6.12 @@ -32,6 +32,8 @@
    6.13  #include "SDL_waylandevents_c.h"
    6.14  #include "SDL_waylandwindow.h"
    6.15  
    6.16 +#include "SDL_waylanddyn.h"
    6.17 +
    6.18  #include <linux/input.h>
    6.19  #include <sys/select.h>
    6.20  #include <sys/mman.h>
    6.21 @@ -60,14 +62,14 @@
    6.22      SDL_VideoData *d = _this->driverdata;
    6.23      struct pollfd pfd[1];
    6.24  
    6.25 -    pfd[0].fd = wl_display_get_fd(d->display);
    6.26 +    pfd[0].fd = WAYLAND_wl_display_get_fd(d->display);
    6.27      pfd[0].events = POLLIN;
    6.28      poll(pfd, 1, 0);
    6.29  
    6.30      if (pfd[0].revents & POLLIN)
    6.31 -        wl_display_dispatch(d->display);
    6.32 +        WAYLAND_wl_display_dispatch(d->display);
    6.33      else
    6.34 -        wl_display_dispatch_pending(d->display);
    6.35 +        WAYLAND_wl_display_dispatch_pending(d->display);
    6.36  }
    6.37  
    6.38  static void
    6.39 @@ -199,7 +201,7 @@
    6.40          return;
    6.41      }
    6.42  
    6.43 -    input->xkb.keymap = xkb_map_new_from_string(input->display->xkb_context,
    6.44 +    input->xkb.keymap = WAYLAND_xkb_keymap_new_from_string(input->display->xkb_context,
    6.45                                                  map_str,
    6.46                                                  XKB_KEYMAP_FORMAT_TEXT_V1,
    6.47                                                  0);
    6.48 @@ -211,10 +213,10 @@
    6.49          return;
    6.50      }
    6.51  
    6.52 -    input->xkb.state = xkb_state_new(input->xkb.keymap);
    6.53 +    input->xkb.state = WAYLAND_xkb_state_new(input->xkb.keymap);
    6.54      if (!input->xkb.state) {
    6.55          fprintf(stderr, "failed to create XKB state\n");
    6.56 -        xkb_map_unref(input->xkb.keymap);
    6.57 +        WAYLAND_xkb_keymap_unref(input->xkb.keymap);
    6.58          input->xkb.keymap = NULL;
    6.59          return;
    6.60      }
    6.61 @@ -266,11 +268,11 @@
    6.62          return;
    6.63  
    6.64      // TODO can this happen?
    6.65 -    if (xkb_key_get_syms(input->xkb.state, key + 8, &syms) != 1)
    6.66 +    if (WAYLAND_xkb_state_key_get_syms(input->xkb.state, key + 8, &syms) != 1)
    6.67          return;
    6.68  
    6.69      if (state) {
    6.70 -        size = xkb_keysym_to_utf8(syms[0], text, sizeof text);
    6.71 +        size = WAYLAND_xkb_keysym_to_utf8(syms[0], text, sizeof text);
    6.72  
    6.73          if (size > 0) {
    6.74              text[size] = 0;
    6.75 @@ -287,7 +289,7 @@
    6.76  {
    6.77      struct SDL_WaylandInput *input = data;
    6.78  
    6.79 -    xkb_state_update_mask(input->xkb.state, mods_depressed, mods_latched,
    6.80 +    WAYLAND_xkb_state_update_mask(input->xkb.state, mods_depressed, mods_latched,
    6.81                            mods_locked, 0, 0, group);
    6.82  }
    6.83  
    6.84 @@ -349,7 +351,7 @@
    6.85      wl_seat_add_listener(input->seat, &seat_listener, input);
    6.86      wl_seat_set_user_data(input->seat, input);
    6.87  
    6.88 -    wayland_schedule_write(d);
    6.89 +    WAYLAND_wl_display_flush(d->display);
    6.90  }
    6.91  
    6.92  void Wayland_display_destroy_input(SDL_VideoData *d)
    6.93 @@ -369,10 +371,10 @@
    6.94          wl_seat_destroy(input->seat);
    6.95  
    6.96      if (input->xkb.state)
    6.97 -        xkb_state_unref(input->xkb.state);
    6.98 +        WAYLAND_xkb_state_unref(input->xkb.state);
    6.99  
   6.100      if (input->xkb.keymap)
   6.101 -        xkb_map_unref(input->xkb.keymap);
   6.102 +        WAYLAND_xkb_keymap_unref(input->xkb.keymap);
   6.103  
   6.104      free(input);
   6.105      d->input = NULL;
     7.1 --- a/src/video/wayland/SDL_waylandevents_c.h	Wed Jan 08 14:53:08 2014 -0500
     7.2 +++ b/src/video/wayland/SDL_waylandevents_c.h	Thu Jan 09 13:56:21 2014 -0300
     7.3 @@ -19,7 +19,7 @@
     7.4    3. This notice may not be removed or altered from any source distribution.
     7.5  */
     7.6  
     7.7 -#include "SDL_config.h"
     7.8 +#include "../../SDL_internal.h"
     7.9  
    7.10  #ifndef _SDL_waylandevents_h
    7.11  #define _SDL_waylandevents_h
     8.1 --- a/src/video/wayland/SDL_waylandmouse.c	Wed Jan 08 14:53:08 2014 -0500
     8.2 +++ b/src/video/wayland/SDL_waylandmouse.c	Thu Jan 09 13:56:21 2014 -0300
     8.3 @@ -31,14 +31,17 @@
     8.4  #include <stdlib.h>
     8.5  #include <limits.h>
     8.6  
     8.7 +#include "../../SDL_internal.h"
     8.8  #include "../SDL_sysvideo.h"
     8.9  
    8.10 -#include "SDL_config.h"
    8.11  #include "SDL_mouse.h"
    8.12  #include "../../events/SDL_mouse_c.h"
    8.13  #include "SDL_waylandvideo.h"
    8.14  #include "SDL_waylandevents_c.h"
    8.15  
    8.16 +#include "SDL_waylanddyn.h"
    8.17 +#include "wayland-cursor.h"
    8.18 +
    8.19  #include "SDL_assert.h"
    8.20  
    8.21  #if SDL_VIDEO_DRIVER_WAYLAND
    8.22 @@ -210,7 +213,7 @@
    8.23          data->buffer = NULL;
    8.24          data->surface = wl_compositor_create_surface(d->compositor);
    8.25          wl_surface_attach(data->surface,
    8.26 -                          wl_cursor_image_get_buffer(wlcursor->images[0]),
    8.27 +                          WAYLAND_wl_cursor_image_get_buffer(wlcursor->images[0]),
    8.28                            0,
    8.29                            0);
    8.30          wl_surface_damage(data->surface,
    8.31 @@ -236,7 +239,7 @@
    8.32      SDL_VideoData *data = device->driverdata;
    8.33  
    8.34      return CreateCursorFromWlCursor (data,
    8.35 -                                     wl_cursor_theme_get_cursor(data->cursor_theme,
    8.36 +                                     WAYLAND_wl_cursor_theme_get_cursor(data->cursor_theme,
    8.37                                                                  "left_ptr"));
    8.38  }
    8.39  
    8.40 @@ -254,40 +257,40 @@
    8.41          SDL_assert(0);
    8.42          return NULL;
    8.43      case SDL_SYSTEM_CURSOR_ARROW:
    8.44 -        cursor = wl_cursor_theme_get_cursor(d->cursor_theme, "left_ptr");
    8.45 +        cursor = WAYLAND_wl_cursor_theme_get_cursor(d->cursor_theme, "left_ptr");
    8.46          break;
    8.47      case SDL_SYSTEM_CURSOR_IBEAM:
    8.48 -        cursor = wl_cursor_theme_get_cursor(d->cursor_theme, "xterm");
    8.49 +        cursor = WAYLAND_wl_cursor_theme_get_cursor(d->cursor_theme, "xterm");
    8.50          break;
    8.51      case SDL_SYSTEM_CURSOR_WAIT:
    8.52 -        cursor = wl_cursor_theme_get_cursor(d->cursor_theme, "wait");
    8.53 +        cursor = WAYLAND_wl_cursor_theme_get_cursor(d->cursor_theme, "wait");
    8.54          break;
    8.55      case SDL_SYSTEM_CURSOR_CROSSHAIR:
    8.56 -        cursor = wl_cursor_theme_get_cursor(d->cursor_theme, "hand1");
    8.57 +        cursor = WAYLAND_wl_cursor_theme_get_cursor(d->cursor_theme, "hand1");
    8.58          break;
    8.59      case SDL_SYSTEM_CURSOR_WAITARROW:
    8.60 -        cursor = wl_cursor_theme_get_cursor(d->cursor_theme, "wait");
    8.61 +        cursor = WAYLAND_wl_cursor_theme_get_cursor(d->cursor_theme, "wait");
    8.62          break;
    8.63      case SDL_SYSTEM_CURSOR_SIZENWSE:
    8.64 -        cursor = wl_cursor_theme_get_cursor(d->cursor_theme, "hand1");
    8.65 +        cursor = WAYLAND_wl_cursor_theme_get_cursor(d->cursor_theme, "hand1");
    8.66          break;
    8.67      case SDL_SYSTEM_CURSOR_SIZENESW:
    8.68 -        cursor = wl_cursor_theme_get_cursor(d->cursor_theme, "hand1");
    8.69 +        cursor = WAYLAND_wl_cursor_theme_get_cursor(d->cursor_theme, "hand1");
    8.70          break;
    8.71      case SDL_SYSTEM_CURSOR_SIZEWE:
    8.72 -        cursor = wl_cursor_theme_get_cursor(d->cursor_theme, "hand1");
    8.73 +        cursor = WAYLAND_wl_cursor_theme_get_cursor(d->cursor_theme, "hand1");
    8.74          break;
    8.75      case SDL_SYSTEM_CURSOR_SIZENS:
    8.76 -        cursor = wl_cursor_theme_get_cursor(d->cursor_theme, "hand1");
    8.77 +        cursor = WAYLAND_wl_cursor_theme_get_cursor(d->cursor_theme, "hand1");
    8.78          break;
    8.79      case SDL_SYSTEM_CURSOR_SIZEALL:
    8.80 -        cursor = wl_cursor_theme_get_cursor(d->cursor_theme, "hand1");
    8.81 +        cursor = WAYLAND_wl_cursor_theme_get_cursor(d->cursor_theme, "hand1");
    8.82          break;
    8.83      case SDL_SYSTEM_CURSOR_NO:
    8.84 -        cursor = wl_cursor_theme_get_cursor(d->cursor_theme, "xterm");
    8.85 +        cursor = WAYLAND_wl_cursor_theme_get_cursor(d->cursor_theme, "xterm");
    8.86          break;
    8.87      case SDL_SYSTEM_CURSOR_HAND:
    8.88 -        cursor = wl_cursor_theme_get_cursor(d->cursor_theme, "hand1");
    8.89 +        cursor = WAYLAND_wl_cursor_theme_get_cursor(d->cursor_theme, "hand1");
    8.90          break;
    8.91      }
    8.92  
     9.1 --- a/src/video/wayland/SDL_waylandmouse.h	Wed Jan 08 14:53:08 2014 -0500
     9.2 +++ b/src/video/wayland/SDL_waylandmouse.h	Thu Jan 09 13:56:21 2014 -0300
     9.3 @@ -19,7 +19,7 @@
     9.4    3. This notice may not be removed or altered from any source distribution.
     9.5  */
     9.6  
     9.7 -#include "SDL_config.h"
     9.8 +#include "../../SDL_internal.h"
     9.9  #include "SDL_mouse.h"
    9.10  #include "SDL_waylandvideo.h"
    9.11  
    10.1 --- a/src/video/wayland/SDL_waylandopengles.c	Wed Jan 08 14:53:08 2014 -0500
    10.2 +++ b/src/video/wayland/SDL_waylandopengles.c	Thu Jan 09 13:56:21 2014 -0300
    10.3 @@ -18,7 +18,7 @@
    10.4       misrepresented as being the original software.
    10.5    3. This notice may not be removed or altered from any source distribution.
    10.6  */
    10.7 -#include "SDL_config.h"
    10.8 +#include "../../SDL_internal.h"
    10.9  
   10.10  #if SDL_VIDEO_DRIVER_WAYLAND && SDL_VIDEO_OPENGL_EGL
   10.11  
   10.12 @@ -26,6 +26,7 @@
   10.13  #include "SDL_waylandopengles.h"
   10.14  #include "SDL_waylandwindow.h"
   10.15  #include "SDL_waylandevents_c.h"
   10.16 +#include "SDL_waylanddyn.h"
   10.17  
   10.18  /* EGL implementation of SDL OpenGL ES support */
   10.19  
   10.20 @@ -37,7 +38,7 @@
   10.21      ret = SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType) data->display);
   10.22  
   10.23      Wayland_PumpEvents(_this);
   10.24 -    wayland_schedule_write(data);
   10.25 +    WAYLAND_wl_display_flush(data->display);
   10.26      
   10.27      return ret;
   10.28  }
   10.29 @@ -48,7 +49,7 @@
   10.30  {
   10.31      SDL_GLContext context;
   10.32      context = SDL_EGL_CreateContext(_this, ((SDL_WindowData *) window->driverdata)->egl_surface);
   10.33 -    wayland_schedule_write(_this->driverdata);
   10.34 +    WAYLAND_wl_display_flush( ((SDL_VideoData*)_this->driverdata)->display );
   10.35      
   10.36      return context;
   10.37  }
   10.38 @@ -57,7 +58,7 @@
   10.39  Wayland_GLES_SwapWindow(_THIS, SDL_Window *window)
   10.40  {
   10.41      SDL_EGL_SwapBuffers(_this, ((SDL_WindowData *) window->driverdata)->egl_surface);
   10.42 -    wayland_schedule_write(_this->driverdata);
   10.43 +    WAYLAND_wl_display_flush( ((SDL_VideoData*)_this->driverdata)->display );
   10.44  }
   10.45  
   10.46  
   10.47 @@ -73,7 +74,7 @@
   10.48          ret = SDL_EGL_MakeCurrent(_this, NULL, NULL);
   10.49      }
   10.50      
   10.51 -    wayland_schedule_write(_this->driverdata);
   10.52 +    WAYLAND_wl_display_flush( ((SDL_VideoData*)_this->driverdata)->display );
   10.53      
   10.54      return ret;
   10.55  }
   10.56 @@ -82,7 +83,7 @@
   10.57  Wayland_GLES_DeleteContext(_THIS, SDL_GLContext context)
   10.58  {
   10.59      SDL_EGL_DeleteContext(_this, context);
   10.60 -    wayland_schedule_write(_this->driverdata);
   10.61 +    WAYLAND_wl_display_flush( ((SDL_VideoData*)_this->driverdata)->display );
   10.62  }
   10.63  
   10.64  #endif /* SDL_VIDEO_DRIVER_WAYLAND && SDL_VIDEO_OPENGL_EGL */
    11.1 --- a/src/video/wayland/SDL_waylandopengles.h	Wed Jan 08 14:53:08 2014 -0500
    11.2 +++ b/src/video/wayland/SDL_waylandopengles.h	Thu Jan 09 13:56:21 2014 -0300
    11.3 @@ -18,7 +18,7 @@
    11.4       misrepresented as being the original software.
    11.5    3. This notice may not be removed or altered from any source distribution.
    11.6  */
    11.7 -#include "SDL_config.h"
    11.8 +#include "../../SDL_internal.h"
    11.9  
   11.10  #ifndef _SDL_waylandopengles_h
   11.11  #define _SDL_waylandopengles_h
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/src/video/wayland/SDL_waylandsym.h	Thu Jan 09 13:56:21 2014 -0300
    12.3 @@ -0,0 +1,102 @@
    12.4 +/*
    12.5 +  Simple DirectMedia Layer
    12.6 +  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    12.7 +
    12.8 +  This software is provided 'as-is', without any express or implied
    12.9 +  warranty.  In no event will the authors be held liable for any damages
   12.10 +  arising from the use of this software.
   12.11 +
   12.12 +  Permission is granted to anyone to use this software for any purpose,
   12.13 +  including commercial applications, and to alter it and redistribute it
   12.14 +  freely, subject to the following restrictions:
   12.15 +
   12.16 +  1. The origin of this software must not be misrepresented; you must not
   12.17 +     claim that you wrote the original software. If you use this software
   12.18 +     in a product, an acknowledgment in the product documentation would be
   12.19 +     appreciated but is not required.
   12.20 +  2. Altered source versions must be plainly marked as such, and must not be
   12.21 +     misrepresented as being the original software.
   12.22 +  3. This notice may not be removed or altered from any source distribution.
   12.23 +*/
   12.24 +
   12.25 +/* *INDENT-OFF* */
   12.26 +
   12.27 +SDL_WAYLAND_MODULE(WAYLAND_CLIENT)
   12.28 +SDL_WAYLAND_SYM(void, wl_proxy_marshal, (struct wl_proxy *, uint32_t, ...))
   12.29 +SDL_WAYLAND_SYM(struct wl_proxy *, wl_proxy_create, (struct wl_proxy *, const struct wl_interface *))
   12.30 +SDL_WAYLAND_SYM(void, wl_proxy_destroy, (struct wl_proxy *))
   12.31 +SDL_WAYLAND_SYM(int, wl_proxy_add_listener, (struct wl_proxy *, void (**)(void), void *))
   12.32 +SDL_WAYLAND_SYM(void, wl_proxy_set_user_data, (struct wl_proxy *, void *))
   12.33 +SDL_WAYLAND_SYM(void *, wl_proxy_get_user_data, (struct wl_proxy *))
   12.34 +SDL_WAYLAND_SYM(uint32_t, wl_proxy_get_id, (struct wl_proxy *))
   12.35 +SDL_WAYLAND_SYM(const char *, wl_proxy_get_class, (struct wl_proxy *))
   12.36 +SDL_WAYLAND_SYM(void, wl_proxy_set_queue, (struct wl_proxy *, struct wl_event_queue *))
   12.37 +SDL_WAYLAND_SYM(struct wl_display *, wl_display_connect, (const char *))
   12.38 +SDL_WAYLAND_SYM(struct wl_display *, wl_display_connect_to_fd, (int))
   12.39 +SDL_WAYLAND_SYM(void, wl_display_disconnect, (struct wl_display *))
   12.40 +SDL_WAYLAND_SYM(int, wl_display_get_fd, (struct wl_display *))
   12.41 +SDL_WAYLAND_SYM(int, wl_display_dispatch, (struct wl_display *))
   12.42 +SDL_WAYLAND_SYM(int, wl_display_dispatch_queue, (struct wl_display *, struct wl_event_queue *))
   12.43 +SDL_WAYLAND_SYM(int, wl_display_dispatch_queue_pending, (struct wl_display *, struct wl_event_queue *))
   12.44 +SDL_WAYLAND_SYM(int, wl_display_dispatch_pending, (struct wl_display *))
   12.45 +SDL_WAYLAND_SYM(int, wl_display_get_error, (struct wl_display *))
   12.46 +SDL_WAYLAND_SYM(int, wl_display_flush, (struct wl_display *))
   12.47 +SDL_WAYLAND_SYM(int, wl_display_roundtrip, (struct wl_display *))
   12.48 +SDL_WAYLAND_SYM(struct wl_event_queue *, wl_display_create_queue, (struct wl_display *))
   12.49 +SDL_WAYLAND_SYM(void, wl_log_set_handler_client, (wl_log_func_t))
   12.50 +SDL_WAYLAND_SYM(void, wl_list_init, (struct wl_list *))
   12.51 +SDL_WAYLAND_SYM(void, wl_list_insert, (struct wl_list *, struct wl_list *) )
   12.52 +SDL_WAYLAND_SYM(void, wl_list_remove, (struct wl_list *))
   12.53 +SDL_WAYLAND_SYM(int, wl_list_length, (const struct wl_list *))
   12.54 +SDL_WAYLAND_SYM(int, wl_list_empty, (const struct wl_list *))
   12.55 +SDL_WAYLAND_SYM(void, wl_list_insert_list, (struct wl_list *, struct wl_list *))
   12.56 +
   12.57 +SDL_WAYLAND_INTERFACE(wl_seat_interface)
   12.58 +SDL_WAYLAND_INTERFACE(wl_surface_interface)
   12.59 +SDL_WAYLAND_INTERFACE(wl_shm_pool_interface)
   12.60 +SDL_WAYLAND_INTERFACE(wl_buffer_interface)
   12.61 +SDL_WAYLAND_INTERFACE(wl_registry_interface)
   12.62 +SDL_WAYLAND_INTERFACE(wl_shell_surface_interface)
   12.63 +SDL_WAYLAND_INTERFACE(wl_region_interface)
   12.64 +SDL_WAYLAND_INTERFACE(wl_pointer_interface)
   12.65 +SDL_WAYLAND_INTERFACE(wl_keyboard_interface)
   12.66 +SDL_WAYLAND_INTERFACE(wl_compositor_interface)
   12.67 +SDL_WAYLAND_INTERFACE(wl_output_interface)
   12.68 +SDL_WAYLAND_INTERFACE(wl_shell_interface)
   12.69 +SDL_WAYLAND_INTERFACE(wl_shm_interface)
   12.70 +
   12.71 +SDL_WAYLAND_MODULE(WAYLAND_EGL)
   12.72 +SDL_WAYLAND_SYM(struct wl_egl_window *, wl_egl_window_create, (struct wl_surface *, int, int))
   12.73 +SDL_WAYLAND_SYM(void, wl_egl_window_destroy, (struct wl_egl_window *))
   12.74 +SDL_WAYLAND_SYM(void, wl_egl_window_resize, (struct wl_egl_window *, int, int, int, int))
   12.75 +SDL_WAYLAND_SYM(void, wl_egl_window_get_attached_size, (struct wl_egl_window *, int *, int *))
   12.76 +
   12.77 +SDL_WAYLAND_MODULE(WAYLAND_CURSOR)
   12.78 +SDL_WAYLAND_SYM(struct wl_cursor_theme *, wl_cursor_theme_load, (const char *, int , struct wl_shm *))
   12.79 +SDL_WAYLAND_SYM(void, wl_cursor_theme_destroy, (struct wl_cursor_theme *))
   12.80 +SDL_WAYLAND_SYM(struct wl_cursor *, wl_cursor_theme_get_cursor, (struct wl_cursor_theme *, const char *))
   12.81 +SDL_WAYLAND_SYM(struct wl_buffer *, wl_cursor_image_get_buffer, (struct wl_cursor_image *))
   12.82 +SDL_WAYLAND_SYM(int, wl_cursor_frame, (struct wl_cursor *, uint32_t))
   12.83 +
   12.84 +SDL_WAYLAND_MODULE(WAYLAND_XKB)
   12.85 +SDL_WAYLAND_SYM(int, xkb_state_key_get_syms, (struct xkb_state *, xkb_keycode_t, const xkb_keysym_t **))
   12.86 +SDL_WAYLAND_SYM(int, xkb_keysym_to_utf8, (xkb_keysym_t, char *, size_t) )
   12.87 +SDL_WAYLAND_SYM(struct xkb_keymap *, xkb_keymap_new_from_string, (struct xkb_context *, const char *, enum xkb_keymap_format, enum xkb_keymap_compile_flags))
   12.88 +SDL_WAYLAND_SYM(struct xkb_state *, xkb_state_new, (struct xkb_keymap *) )
   12.89 +SDL_WAYLAND_SYM(void, xkb_keymap_unref, (struct xkb_keymap *) )
   12.90 +SDL_WAYLAND_SYM(void, xkb_state_unref, (struct xkb_state *) )
   12.91 +SDL_WAYLAND_SYM(void, xkb_context_unref, (struct xkb_context *) )
   12.92 +SDL_WAYLAND_SYM(struct xkb_context *, xkb_context_new, (enum xkb_context_flags flags) )
   12.93 +SDL_WAYLAND_SYM(enum xkb_state_component, xkb_state_update_mask, (struct xkb_state *state,\
   12.94 +                      xkb_mod_mask_t depressed_mods,\
   12.95 +                      xkb_mod_mask_t latched_mods,\
   12.96 +                      xkb_mod_mask_t locked_mods,\
   12.97 +                      xkb_layout_index_t depressed_layout,\
   12.98 +                      xkb_layout_index_t latched_layout,\
   12.99 +                      xkb_layout_index_t locked_layout) )
  12.100 +
  12.101 +
  12.102 +/* *INDENT-ON* */
  12.103 +
  12.104 +/* vi: set ts=4 sw=4 expandtab: */
  12.105 +//SDL_WAYLAND_SYM(ret, fn, params)
  12.106 \ No newline at end of file
    13.1 --- a/src/video/wayland/SDL_waylandtouch.c	Wed Jan 08 14:53:08 2014 -0500
    13.2 +++ b/src/video/wayland/SDL_waylandtouch.c	Thu Jan 09 13:56:21 2014 -0300
    13.3 @@ -21,7 +21,7 @@
    13.4  
    13.5  /* Contributed by Thomas Perl <thomas.perl@jollamobile.com> */
    13.6  
    13.7 -#include "SDL_config.h"
    13.8 +#include "../../SDL_internal.h"
    13.9  
   13.10  #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
   13.11  
   13.12 @@ -118,6 +118,7 @@
   13.13  {
   13.14  }
   13.15  
   13.16 +
   13.17  /* wayland-qt-touch-extension.c BEGINS */
   13.18  
   13.19  static const struct qt_touch_extension_listener touch_listener = {
   13.20 @@ -183,13 +184,23 @@
   13.21  
   13.22  /* wayland-qt-surface-extension.c BEGINS */
   13.23  extern const struct wl_interface qt_extended_surface_interface;
   13.24 +#ifndef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC
   13.25  extern const struct wl_interface wl_surface_interface;
   13.26 +#endif
   13.27  
   13.28  static const struct wl_interface *qt_surface_extension_types[] = {
   13.29      NULL,
   13.30      NULL,
   13.31      &qt_extended_surface_interface,
   13.32 +#ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC
   13.33 +    /* FIXME: Set this dynamically to (*WAYLAND_wl_surface_interface) ? 
   13.34 +     * The value comes from auto generated code and does 
   13.35 +     * not appear to actually be used anywhere
   13.36 +     */
   13.37 +    NULL, 
   13.38 +#else
   13.39      &wl_surface_interface,
   13.40 +#endif    
   13.41  };
   13.42  
   13.43  static const struct wl_message qt_surface_extension_requests[] = {
    14.1 --- a/src/video/wayland/SDL_waylandtouch.h	Wed Jan 08 14:53:08 2014 -0500
    14.2 +++ b/src/video/wayland/SDL_waylandtouch.h	Thu Jan 09 13:56:21 2014 -0300
    14.3 @@ -19,7 +19,7 @@
    14.4    3. This notice may not be removed or altered from any source distribution.
    14.5  */
    14.6  
    14.7 -#include "SDL_config.h"
    14.8 +#include "../../SDL_internal.h"
    14.9  
   14.10  #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
   14.11  
   14.12 @@ -29,8 +29,9 @@
   14.13  #include "SDL_waylandvideo.h"
   14.14  #include <stdint.h>
   14.15  #include <stddef.h>
   14.16 -#include "wayland-client.h"
   14.17  #include "wayland-util.h"
   14.18 +#include "SDL_waylanddyn.h"
   14.19 +
   14.20  
   14.21  void Wayland_touch_create(SDL_VideoData *data, uint32_t id);
   14.22  void Wayland_touch_destroy(SDL_VideoData *data);
   14.23 @@ -89,7 +90,7 @@
   14.24  static inline void
   14.25  qt_surface_extension_destroy(struct qt_surface_extension *qt_surface_extension)
   14.26  {
   14.27 -    wl_proxy_destroy((struct wl_proxy *) qt_surface_extension);
   14.28 +    WAYLAND_wl_proxy_destroy((struct wl_proxy *) qt_surface_extension);
   14.29  }
   14.30  
   14.31  static inline struct qt_extended_surface *
   14.32 @@ -102,7 +103,7 @@
   14.33      if (!id)
   14.34          return NULL;
   14.35  
   14.36 -    wl_proxy_marshal((struct wl_proxy *) qt_surface_extension,
   14.37 +    WAYLAND_wl_proxy_marshal((struct wl_proxy *) qt_surface_extension,
   14.38               QT_SURFACE_EXTENSION_GET_EXTENDED_SURFACE, id, surface);
   14.39  
   14.40      return (struct qt_extended_surface *) id;
   14.41 @@ -166,39 +167,39 @@
   14.42  static inline void
   14.43  qt_extended_surface_set_user_data(struct qt_extended_surface *qt_extended_surface, void *user_data)
   14.44  {
   14.45 -    wl_proxy_set_user_data((struct wl_proxy *) qt_extended_surface, user_data);
   14.46 +    WAYLAND_wl_proxy_set_user_data((struct wl_proxy *) qt_extended_surface, user_data);
   14.47  }
   14.48  
   14.49  static inline void *
   14.50  qt_extended_surface_get_user_data(struct qt_extended_surface *qt_extended_surface)
   14.51  {
   14.52 -    return wl_proxy_get_user_data((struct wl_proxy *) qt_extended_surface);
   14.53 +    return WAYLAND_wl_proxy_get_user_data((struct wl_proxy *) qt_extended_surface);
   14.54  }
   14.55  
   14.56  static inline void
   14.57  qt_extended_surface_destroy(struct qt_extended_surface *qt_extended_surface)
   14.58  {
   14.59 -    wl_proxy_destroy((struct wl_proxy *) qt_extended_surface);
   14.60 +    WAYLAND_wl_proxy_destroy((struct wl_proxy *) qt_extended_surface);
   14.61  }
   14.62  
   14.63  static inline void
   14.64  qt_extended_surface_update_generic_property(struct qt_extended_surface *qt_extended_surface, const char *name, struct wl_array *value)
   14.65  {
   14.66 -    wl_proxy_marshal((struct wl_proxy *) qt_extended_surface,
   14.67 +    WAYLAND_wl_proxy_marshal((struct wl_proxy *) qt_extended_surface,
   14.68               QT_EXTENDED_SURFACE_UPDATE_GENERIC_PROPERTY, name, value);
   14.69  }
   14.70  
   14.71  static inline void
   14.72  qt_extended_surface_set_content_orientation(struct qt_extended_surface *qt_extended_surface, int32_t orientation)
   14.73  {
   14.74 -    wl_proxy_marshal((struct wl_proxy *) qt_extended_surface,
   14.75 +    WAYLAND_wl_proxy_marshal((struct wl_proxy *) qt_extended_surface,
   14.76               QT_EXTENDED_SURFACE_SET_CONTENT_ORIENTATION, orientation);
   14.77  }
   14.78  
   14.79  static inline void
   14.80  qt_extended_surface_set_window_flags(struct qt_extended_surface *qt_extended_surface, int32_t flags)
   14.81  {
   14.82 -    wl_proxy_marshal((struct wl_proxy *) qt_extended_surface,
   14.83 +    WAYLAND_wl_proxy_marshal((struct wl_proxy *) qt_extended_surface,
   14.84               QT_EXTENDED_SURFACE_SET_WINDOW_FLAGS, flags);
   14.85  }
   14.86  
   14.87 @@ -269,25 +270,25 @@
   14.88  static inline void
   14.89  qt_touch_extension_set_user_data(struct qt_touch_extension *qt_touch_extension, void *user_data)
   14.90  {
   14.91 -    wl_proxy_set_user_data((struct wl_proxy *) qt_touch_extension, user_data);
   14.92 +    WAYLAND_wl_proxy_set_user_data((struct wl_proxy *) qt_touch_extension, user_data);
   14.93  }
   14.94  
   14.95  static inline void *
   14.96  qt_touch_extension_get_user_data(struct qt_touch_extension *qt_touch_extension)
   14.97  {
   14.98 -    return wl_proxy_get_user_data((struct wl_proxy *) qt_touch_extension);
   14.99 +    return WAYLAND_wl_proxy_get_user_data((struct wl_proxy *) qt_touch_extension);
  14.100  }
  14.101  
  14.102  static inline void
  14.103  qt_touch_extension_destroy(struct qt_touch_extension *qt_touch_extension)
  14.104  {
  14.105 -    wl_proxy_destroy((struct wl_proxy *) qt_touch_extension);
  14.106 +    WAYLAND_wl_proxy_destroy((struct wl_proxy *) qt_touch_extension);
  14.107  }
  14.108  
  14.109  static inline void
  14.110  qt_touch_extension_dummy(struct qt_touch_extension *qt_touch_extension)
  14.111  {
  14.112 -    wl_proxy_marshal((struct wl_proxy *) qt_touch_extension,
  14.113 +    WAYLAND_wl_proxy_marshal((struct wl_proxy *) qt_touch_extension,
  14.114               QT_TOUCH_EXTENSION_DUMMY);
  14.115  }
  14.116  
  14.117 @@ -324,25 +325,25 @@
  14.118  static inline void
  14.119  qt_windowmanager_set_user_data(struct qt_windowmanager *qt_windowmanager, void *user_data)
  14.120  {
  14.121 -    wl_proxy_set_user_data((struct wl_proxy *) qt_windowmanager, user_data);
  14.122 +    WAYLAND_wl_proxy_set_user_data((struct wl_proxy *) qt_windowmanager, user_data);
  14.123  }
  14.124  
  14.125  static inline void *
  14.126  qt_windowmanager_get_user_data(struct qt_windowmanager *qt_windowmanager)
  14.127  {
  14.128 -    return wl_proxy_get_user_data((struct wl_proxy *) qt_windowmanager);
  14.129 +    return WAYLAND_wl_proxy_get_user_data((struct wl_proxy *) qt_windowmanager);
  14.130  }
  14.131  
  14.132  static inline void
  14.133  qt_windowmanager_destroy(struct qt_windowmanager *qt_windowmanager)
  14.134  {
  14.135 -    wl_proxy_destroy((struct wl_proxy *) qt_windowmanager);
  14.136 +    WAYLAND_wl_proxy_destroy((struct wl_proxy *) qt_windowmanager);
  14.137  }
  14.138  
  14.139  static inline void
  14.140  qt_windowmanager_open_url(struct qt_windowmanager *qt_windowmanager, uint32_t remaining, const char *url)
  14.141  {
  14.142 -    wl_proxy_marshal((struct wl_proxy *) qt_windowmanager,
  14.143 +    WAYLAND_wl_proxy_marshal((struct wl_proxy *) qt_windowmanager,
  14.144               QT_WINDOWMANAGER_OPEN_URL, remaining, url);
  14.145  }
  14.146  
    15.1 --- a/src/video/wayland/SDL_waylandvideo.c	Wed Jan 08 14:53:08 2014 -0500
    15.2 +++ b/src/video/wayland/SDL_waylandvideo.c	Thu Jan 09 13:56:21 2014 -0300
    15.3 @@ -19,10 +19,11 @@
    15.4    3. This notice may not be removed or altered from any source distribution.
    15.5  */
    15.6  
    15.7 -#include "SDL_config.h"
    15.8 +#include "../../SDL_internal.h"
    15.9  
   15.10  #include "SDL_video.h"
   15.11  #include "SDL_mouse.h"
   15.12 +#include "SDL_stdinc.h"
   15.13  #include "../../events/SDL_events_c.h"
   15.14  
   15.15  #include "SDL_waylandvideo.h"
   15.16 @@ -35,6 +36,9 @@
   15.17  #include <fcntl.h>
   15.18  #include <xkbcommon/xkbcommon.h>
   15.19  
   15.20 +#include "SDL_waylanddyn.h"
   15.21 +#include <wayland-util.h>
   15.22 +
   15.23  #define WAYLANDVID_DRIVER_NAME "wayland"
   15.24  
   15.25  struct wayland_mode {
   15.26 @@ -59,10 +63,12 @@
   15.27  Wayland_Available(void)
   15.28  {
   15.29      struct wl_display *display = NULL;
   15.30 -
   15.31 -    display = wl_display_connect(NULL);
   15.32 -    if (display != NULL) {
   15.33 -        wl_display_disconnect(display);
   15.34 +    if (SDL_WAYLAND_LoadSymbols()) {
   15.35 +        display = WAYLAND_wl_display_connect(NULL);
   15.36 +        if (display != NULL) {
   15.37 +            WAYLAND_wl_display_disconnect(display);
   15.38 +        }
   15.39 +        SDL_WAYLAND_UnloadSymbols();
   15.40      }
   15.41  
   15.42      return (display != NULL);
   15.43 @@ -72,12 +78,17 @@
   15.44  Wayland_DeleteDevice(SDL_VideoDevice *device)
   15.45  {
   15.46      SDL_free(device);
   15.47 +    SDL_WAYLAND_UnloadSymbols();
   15.48  }
   15.49  
   15.50  static SDL_VideoDevice *
   15.51  Wayland_CreateDevice(int devindex)
   15.52  {
   15.53      SDL_VideoDevice *device;
   15.54 +    
   15.55 +    if (!SDL_WAYLAND_LoadSymbols()) {
   15.56 +        return NULL;
   15.57 +    }
   15.58  
   15.59      /* Initialize all variables that we clean on shutdown */
   15.60      device = SDL_calloc(1, sizeof(SDL_VideoDevice));
   15.61 @@ -133,13 +144,13 @@
   15.62  	    return;
   15.63  
   15.64      /* Add new mode to the list */
   15.65 -    mode = SDL_calloc(1, sizeof *mode);
   15.66 +    mode = (struct wayland_mode *) SDL_calloc(1, sizeof *mode);
   15.67  
   15.68      if (!mode)
   15.69  	return;
   15.70  
   15.71      mode->mode = m;
   15.72 -    wl_list_insert(&d->modes_list, &mode->link);
   15.73 +    WAYLAND_wl_list_insert(&d->modes_list, &mode->link);
   15.74  }
   15.75  
   15.76  static void
   15.77 @@ -227,7 +238,7 @@
   15.78  					const char *interface, uint32_t version)
   15.79  {
   15.80      SDL_VideoData *d = data;
   15.81 -
   15.82 +    
   15.83      if (strcmp(interface, "wl_compositor") == 0) {
   15.84          d->compositor = wl_registry_bind(d->registry, id, &wl_compositor_interface, 1);
   15.85      } else if (strcmp(interface, "wl_output") == 0) {
   15.86 @@ -239,8 +250,8 @@
   15.87          d->shell = wl_registry_bind(d->registry, id, &wl_shell_interface, 1);
   15.88      } else if (strcmp(interface, "wl_shm") == 0) {
   15.89          d->shm = wl_registry_bind(registry, id, &wl_shm_interface, 1);
   15.90 -        d->cursor_theme = wl_cursor_theme_load(NULL, 32, d->shm);
   15.91 -        d->default_cursor = wl_cursor_theme_get_cursor(d->cursor_theme, "left_ptr");
   15.92 +        d->cursor_theme = WAYLAND_wl_cursor_theme_load(NULL, 32, d->shm);
   15.93 +        d->default_cursor = WAYLAND_wl_cursor_theme_get_cursor(d->cursor_theme, "left_ptr");
   15.94          wl_shm_add_listener(d->shm, &shm_listener, d);
   15.95      
   15.96  #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
   15.97 @@ -265,7 +276,10 @@
   15.98  Wayland_VideoInit(_THIS)
   15.99  {
  15.100      SDL_VideoData *data;
  15.101 -
  15.102 +    SDL_VideoDisplay display;
  15.103 +    SDL_DisplayMode mode;
  15.104 +    int i;
  15.105 +    
  15.106      data = malloc(sizeof *data);
  15.107      if (data == NULL)
  15.108          return 0;
  15.109 @@ -273,29 +287,41 @@
  15.110  
  15.111      _this->driverdata = data;
  15.112  
  15.113 -    wl_list_init(&data->modes_list);
  15.114 +    WAYLAND_wl_list_init(&data->modes_list);
  15.115      
  15.116 -    data->display = wl_display_connect(NULL);
  15.117 +    data->display = WAYLAND_wl_display_connect(NULL);
  15.118      if (data->display == NULL) {
  15.119          SDL_SetError("Failed to connect to a Wayland display");
  15.120          return 0;
  15.121      }
  15.122  
  15.123      data->registry = wl_display_get_registry(data->display);
  15.124 +   
  15.125 +    if ( data->registry == NULL) {
  15.126 +        SDL_SetError("Failed to get the Wayland registry");
  15.127 +        return 0;
  15.128 +    }
  15.129 +    
  15.130      wl_registry_add_listener(data->registry, &registry_listener, data);
  15.131  
  15.132 -    while (data->screen_allocation.width == 0)
  15.133 -        wl_display_dispatch(data->display);
  15.134 +    for (i=0; i < 100; i++) {
  15.135 +        if (data->screen_allocation.width != 0 || WAYLAND_wl_display_get_error(data->display) != 0) {
  15.136 +            break;
  15.137 +        }
  15.138 +        WAYLAND_wl_display_dispatch(data->display);
  15.139 +    }
  15.140 +    
  15.141 +    if (data->screen_allocation.width == 0) {
  15.142 +        SDL_SetError("Failed while waiting for screen allocation: %d ", WAYLAND_wl_display_get_error(data->display));
  15.143 +        return 0;
  15.144 +    }
  15.145  
  15.146 -    data->xkb_context = xkb_context_new(0);
  15.147 +    data->xkb_context = WAYLAND_xkb_context_new(0);
  15.148      if (!data->xkb_context) {
  15.149          SDL_SetError("Failed to create XKB context");
  15.150          return 0;
  15.151      }
  15.152  
  15.153 -    SDL_VideoDisplay display;
  15.154 -    SDL_DisplayMode mode;
  15.155 -
  15.156      /* Use a fake 32-bpp desktop mode */
  15.157      mode.format = SDL_PIXELFORMAT_RGB888;
  15.158      mode.w = data->screen_allocation.width;
  15.159 @@ -311,7 +337,7 @@
  15.160  
  15.161      Wayland_InitMouse ();
  15.162  
  15.163 -    wayland_schedule_write(data);
  15.164 +    WAYLAND_wl_display_flush(data->display);
  15.165  
  15.166      return 0;
  15.167  }
  15.168 @@ -363,7 +389,7 @@
  15.169      Wayland_display_destroy_input(data);
  15.170  
  15.171      if (data->xkb_context) {
  15.172 -        xkb_context_unref(data->xkb_context);
  15.173 +        WAYLAND_xkb_context_unref(data->xkb_context);
  15.174          data->xkb_context = NULL;
  15.175      }
  15.176  #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
  15.177 @@ -380,7 +406,7 @@
  15.178          wl_shm_destroy(data->shm);
  15.179  
  15.180      if (data->cursor_theme)
  15.181 -        wl_cursor_theme_destroy(data->cursor_theme);
  15.182 +        WAYLAND_wl_cursor_theme_destroy(data->cursor_theme);
  15.183  
  15.184      if (data->shell)
  15.185          wl_shell_destroy(data->shell);
  15.186 @@ -389,12 +415,12 @@
  15.187          wl_compositor_destroy(data->compositor);
  15.188  
  15.189      if (data->display) {
  15.190 -        wl_display_flush(data->display);
  15.191 -        wl_display_disconnect(data->display);
  15.192 +        WAYLAND_wl_display_flush(data->display);
  15.193 +        WAYLAND_wl_display_disconnect(data->display);
  15.194      }
  15.195      
  15.196      wl_list_for_each_safe(m, t, &data->modes_list, link) {
  15.197 -        wl_list_remove(&m->link);
  15.198 +        WAYLAND_wl_list_remove(&m->link);
  15.199          free(m);
  15.200      }
  15.201  
    16.1 --- a/src/video/wayland/SDL_waylandvideo.h	Wed Jan 08 14:53:08 2014 -0500
    16.2 +++ b/src/video/wayland/SDL_waylandvideo.h	Thu Jan 09 13:56:21 2014 -0300
    16.3 @@ -19,16 +19,13 @@
    16.4    3. This notice may not be removed or altered from any source distribution.
    16.5  */
    16.6  
    16.7 -#include "SDL_config.h"
    16.8 +#include "../../SDL_internal.h"
    16.9  
   16.10  #ifndef _SDL_waylandvideo_h
   16.11  #define _SDL_waylandvideo_h
   16.12  
   16.13 -#include <wayland-client.h>
   16.14 -#include <wayland-cursor.h>
   16.15 -#include <wayland-egl.h>
   16.16 -
   16.17  #include <EGL/egl.h>
   16.18 +#include "wayland-util.h"
   16.19  
   16.20  struct xkb_context;
   16.21  struct SDL_WaylandInput;
   16.22 @@ -72,12 +69,6 @@
   16.23      uint32_t shm_formats;
   16.24  } SDL_VideoData;
   16.25  
   16.26 -static inline void
   16.27 -wayland_schedule_write(SDL_VideoData *data)
   16.28 -{
   16.29 -    wl_display_flush(data->display);
   16.30 -}
   16.31 -
   16.32  #endif /* _SDL_nullvideo_h */
   16.33  
   16.34  /* vi: set ts=4 sw=4 expandtab: */
    17.1 --- a/src/video/wayland/SDL_waylandwindow.c	Wed Jan 08 14:53:08 2014 -0500
    17.2 +++ b/src/video/wayland/SDL_waylandwindow.c	Thu Jan 09 13:56:21 2014 -0300
    17.3 @@ -19,7 +19,7 @@
    17.4    3. This notice may not be removed or altered from any source distribution.
    17.5  */
    17.6  
    17.7 -#include "SDL_config.h"
    17.8 +#include "../../SDL_internal.h"
    17.9  
   17.10  #include "../SDL_sysvideo.h"
   17.11  #include "../../events/SDL_windowevents_c.h"
   17.12 @@ -104,7 +104,7 @@
   17.13      else
   17.14          wl_shell_surface_set_toplevel(wind->shell_surface);
   17.15  
   17.16 -    wayland_schedule_write(_this->driverdata);
   17.17 +    WAYLAND_wl_display_flush( ((SDL_VideoData*)_this->driverdata)->display );
   17.18  }
   17.19  
   17.20  void
   17.21 @@ -120,7 +120,7 @@
   17.22      else
   17.23          wl_shell_surface_set_toplevel(wind->shell_surface);
   17.24  
   17.25 -    wayland_schedule_write(_this->driverdata);
   17.26 +    WAYLAND_wl_display_flush( ((SDL_VideoData*)_this->driverdata)->display );
   17.27  }
   17.28  
   17.29  int Wayland_CreateWindow(_THIS, SDL_Window *window)
   17.30 @@ -162,7 +162,7 @@
   17.31                  c->surface_extension, data->surface);
   17.32      }
   17.33  #endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
   17.34 -    data->egl_window = wl_egl_window_create(data->surface,
   17.35 +    data->egl_window = WAYLAND_wl_egl_window_create(data->surface,
   17.36                                              window->w, window->h);
   17.37  
   17.38      /* Create the GLES window surface */
   17.39 @@ -192,7 +192,7 @@
   17.40      wl_surface_set_opaque_region(data->surface, region);
   17.41      wl_region_destroy(region);
   17.42  
   17.43 -    wayland_schedule_write(c);
   17.44 +    WAYLAND_wl_display_flush(c->display);
   17.45  
   17.46      return 0;
   17.47  }
   17.48 @@ -203,9 +203,9 @@
   17.49      SDL_WindowData *wind = window->driverdata;
   17.50      struct wl_region *region;
   17.51  
   17.52 -    wl_egl_window_resize(wind->egl_window, window->w, window->h, 0, 0);
   17.53 +    WAYLAND_wl_egl_window_resize(wind->egl_window, window->w, window->h, 0, 0);
   17.54  
   17.55 -    region = wl_compositor_create_region(data->compositor);
   17.56 +    region =wl_compositor_create_region(data->compositor);
   17.57      wl_region_add(region, 0, 0, window->w, window->h);
   17.58      wl_surface_set_opaque_region(wind->surface, region);
   17.59      wl_region_destroy(region);
   17.60 @@ -220,7 +220,7 @@
   17.61  
   17.62      if (data) {
   17.63          SDL_EGL_DestroySurface(_this, wind->egl_surface);
   17.64 -        wl_egl_window_destroy(wind->egl_window);
   17.65 +        WAYLAND_wl_egl_window_destroy(wind->egl_window);
   17.66  
   17.67          if (wind->shell_surface)
   17.68              wl_shell_surface_destroy(wind->shell_surface);
   17.69 @@ -232,7 +232,7 @@
   17.70          wl_surface_destroy(wind->surface);
   17.71  
   17.72          SDL_free(wind);
   17.73 -        wayland_schedule_write(data);
   17.74 +        WAYLAND_wl_display_flush(data->display);
   17.75      }
   17.76  }
   17.77  
    18.1 --- a/src/video/wayland/SDL_waylandwindow.h	Wed Jan 08 14:53:08 2014 -0500
    18.2 +++ b/src/video/wayland/SDL_waylandwindow.h	Thu Jan 09 13:56:21 2014 -0300
    18.3 @@ -19,7 +19,7 @@
    18.4    3. This notice may not be removed or altered from any source distribution.
    18.5  */
    18.6  
    18.7 -#include "SDL_config.h"
    18.8 +#include "../../SDL_internal.h"
    18.9  
   18.10  #ifndef _SDL_waylandwindow_h
   18.11  #define _SDL_waylandwindow_h