wayland: Clean up Wayland_HandlePendingResize Commit 871c11191bfc7214061a3da37c112522a102ddf5 removed delayed resize handling, but it left the whole structure untouched that now became unnecessary. To help with code clarity, get rid of the structure where pending resize state used to be stored and pass all the data directly to Wayland_HandlePendingResize (now renamed to Wayland_HandleResize, since it's not "pending" anymore but applied immediately)
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 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c
index f5ea3fa..e795b63 100644
--- a/src/video/wayland/SDL_waylandwindow.c
+++ b/src/video/wayland/SDL_waylandwindow.c
@@ -157,44 +157,18 @@ static const struct wl_callback_listener surface_frame_listener = {
};
-static void Wayland_HandlePendingResize(SDL_Window *window);
+static void Wayland_HandleResize(SDL_Window *window, int width, int height, float scale);
static void
handle_configure_xdg_shell_surface(void *data, struct xdg_surface *xdg, uint32_t serial)
{
SDL_WindowData *wind = (SDL_WindowData *)data;
SDL_Window *window = wind->sdlwindow;
- struct wl_region *region;
-
- if (!wind->shell_surface.xdg.initial_configure_seen) {
- window->w = 0;
- window->h = 0;
- SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, wind->resize.width, wind->resize.height);
- window->w = wind->resize.width;
- window->h = wind->resize.height;
-
- wl_surface_set_buffer_scale(wind->surface, wind->scale_factor);
- if (wind->egl_window) {
- WAYLAND_wl_egl_window_resize(wind->egl_window,
- window->w * wind->scale_factor,
- window->h * wind->scale_factor,
- 0, 0);
- }
-
- xdg_surface_ack_configure(xdg, serial);
- region = wl_compositor_create_region(wind->waylandData->compositor);
- wl_region_add(region, 0, 0, window->w, window->h);
- wl_surface_set_opaque_region(wind->surface, region);
- wl_region_destroy(region);
+ Wayland_HandleResize(window, window->w, window->h, wind->scale_factor);
+ xdg_surface_ack_configure(xdg, serial);
- wind->shell_surface.xdg.initial_configure_seen = SDL_TRUE;
- } else {
- wind->resize.pending = SDL_TRUE;
- wind->resize.configure = SDL_TRUE;
- wind->resize.serial = serial;
- Wayland_HandlePendingResize(window);
- }
+ wind->shell_surface.xdg.initial_configure_seen = SDL_TRUE;
}
static const struct xdg_surface_listener shell_surface_listener_xdg = {
@@ -261,8 +235,6 @@ handle_configure_xdg_toplevel(void *data,
}
height = SDL_max(height, window->min_h);
} else {
- wind->resize.width = window->w;
- wind->resize.height = window->h;
return;
}
}
@@ -281,8 +253,6 @@ handle_configure_xdg_toplevel(void *data,
}
if (width == 0 || height == 0) {
- wind->resize.width = window->w;
- wind->resize.height = window->h;
return;
}
@@ -292,8 +262,8 @@ handle_configure_xdg_toplevel(void *data,
wind->floating_height = height;
}
- wind->resize.width = width;
- wind->resize.height = height;
+ window->w = width;
+ window->h = height;
}
static void
@@ -332,17 +302,9 @@ decoration_frame_configure(struct libdecor_frame *frame,
width = (width == 0) ? window->w : width;
height = (height == 0) ? window->h : height;
- wind->resize.width = width;
- wind->resize.height = height;
-
- wind->resize.pending = SDL_TRUE;
- wind->resize.configure = SDL_TRUE;
- Wayland_HandlePendingResize(window);
+ Wayland_HandleResize(window, width, height, wind->scale_factor);
wind->shell_surface.libdecor.initial_configure_seen = SDL_TRUE;
- window->w = wind->resize.width;
- window->h = wind->resize.height;
-
/* window state */
if (!libdecor_configuration_get_window_state(configuration, &window_state)) {
window_state = LIBDECOR_WINDOW_STATE_NONE;
@@ -382,8 +344,6 @@ decoration_frame_configure(struct libdecor_frame *frame,
}
height = SDL_max(height, window->min_h);
} else {
- wind->resize.width = window->w;
- wind->resize.height = window->h;
return;
}
}
@@ -496,12 +456,7 @@ update_scale_factor(SDL_WindowData *window)
}
if (new_factor != old_factor) {
- /* force the resize event to trigger, as the logical size didn't change */
- window->resize.width = window->sdlwindow->w;
- window->resize.height = window->sdlwindow->h;
- window->resize.scale_factor = new_factor;
- window->resize.pending = SDL_TRUE;
- Wayland_HandlePendingResize(window->sdlwindow);
+ Wayland_HandleResize(window->sdlwindow, window->sdlwindow->w, window->sdlwindow->h, new_factor);
}
}
@@ -986,10 +941,7 @@ Wayland_SetWindowFullscreen(_THIS, SDL_Window * window,
*/
if (!fullscreen) {
SDL_WindowData *wind = (SDL_WindowData*) window->driverdata;
- wind->resize.width = window->windowed.w;
- wind->resize.height = window->windowed.h;
- wind->resize.pending = SDL_TRUE;
- Wayland_HandlePendingResize(window);
+ Wayland_HandleResize(window, window->windowed.w, window->windowed.h, wind->scale_factor);
}
}
@@ -1187,11 +1139,6 @@ int Wayland_CreateWindow(_THIS, SDL_Window *window)
}
}
- data->resize.pending = SDL_FALSE;
- data->resize.width = window->w;
- data->resize.height = window->h;
- data->resize.scale_factor = data->scale_factor;
-
data->outputs = NULL;
data->num_outputs = 0;
@@ -1261,47 +1208,31 @@ int Wayland_CreateWindow(_THIS, SDL_Window *window)
static void
-Wayland_HandlePendingResize(SDL_Window *window)
+Wayland_HandleResize(SDL_Window *window, int width, int height, float scale)
{
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
- if (data->resize.pending) {
- struct wl_region *region;
- if (data->scale_factor != data->resize.scale_factor || data->resize.configure) {
- window->w = 0;
- window->h = 0;
- }
- SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, data->resize.width, data->resize.height);
- window->w = data->resize.width;
- window->h = data->resize.height;
- data->scale_factor = data->resize.scale_factor;
- wl_surface_set_buffer_scale(data->surface, data->scale_factor);
- if (data->egl_window) {
- WAYLAND_wl_egl_window_resize(data->egl_window,
- window->w * data->scale_factor,
- window->h * data->scale_factor,
- 0, 0);
- }
-
- if (data->resize.configure) {
-#ifdef HAVE_LIBDECOR_H
- if (data->waylandData->shell.libdecor) {
- /* this has already been acknowledged in the the frames's 'configure' callback */
- } else
-#endif
- if (data->waylandData->shell.xdg) {
- xdg_surface_ack_configure(data->shell_surface.xdg.surface, data->resize.serial);
- }
- data->resize.configure = SDL_FALSE;
- }
+ struct wl_region *region;
+ window->w = 0;
+ window->h = 0;
+ SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, width, height);
+ window->w = width;
+ window->h = height;
+ data->scale_factor = scale;
- region = wl_compositor_create_region(data->waylandData->compositor);
- wl_region_add(region, 0, 0, window->w, window->h);
- wl_surface_set_opaque_region(data->surface, region);
- wl_region_destroy(region);
+ wl_surface_set_buffer_scale(data->surface, data->scale_factor);
- data->resize.pending = SDL_FALSE;
+ if (data->egl_window) {
+ WAYLAND_wl_egl_window_resize(data->egl_window,
+ window->w * data->scale_factor,
+ window->h * data->scale_factor,
+ 0, 0);
}
+
+ region = wl_compositor_create_region(data->waylandData->compositor);
+ wl_region_add(region, 0, 0, window->w, window->h);
+ wl_surface_set_opaque_region(data->surface, region);
+ wl_region_destroy(region);
}
void
diff --git a/src/video/wayland/SDL_waylandwindow.h b/src/video/wayland/SDL_waylandwindow.h
index 8cc4d03..852a8dc 100644
--- a/src/video/wayland/SDL_waylandwindow.h
+++ b/src/video/wayland/SDL_waylandwindow.h
@@ -77,13 +77,6 @@ typedef struct {
struct qt_extended_surface *extended_surface;
#endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
- struct {
- SDL_bool pending, configure;
- uint32_t serial;
- int width, height;
- float scale_factor;
- } resize;
-
SDL_WaylandOutputData **outputs;
int num_outputs;