summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2020-02-05 20:47:10 -0600
committerDudemanguy <random342@airmail.cc>2020-02-06 16:17:25 +0000
commit2aaf5317200da0b836b1772576a0d8654e5313a7 (patch)
tree7967afaa6279a12ed584843ba28f060c8672477f
parent7c5c05771796468f96c97e03a692b0dbeb484e02 (diff)
downloadmpv-2aaf5317200da0b836b1772576a0d8654e5313a7.tar.bz2
mpv-2aaf5317200da0b836b1772576a0d8654e5313a7.tar.xz
wayland: toplevel config fixes
There were a couple of erroneous things in the handle_toplevel_config function. Firstly, looping through the different states was not handled correctly. Launching a window as maximized (can happen in sway for example) was always stuck on true and would never be set to false. Fix this by always checking if XDG_TOPLEVEL_STATE_MAXIMIZED is found or not. Also do a similar thing for the fullscreen state. Additionally, there were some issues with resizing windows and window-scale going back to old sizes. The root of this problem is that the width and height arguments of handle_toplevel_config aren't actually guarenteed to be the actual width and height of the surface. There are times when mpv will set the surface size on its own (like with window-scale) which will be unknown to the toplevel listener. To complicate matters, there are times when we do want to use the width and height arguments (like when resizing with the mouse). Fix this by checking if the width and height arguments reported by handle_toplevel_config changed from the previous call of the function. If the value is different, then we go ahead and use them when setting mpv's geometry. If not, then we just ignore it.
-rw-r--r--video/out/wayland_common.c19
-rw-r--r--video/out/wayland_common.h2
2 files changed, 18 insertions, 3 deletions
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index 6df646739f..73949f4555 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -941,13 +941,15 @@ 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;
+ bool found_fullscreen = false;
+ bool found_maximized = false;
bool is_maximized = vo_opts->window_maximized;
bool is_fullscreen = vo_opts->fullscreen;
enum xdg_toplevel_state *state;
wl_array_for_each(state, states) {
switch (*state) {
case XDG_TOPLEVEL_STATE_FULLSCREEN:
- is_fullscreen = true;
+ found_fullscreen = true;
break;
case XDG_TOPLEVEL_STATE_RESIZING:
wl->pending_vo_events |= VO_EVENT_LIVE_RESIZING;
@@ -955,7 +957,7 @@ static void handle_toplevel_config(void *data, struct xdg_toplevel *toplevel,
case XDG_TOPLEVEL_STATE_ACTIVATED:
/*
* If we get an ACTIVATED state, we know it cannot be
- * minimised, but it may not have been minimized
+ * minimized, but it may not have been minimized
* previously, so we can't detect the exact state.
*/
vo_opts->window_minimized = false;
@@ -967,19 +969,29 @@ static void handle_toplevel_config(void *data, struct xdg_toplevel *toplevel,
case XDG_TOPLEVEL_STATE_TILED_RIGHT:
case XDG_TOPLEVEL_STATE_TILED_BOTTOM:
case XDG_TOPLEVEL_STATE_MAXIMIZED:
- is_maximized = true;
+ found_maximized = true;
break;
}
}
+ is_maximized = found_maximized;
+ is_fullscreen = found_fullscreen;
vo_opts->fullscreen = is_fullscreen;
m_config_cache_write_opt(wl->vo_opts_cache, &vo_opts->fullscreen);
vo_opts->window_maximized = is_maximized;
m_config_cache_write_opt(wl->vo_opts_cache, &vo_opts->window_maximized);
+ int old_toplevel_width = wl->toplevel_width;
+ int old_toplevel_height = wl->toplevel_height;
+ wl->toplevel_width = width;
+ wl->toplevel_height = height;
+
if (!(wl->pending_vo_events & VO_EVENT_LIVE_RESIZING))
vo_query_and_reset_events(wl->vo, VO_EVENT_LIVE_RESIZING);
+ if (old_toplevel_width == wl->toplevel_width && old_toplevel_height == wl->toplevel_height)
+ return;
+
if (width > 0 && height > 0) {
if (!is_fullscreen && !is_maximized) {
if (wl->vo_opts->keepaspect && wl->vo_opts->keepaspect_window) {
@@ -1487,6 +1499,7 @@ int vo_wayland_control(struct vo *vo, int *events, int request, void *arg)
wl->geometry.y0 = 0;
wl->geometry.x1 = s[0]/wl->scaling;
wl->geometry.y1 = s[1]/wl->scaling;
+ wl->window_size = wl->geometry;
wl->pending_vo_events |= VO_EVENT_RESIZE;
}
return VO_TRUE;
diff --git a/video/out/wayland_common.h b/video/out/wayland_common.h
index ad965ef1d3..86ead415f9 100644
--- a/video/out/wayland_common.h
+++ b/video/out/wayland_common.h
@@ -83,6 +83,8 @@ struct vo_wayland_state {
int mouse_unscaled_y;
int scaling;
int touch_entries;
+ int toplevel_width;
+ int toplevel_height;
uint32_t pointer_id;
int display_fd;
struct wl_callback *frame_callback;