From 901b3dddb0c03d20ec634197b17a9d6b15e8e641 Mon Sep 17 00:00:00 2001 From: Philip Langdale Date: Tue, 26 Nov 2019 08:47:44 +0800 Subject: wayland: implement minimize and maximize related VOCTRLs We primarily care about pseudo-decorations for wayland, where the compositor may not support server-side decorations. So let's implement the minimize and maximize commands and return the maximized window state. --- video/out/wayland_common.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c index dee87e617e..f66016dcbb 100644 --- a/video/out/wayland_common.c +++ b/video/out/wayland_common.c @@ -1342,6 +1342,25 @@ static int toggle_fullscreen(struct vo_wayland_state *wl) return VO_TRUE; } +static int toggle_maximized(struct vo_wayland_state *wl) +{ + if (!wl->xdg_toplevel) + return VO_NOTAVAIL; + if (wl->maximized) + xdg_toplevel_unset_maximized(wl->xdg_toplevel); + else + xdg_toplevel_set_maximized(wl->xdg_toplevel); + return VO_TRUE; +} + +static int do_minimize(struct vo_wayland_state *wl) +{ + if (!wl->xdg_toplevel) + return VO_NOTAVAIL; + xdg_toplevel_set_minimized(wl->xdg_toplevel); + return VO_TRUE; +} + static int update_window_title(struct vo_wayland_state *wl, char *title) { if (!wl->xdg_toplevel) @@ -1428,6 +1447,10 @@ int vo_wayland_control(struct vo *vo, int *events, int request, void *arg) *(char ***)arg = get_displays_spanned(wl); return VO_TRUE; } + case VOCTRL_GET_WIN_STATE: { + *(int *)arg = wl->maximized ? VO_WIN_STATE_MAXIMIZED : 0; + return VO_TRUE; + } case VOCTRL_GET_UNFS_WINDOW_SIZE: { int *s = arg; s[0] = mp_rect_w(wl->geometry)*wl->scaling; @@ -1455,6 +1478,10 @@ int vo_wayland_control(struct vo *vo, int *events, int request, void *arg) return update_window_title(wl, (char *)arg); case VOCTRL_FULLSCREEN: return toggle_fullscreen(wl); + case VOCTRL_MAXIMIZE: + return toggle_maximized(wl); + case VOCTRL_MINIMIZE: + return do_minimize(wl); case VOCTRL_SET_CURSOR_VISIBILITY: return set_cursor_visibility(wl, *(bool *)arg); case VOCTRL_BORDER: -- cgit v1.2.3