From 94afd1f7b065483a4e796b114ad167189d2e984c Mon Sep 17 00:00:00 2001 From: Simon Long Date: Wed, 8 May 2024 08:45:02 +0100 Subject: [PATCH] Now with the right calculation... --- src/common/scene-helpers.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/common/scene-helpers.c b/src/common/scene-helpers.c index f4c35f30..ab7d450e 100644 --- a/src/common/scene-helpers.c +++ b/src/common/scene-helpers.c @@ -44,6 +44,17 @@ lab_wlr_scene_get_prev_node(struct wlr_scene_node *node) return prev; } +static double constrain (double lower, double in, double upper) +{ + if (in < lower) { + return lower; + } + if (in > upper) { + return upper; + } + return in; +} + static void magnify(struct output *output, struct wlr_buffer *output_buffer, struct wlr_box *damage) { @@ -211,8 +222,10 @@ magnify(struct output *output, struct wlr_buffer *output_buffer, struct wlr_box dst_box.height = height; if (theme->mag_fullscreen) { - src_box.x = MAX(0, MIN(ox - width / (2 * mag_scale), width * (mag_scale - 1) / mag_scale)); - src_box.y = MAX(0, MIN(oy - height / (2 * mag_scale), height * (mag_scale - 1) / mag_scale)); + src_box.x = constrain (0.0, ox - (ox / mag_scale), + width * (mag_scale - 1.0) / mag_scale); + src_box.y = constrain (0.0, oy - (oy / mag_scale), + height * (mag_scale - 1.0) / mag_scale); dst_box.x = 0; dst_box.y = 0; } else {