mirror of https://github.com/mpv-player/mpv
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.
This commit is contained in:
parent
7c5c057717
commit
2aaf531720
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue