Skip to content

Commit 921582f

Browse files
committed
wayland: Refactor toplevel mapping, implement HideWindow
1 parent a0a5da5 commit 921582f

File tree

4 files changed

+196
-95
lines changed

4 files changed

+196
-95
lines changed

src/video/wayland/SDL_waylandevents.c

+28-6
Original file line numberDiff line numberDiff line change
@@ -331,11 +331,21 @@ ProcessHitTest(struct SDL_WaylandInput *input, uint32_t serial)
331331
switch (rc) {
332332
case SDL_HITTEST_DRAGGABLE:
333333
if (input->display->shell.xdg) {
334-
xdg_toplevel_move(window_data->shell_surface.xdg.roleobj.toplevel, input->seat, serial);
334+
if (window_data->shell_surface.xdg.roleobj.toplevel) {
335+
xdg_toplevel_move(window_data->shell_surface.xdg.roleobj.toplevel,
336+
input->seat,
337+
serial);
338+
}
335339
} else if (input->display->shell.zxdg) {
336-
zxdg_toplevel_v6_move(window_data->shell_surface.zxdg.roleobj.toplevel, input->seat, serial);
340+
if (window_data->shell_surface.zxdg.roleobj.toplevel) {
341+
zxdg_toplevel_v6_move(window_data->shell_surface.zxdg.roleobj.toplevel,
342+
input->seat,
343+
serial);
344+
}
337345
} else {
338-
wl_shell_surface_move(window_data->shell_surface.wl, input->seat, serial);
346+
if (window_data->shell_surface.wl) {
347+
wl_shell_surface_move(window_data->shell_surface.wl, input->seat, serial);
348+
}
339349
}
340350
return SDL_TRUE;
341351

@@ -348,11 +358,23 @@ ProcessHitTest(struct SDL_WaylandInput *input, uint32_t serial)
348358
case SDL_HITTEST_RESIZE_BOTTOMLEFT:
349359
case SDL_HITTEST_RESIZE_LEFT:
350360
if (input->display->shell.xdg) {
351-
xdg_toplevel_resize(window_data->shell_surface.xdg.roleobj.toplevel, input->seat, serial, directions_zxdg[rc - SDL_HITTEST_RESIZE_TOPLEFT]);
361+
if (window_data->shell_surface.xdg.roleobj.toplevel) {
362+
xdg_toplevel_resize(window_data->shell_surface.xdg.roleobj.toplevel,
363+
input->seat,
364+
serial,
365+
directions_zxdg[rc - SDL_HITTEST_RESIZE_TOPLEFT]);
366+
}
352367
} else if (input->display->shell.zxdg) {
353-
zxdg_toplevel_v6_resize(window_data->shell_surface.zxdg.roleobj.toplevel, input->seat, serial, directions_zxdg[rc - SDL_HITTEST_RESIZE_TOPLEFT]);
368+
if (window_data->shell_surface.zxdg.roleobj.toplevel) {
369+
zxdg_toplevel_v6_resize(window_data->shell_surface.zxdg.roleobj.toplevel,
370+
input->seat,
371+
serial,
372+
directions_zxdg[rc - SDL_HITTEST_RESIZE_TOPLEFT]);
373+
}
354374
} else {
355-
wl_shell_surface_resize(window_data->shell_surface.wl, input->seat, serial, directions_wl[rc - SDL_HITTEST_RESIZE_TOPLEFT]);
375+
if (window_data->shell_surface.wl) {
376+
wl_shell_surface_resize(window_data->shell_surface.wl, input->seat, serial, directions_wl[rc - SDL_HITTEST_RESIZE_TOPLEFT]);
377+
}
356378
}
357379
return SDL_TRUE;
358380

src/video/wayland/SDL_waylandvideo.c

+1
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ Wayland_CreateDevice(int devindex)
198198

199199
device->CreateSDLWindow = Wayland_CreateWindow;
200200
device->ShowWindow = Wayland_ShowWindow;
201+
device->HideWindow = Wayland_HideWindow;
201202
device->SetWindowFullscreen = Wayland_SetWindowFullscreen;
202203
device->MaximizeWindow = Wayland_MaximizeWindow;
203204
device->MinimizeWindow = Wayland_MinimizeWindow;

0 commit comments

Comments
 (0)