Implements touch support on QTWayland. Contributed by Thomas Perl.
authorGabriel Jacobo <gabomdq@gmail.com>
Fri, 27 Dec 2013 09:29:39 -0300
changeset 80825b83ad3f01ac
parent 8081 402b8c313246
child 8083 3782a12331d6
Implements touch support on QTWayland. Contributed by Thomas Perl.
configure
configure.in
include/SDL_config.h.in
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 Dec 25 17:02:15 2013 +0100
     1.2 +++ b/configure	Fri Dec 27 09:29:39 2013 -0300
     1.3 @@ -818,6 +818,7 @@
     1.4  enable_diskaudio
     1.5  enable_dummyaudio
     1.6  enable_video_wayland
     1.7 +enable_video_wayland_qt_touch
     1.8  enable_video_x11
     1.9  with_x
    1.10  enable_x11_shared
    1.11 @@ -1534,6 +1535,9 @@
    1.12    --enable-diskaudio      support the disk writer audio driver [[default=yes]]
    1.13    --enable-dummyaudio     support the dummy audio driver [[default=yes]]
    1.14    --enable-video-wayland  use Wayland video driver [[default=yes]]
    1.15 +  --enable-video-wayland-qt-touch
    1.16 +                          QtWayland server support for Wayland video driver
    1.17 +                          [[default=yes]]
    1.18    --enable-video-x11      use X11 video driver [[default=yes]]
    1.19    --enable-x11-shared     dynamically load X11 support [[default=maybe]]
    1.20    --enable-video-x11-xcursor
    1.21 @@ -18645,6 +18649,14 @@
    1.22  fi
    1.23  
    1.24  
    1.25 +    # Check whether --enable-video-wayland-qt-touch was given.
    1.26 +if test "${enable_video_wayland_qt_touch+set}" = set; then :
    1.27 +  enableval=$enable_video_wayland_qt_touch;
    1.28 +else
    1.29 +  enable_video_wayland_qt_touch=yes
    1.30 +fi
    1.31 +
    1.32 +
    1.33      if test x$enable_video = xyes -a x$enable_video_wayland = xyes; then
    1.34          # Extract the first word of "pkg-config", so it can be a program name with args.
    1.35  set dummy pkg-config; ac_word=$2
    1.36 @@ -18704,6 +18716,11 @@
    1.37  
    1.38  $as_echo "#define SDL_VIDEO_DRIVER_WAYLAND 1" >>confdefs.h
    1.39  
    1.40 +            if test x$enable_video_wayland_qt_touch = xyes; then
    1.41 +
    1.42 +$as_echo "#define SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH 1" >>confdefs.h
    1.43 +
    1.44 +            fi
    1.45              SOURCES="$SOURCES $srcdir/src/video/wayland/*.c"
    1.46              EXTRA_CFLAGS="$EXTRA_CFLAGS $WAYLAND_CFLAGS"
    1.47                          EXTRA_LDFLAGS="$EXTRA_LDFLAGS $WAYLAND_LIBS"
     2.1 --- a/configure.in	Wed Dec 25 17:02:15 2013 +0100
     2.2 +++ b/configure.in	Fri Dec 27 09:29:39 2013 -0300
     2.3 @@ -1122,6 +1122,10 @@
     2.4  AC_HELP_STRING([--enable-video-wayland], [use Wayland video driver [[default=yes]]]),
     2.5                    ,enable_video_wayland=yes)
     2.6  
     2.7 +    AC_ARG_ENABLE(video-wayland-qt-touch,
     2.8 +AC_HELP_STRING([--enable-video-wayland-qt-touch], [QtWayland server support for Wayland video driver [[default=yes]]]),
     2.9 +                  ,enable_video_wayland_qt_touch=yes)
    2.10 +
    2.11      if test x$enable_video = xyes -a x$enable_video_wayland = xyes; then
    2.12          AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
    2.13          AC_MSG_CHECKING(for Wayland support)
    2.14 @@ -1137,6 +1141,9 @@
    2.15  
    2.16          if test x$video_wayland = xyes; then
    2.17              AC_DEFINE(SDL_VIDEO_DRIVER_WAYLAND, 1, [ ])
    2.18 +            if test x$enable_video_wayland_qt_touch = xyes; then
    2.19 +                AC_DEFINE(SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH, 1, [ ])
    2.20 +            fi
    2.21              SOURCES="$SOURCES $srcdir/src/video/wayland/*.c"
    2.22              EXTRA_CFLAGS="$EXTRA_CFLAGS $WAYLAND_CFLAGS"
    2.23              dnl FIXME do dynamic loading code here.
     3.1 --- a/include/SDL_config.h.in	Wed Dec 25 17:02:15 2013 +0100
     3.2 +++ b/include/SDL_config.h.in	Fri Dec 27 09:29:39 2013 -0300
     3.3 @@ -261,6 +261,7 @@
     3.4  #undef SDL_VIDEO_DRIVER_DUMMY
     3.5  #undef SDL_VIDEO_DRIVER_WINDOWS
     3.6  #undef SDL_VIDEO_DRIVER_WAYLAND
     3.7 +#undef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
     3.8  #undef SDL_VIDEO_DRIVER_X11
     3.9  #undef SDL_VIDEO_DRIVER_RPI
    3.10  #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_waylandtouch.c	Fri Dec 27 09:29:39 2013 -0300
     4.3 @@ -0,0 +1,253 @@
     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 +
    4.25 +/* Contributed by Thomas Perl <thomas.perl@jollamobile.com> */
    4.26 +
    4.27 +#include "SDL_config.h"
    4.28 +
    4.29 +#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
    4.30 +
    4.31 +#include "SDL_waylandtouch.h"
    4.32 +#include "SDL_log.h"
    4.33 +#include "../../events/SDL_touch_c.h"
    4.34 +
    4.35 +struct SDL_WaylandTouch {
    4.36 +    struct qt_touch_extension *touch_extension;
    4.37 +};
    4.38 +
    4.39 +
    4.40 +/**
    4.41 + * Qt TouchPointState
    4.42 + * adapted from qtbase/src/corelib/global/qnamespace.h
    4.43 + **/
    4.44 +enum QtWaylandTouchPointState {
    4.45 +    QtWaylandTouchPointPressed    = 0x01,
    4.46 +    QtWaylandTouchPointMoved      = 0x02,
    4.47 +    /*
    4.48 +    Never sent by the server:
    4.49 +    QtWaylandTouchPointStationary = 0x04,
    4.50 +    */
    4.51 +    QtWaylandTouchPointReleased   = 0x08,
    4.52 +};
    4.53 +
    4.54 +static void
    4.55 +touch_handle_touch(void *data,
    4.56 +        struct qt_touch_extension *qt_touch_extension,
    4.57 +        uint32_t time,
    4.58 +        uint32_t id,
    4.59 +        uint32_t state,
    4.60 +        int32_t x,
    4.61 +        int32_t y,
    4.62 +        int32_t normalized_x,
    4.63 +        int32_t normalized_y,
    4.64 +        int32_t width,
    4.65 +        int32_t height,
    4.66 +        uint32_t pressure,
    4.67 +        int32_t velocity_x,
    4.68 +        int32_t velocity_y,
    4.69 +        uint32_t flags,
    4.70 +        struct wl_array *rawdata)
    4.71 +{
    4.72 +    /**
    4.73 +     * Event is assembled in QtWayland in TouchExtensionGlobal::postTouchEvent
    4.74 +     * (src/compositor/wayland_wrapper/qwltouch.cpp)
    4.75 +     **/
    4.76 +
    4.77 +    float FIXED_TO_FLOAT = 1. / 10000.;
    4.78 +    float xf = FIXED_TO_FLOAT * x;
    4.79 +    float yf = FIXED_TO_FLOAT * y;
    4.80 +
    4.81 +    float PRESSURE_TO_FLOAT = 1. / 255.;
    4.82 +    float pressuref = PRESSURE_TO_FLOAT * pressure;
    4.83 +
    4.84 +    uint32_t touchState = state & 0xFFFF;
    4.85 +    /*
    4.86 +    Other fields that are sent by the server (qwltouch.cpp),
    4.87 +    but not used at the moment can be decoded in this way:
    4.88 +
    4.89 +    uint32_t sentPointCount = state >> 16;
    4.90 +    uint32_t touchFlags = flags & 0xFFFF;
    4.91 +    uint32_t capabilities = flags >> 16;
    4.92 +    */
    4.93 +
    4.94 +    SDL_TouchID deviceId = 0;
    4.95 +    if (!SDL_GetTouch(deviceId)) {
    4.96 +        if (SDL_AddTouch(deviceId, "qt_touch_extension") < 0) {
    4.97 +             SDL_Log("error: can't add touch %s, %d", __FILE__, __LINE__);
    4.98 +        }
    4.99 +    }
   4.100 +
   4.101 +    switch (touchState) {
   4.102 +        case QtWaylandTouchPointPressed:
   4.103 +        case QtWaylandTouchPointReleased:
   4.104 +            SDL_SendTouch(deviceId, (SDL_FingerID)id,
   4.105 +                    (touchState == QtWaylandTouchPointPressed) ? SDL_TRUE : SDL_FALSE,
   4.106 +                    xf, yf, pressuref);
   4.107 +            break;
   4.108 +        case QtWaylandTouchPointMoved:
   4.109 +            SDL_SendTouchMotion(deviceId, (SDL_FingerID)id, xf, yf, pressuref);
   4.110 +            break;
   4.111 +        default:
   4.112 +            /* Should not happen */
   4.113 +            break;
   4.114 +    }
   4.115 +}
   4.116 +
   4.117 +static void
   4.118 +touch_handle_configure(void *data,
   4.119 +        struct qt_touch_extension *qt_touch_extension,
   4.120 +        uint32_t flags)
   4.121 +{
   4.122 +}
   4.123 +
   4.124 +/* wayland-qt-touch-extension.c BEGINS */
   4.125 +
   4.126 +static const struct qt_touch_extension_listener touch_listener = {
   4.127 +    touch_handle_touch,
   4.128 +    touch_handle_configure,
   4.129 +};
   4.130 +
   4.131 +static const struct wl_interface *qt_touch_extension_types[] = {
   4.132 +    NULL,
   4.133 +    NULL,
   4.134 +    NULL,
   4.135 +    NULL,
   4.136 +    NULL,
   4.137 +    NULL,
   4.138 +    NULL,
   4.139 +    NULL,
   4.140 +    NULL,
   4.141 +    NULL,
   4.142 +    NULL,
   4.143 +    NULL,
   4.144 +    NULL,
   4.145 +    NULL,
   4.146 +};
   4.147 +
   4.148 +static const struct wl_message qt_touch_extension_requests[] = {
   4.149 +    { "dummy", "", qt_touch_extension_types + 0 },
   4.150 +};
   4.151 +
   4.152 +static const struct wl_message qt_touch_extension_events[] = {
   4.153 +    { "touch", "uuuiiiiiiuiiua", qt_touch_extension_types + 0 },
   4.154 +    { "configure", "u", qt_touch_extension_types + 0 },
   4.155 +};
   4.156 +
   4.157 +WL_EXPORT const struct wl_interface qt_touch_extension_interface = {
   4.158 +    "qt_touch_extension", 1,
   4.159 +    1, qt_touch_extension_requests,
   4.160 +    2, qt_touch_extension_events,
   4.161 +};
   4.162 +
   4.163 +/* wayland-qt-touch-extension.c ENDS */
   4.164 +
   4.165 +/* wayland-qt-windowmanager.c BEGINS */
   4.166 +static const struct wl_interface *qt_windowmanager_types[] = {
   4.167 +    NULL,
   4.168 +    NULL,
   4.169 +};
   4.170 +
   4.171 +static const struct wl_message qt_windowmanager_requests[] = {
   4.172 +    { "open_url", "us", qt_windowmanager_types + 0 },
   4.173 +};
   4.174 +
   4.175 +static const struct wl_message qt_windowmanager_events[] = {
   4.176 +    { "hints", "i", qt_windowmanager_types + 0 },
   4.177 +    { "quit", "", qt_windowmanager_types + 0 },
   4.178 +};
   4.179 +
   4.180 +WL_EXPORT const struct wl_interface qt_windowmanager_interface = {
   4.181 +    "qt_windowmanager", 1,
   4.182 +    1, qt_windowmanager_requests,
   4.183 +    2, qt_windowmanager_events,
   4.184 +};
   4.185 +/* wayland-qt-windowmanager.c ENDS */
   4.186 +
   4.187 +/* wayland-qt-surface-extension.c BEGINS */
   4.188 +extern const struct wl_interface qt_extended_surface_interface;
   4.189 +extern const struct wl_interface wl_surface_interface;
   4.190 +
   4.191 +static const struct wl_interface *qt_surface_extension_types[] = {
   4.192 +    NULL,
   4.193 +    NULL,
   4.194 +    &qt_extended_surface_interface,
   4.195 +    &wl_surface_interface,
   4.196 +};
   4.197 +
   4.198 +static const struct wl_message qt_surface_extension_requests[] = {
   4.199 +    { "get_extended_surface", "no", qt_surface_extension_types + 2 },
   4.200 +};
   4.201 +
   4.202 +WL_EXPORT const struct wl_interface qt_surface_extension_interface = {
   4.203 +    "qt_surface_extension", 1,
   4.204 +    1, qt_surface_extension_requests,
   4.205 +    0, NULL,
   4.206 +};
   4.207 +
   4.208 +static const struct wl_message qt_extended_surface_requests[] = {
   4.209 +    { "update_generic_property", "sa", qt_surface_extension_types + 0 },
   4.210 +    { "set_content_orientation", "i", qt_surface_extension_types + 0 },
   4.211 +    { "set_window_flags", "i", qt_surface_extension_types + 0 },
   4.212 +};
   4.213 +
   4.214 +static const struct wl_message qt_extended_surface_events[] = {
   4.215 +    { "onscreen_visibility", "i", qt_surface_extension_types + 0 },
   4.216 +    { "set_generic_property", "sa", qt_surface_extension_types + 0 },
   4.217 +    { "close", "", qt_surface_extension_types + 0 },
   4.218 +};
   4.219 +
   4.220 +WL_EXPORT const struct wl_interface qt_extended_surface_interface = {
   4.221 +    "qt_extended_surface", 1,
   4.222 +    3, qt_extended_surface_requests,
   4.223 +    3, qt_extended_surface_events,
   4.224 +};
   4.225 +
   4.226 +/* wayland-qt-surface-extension.c ENDS */
   4.227 +
   4.228 +void
   4.229 +Wayland_touch_create(SDL_VideoData *data, uint32_t id)
   4.230 +{
   4.231 +    if (data->touch) {
   4.232 +        Wayland_touch_destroy(data);
   4.233 +    }
   4.234 +
   4.235 +    data->touch = malloc(sizeof(struct SDL_WaylandTouch));
   4.236 +
   4.237 +    struct SDL_WaylandTouch *touch = data->touch;
   4.238 +    touch->touch_extension = wl_registry_bind(data->registry, id, &qt_touch_extension_interface, 1);
   4.239 +    qt_touch_extension_add_listener(touch->touch_extension, &touch_listener, data);
   4.240 +}
   4.241 +
   4.242 +void
   4.243 +Wayland_touch_destroy(SDL_VideoData *data)
   4.244 +{
   4.245 +    if (data->touch) {
   4.246 +        struct SDL_WaylandTouch *touch = data->touch;
   4.247 +        if (touch->touch_extension) {
   4.248 +            qt_touch_extension_destroy(touch->touch_extension);
   4.249 +        }
   4.250 +
   4.251 +        free(data->touch);
   4.252 +        data->touch = NULL;
   4.253 +    }
   4.254 +}
   4.255 +
   4.256 +#endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/src/video/wayland/SDL_waylandtouch.h	Fri Dec 27 09:29:39 2013 -0300
     5.3 @@ -0,0 +1,351 @@
     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 +#include "SDL_config.h"
    5.26 +
    5.27 +#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
    5.28 +
    5.29 +#ifndef _SDL_waylandtouch_h
    5.30 +#define _SDL_waylandtouch_h
    5.31 +
    5.32 +#include "SDL_waylandvideo.h"
    5.33 +#include <stdint.h>
    5.34 +#include <stddef.h>
    5.35 +#include "wayland-client.h"
    5.36 +#include "wayland-util.h"
    5.37 +
    5.38 +void Wayland_touch_create(SDL_VideoData *data, uint32_t id);
    5.39 +void Wayland_touch_destroy(SDL_VideoData *data);
    5.40 +
    5.41 +struct qt_touch_extension;
    5.42 +
    5.43 +/* Autogenerated QT headers */
    5.44 +
    5.45 +/*
    5.46 + Support for Wayland with QmlCompositor as Server
    5.47 +================================================
    5.48 +
    5.49 +The Wayland video driver has support for some additional features when
    5.50 +using QtWayland's "qmlcompositor" as Wayland server. This is needed for touch
    5.51 +input when running SDL applications under a qmlcompositor Wayland server.
    5.52 +
    5.53 +The files following headers have been
    5.54 +generated from the Wayland XML Protocol Definition in QtWayland as follows:
    5.55 +
    5.56 +Clone QtWayland from Git:
    5.57 +    http://qt.gitorious.org/qt/qtwayland/
    5.58 +
    5.59 +Generate headers and glue code:
    5.60 +    for extension in touch-extension surface-extension windowmanager; do
    5.61 +        wayland-scanner client-header < src/extensions/$extension.xml > wayland-qt-$extension.h
    5.62 +        wayland-scanner code < src/extensions/$extension.xml > wayland-qt-$extension.c
    5.63 +    done
    5.64 +
    5.65 +*/
    5.66 +
    5.67 +/* wayland-qt-surface-extension.h */
    5.68 +
    5.69 +struct wl_client;
    5.70 +struct wl_resource;
    5.71 +
    5.72 +struct qt_surface_extension;
    5.73 +struct qt_extended_surface;
    5.74 +
    5.75 +extern const struct wl_interface qt_surface_extension_interface;
    5.76 +extern const struct wl_interface qt_extended_surface_interface;
    5.77 +
    5.78 +#define QT_SURFACE_EXTENSION_GET_EXTENDED_SURFACE   0
    5.79 +
    5.80 +static inline void
    5.81 +qt_surface_extension_set_user_data(struct qt_surface_extension *qt_surface_extension, void *user_data)
    5.82 +{
    5.83 +    wl_proxy_set_user_data((struct wl_proxy *) qt_surface_extension, user_data);
    5.84 +}
    5.85 +
    5.86 +static inline void *
    5.87 +qt_surface_extension_get_user_data(struct qt_surface_extension *qt_surface_extension)
    5.88 +{
    5.89 +    return wl_proxy_get_user_data((struct wl_proxy *) qt_surface_extension);
    5.90 +}
    5.91 +
    5.92 +static inline void
    5.93 +qt_surface_extension_destroy(struct qt_surface_extension *qt_surface_extension)
    5.94 +{
    5.95 +    wl_proxy_destroy((struct wl_proxy *) qt_surface_extension);
    5.96 +}
    5.97 +
    5.98 +static inline struct qt_extended_surface *
    5.99 +qt_surface_extension_get_extended_surface(struct qt_surface_extension *qt_surface_extension, struct wl_surface *surface)
   5.100 +{
   5.101 +    struct wl_proxy *id;
   5.102 +
   5.103 +    id = wl_proxy_create((struct wl_proxy *) qt_surface_extension,
   5.104 +                 &qt_extended_surface_interface);
   5.105 +    if (!id)
   5.106 +        return NULL;
   5.107 +
   5.108 +    wl_proxy_marshal((struct wl_proxy *) qt_surface_extension,
   5.109 +             QT_SURFACE_EXTENSION_GET_EXTENDED_SURFACE, id, surface);
   5.110 +
   5.111 +    return (struct qt_extended_surface *) id;
   5.112 +}
   5.113 +
   5.114 +#ifndef QT_EXTENDED_SURFACE_ORIENTATION_ENUM
   5.115 +#define QT_EXTENDED_SURFACE_ORIENTATION_ENUM
   5.116 +enum qt_extended_surface_orientation {
   5.117 +    QT_EXTENDED_SURFACE_ORIENTATION_PRIMARYORIENTATION = 0,
   5.118 +    QT_EXTENDED_SURFACE_ORIENTATION_PORTRAITORIENTATION = 1,
   5.119 +    QT_EXTENDED_SURFACE_ORIENTATION_LANDSCAPEORIENTATION = 2,
   5.120 +    QT_EXTENDED_SURFACE_ORIENTATION_INVERTEDPORTRAITORIENTATION = 4,
   5.121 +    QT_EXTENDED_SURFACE_ORIENTATION_INVERTEDLANDSCAPEORIENTATION = 8,
   5.122 +};
   5.123 +#endif /* QT_EXTENDED_SURFACE_ORIENTATION_ENUM */
   5.124 +
   5.125 +#ifndef QT_EXTENDED_SURFACE_WINDOWFLAG_ENUM
   5.126 +#define QT_EXTENDED_SURFACE_WINDOWFLAG_ENUM
   5.127 +enum qt_extended_surface_windowflag {
   5.128 +    QT_EXTENDED_SURFACE_WINDOWFLAG_OVERRIDESSYSTEMGESTURES = 1,
   5.129 +    QT_EXTENDED_SURFACE_WINDOWFLAG_STAYSONTOP = 2,
   5.130 +};
   5.131 +#endif /* QT_EXTENDED_SURFACE_WINDOWFLAG_ENUM */
   5.132 +
   5.133 +struct qt_extended_surface_listener {
   5.134 +    /**
   5.135 +     * onscreen_visibility - (none)
   5.136 +     * @visible: (none)
   5.137 +     */
   5.138 +    void (*onscreen_visibility)(void *data,
   5.139 +                    struct qt_extended_surface *qt_extended_surface,
   5.140 +                    int32_t visible);
   5.141 +    /**
   5.142 +     * set_generic_property - (none)
   5.143 +     * @name: (none)
   5.144 +     * @value: (none)
   5.145 +     */
   5.146 +    void (*set_generic_property)(void *data,
   5.147 +                     struct qt_extended_surface *qt_extended_surface,
   5.148 +                     const char *name,
   5.149 +                     struct wl_array *value);
   5.150 +    /**
   5.151 +     * close - (none)
   5.152 +     */
   5.153 +    void (*close)(void *data,
   5.154 +              struct qt_extended_surface *qt_extended_surface);
   5.155 +};
   5.156 +
   5.157 +static inline int
   5.158 +qt_extended_surface_add_listener(struct qt_extended_surface *qt_extended_surface,
   5.159 +                 const struct qt_extended_surface_listener *listener, void *data)
   5.160 +{
   5.161 +    return wl_proxy_add_listener((struct wl_proxy *) qt_extended_surface,
   5.162 +                     (void (**)(void)) listener, data);
   5.163 +}
   5.164 +
   5.165 +#define QT_EXTENDED_SURFACE_UPDATE_GENERIC_PROPERTY 0
   5.166 +#define QT_EXTENDED_SURFACE_SET_CONTENT_ORIENTATION 1
   5.167 +#define QT_EXTENDED_SURFACE_SET_WINDOW_FLAGS    2
   5.168 +
   5.169 +static inline void
   5.170 +qt_extended_surface_set_user_data(struct qt_extended_surface *qt_extended_surface, void *user_data)
   5.171 +{
   5.172 +    wl_proxy_set_user_data((struct wl_proxy *) qt_extended_surface, user_data);
   5.173 +}
   5.174 +
   5.175 +static inline void *
   5.176 +qt_extended_surface_get_user_data(struct qt_extended_surface *qt_extended_surface)
   5.177 +{
   5.178 +    return wl_proxy_get_user_data((struct wl_proxy *) qt_extended_surface);
   5.179 +}
   5.180 +
   5.181 +static inline void
   5.182 +qt_extended_surface_destroy(struct qt_extended_surface *qt_extended_surface)
   5.183 +{
   5.184 +    wl_proxy_destroy((struct wl_proxy *) qt_extended_surface);
   5.185 +}
   5.186 +
   5.187 +static inline void
   5.188 +qt_extended_surface_update_generic_property(struct qt_extended_surface *qt_extended_surface, const char *name, struct wl_array *value)
   5.189 +{
   5.190 +    wl_proxy_marshal((struct wl_proxy *) qt_extended_surface,
   5.191 +             QT_EXTENDED_SURFACE_UPDATE_GENERIC_PROPERTY, name, value);
   5.192 +}
   5.193 +
   5.194 +static inline void
   5.195 +qt_extended_surface_set_content_orientation(struct qt_extended_surface *qt_extended_surface, int32_t orientation)
   5.196 +{
   5.197 +    wl_proxy_marshal((struct wl_proxy *) qt_extended_surface,
   5.198 +             QT_EXTENDED_SURFACE_SET_CONTENT_ORIENTATION, orientation);
   5.199 +}
   5.200 +
   5.201 +static inline void
   5.202 +qt_extended_surface_set_window_flags(struct qt_extended_surface *qt_extended_surface, int32_t flags)
   5.203 +{
   5.204 +    wl_proxy_marshal((struct wl_proxy *) qt_extended_surface,
   5.205 +             QT_EXTENDED_SURFACE_SET_WINDOW_FLAGS, flags);
   5.206 +}
   5.207 +
   5.208 +/* wayland-qt-touch-extension.h */
   5.209 +
   5.210 +extern const struct wl_interface qt_touch_extension_interface;
   5.211 +
   5.212 +#ifndef QT_TOUCH_EXTENSION_FLAGS_ENUM
   5.213 +#define QT_TOUCH_EXTENSION_FLAGS_ENUM
   5.214 +enum qt_touch_extension_flags {
   5.215 +    QT_TOUCH_EXTENSION_FLAGS_MOUSE_FROM_TOUCH = 0x1,
   5.216 +};
   5.217 +#endif /* QT_TOUCH_EXTENSION_FLAGS_ENUM */
   5.218 +
   5.219 +struct qt_touch_extension_listener {
   5.220 +    /**
   5.221 +     * touch - (none)
   5.222 +     * @time: (none)
   5.223 +     * @id: (none)
   5.224 +     * @state: (none)
   5.225 +     * @x: (none)
   5.226 +     * @y: (none)
   5.227 +     * @normalized_x: (none)
   5.228 +     * @normalized_y: (none)
   5.229 +     * @width: (none)
   5.230 +     * @height: (none)
   5.231 +     * @pressure: (none)
   5.232 +     * @velocity_x: (none)
   5.233 +     * @velocity_y: (none)
   5.234 +     * @flags: (none)
   5.235 +     * @rawdata: (none)
   5.236 +     */
   5.237 +    void (*touch)(void *data,
   5.238 +              struct qt_touch_extension *qt_touch_extension,
   5.239 +              uint32_t time,
   5.240 +              uint32_t id,
   5.241 +              uint32_t state,
   5.242 +              int32_t x,
   5.243 +              int32_t y,
   5.244 +              int32_t normalized_x,
   5.245 +              int32_t normalized_y,
   5.246 +              int32_t width,
   5.247 +              int32_t height,
   5.248 +              uint32_t pressure,
   5.249 +              int32_t velocity_x,
   5.250 +              int32_t velocity_y,
   5.251 +              uint32_t flags,
   5.252 +              struct wl_array *rawdata);
   5.253 +    /**
   5.254 +     * configure - (none)
   5.255 +     * @flags: (none)
   5.256 +     */
   5.257 +    void (*configure)(void *data,
   5.258 +              struct qt_touch_extension *qt_touch_extension,
   5.259 +              uint32_t flags);
   5.260 +};
   5.261 +
   5.262 +static inline int
   5.263 +qt_touch_extension_add_listener(struct qt_touch_extension *qt_touch_extension,
   5.264 +                const struct qt_touch_extension_listener *listener, void *data)
   5.265 +{
   5.266 +    return wl_proxy_add_listener((struct wl_proxy *) qt_touch_extension,
   5.267 +                     (void (**)(void)) listener, data);
   5.268 +}
   5.269 +
   5.270 +#define QT_TOUCH_EXTENSION_DUMMY    0
   5.271 +
   5.272 +static inline void
   5.273 +qt_touch_extension_set_user_data(struct qt_touch_extension *qt_touch_extension, void *user_data)
   5.274 +{
   5.275 +    wl_proxy_set_user_data((struct wl_proxy *) qt_touch_extension, user_data);
   5.276 +}
   5.277 +
   5.278 +static inline void *
   5.279 +qt_touch_extension_get_user_data(struct qt_touch_extension *qt_touch_extension)
   5.280 +{
   5.281 +    return wl_proxy_get_user_data((struct wl_proxy *) qt_touch_extension);
   5.282 +}
   5.283 +
   5.284 +static inline void
   5.285 +qt_touch_extension_destroy(struct qt_touch_extension *qt_touch_extension)
   5.286 +{
   5.287 +    wl_proxy_destroy((struct wl_proxy *) qt_touch_extension);
   5.288 +}
   5.289 +
   5.290 +static inline void
   5.291 +qt_touch_extension_dummy(struct qt_touch_extension *qt_touch_extension)
   5.292 +{
   5.293 +    wl_proxy_marshal((struct wl_proxy *) qt_touch_extension,
   5.294 +             QT_TOUCH_EXTENSION_DUMMY);
   5.295 +}
   5.296 +
   5.297 +
   5.298 +/* wayland-qt-windowmanager.h */
   5.299 +
   5.300 +extern const struct wl_interface qt_windowmanager_interface;
   5.301 +
   5.302 +struct qt_windowmanager_listener {
   5.303 +    /**
   5.304 +     * hints - (none)
   5.305 +     * @show_is_fullscreen: (none)
   5.306 +     */
   5.307 +    void (*hints)(void *data,
   5.308 +              struct qt_windowmanager *qt_windowmanager,
   5.309 +              int32_t show_is_fullscreen);
   5.310 +    /**
   5.311 +     * quit - (none)
   5.312 +     */
   5.313 +    void (*quit)(void *data,
   5.314 +             struct qt_windowmanager *qt_windowmanager);
   5.315 +};
   5.316 +
   5.317 +static inline int
   5.318 +qt_windowmanager_add_listener(struct qt_windowmanager *qt_windowmanager,
   5.319 +                  const struct qt_windowmanager_listener *listener, void *data)
   5.320 +{
   5.321 +    return wl_proxy_add_listener((struct wl_proxy *) qt_windowmanager,
   5.322 +                     (void (**)(void)) listener, data);
   5.323 +}
   5.324 +
   5.325 +#define QT_WINDOWMANAGER_OPEN_URL   0
   5.326 +
   5.327 +static inline void
   5.328 +qt_windowmanager_set_user_data(struct qt_windowmanager *qt_windowmanager, void *user_data)
   5.329 +{
   5.330 +    wl_proxy_set_user_data((struct wl_proxy *) qt_windowmanager, user_data);
   5.331 +}
   5.332 +
   5.333 +static inline void *
   5.334 +qt_windowmanager_get_user_data(struct qt_windowmanager *qt_windowmanager)
   5.335 +{
   5.336 +    return wl_proxy_get_user_data((struct wl_proxy *) qt_windowmanager);
   5.337 +}
   5.338 +
   5.339 +static inline void
   5.340 +qt_windowmanager_destroy(struct qt_windowmanager *qt_windowmanager)
   5.341 +{
   5.342 +    wl_proxy_destroy((struct wl_proxy *) qt_windowmanager);
   5.343 +}
   5.344 +
   5.345 +static inline void
   5.346 +qt_windowmanager_open_url(struct qt_windowmanager *qt_windowmanager, uint32_t remaining, const char *url)
   5.347 +{
   5.348 +    wl_proxy_marshal((struct wl_proxy *) qt_windowmanager,
   5.349 +             QT_WINDOWMANAGER_OPEN_URL, remaining, url);
   5.350 +}
   5.351 +
   5.352 +#endif /* _SDL_waylandtouch_h */
   5.353 +
   5.354 +#endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
     6.1 --- a/src/video/wayland/SDL_waylandvideo.c	Wed Dec 25 17:02:15 2013 +0100
     6.2 +++ b/src/video/wayland/SDL_waylandvideo.c	Fri Dec 27 09:29:39 2013 -0300
     6.3 @@ -30,6 +30,7 @@
     6.4  #include "SDL_waylandwindow.h"
     6.5  #include "SDL_waylandopengles.h"
     6.6  #include "SDL_waylandmouse.h"
     6.7 +#include "SDL_waylandtouch.h"
     6.8  
     6.9  #include <fcntl.h>
    6.10  #include <xkbcommon/xkbcommon.h>
    6.11 @@ -202,6 +203,25 @@
    6.12      shm_handle_format
    6.13  };
    6.14  
    6.15 +#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
    6.16 +static void
    6.17 +windowmanager_hints(void *data, struct qt_windowmanager *qt_windowmanager,
    6.18 +        int32_t show_is_fullscreen)
    6.19 +{
    6.20 +}
    6.21 +
    6.22 +static void
    6.23 +windowmanager_quit(void *data, struct qt_windowmanager *qt_windowmanager)
    6.24 +{
    6.25 +    SDL_SendQuit();
    6.26 +}
    6.27 +
    6.28 +static const struct qt_windowmanager_listener windowmanager_listener = {
    6.29 +    windowmanager_hints,
    6.30 +    windowmanager_quit,
    6.31 +};
    6.32 +#endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
    6.33 +
    6.34  static void
    6.35  display_handle_global(void *data, struct wl_registry *registry, uint32_t id,
    6.36  					const char *interface, uint32_t version)
    6.37 @@ -222,6 +242,18 @@
    6.38          d->cursor_theme = wl_cursor_theme_load(NULL, 32, d->shm);
    6.39          d->default_cursor = wl_cursor_theme_get_cursor(d->cursor_theme, "left_ptr");
    6.40          wl_shm_add_listener(d->shm, &shm_listener, d);
    6.41 +    
    6.42 +#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
    6.43 +    } else if (strcmp(interface, "qt_touch_extension") == 0) {
    6.44 +        Wayland_touch_create(d, id);
    6.45 +    } else if (strcmp(interface, "qt_surface_extension") == 0) {
    6.46 +        d->surface_extension = wl_registry_bind(registry, id,
    6.47 +                &qt_surface_extension_interface, 1);
    6.48 +    } else if (strcmp(interface, "qt_windowmanager") == 0) {
    6.49 +        d->windowmanager = wl_registry_bind(registry, id,
    6.50 +                &qt_windowmanager_interface, 1);
    6.51 +        qt_windowmanager_add_listener(d->windowmanager, &windowmanager_listener, d);
    6.52 +#endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
    6.53      }
    6.54  }
    6.55  
    6.56 @@ -334,6 +366,15 @@
    6.57          xkb_context_unref(data->xkb_context);
    6.58          data->xkb_context = NULL;
    6.59      }
    6.60 +#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
    6.61 +    if (data->windowmanager)
    6.62 +        qt_windowmanager_destroy(data->windowmanager);
    6.63 +
    6.64 +    if (data->surface_extension)
    6.65 +        qt_surface_extension_destroy(data->surface_extension);
    6.66 +
    6.67 +    Wayland_touch_destroy(data);
    6.68 +#endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
    6.69  
    6.70      if (data->shm)
    6.71          wl_shm_destroy(data->shm);
     7.1 --- a/src/video/wayland/SDL_waylandvideo.h	Wed Dec 25 17:02:15 2013 +0100
     7.2 +++ b/src/video/wayland/SDL_waylandvideo.h	Fri Dec 27 09:29:39 2013 -0300
     7.3 @@ -33,6 +33,12 @@
     7.4  struct xkb_context;
     7.5  struct SDL_WaylandInput;
     7.6  
     7.7 +#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
     7.8 +struct SDL_WaylandTouch;
     7.9 +struct qt_surface_extension;
    7.10 +struct qt_windowmanager;
    7.11 +#endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
    7.12 +
    7.13  typedef struct {
    7.14      struct wl_display *display;
    7.15      struct wl_registry *registry;
    7.16 @@ -56,6 +62,12 @@
    7.17  
    7.18      struct xkb_context *xkb_context;
    7.19      struct SDL_WaylandInput *input;
    7.20 +    
    7.21 +#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH    
    7.22 +    struct SDL_WaylandTouch *touch;
    7.23 +    struct qt_surface_extension *surface_extension;
    7.24 +    struct qt_windowmanager *windowmanager;
    7.25 +#endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
    7.26  
    7.27      uint32_t shm_formats;
    7.28  } SDL_VideoData;
     8.1 --- a/src/video/wayland/SDL_waylandwindow.c	Wed Dec 25 17:02:15 2013 +0100
     8.2 +++ b/src/video/wayland/SDL_waylandwindow.c	Fri Dec 27 09:29:39 2013 -0300
     8.3 @@ -26,6 +26,7 @@
     8.4  #include "../SDL_egl_c.h"
     8.5  #include "SDL_waylandwindow.h"
     8.6  #include "SDL_waylandvideo.h"
     8.7 +#include "SDL_waylandtouch.h"
     8.8  
     8.9  static void
    8.10  handle_ping(void *data, struct wl_shell_surface *shell_surface,
    8.11 @@ -51,6 +52,34 @@
    8.12      handle_popup_done
    8.13  };
    8.14  
    8.15 +#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
    8.16 +static void
    8.17 +handle_onscreen_visibility(void *data,
    8.18 +        struct qt_extended_surface *qt_extended_surface, int32_t visible)
    8.19 +{
    8.20 +}
    8.21 +
    8.22 +static void
    8.23 +handle_set_generic_property(void *data,
    8.24 +        struct qt_extended_surface *qt_extended_surface, const char *name,
    8.25 +        struct wl_array *value)
    8.26 +{
    8.27 +}
    8.28 +
    8.29 +static void
    8.30 +handle_close(void *data, struct qt_extended_surface *qt_extended_surface)
    8.31 +{
    8.32 +    SDL_WindowData *window = (SDL_WindowData *)data;
    8.33 +    SDL_SendWindowEvent(window->sdlwindow, SDL_WINDOWEVENT_CLOSE, 0, 0);
    8.34 +}
    8.35 +
    8.36 +static const struct qt_extended_surface_listener extended_surface_listener = {
    8.37 +    handle_onscreen_visibility,
    8.38 +    handle_set_generic_property,
    8.39 +    handle_close,
    8.40 +};
    8.41 +#endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
    8.42 +
    8.43  SDL_bool
    8.44  Wayland_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
    8.45  {
    8.46 @@ -127,6 +156,12 @@
    8.47      wl_surface_set_user_data(data->surface, data);
    8.48      data->shell_surface = wl_shell_get_shell_surface(c->shell,
    8.49                                                       data->surface);
    8.50 +#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH    
    8.51 +    if (c->surface_extension) {
    8.52 +        data->extended_surface = qt_surface_extension_get_extended_surface(
    8.53 +                c->surface_extension, data->surface);
    8.54 +    }
    8.55 +#endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
    8.56      data->egl_window = wl_egl_window_create(data->surface,
    8.57                                              window->w, window->h);
    8.58  
    8.59 @@ -144,6 +179,14 @@
    8.60                                        &shell_surface_listener, data);
    8.61      }
    8.62  
    8.63 +#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
    8.64 +    if (data->extended_surface) {
    8.65 +        qt_extended_surface_set_user_data(data->extended_surface, data);
    8.66 +        qt_extended_surface_add_listener(data->extended_surface,
    8.67 +                                         &extended_surface_listener, data);
    8.68 +    }
    8.69 +#endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
    8.70 +
    8.71      region = wl_compositor_create_region(c->compositor);
    8.72      wl_region_add(region, 0, 0, window->w, window->h);
    8.73      wl_surface_set_opaque_region(data->surface, region);
    8.74 @@ -182,6 +225,10 @@
    8.75          if (wind->shell_surface)
    8.76              wl_shell_surface_destroy(wind->shell_surface);
    8.77  
    8.78 +#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
    8.79 +        if (wind->extended_surface)
    8.80 +            qt_extended_surface_destroy(wind->extended_surface);
    8.81 +#endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
    8.82          wl_surface_destroy(wind->surface);
    8.83  
    8.84          SDL_free(wind);
     9.1 --- a/src/video/wayland/SDL_waylandwindow.h	Wed Dec 25 17:02:15 2013 +0100
     9.2 +++ b/src/video/wayland/SDL_waylandwindow.h	Fri Dec 27 09:29:39 2013 -0300
     9.3 @@ -38,8 +38,11 @@
     9.4      struct wl_shell_surface *shell_surface;
     9.5      struct wl_egl_window *egl_window;
     9.6      struct SDL_WaylandInput *keyboard_device;
     9.7 +    EGLSurface egl_surface;
     9.8  
     9.9 -    EGLSurface egl_surface;
    9.10 +#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
    9.11 +    struct qt_extended_surface *extended_surface;
    9.12 +#endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */    
    9.13  } SDL_WindowData;
    9.14  
    9.15  extern void Wayland_ShowWindow(_THIS, SDL_Window *window);