wayland: Try to avoid committing before the window is shown
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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c
index d4b89de..4c3c60a 100644
--- a/src/video/wayland/SDL_waylandwindow.c
+++ b/src/video/wayland/SDL_waylandwindow.c
@@ -42,7 +42,7 @@
#endif
static void
-CommitMinMaxDimensions(SDL_Window *window)
+SetMinMaxDimensions(SDL_Window *window, SDL_bool commit)
{
SDL_WindowData *wind = window->driverdata;
SDL_VideoData *viddata = wind->waylandData;
@@ -88,12 +88,14 @@ CommitMinMaxDimensions(SDL_Window *window)
xdg_toplevel_set_max_size(wind->shell_surface.xdg.roleobj.toplevel,
max_width,
max_height);
- wl_surface_commit(wind->surface);
+ if (commit) {
+ wl_surface_commit(wind->surface);
+ }
}
}
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_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
* fullscreen and on (if applicable) for windowed
*/
- CommitMinMaxDimensions(window);
+ SetMinMaxDimensions(window, SDL_FALSE);
#ifdef HAVE_LIBDECOR_H
if (viddata->shell.libdecor) {
@@ -134,6 +136,9 @@ SetFullscreen(SDL_Window *window, struct wl_output *output)
} else {
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 (window->flags & SDL_WINDOW_FULLSCREEN) {
/* 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
* blame us, we were explicitly instructed to do this.
@@ -364,7 +369,7 @@ decoration_frame_configure(struct libdecor_frame *frame,
if (!fullscreen) {
if (window->flags & SDL_WINDOW_FULLSCREEN) {
/* 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;
floating = SDL_FALSE;
}
@@ -779,7 +784,7 @@ void Wayland_ShowWindow(_THIS, SDL_Window *window)
* -flibit
*/
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) {
while (!data->shell_surface.xdg.initial_configure_seen) {
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) {
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
@@ -1053,7 +1061,7 @@ Wayland_SetWindowFullscreen(_THIS, SDL_Window * window,
{
struct wl_output *output = ((SDL_WaylandOutputData*) _display->driverdata)->output;
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);
}
@@ -1125,7 +1133,7 @@ Wayland_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable)
} else
#endif
{
- CommitMinMaxDimensions(window);
+ SetMinMaxDimensions(window, SDL_TRUE);
}
}
@@ -1338,7 +1346,7 @@ int Wayland_CreateWindow(_THIS, SDL_Window *window)
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);
/* 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
Wayland_SetWindowMinimumSize(_THIS, SDL_Window * window)
{
- CommitMinMaxDimensions(window);
+ SetMinMaxDimensions(window, SDL_TRUE);
}
void
Wayland_SetWindowMaximumSize(_THIS, SDL_Window * window)
{
- CommitMinMaxDimensions(window);
+ SetMinMaxDimensions(window, SDL_TRUE);
}
void Wayland_SetWindowSize(_THIS, SDL_Window * window)