Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wayland: Clamp libdecor windows to toplevel bounds #11998

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/video/wayland/SDL_waylandwindow.c
Original file line number Diff line number Diff line change
Expand Up @@ -1275,6 +1275,13 @@ static void decoration_frame_configure(struct libdecor_frame *frame,
if (floating) {
width = window->floating.w;
height = window->floating.h;

// Clamp the window to the toplevel bounds, if any are set.
if (wind->shell_surface_status == WAYLAND_SHELL_SURFACE_STATUS_WAITING_FOR_CONFIGURE &&
wind->toplevel_bounds.width && wind->toplevel_bounds.height) {
width = SDL_min(wind->toplevel_bounds.width, width);
height = SDL_min(wind->toplevel_bounds.height, height);
}
} else {
width = window->windowed.w;
height = window->windowed.h;
Expand Down Expand Up @@ -1440,11 +1447,20 @@ static void decoration_dismiss_popup(struct libdecor_frame *frame, const char *s
// NOP
}

static void decoration_frame_toplevel_bounds(struct libdecor_frame *frame, int width, int height, void *user_data)
{
SDL_WindowData *wind = (SDL_WindowData *)user_data;
wind->toplevel_bounds.width = width;
wind->toplevel_bounds.height = height;
}

// Note: Functions pointers after dismiss_popup are cast to avoid compiler warnings if building against an older version.
static struct libdecor_frame_interface libdecor_frame_interface = {
decoration_frame_configure,
decoration_frame_close,
decoration_frame_commit,
decoration_dismiss_popup
decoration_dismiss_popup,
(void (*)(void))decoration_frame_toplevel_bounds
};
#endif

Expand Down
Loading