summaryrefslogtreecommitdiffstats
path: root/video/out
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2023-07-15 23:11:04 -0500
committerDudemanguy <random342@airmail.cc>2023-07-16 21:20:50 -0500
commit9e9abb1a0f6e2b6b9619bc5f6443a75bf89ee0c7 (patch)
tree69e449b204f7d493e71e5456789021fee142d5ee /video/out
parent580f36e436225aa01bc3da03bd94882a983af3d6 (diff)
downloadmpv-9e9abb1a0f6e2b6b9619bc5f6443a75bf89ee0c7.tar.bz2
mpv-9e9abb1a0f6e2b6b9619bc5f6443a75bf89ee0c7.tar.xz
wayland: wrap resize requests in prepare_resize
828dd65ef84b4d8e95e70752b9eb0833909d1d23 started this and put it in the most common place, but any resize mpv is doing should be accompanied by that function call to correctly inform the compositor of the window bounds. Since we also have to set VO_EVENT_RESIZE at the same time, it makes sense to just put these in the same function. A slight thing to note is that xdg_surface_set_window_geometry uses surface local coordinates which means they are divided by the wl->scaling factor. If possible, we should use surface local coordinates directly if available (like in the toplevel config) to avoid potential rounding errors. Otherwise, just calculate it out. The linked commit actually broke some weston resizes in weird ways (window disappearing or completely freezing). Don't ask me why and I didn't attempt to find out why either, but with this it all appears to work normally again (the other compositors don't appear to be any different, and they shouldn't be), so we'll go with this since it fixes soemthing and it also is more conceptually correct.
Diffstat (limited to 'video/out')
-rw-r--r--video/out/wayland_common.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index 86673b6baa..4d9375c406 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -191,6 +191,7 @@ static void add_feedback(struct vo_wayland_feedback_pool *fback_pool,
static void get_shape_device(struct vo_wayland_state *wl);
static void greatest_common_divisor(struct vo_wayland_state *wl, int a, int b);
static void guess_focus(struct vo_wayland_state *wl);
+static void prepare_resize(struct vo_wayland_state *wl, int width, int height);
static void remove_feedback(struct vo_wayland_feedback_pool *fback_pool,
struct wp_presentation_feedback *fback);
static void remove_output(struct vo_wayland_output *out);
@@ -713,8 +714,8 @@ static void output_handle_done(void *data, struct wl_output *wl_output)
set_surface_scaling(wl);
spawn_cursor(wl);
set_geometry(wl, false);
+ prepare_resize(wl, 0, 0);
wl->pending_vo_events |= VO_EVENT_DPI;
- wl->pending_vo_events |= VO_EVENT_RESIZE;
}
wl->pending_vo_events |= VO_EVENT_WIN_STATE;
@@ -789,7 +790,7 @@ static void surface_handle_enter(void *data, struct wl_surface *wl_surface,
}
if (!mp_rect_equals(&old_geometry, &wl->geometry) || force_resize)
- wl->pending_vo_events |= VO_EVENT_RESIZE;
+ prepare_resize(wl, 0, 0);
MP_VERBOSE(wl, "Surface entered output %s %s (0x%x), scale = %f, refresh rate = %f Hz\n",
o->make, o->model, o->id, wl->scaling, o->refresh_rate);
@@ -831,7 +832,7 @@ static void surface_handle_preferred_buffer_scale(void *data,
if (wl->current_output) {
rescale_geometry(wl, old_scale);
set_geometry(wl, false);
- wl->pending_vo_events |= VO_EVENT_RESIZE;
+ prepare_resize(wl, 0, 0);
}
}
@@ -995,8 +996,7 @@ resize:
mp_rect_w(old_geometry), mp_rect_h(old_geometry),
mp_rect_w(wl->geometry), mp_rect_h(wl->geometry));
- wl->pending_vo_events |= VO_EVENT_RESIZE;
- xdg_surface_set_window_geometry(wl->xdg_surface, 0, 0, width, height);
+ prepare_resize(wl, width, height);
wl->toplevel_configured = true;
}
@@ -1046,7 +1046,7 @@ static void preferred_scale(void *data,
if (wl->current_output) {
rescale_geometry(wl, old_scale);
set_geometry(wl, false);
- wl->pending_vo_events |= VO_EVENT_RESIZE;
+ prepare_resize(wl, 0, 0);
}
}
@@ -1657,6 +1657,16 @@ static int lookupkey(int key)
return mpkey;
}
+static void prepare_resize(struct vo_wayland_state *wl, int width, int height)
+{
+ if (!width)
+ width = mp_rect_w(wl->geometry) / wl->scaling;
+ if (!height)
+ height = mp_rect_h(wl->geometry) / wl->scaling;
+ xdg_surface_set_window_geometry(wl->xdg_surface, 0, 0, width, height);
+ wl->pending_vo_events |= VO_EVENT_RESIZE;
+}
+
static void request_decoration_mode(struct vo_wayland_state *wl, uint32_t mode)
{
wl->requested_decoration = mode;
@@ -1777,7 +1787,7 @@ static void set_geometry(struct vo_wayland_state *wl, bool resize)
if (resize) {
if (!wl->vo_opts->fullscreen && !wl->vo_opts->window_maximized)
wl->geometry = wl->window_size;
- wl->pending_vo_events |= VO_EVENT_RESIZE;
+ prepare_resize(wl, 0, 0);
}
}
@@ -2104,7 +2114,7 @@ int vo_wayland_control(struct vo *vo, int *events, int request, void *arg)
return VO_TRUE;
}
wl->geometry = wl->window_size;
- wl->pending_vo_events |= VO_EVENT_RESIZE;
+ prepare_resize(wl, 0, 0);
}
return VO_TRUE;
}
@@ -2348,7 +2358,7 @@ bool vo_wayland_reconfig(struct vo *vo)
if (wl->vo_opts->window_minimized)
do_minimize(wl);
- wl->pending_vo_events |= VO_EVENT_RESIZE;
+ prepare_resize(wl, 0, 0);
return true;
}