src/video/wayland/SDL_waylandwindow.c
changeset 8082 5b83ad3f01ac
parent 8062 4fc5f66d63cc
child 8104 2e4f1bd21196
equal deleted inserted replaced
8081:402b8c313246 8082:5b83ad3f01ac
    24 #include "../SDL_sysvideo.h"
    24 #include "../SDL_sysvideo.h"
    25 #include "../../events/SDL_windowevents_c.h"
    25 #include "../../events/SDL_windowevents_c.h"
    26 #include "../SDL_egl_c.h"
    26 #include "../SDL_egl_c.h"
    27 #include "SDL_waylandwindow.h"
    27 #include "SDL_waylandwindow.h"
    28 #include "SDL_waylandvideo.h"
    28 #include "SDL_waylandvideo.h"
       
    29 #include "SDL_waylandtouch.h"
    29 
    30 
    30 static void
    31 static void
    31 handle_ping(void *data, struct wl_shell_surface *shell_surface,
    32 handle_ping(void *data, struct wl_shell_surface *shell_surface,
    32             uint32_t serial)
    33             uint32_t serial)
    33 {
    34 {
    48 static const struct wl_shell_surface_listener shell_surface_listener = {
    49 static const struct wl_shell_surface_listener shell_surface_listener = {
    49     handle_ping,
    50     handle_ping,
    50     handle_configure,
    51     handle_configure,
    51     handle_popup_done
    52     handle_popup_done
    52 };
    53 };
       
    54 
       
    55 #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
       
    56 static void
       
    57 handle_onscreen_visibility(void *data,
       
    58         struct qt_extended_surface *qt_extended_surface, int32_t visible)
       
    59 {
       
    60 }
       
    61 
       
    62 static void
       
    63 handle_set_generic_property(void *data,
       
    64         struct qt_extended_surface *qt_extended_surface, const char *name,
       
    65         struct wl_array *value)
       
    66 {
       
    67 }
       
    68 
       
    69 static void
       
    70 handle_close(void *data, struct qt_extended_surface *qt_extended_surface)
       
    71 {
       
    72     SDL_WindowData *window = (SDL_WindowData *)data;
       
    73     SDL_SendWindowEvent(window->sdlwindow, SDL_WINDOWEVENT_CLOSE, 0, 0);
       
    74 }
       
    75 
       
    76 static const struct qt_extended_surface_listener extended_surface_listener = {
       
    77     handle_onscreen_visibility,
       
    78     handle_set_generic_property,
       
    79     handle_close,
       
    80 };
       
    81 #endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
    53 
    82 
    54 SDL_bool
    83 SDL_bool
    55 Wayland_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
    84 Wayland_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
    56 {
    85 {
    57     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    86     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
   125     data->surface =
   154     data->surface =
   126         wl_compositor_create_surface(c->compositor);
   155         wl_compositor_create_surface(c->compositor);
   127     wl_surface_set_user_data(data->surface, data);
   156     wl_surface_set_user_data(data->surface, data);
   128     data->shell_surface = wl_shell_get_shell_surface(c->shell,
   157     data->shell_surface = wl_shell_get_shell_surface(c->shell,
   129                                                      data->surface);
   158                                                      data->surface);
       
   159 #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH    
       
   160     if (c->surface_extension) {
       
   161         data->extended_surface = qt_surface_extension_get_extended_surface(
       
   162                 c->surface_extension, data->surface);
       
   163     }
       
   164 #endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
   130     data->egl_window = wl_egl_window_create(data->surface,
   165     data->egl_window = wl_egl_window_create(data->surface,
   131                                             window->w, window->h);
   166                                             window->w, window->h);
   132 
   167 
   133     /* Create the GLES window surface */
   168     /* Create the GLES window surface */
   134     data->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) data->egl_window);
   169     data->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) data->egl_window);
   142         wl_shell_surface_set_user_data(data->shell_surface, data);
   177         wl_shell_surface_set_user_data(data->shell_surface, data);
   143         wl_shell_surface_add_listener(data->shell_surface,
   178         wl_shell_surface_add_listener(data->shell_surface,
   144                                       &shell_surface_listener, data);
   179                                       &shell_surface_listener, data);
   145     }
   180     }
   146 
   181 
       
   182 #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
       
   183     if (data->extended_surface) {
       
   184         qt_extended_surface_set_user_data(data->extended_surface, data);
       
   185         qt_extended_surface_add_listener(data->extended_surface,
       
   186                                          &extended_surface_listener, data);
       
   187     }
       
   188 #endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
       
   189 
   147     region = wl_compositor_create_region(c->compositor);
   190     region = wl_compositor_create_region(c->compositor);
   148     wl_region_add(region, 0, 0, window->w, window->h);
   191     wl_region_add(region, 0, 0, window->w, window->h);
   149     wl_surface_set_opaque_region(data->surface, region);
   192     wl_surface_set_opaque_region(data->surface, region);
   150     wl_region_destroy(region);
   193     wl_region_destroy(region);
   151 
   194 
   180         wl_egl_window_destroy(wind->egl_window);
   223         wl_egl_window_destroy(wind->egl_window);
   181 
   224 
   182         if (wind->shell_surface)
   225         if (wind->shell_surface)
   183             wl_shell_surface_destroy(wind->shell_surface);
   226             wl_shell_surface_destroy(wind->shell_surface);
   184 
   227 
       
   228 #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
       
   229         if (wind->extended_surface)
       
   230             qt_extended_surface_destroy(wind->extended_surface);
       
   231 #endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
   185         wl_surface_destroy(wind->surface);
   232         wl_surface_destroy(wind->surface);
   186 
   233 
   187         SDL_free(wind);
   234         SDL_free(wind);
   188         wayland_schedule_write(data);
   235         wayland_schedule_write(data);
   189     }
   236     }