wayland: Implement SetWindowModalFor
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
diff --git a/src/video/wayland/SDL_waylandvideo.c b/src/video/wayland/SDL_waylandvideo.c
index 6155062..3812245 100644
--- a/src/video/wayland/SDL_waylandvideo.c
+++ b/src/video/wayland/SDL_waylandvideo.c
@@ -205,6 +205,7 @@ Wayland_CreateDevice(int devindex)
device->SetWindowSize = Wayland_SetWindowSize;
device->SetWindowMinimumSize = Wayland_SetWindowMinimumSize;
device->SetWindowMaximumSize = Wayland_SetWindowMaximumSize;
+ device->SetWindowModalFor = Wayland_SetWindowModalFor;
device->SetWindowTitle = Wayland_SetWindowTitle;
device->DestroyWindow = Wayland_DestroyWindow;
device->SetWindowHitTest = Wayland_SetWindowHitTest;
diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c
index 5422698..9a81047 100644
--- a/src/video/wayland/SDL_waylandwindow.c
+++ b/src/video/wayland/SDL_waylandwindow.c
@@ -595,6 +595,27 @@ Wayland_SetWindowHitTest(SDL_Window *window, SDL_bool enabled)
return 0; /* just succeed, the real work is done elsewhere. */
}
+int
+Wayland_SetWindowModalFor(_THIS, SDL_Window *modal_window, SDL_Window *parent_window)
+{
+ const SDL_VideoData *viddata = (const SDL_VideoData *) _this->driverdata;
+ SDL_WindowData *modal_data = modal_window->driverdata;
+ SDL_WindowData *parent_data = parent_window->driverdata;
+
+ if (viddata->shell.xdg) {
+ xdg_toplevel_set_parent(modal_data->shell_surface.xdg.roleobj.toplevel,
+ parent_data->shell_surface.xdg.roleobj.toplevel);
+ } else if (viddata->shell.zxdg) {
+ zxdg_toplevel_v6_set_parent(modal_data->shell_surface.zxdg.roleobj.toplevel,
+ parent_data->shell_surface.zxdg.roleobj.toplevel);
+ } else {
+ return SDL_Unsupported();
+ }
+
+ WAYLAND_wl_display_flush( ((SDL_VideoData*)_this->driverdata)->display );
+ return 0;
+}
+
void Wayland_ShowWindow(_THIS, SDL_Window *window)
{
SDL_WaylandOutputData *driverdata = (SDL_WaylandOutputData *) SDL_GetDisplayForWindow(window)->driverdata;
diff --git a/src/video/wayland/SDL_waylandwindow.h b/src/video/wayland/SDL_waylandwindow.h
index 892be16..a4c9902 100644
--- a/src/video/wayland/SDL_waylandwindow.h
+++ b/src/video/wayland/SDL_waylandwindow.h
@@ -99,6 +99,7 @@ extern int Wayland_CreateWindow(_THIS, SDL_Window *window);
extern void Wayland_SetWindowSize(_THIS, SDL_Window * window);
extern void Wayland_SetWindowMinimumSize(_THIS, SDL_Window * window);
extern void Wayland_SetWindowMaximumSize(_THIS, SDL_Window * window);
+extern int Wayland_SetWindowModalFor(_THIS, SDL_Window * modal_window, SDL_Window * parent_window);
extern void Wayland_SetWindowTitle(_THIS, SDL_Window * window);
extern void Wayland_DestroyWindow(_THIS, SDL_Window *window);
extern void Wayland_SuspendScreenSaver(_THIS);