mirror of https://github.com/encounter/SDL.git
wayland: Try to avoid committing before the window is shown
This commit is contained in:
parent
84320266f2
commit
68a71f91c6
|
@ -42,7 +42,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
CommitMinMaxDimensions(SDL_Window *window)
|
SetMinMaxDimensions(SDL_Window *window, SDL_bool commit)
|
||||||
{
|
{
|
||||||
SDL_WindowData *wind = window->driverdata;
|
SDL_WindowData *wind = window->driverdata;
|
||||||
SDL_VideoData *viddata = wind->waylandData;
|
SDL_VideoData *viddata = wind->waylandData;
|
||||||
|
@ -88,12 +88,14 @@ CommitMinMaxDimensions(SDL_Window *window)
|
||||||
xdg_toplevel_set_max_size(wind->shell_surface.xdg.roleobj.toplevel,
|
xdg_toplevel_set_max_size(wind->shell_surface.xdg.roleobj.toplevel,
|
||||||
max_width,
|
max_width,
|
||||||
max_height);
|
max_height);
|
||||||
wl_surface_commit(wind->surface);
|
if (commit) {
|
||||||
|
wl_surface_commit(wind->surface);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
SetFullscreen(SDL_Window *window, struct wl_output *output)
|
SetFullscreen(SDL_Window *window, struct wl_output *output, SDL_bool commit)
|
||||||
{
|
{
|
||||||
SDL_WindowData *wind = window->driverdata;
|
SDL_WindowData *wind = window->driverdata;
|
||||||
SDL_VideoData *viddata = wind->waylandData;
|
SDL_VideoData *viddata = wind->waylandData;
|
||||||
|
@ -101,7 +103,7 @@ SetFullscreen(SDL_Window *window, struct wl_output *output)
|
||||||
/* The desktop may try to enforce min/max sizes here, so turn them off for
|
/* The desktop may try to enforce min/max sizes here, so turn them off for
|
||||||
* fullscreen and on (if applicable) for windowed
|
* fullscreen and on (if applicable) for windowed
|
||||||
*/
|
*/
|
||||||
CommitMinMaxDimensions(window);
|
SetMinMaxDimensions(window, SDL_FALSE);
|
||||||
|
|
||||||
#ifdef HAVE_LIBDECOR_H
|
#ifdef HAVE_LIBDECOR_H
|
||||||
if (viddata->shell.libdecor) {
|
if (viddata->shell.libdecor) {
|
||||||
|
@ -134,6 +136,9 @@ SetFullscreen(SDL_Window *window, struct wl_output *output)
|
||||||
} else {
|
} else {
|
||||||
xdg_toplevel_unset_fullscreen(wind->shell_surface.xdg.roleobj.toplevel);
|
xdg_toplevel_unset_fullscreen(wind->shell_surface.xdg.roleobj.toplevel);
|
||||||
}
|
}
|
||||||
|
if (commit) {
|
||||||
|
wl_surface_commit(wind->surface);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,7 +220,7 @@ handle_configure_xdg_toplevel(void *data,
|
||||||
if (!fullscreen) {
|
if (!fullscreen) {
|
||||||
if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
||||||
/* We might need to re-enter fullscreen after being restored from minimized */
|
/* We might need to re-enter fullscreen after being restored from minimized */
|
||||||
SetFullscreen(window, driverdata->output);
|
SetFullscreen(window, driverdata->output, SDL_FALSE);
|
||||||
|
|
||||||
/* Foolishly do what the compositor says here. If it's wrong, don't
|
/* Foolishly do what the compositor says here. If it's wrong, don't
|
||||||
* blame us, we were explicitly instructed to do this.
|
* blame us, we were explicitly instructed to do this.
|
||||||
|
@ -364,7 +369,7 @@ decoration_frame_configure(struct libdecor_frame *frame,
|
||||||
if (!fullscreen) {
|
if (!fullscreen) {
|
||||||
if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
||||||
/* We might need to re-enter fullscreen after being restored from minimized */
|
/* We might need to re-enter fullscreen after being restored from minimized */
|
||||||
SetFullscreen(window, driverdata->output);
|
SetFullscreen(window, driverdata->output, SDL_FALSE);
|
||||||
fullscreen = SDL_TRUE;
|
fullscreen = SDL_TRUE;
|
||||||
floating = SDL_FALSE;
|
floating = SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
@ -779,7 +784,7 @@ void Wayland_ShowWindow(_THIS, SDL_Window *window)
|
||||||
* -flibit
|
* -flibit
|
||||||
*/
|
*/
|
||||||
SDL_WaylandOutputData *odata = SDL_GetDisplayForWindow(window)->driverdata;
|
SDL_WaylandOutputData *odata = SDL_GetDisplayForWindow(window)->driverdata;
|
||||||
SetFullscreen(window, (window->flags & SDL_WINDOW_FULLSCREEN) ? odata->output : NULL);
|
SetFullscreen(window, (window->flags & SDL_WINDOW_FULLSCREEN) ? odata->output : NULL, SDL_TRUE);
|
||||||
if (data->shell_surface.xdg.surface) {
|
if (data->shell_surface.xdg.surface) {
|
||||||
while (!data->shell_surface.xdg.initial_configure_seen) {
|
while (!data->shell_surface.xdg.initial_configure_seen) {
|
||||||
WAYLAND_wl_display_flush(c->display);
|
WAYLAND_wl_display_flush(c->display);
|
||||||
|
@ -791,6 +796,9 @@ void Wayland_ShowWindow(_THIS, SDL_Window *window)
|
||||||
if (data->shell_surface.xdg.roleobj.toplevel && c->decoration_manager) {
|
if (data->shell_surface.xdg.roleobj.toplevel && c->decoration_manager) {
|
||||||
data->server_decoration = zxdg_decoration_manager_v1_get_toplevel_decoration(c->decoration_manager, data->shell_surface.xdg.roleobj.toplevel);
|
data->server_decoration = zxdg_decoration_manager_v1_get_toplevel_decoration(c->decoration_manager, data->shell_surface.xdg.roleobj.toplevel);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
/* Nothing to see here, just commit. */
|
||||||
|
wl_surface_commit(data->surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Unlike the rest of window state we have to set this _after_ flushing the
|
/* Unlike the rest of window state we have to set this _after_ flushing the
|
||||||
|
@ -1053,7 +1061,7 @@ Wayland_SetWindowFullscreen(_THIS, SDL_Window * window,
|
||||||
{
|
{
|
||||||
struct wl_output *output = ((SDL_WaylandOutputData*) _display->driverdata)->output;
|
struct wl_output *output = ((SDL_WaylandOutputData*) _display->driverdata)->output;
|
||||||
SDL_VideoData *viddata = (SDL_VideoData *) _this->driverdata;
|
SDL_VideoData *viddata = (SDL_VideoData *) _this->driverdata;
|
||||||
SetFullscreen(window, fullscreen ? output : NULL);
|
SetFullscreen(window, fullscreen ? output : NULL, SDL_TRUE);
|
||||||
|
|
||||||
WAYLAND_wl_display_flush(viddata->display);
|
WAYLAND_wl_display_flush(viddata->display);
|
||||||
}
|
}
|
||||||
|
@ -1125,7 +1133,7 @@ Wayland_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable)
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
CommitMinMaxDimensions(window);
|
SetMinMaxDimensions(window, SDL_TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1338,7 +1346,7 @@ int Wayland_CreateWindow(_THIS, SDL_Window *window)
|
||||||
Wayland_input_lock_pointer(c->input);
|
Wayland_input_lock_pointer(c->input);
|
||||||
}
|
}
|
||||||
|
|
||||||
wl_surface_commit(data->surface);
|
/* Moved this call to ShowWindow: wl_surface_commit(data->surface); */
|
||||||
WAYLAND_wl_display_flush(c->display);
|
WAYLAND_wl_display_flush(c->display);
|
||||||
|
|
||||||
/* We may need to create an idle inhibitor for this new window */
|
/* We may need to create an idle inhibitor for this new window */
|
||||||
|
@ -1393,13 +1401,13 @@ Wayland_HandleResize(SDL_Window *window, int width, int height, float scale)
|
||||||
void
|
void
|
||||||
Wayland_SetWindowMinimumSize(_THIS, SDL_Window * window)
|
Wayland_SetWindowMinimumSize(_THIS, SDL_Window * window)
|
||||||
{
|
{
|
||||||
CommitMinMaxDimensions(window);
|
SetMinMaxDimensions(window, SDL_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Wayland_SetWindowMaximumSize(_THIS, SDL_Window * window)
|
Wayland_SetWindowMaximumSize(_THIS, SDL_Window * window)
|
||||||
{
|
{
|
||||||
CommitMinMaxDimensions(window);
|
SetMinMaxDimensions(window, SDL_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Wayland_SetWindowSize(_THIS, SDL_Window * window)
|
void Wayland_SetWindowSize(_THIS, SDL_Window * window)
|
||||||
|
|
Loading…
Reference in New Issue