Add 'xdg-shell' handling functionality wherever wl_shell is modified 16/69216/3
authorPrudhvi Raj, Vasireddi <prudhvi.raj@samsung.com>
Thu, 12 May 2016 07:27:48 +0000 (16:27 +0900)
committerPrudhvi Raj, Vasireddi <prudhvi.raj@samsung.com>
Thu, 12 May 2016 07:39:44 +0000 (16:39 +0900)
Change-Id: Ib980a3c402bc8e6b2f0c02efe319e71018fbb6af

src/video/wayland/SDL_waylandevents.c
src/video/wayland/SDL_waylandwindow.c

index 53b0ac9..0cd7d3d 100644 (file)
@@ -149,6 +149,9 @@ ProcessHitTest(struct SDL_WaylandInput *input, uint32_t serial)
         };
         switch (rc) {
             case SDL_HITTEST_DRAGGABLE:
+            if (window_data->xdgsurface)
+                xdg_surface_move(window_data->xdgsurface, input->seat, serial);
+            else if (window_data->shell_surface)
                 wl_shell_surface_move(window_data->shell_surface, input->seat, serial);
                 return SDL_TRUE;
 
@@ -160,7 +163,10 @@ ProcessHitTest(struct SDL_WaylandInput *input, uint32_t serial)
             case SDL_HITTEST_RESIZE_BOTTOM:
             case SDL_HITTEST_RESIZE_BOTTOMLEFT:
             case SDL_HITTEST_RESIZE_LEFT:
-                wl_shell_surface_resize(window_data->shell_surface, input->seat, serial, directions[rc - SDL_HITTEST_RESIZE_TOPLEFT]);
+                if (window_data->xdgsurface)
+                    xdg_surface_resize(window_data->xdgsurface, input->seat, serial, directions[rc - SDL_HITTEST_RESIZE_TOPLEFT]);
+                else if (window_data->shell_surface)
+                    wl_shell_surface_resize(window_data->shell_surface, input->seat, serial, directions[rc - SDL_HITTEST_RESIZE_TOPLEFT]);
                 return SDL_TRUE;
 
             default: return SDL_FALSE;
index 3efea19..5f5ca7f 100644 (file)
@@ -151,11 +151,21 @@ void Wayland_ShowWindow(_THIS, SDL_Window *window)
     SDL_WindowData *wind = window->driverdata;
 
     if (window->flags & SDL_WINDOW_FULLSCREEN)
-        wl_shell_surface_set_fullscreen(wind->shell_surface,
-                                        WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
-                                        0, (struct wl_output *)window->fullscreen_mode.driverdata);
+    {
+        if (wind->xdgsurface)
+            xdg_surface_set_fullscreen(wind->xdgsurface, (struct wl_output *)window->fullscreen_mode.driverdata);
+        else if(wind->shell_surface)
+            wl_shell_surface_set_fullscreen(wind->shell_surface,
+                                            WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
+                                            0, (struct wl_output *)window->fullscreen_mode.driverdata);
+    }
     else
-        wl_shell_surface_set_toplevel(wind->shell_surface);
+    {
+        if (wind->xdgsurface)
+            xdg_surface_set_parent(wind->xdgsurface, NULL);
+        else if (wind->shell_surface)
+            wl_shell_surface_set_toplevel(wind->shell_surface);
+    }
 
     WAYLAND_wl_display_flush( ((SDL_VideoData*)_this->driverdata)->display );
 }
@@ -167,11 +177,22 @@ Wayland_SetWindowFullscreen(_THIS, SDL_Window * window,
     SDL_WindowData *wind = window->driverdata;
 
     if (fullscreen)
-        wl_shell_surface_set_fullscreen(wind->shell_surface,
-                                        WL_SHELL_SURFACE_FULLSCREEN_METHOD_SCALE,
-                                        0, (struct wl_output *)_display->driverdata);
+    {
+        if (wind->xdgsurface)
+            xdg_surface_set_fullscreen(wind->xdgsurface, (struct wl_output *)_display->driverdata);
+
+        if(wind->shell_surface)
+            wl_shell_surface_set_fullscreen(wind->shell_surface,
+                                            WL_SHELL_SURFACE_FULLSCREEN_METHOD_SCALE,
+                                            0, (struct wl_output *)_display->driverdata);
+    }
     else
-        wl_shell_surface_set_toplevel(wind->shell_surface);
+    {
+        if (wind->xdgsurface)
+            xdg_surface_unset_fullscreen(wind->xdgsurface);
+        else if (wind->shell_surface)
+            wl_shell_surface_set_toplevel(wind->shell_surface);
+    }
 
     WAYLAND_wl_display_flush( ((SDL_VideoData*)_this->driverdata)->display );
 }
@@ -288,6 +309,10 @@ void Wayland_DestroyWindow(_THIS, SDL_Window *window)
         SDL_EGL_DestroySurface(_this, wind->egl_surface);
         WAYLAND_wl_egl_window_destroy(wind->egl_window);
 
+        if (wind->xdgsurface)
+            xdg_surface_destroy(wind->xdgsurface);
+        wind->xdgsurface = NULL;
+
         if (wind->shell_surface)
             wl_shell_surface_destroy(wind->shell_surface);