wayland_common: guard against negative configure sizes

Negative values are nonsense to mpv, and can cause protocol error afterwards,
like xdg_surface::set_window_geometry which doesn't accept negative values.
Treat any negative values as zero (client determines size) for now.
This commit is contained in:
nanahi 2024-01-17 10:20:20 -05:00 committed by Dudemanguy
parent 92d1e9cd8a
commit 146bef059a
1 changed files with 5 additions and 0 deletions

View File

@ -890,6 +890,11 @@ static void handle_toplevel_config(void *data, struct xdg_toplevel *toplevel,
struct mp_vo_opts *vo_opts = wl->vo_opts;
struct mp_rect old_geometry = wl->geometry;
if (width < 0 || height < 0) {
MP_WARN(wl, "Compositor sent negative width/height values. Treating them as zero.\n");
width = height = 0;
}
int old_toplevel_width = wl->toplevel_width;
int old_toplevel_height = wl->toplevel_height;
wl->toplevel_width = width;