summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Preisinger <alexander.preisinger@gmail.com>2014-01-07 21:12:24 +0100
committerwm4 <wm4@nowhere>2014-01-15 20:49:32 +0100
commit0fe1385d80de4acf7d600700e0fe8ed1d884c172 (patch)
tree5d43ad2f308a996ab38b926f273e49cad22dc57a
parentf4e9371d0f33fea115f1390a0f5280f102dd6f98 (diff)
downloadmpv-0fe1385d80de4acf7d600700e0fe8ed1d884c172.tar.bz2
mpv-0fe1385d80de4acf7d600700e0fe8ed1d884c172.tar.xz
wayland: fix fullscreen & resizing for good
I added enough logic to never set ontop or fullscreen twitce. This commit keeps also the size of the video if multiple videos are played. If the ratio differs the width will be kept at the same size and only the height changes.
-rw-r--r--video/out/vo_wayland.c3
-rw-r--r--video/out/wayland_common.c38
-rw-r--r--video/out/wayland_common.h5
3 files changed, 34 insertions, 12 deletions
diff --git a/video/out/vo_wayland.c b/video/out/vo_wayland.c
index 259f6bcf6c..2c0d1ef798 100644
--- a/video/out/vo_wayland.c
+++ b/video/out/vo_wayland.c
@@ -639,6 +639,9 @@ static int reconfig(struct vo *vo, struct mp_image_params *fmt, int flags)
vo_wayland_config(vo, vo->dwidth, vo->dheight, flags);
+ if (p->wl->window.events & VO_EVENT_RESIZE)
+ resize(p);
+
return 0;
}
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index c77a608d69..9c43d44a1c 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -578,6 +578,8 @@ static void shedule_resize(struct vo_wayland_state *wl,
int32_t x, y;
float temp_aspect = width / (float) MPMAX(height, 1);
+ MP_DBG(wl, "shedule resize: %dx%d\n", width, height);
+
if (width < minimum_size)
width = minimum_size;
@@ -796,13 +798,11 @@ void vo_wayland_uninit (struct vo *vo)
static void vo_wayland_ontop (struct vo *vo)
{
- MP_DBG(vo->wayland, "going ontop\n");
- vo->opts->ontop = 0;
- vo->opts->fullscreen = 1;
-
- /* use the already existing code to leave fullscreen mode and go into
- * toplevel mode */
- vo_wayland_fullscreen(vo);
+ struct vo_wayland_state *wl = vo->wayland;
+ MP_DBG(wl, "going ontop\n");
+ vo->opts->ontop = 1;
+ wl_shell_surface_set_toplevel(wl->window.shell_surface);
+ shedule_resize(wl, 0, wl->window.width, wl->window.height);
}
static void vo_wayland_border (struct vo *vo)
@@ -928,6 +928,9 @@ static void vo_wayland_update_screeninfo (struct vo *vo)
}
}
+ wl->window.fs_width = opts->screenwidth;
+ wl->window.fs_height = opts->screenheight;
+
aspect_save_screenres(vo, opts->screenwidth, opts->screenheight);
}
@@ -989,13 +992,26 @@ bool vo_wayland_config (struct vo *vo, uint32_t d_width,
{
struct vo_wayland_state *wl = vo->wayland;
- wl->window.width = d_width;
- wl->window.height = d_height;
wl->window.p_width = d_width;
wl->window.p_height = d_height;
- wl->window.aspect = wl->window.width / (float) MPMAX(wl->window.height, 1);
+ wl->window.aspect = d_width / (float) MPMAX(d_height, 1);
- vo_wayland_fullscreen(vo);
+ if (!(flags & VOFLAG_HIDDEN)) {
+ if (!wl->window.is_init) {
+ wl->window.width = d_width;
+ wl->window.height = d_height;
+ }
+
+ if (vo->opts->fullscreen) {
+ if (wl->window.is_fullscreen)
+ shedule_resize(wl, 0, wl->window.fs_width, wl->window.fs_height);
+ else
+ vo_wayland_fullscreen(vo);
+ }
+ else
+ vo_wayland_ontop(vo);
+ wl->window.is_init = true;
+ }
return true;
}
diff --git a/video/out/wayland_common.h b/video/out/wayland_common.h
index efbe071f9d..ecfe6fc928 100644
--- a/video/out/wayland_common.h
+++ b/video/out/wayland_common.h
@@ -80,7 +80,7 @@ struct vo_wayland_state {
} display;
struct {
- int32_t width;
+ int32_t width; // current size of the window
int32_t height;
int32_t p_width; // previous sizes for leaving fullscreen
int32_t p_height;
@@ -90,7 +90,10 @@ struct vo_wayland_state {
int32_t sh_y;
float aspect;
+ bool is_init; // true if the window has a valid size
bool is_fullscreen; // don't keep aspect ratio in fullscreen mode
+ int32_t fs_width; // fullscreen sizes
+ int32_t fs_height;
struct wl_surface *surface;
int32_t mouse_x; // mouse position inside the surface