mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-05 09:26:25 +00:00
wayland: store and restore floating states
Some Wayland compositors send (0,0) as "suggested" configure event sizes to indicate that the client has to decide on its own which sizes to used. This is commonly done when restoring from maximised, fullscreen or tiles states to fullscreen. We now store the last known floating states in a new set of variables and restore them when we receive such a (0,0) configure event.
This commit is contained in:

committed by
Sam Lantinga

parent
d4e1b4974a
commit
42452f8ca5
@@ -214,11 +214,23 @@ handle_configure_xdg_toplevel(void *data,
|
||||
enum xdg_toplevel_state *state;
|
||||
SDL_bool fullscreen = SDL_FALSE;
|
||||
SDL_bool maximized = SDL_FALSE;
|
||||
SDL_bool floating = SDL_TRUE;
|
||||
wl_array_for_each(state, states) {
|
||||
if (*state == XDG_TOPLEVEL_STATE_FULLSCREEN) {
|
||||
switch (*state) {
|
||||
case XDG_TOPLEVEL_STATE_FULLSCREEN:
|
||||
fullscreen = SDL_TRUE;
|
||||
} else if (*state == XDG_TOPLEVEL_STATE_MAXIMIZED) {
|
||||
floating = SDL_FALSE;
|
||||
break;
|
||||
case XDG_TOPLEVEL_STATE_MAXIMIZED:
|
||||
maximized = SDL_TRUE;
|
||||
floating = SDL_FALSE;
|
||||
break;
|
||||
case XDG_TOPLEVEL_STATE_TILED_LEFT:
|
||||
case XDG_TOPLEVEL_STATE_TILED_RIGHT:
|
||||
case XDG_TOPLEVEL_STATE_TILED_TOP:
|
||||
case XDG_TOPLEVEL_STATE_TILED_BOTTOM:
|
||||
floating = SDL_FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,8 +243,8 @@ handle_configure_xdg_toplevel(void *data,
|
||||
}
|
||||
|
||||
if (width == 0 || height == 0) {
|
||||
width = window->windowed.w;
|
||||
height = window->windowed.h;
|
||||
width = wind->floating_width;
|
||||
height = wind->floating_height;
|
||||
}
|
||||
|
||||
/* xdg_toplevel spec states that this is a suggestion.
|
||||
@@ -274,6 +286,12 @@ handle_configure_xdg_toplevel(void *data,
|
||||
return;
|
||||
}
|
||||
|
||||
if (floating) {
|
||||
/* store current floating dimensions for restoring */
|
||||
wind->floating_width = width;
|
||||
wind->floating_height = height;
|
||||
}
|
||||
|
||||
wind->resize.width = width;
|
||||
wind->resize.height = height;
|
||||
}
|
||||
@@ -1303,6 +1321,11 @@ void Wayland_SetWindowSize(_THIS, SDL_Window * window)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!(window->flags & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_MAXIMIZED))) {
|
||||
wind->floating_width = window->w;
|
||||
wind->floating_height = window->h;
|
||||
}
|
||||
|
||||
region = wl_compositor_create_region(data->compositor);
|
||||
wl_region_add(region, 0, 0, window->w, window->h);
|
||||
wl_surface_set_opaque_region(wind->surface, region);
|
||||
|
Reference in New Issue
Block a user