summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2023-07-17 13:59:51 -0500
committerDudemanguy <random342@airmail.cc>2023-07-19 01:14:32 +0000
commit949e1f0dcc9d4fc9b15212dea981e00248c562f1 (patch)
tree201815e78cd9bbcc47b9c44190499947ac890214 /video
parentdbbcd9ec9c6f65fc911161919dd01b2117e3ac71 (diff)
downloadmpv-949e1f0dcc9d4fc9b15212dea981e00248c562f1.tar.bz2
mpv-949e1f0dcc9d4fc9b15212dea981e00248c562f1.tar.xz
wayland: add locked_size convenience shorthand
There's a lot of checks that are along the lines of !maximized && !minimized or vice versa. Make a locked_size boolean and store the value of this in here to avoid writing long lines since the next commit will add yet another condition to this.
Diffstat (limited to 'video')
-rw-r--r--video/out/wayland_common.c17
-rw-r--r--video/out/wayland_common.h1
2 files changed, 10 insertions, 8 deletions
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index cb291d0eed..305f65727f 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -272,8 +272,7 @@ static void pointer_handle_button(void *data, struct wl_pointer *wl_pointer,
mp_input_put_key(wl->vo->input_ctx, button | state | wl->mpmod);
if (!mp_input_test_dragging(wl->vo->input_ctx, wl->mouse_x, wl->mouse_y) &&
- (!wl->vo_opts->fullscreen) && (!wl->vo_opts->window_maximized) &&
- (button == MP_MBTN_LEFT) && (state == MP_KEY_STATE_DOWN))
+ !wl->locked_size && (button == MP_MBTN_LEFT) && (state == MP_KEY_STATE_DOWN))
{
uint32_t edges;
// Implement an edge resize zone if there are no decorations
@@ -938,6 +937,8 @@ static void handle_toplevel_config(void *data, struct xdg_toplevel *toplevel,
m_config_cache_write_opt(wl->vo_opts_cache, &vo_opts->window_maximized);
}
+ wl->locked_size = is_fullscreen || is_maximized;
+
if (wl->requested_decoration)
request_decoration_mode(wl, wl->requested_decoration);
@@ -952,7 +953,7 @@ static void handle_toplevel_config(void *data, struct xdg_toplevel *toplevel,
}
if (wl->state_change) {
- if (!is_fullscreen && !is_maximized) {
+ if (!wl->locked_size) {
wl->geometry = wl->window_size;
wl->state_change = false;
goto resize;
@@ -961,7 +962,7 @@ static void handle_toplevel_config(void *data, struct xdg_toplevel *toplevel,
/* Reuse old size if either of these are 0. */
if (width == 0 || height == 0) {
- if (!is_fullscreen && !is_maximized) {
+ if (!wl->locked_size) {
wl->geometry = wl->window_size;
}
goto resize;
@@ -971,7 +972,7 @@ static void handle_toplevel_config(void *data, struct xdg_toplevel *toplevel,
old_toplevel_height == wl->toplevel_height)
return;
- if (!is_fullscreen && !is_maximized) {
+ if (!wl->locked_size) {
if (vo_opts->keepaspect) {
double scale_factor = (double)width / wl->reduced_width;
width = ceil(wl->reduced_width * scale_factor);
@@ -1785,7 +1786,7 @@ static void set_geometry(struct vo_wayland_state *wl, bool resize)
wl->window_size = (struct mp_rect){0, 0, vo->dwidth, vo->dheight};
if (resize) {
- if (!wl->vo_opts->fullscreen && !wl->vo_opts->window_maximized)
+ if (!wl->locked_size)
wl->geometry = wl->window_size;
prepare_resize(wl, 0, 0);
}
@@ -2340,8 +2341,8 @@ bool vo_wayland_reconfig(struct vo *vo)
if (wl->opts->configure_bounds)
set_window_bounds(wl);
- if ((!wl->vo_opts->fullscreen && !wl->vo_opts->window_maximized) ||
- mp_rect_w(wl->geometry) == 0 || mp_rect_h(wl->geometry) == 0)
+ if (mp_rect_w(wl->geometry) == 0 || mp_rect_h(wl->geometry) == 0 ||
+ !wl->locked_size)
{
wl->geometry = wl->window_size;
}
diff --git a/video/out/wayland_common.h b/video/out/wayland_common.h
index d4e224fe84..2c554d4728 100644
--- a/video/out/wayland_common.h
+++ b/video/out/wayland_common.h
@@ -74,6 +74,7 @@ struct vo_wayland_state {
bool focused;
bool frame_wait;
bool hidden;
+ bool locked_size;
bool state_change;
bool toplevel_configured;
int display_fd;