Skip to content

Commit 79aae51

Browse files
committed
wayland: Clamp libdecor windows to toplevel bounds
1 parent b96bb15 commit 79aae51

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/video/wayland/SDL_waylandwindow.c

+19
Original file line numberDiff line numberDiff line change
@@ -1275,6 +1275,13 @@ static void decoration_frame_configure(struct libdecor_frame *frame,
12751275
if (floating) {
12761276
width = window->floating.w;
12771277
height = window->floating.h;
1278+
1279+
// Clamp the window to the toplevel bounds, if any are set.
1280+
if (wind->shell_surface_status == WAYLAND_SHELL_SURFACE_STATUS_WAITING_FOR_CONFIGURE &&
1281+
wind->toplevel_bounds.width && wind->toplevel_bounds.height) {
1282+
width = SDL_min(wind->toplevel_bounds.width, width);
1283+
height = SDL_min(wind->toplevel_bounds.height, height);
1284+
}
12781285
} else {
12791286
width = window->windowed.w;
12801287
height = window->windowed.h;
@@ -1440,11 +1447,23 @@ static void decoration_dismiss_popup(struct libdecor_frame *frame, const char *s
14401447
// NOP
14411448
}
14421449

1450+
#if SDL_LIBDECOR_CHECK_VERSION(0, 3, 0)
1451+
static void decoration_frame_toplevel_bounds(struct libdecor_frame *frame, int width, int height, void *user_data)
1452+
{
1453+
SDL_WindowData *wind = (SDL_WindowData *)user_data;
1454+
wind->toplevel_bounds.width = width;
1455+
wind->toplevel_bounds.height = height;
1456+
}
1457+
#endif
1458+
14431459
static struct libdecor_frame_interface libdecor_frame_interface = {
14441460
decoration_frame_configure,
14451461
decoration_frame_close,
14461462
decoration_frame_commit,
14471463
decoration_dismiss_popup
1464+
#if SDL_LIBDECOR_CHECK_VERSION(0, 3, 0)
1465+
decoration_frame_toplevel_bounds
1466+
#endif
14481467
};
14491468
#endif
14501469

0 commit comments

Comments
 (0)