aboutsummaryrefslogtreecommitdiffhomepage
path: root/video
diff options
context:
space:
mode:
authorGravatar Rostislav Pehlivanov <atomnuker@gmail.com>2018-05-15 20:20:16 +0100
committerGravatar Jan Ekström <jeebjp@gmail.com>2018-05-20 02:48:23 +0300
commit43d575616cc942943f3f41c2673de158127daef6 (patch)
tree7a19cc000f64498b806871c2add95c9df1170e82 /video
parent05b392bc949e918aaedb6383193edfd667bba646 (diff)
wayland_common: fix maximized state
Window size should not change if the window has been maximized or tiled.
Diffstat (limited to 'video')
-rw-r--r--video/out/wayland_common.c34
-rw-r--r--video/out/wayland_common.h1
2 files changed, 22 insertions, 13 deletions
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index 25ba9f0fd1..e0adeea1b7 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -179,7 +179,7 @@ static const struct wl_pointer_listener pointer_listener = {
static int check_for_resize(struct vo_wayland_state *wl, wl_fixed_t x_w, wl_fixed_t y_w,
enum xdg_toplevel_resize_edge *edge)
{
- if (wl->touch_entries || wl->fullscreen)
+ if (wl->touch_entries || wl->fullscreen || wl->maximized)
return 0;
const int edge_pixels = 64;
@@ -806,7 +806,8 @@ static void registry_handle_add(void *data, struct wl_registry *reg, uint32_t id
}
if (!strcmp(interface, xdg_wm_base_interface.name) && found++) {
- wl->shell = wl_registry_bind(reg, id, &xdg_wm_base_interface, 1);
+ ver = MPMIN(ver, 2); /* We can use either 1 or 2 */
+ wl->shell = wl_registry_bind(reg, id, &xdg_wm_base_interface, ver);
xdg_wm_base_add_listener(wl->shell, &xdg_shell_listener, wl);
}
@@ -883,7 +884,7 @@ static void handle_toplevel_config(void *data, struct xdg_toplevel *toplevel,
struct mp_rect old_geometry = wl->geometry;
int prev_fs_state = wl->fullscreen;
- bool maximized = false;
+ wl->maximized = false;
wl->fullscreen = false;
enum xdg_toplevel_state *state;
wl_array_for_each(state, states) {
@@ -894,11 +895,15 @@ static void handle_toplevel_config(void *data, struct xdg_toplevel *toplevel,
case XDG_TOPLEVEL_STATE_RESIZING:
wl->pending_vo_events |= VO_EVENT_LIVE_RESIZING;
break;
- case XDG_TOPLEVEL_STATE_MAXIMIZED:
- maximized = true;
- break;
case XDG_TOPLEVEL_STATE_ACTIVATED:
break;
+ case XDG_TOPLEVEL_STATE_TILED_TOP:
+ case XDG_TOPLEVEL_STATE_TILED_LEFT:
+ case XDG_TOPLEVEL_STATE_TILED_RIGHT:
+ case XDG_TOPLEVEL_STATE_TILED_BOTTOM:
+ case XDG_TOPLEVEL_STATE_MAXIMIZED:
+ wl->maximized = true;
+ break;
}
}
@@ -910,7 +915,7 @@ static void handle_toplevel_config(void *data, struct xdg_toplevel *toplevel,
if (width > 0 && height > 0) {
if (!wl->fullscreen) {
if (wl->vo->opts->keepaspect && wl->vo->opts->keepaspect_window &&
- !maximized) {
+ !wl->maximized) {
if (width > height)
width = height * wl->aspect_ratio;
else
@@ -1153,11 +1158,14 @@ int vo_wayland_reconfig(struct vo *vo)
vo_calc_window_geometry(vo, &screenrc, &geo);
vo_apply_window_geometry(vo, &geo);
- wl->geometry.x0 = 0;
- wl->geometry.y0 = 0;
- wl->geometry.x1 = vo->dwidth / wl->scaling;
- wl->geometry.y1 = vo->dheight / wl->scaling;
- wl->window_size = wl->geometry;
+ if (!wl->configured || !wl->maximized) {
+ wl->geometry.x0 = 0;
+ wl->geometry.y0 = 0;
+ wl->geometry.x1 = vo->dwidth / wl->scaling;
+ wl->geometry.y1 = vo->dheight / wl->scaling;
+ wl->window_size = wl->geometry;
+ }
+
wl->aspect_ratio = vo->dwidth / (float)vo->dheight;
if (vo->opts->fullscreen) {
@@ -1319,7 +1327,7 @@ int vo_wayland_control(struct vo *vo, int *events, int request, void *arg)
}
case VOCTRL_SET_UNFS_WINDOW_SIZE: {
int *s = arg;
- if (!wl->fullscreen) {
+ if (!wl->fullscreen && !wl->maximized) {
wl->geometry.x0 = 0;
wl->geometry.y0 = 0;
wl->geometry.x1 = s[0]/wl->scaling;
diff --git a/video/out/wayland_common.h b/video/out/wayland_common.h
index f96226dbc2..9aa057fa57 100644
--- a/video/out/wayland_common.h
+++ b/video/out/wayland_common.h
@@ -54,6 +54,7 @@ struct vo_wayland_state {
struct mp_rect window_size;
float aspect_ratio;
bool fullscreen;
+ bool maximized;
bool configured;
int wakeup_pipe[2];
int pending_vo_events;