summaryrefslogtreecommitdiffstats
path: root/video/out
diff options
context:
space:
mode:
Diffstat (limited to 'video/out')
-rw-r--r--video/out/gl_wayland.c31
-rw-r--r--video/out/wayland_common.c2
-rw-r--r--video/out/wayland_common.h1
3 files changed, 27 insertions, 7 deletions
diff --git a/video/out/gl_wayland.c b/video/out/gl_wayland.c
index 7fb9c4d810..45c58cf42a 100644
--- a/video/out/gl_wayland.c
+++ b/video/out/gl_wayland.c
@@ -48,11 +48,12 @@ static void egl_resize_func(struct vo_wayland_state *wl,
struct egl_context *ctx = user_data;
int32_t minimum_size = 150;
int32_t x, y;
+ float temp_aspect = width / (float) MPMAX(height, 1);
/* get the real window size of the window */
wl_egl_window_get_attached_size(ctx->egl_window,
- &wl->window->width,
- &wl->window->height);
+ &w->width,
+ &w->height);
if (width < minimum_size)
width = minimum_size;
@@ -61,11 +62,27 @@ static void egl_resize_func(struct vo_wayland_state *wl,
/* if only the height is changed we have to calculate the width
* in any other case we calculate the height */
- if (edges == WL_SHELL_SURFACE_RESIZE_BOTTOM ||
- edges == WL_SHELL_SURFACE_RESIZE_TOP)
- width = wl->vo->aspdat.asp * height;
- else
- height = (1 / wl->vo->aspdat.asp) * width;
+ switch (edges) {
+ case WL_SHELL_SURFACE_RESIZE_TOP:
+ case WL_SHELL_SURFACE_RESIZE_BOTTOM:
+ width = w->aspect * height;
+ break;
+ case WL_SHELL_SURFACE_RESIZE_LEFT:
+ case WL_SHELL_SURFACE_RESIZE_RIGHT:
+ case WL_SHELL_SURFACE_RESIZE_TOP_LEFT: // just a preference
+ case WL_SHELL_SURFACE_RESIZE_TOP_RIGHT:
+ case WL_SHELL_SURFACE_RESIZE_BOTTOM_LEFT:
+ case WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT:
+ height = (1 / w->aspect) * width;
+ break;
+ default:
+ if (w->aspect < temp_aspect)
+ width = w->aspect * height;
+ else
+ height = (1 / w->aspect) * width;
+ break;
+ }
+
if (edges & WL_SHELL_SURFACE_RESIZE_LEFT)
x = w->width - width;
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index b78b283e9c..2ba8dcec9f 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -882,6 +882,8 @@ bool vo_wayland_config (struct vo *vo, uint32_t d_width,
w->width = d_width;
w->height = d_height;
+ w->aspect = w->width / (float) MPMAX(w->height, 1);
+
if ((VOFLAG_FULLSCREEN & flags) && w->type != TYPE_FULLSCREEN)
vo_wayland_fullscreen(vo);
diff --git a/video/out/wayland_common.h b/video/out/wayland_common.h
index d55fcc0bbc..dce992beb2 100644
--- a/video/out/wayland_common.h
+++ b/video/out/wayland_common.h
@@ -79,6 +79,7 @@ struct vo_wayland_window {
int32_t height;
int32_t p_width;
int32_t p_height;
+ float aspect;
struct wl_surface *surface;
struct wl_shell_surface *shell_surface;