src/video/wayland/SDL_waylandwindow.c
changeset 8082 5b83ad3f01ac
parent 8062 4fc5f66d63cc
child 8104 2e4f1bd21196
--- a/src/video/wayland/SDL_waylandwindow.c	Wed Dec 25 17:02:15 2013 +0100
+++ b/src/video/wayland/SDL_waylandwindow.c	Fri Dec 27 09:29:39 2013 -0300
@@ -26,6 +26,7 @@
 #include "../SDL_egl_c.h"
 #include "SDL_waylandwindow.h"
 #include "SDL_waylandvideo.h"
+#include "SDL_waylandtouch.h"
 
 static void
 handle_ping(void *data, struct wl_shell_surface *shell_surface,
@@ -51,6 +52,34 @@
     handle_popup_done
 };
 
+#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
+static void
+handle_onscreen_visibility(void *data,
+        struct qt_extended_surface *qt_extended_surface, int32_t visible)
+{
+}
+
+static void
+handle_set_generic_property(void *data,
+        struct qt_extended_surface *qt_extended_surface, const char *name,
+        struct wl_array *value)
+{
+}
+
+static void
+handle_close(void *data, struct qt_extended_surface *qt_extended_surface)
+{
+    SDL_WindowData *window = (SDL_WindowData *)data;
+    SDL_SendWindowEvent(window->sdlwindow, SDL_WINDOWEVENT_CLOSE, 0, 0);
+}
+
+static const struct qt_extended_surface_listener extended_surface_listener = {
+    handle_onscreen_visibility,
+    handle_set_generic_property,
+    handle_close,
+};
+#endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
+
 SDL_bool
 Wayland_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
 {
@@ -127,6 +156,12 @@
     wl_surface_set_user_data(data->surface, data);
     data->shell_surface = wl_shell_get_shell_surface(c->shell,
                                                      data->surface);
+#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH    
+    if (c->surface_extension) {
+        data->extended_surface = qt_surface_extension_get_extended_surface(
+                c->surface_extension, data->surface);
+    }
+#endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
     data->egl_window = wl_egl_window_create(data->surface,
                                             window->w, window->h);
 
@@ -144,6 +179,14 @@
                                       &shell_surface_listener, data);
     }
 
+#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
+    if (data->extended_surface) {
+        qt_extended_surface_set_user_data(data->extended_surface, data);
+        qt_extended_surface_add_listener(data->extended_surface,
+                                         &extended_surface_listener, data);
+    }
+#endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
+
     region = wl_compositor_create_region(c->compositor);
     wl_region_add(region, 0, 0, window->w, window->h);
     wl_surface_set_opaque_region(data->surface, region);
@@ -182,6 +225,10 @@
         if (wind->shell_surface)
             wl_shell_surface_destroy(wind->shell_surface);
 
+#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
+        if (wind->extended_surface)
+            qt_extended_surface_destroy(wind->extended_surface);
+#endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
         wl_surface_destroy(wind->surface);
 
         SDL_free(wind);