src/video/wayland/SDL_waylandwindow.c
changeset 8104 2e4f1bd21196
parent 8082 5b83ad3f01ac
child 8116 f7c2f71251e5
equal deleted inserted replaced
8103:d4a88c49247e 8104:2e4f1bd21196
    17   2. Altered source versions must be plainly marked as such, and must not be
    17   2. Altered source versions must be plainly marked as such, and must not be
    18      misrepresented as being the original software.
    18      misrepresented as being the original software.
    19   3. This notice may not be removed or altered from any source distribution.
    19   3. This notice may not be removed or altered from any source distribution.
    20 */
    20 */
    21 
    21 
    22 #include "SDL_config.h"
    22 #include "../../SDL_internal.h"
    23 
    23 
    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"
   102                                         WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
   102                                         WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
   103                                         0, NULL);
   103                                         0, NULL);
   104     else
   104     else
   105         wl_shell_surface_set_toplevel(wind->shell_surface);
   105         wl_shell_surface_set_toplevel(wind->shell_surface);
   106 
   106 
   107     wayland_schedule_write(_this->driverdata);
   107     WAYLAND_wl_display_flush( ((SDL_VideoData*)_this->driverdata)->display );
   108 }
   108 }
   109 
   109 
   110 void
   110 void
   111 Wayland_SetWindowFullscreen(_THIS, SDL_Window * window,
   111 Wayland_SetWindowFullscreen(_THIS, SDL_Window * window,
   112                             SDL_VideoDisplay * _display, SDL_bool fullscreen)
   112                             SDL_VideoDisplay * _display, SDL_bool fullscreen)
   118                                         WL_SHELL_SURFACE_FULLSCREEN_METHOD_SCALE,
   118                                         WL_SHELL_SURFACE_FULLSCREEN_METHOD_SCALE,
   119                                         0, NULL);
   119                                         0, NULL);
   120     else
   120     else
   121         wl_shell_surface_set_toplevel(wind->shell_surface);
   121         wl_shell_surface_set_toplevel(wind->shell_surface);
   122 
   122 
   123     wayland_schedule_write(_this->driverdata);
   123     WAYLAND_wl_display_flush( ((SDL_VideoData*)_this->driverdata)->display );
   124 }
   124 }
   125 
   125 
   126 int Wayland_CreateWindow(_THIS, SDL_Window *window)
   126 int Wayland_CreateWindow(_THIS, SDL_Window *window)
   127 {
   127 {
   128     SDL_WindowData *data;
   128     SDL_WindowData *data;
   160     if (c->surface_extension) {
   160     if (c->surface_extension) {
   161         data->extended_surface = qt_surface_extension_get_extended_surface(
   161         data->extended_surface = qt_surface_extension_get_extended_surface(
   162                 c->surface_extension, data->surface);
   162                 c->surface_extension, data->surface);
   163     }
   163     }
   164 #endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
   164 #endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
   165     data->egl_window = wl_egl_window_create(data->surface,
   165     data->egl_window = WAYLAND_wl_egl_window_create(data->surface,
   166                                             window->w, window->h);
   166                                             window->w, window->h);
   167 
   167 
   168     /* Create the GLES window surface */
   168     /* Create the GLES window surface */
   169     data->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) data->egl_window);
   169     data->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) data->egl_window);
   170     
   170     
   190     region = wl_compositor_create_region(c->compositor);
   190     region = wl_compositor_create_region(c->compositor);
   191     wl_region_add(region, 0, 0, window->w, window->h);
   191     wl_region_add(region, 0, 0, window->w, window->h);
   192     wl_surface_set_opaque_region(data->surface, region);
   192     wl_surface_set_opaque_region(data->surface, region);
   193     wl_region_destroy(region);
   193     wl_region_destroy(region);
   194 
   194 
   195     wayland_schedule_write(c);
   195     WAYLAND_wl_display_flush(c->display);
   196 
   196 
   197     return 0;
   197     return 0;
   198 }
   198 }
   199 
   199 
   200 void Wayland_SetWindowSize(_THIS, SDL_Window * window)
   200 void Wayland_SetWindowSize(_THIS, SDL_Window * window)
   201 {
   201 {
   202     SDL_VideoData *data = _this->driverdata;
   202     SDL_VideoData *data = _this->driverdata;
   203     SDL_WindowData *wind = window->driverdata;
   203     SDL_WindowData *wind = window->driverdata;
   204     struct wl_region *region;
   204     struct wl_region *region;
   205 
   205 
   206     wl_egl_window_resize(wind->egl_window, window->w, window->h, 0, 0);
   206     WAYLAND_wl_egl_window_resize(wind->egl_window, window->w, window->h, 0, 0);
   207 
   207 
   208     region = wl_compositor_create_region(data->compositor);
   208     region =wl_compositor_create_region(data->compositor);
   209     wl_region_add(region, 0, 0, window->w, window->h);
   209     wl_region_add(region, 0, 0, window->w, window->h);
   210     wl_surface_set_opaque_region(wind->surface, region);
   210     wl_surface_set_opaque_region(wind->surface, region);
   211     wl_region_destroy(region);
   211     wl_region_destroy(region);
   212 }
   212 }
   213 
   213 
   218 
   218 
   219     window->driverdata = NULL;
   219     window->driverdata = NULL;
   220 
   220 
   221     if (data) {
   221     if (data) {
   222         SDL_EGL_DestroySurface(_this, wind->egl_surface);
   222         SDL_EGL_DestroySurface(_this, wind->egl_surface);
   223         wl_egl_window_destroy(wind->egl_window);
   223         WAYLAND_wl_egl_window_destroy(wind->egl_window);
   224 
   224 
   225         if (wind->shell_surface)
   225         if (wind->shell_surface)
   226             wl_shell_surface_destroy(wind->shell_surface);
   226             wl_shell_surface_destroy(wind->shell_surface);
   227 
   227 
   228 #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
   228 #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
   230             qt_extended_surface_destroy(wind->extended_surface);
   230             qt_extended_surface_destroy(wind->extended_surface);
   231 #endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
   231 #endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
   232         wl_surface_destroy(wind->surface);
   232         wl_surface_destroy(wind->surface);
   233 
   233 
   234         SDL_free(wind);
   234         SDL_free(wind);
   235         wayland_schedule_write(data);
   235         WAYLAND_wl_display_flush(data->display);
   236     }
   236     }
   237 }
   237 }
   238 
   238 
   239 /* vi: set ts=4 sw=4 expandtab: */
   239 /* vi: set ts=4 sw=4 expandtab: */