From 4dc9255fe34b9126a850f79d5bae622656cef048 Mon Sep 17 00:00:00 2001 From: Simon Long Date: Wed, 8 May 2024 08:54:20 +0100 Subject: [PATCH] Remove explicit fullscreen flag --- docs/labwc-theme.5.scd | 2 ++ include/theme.h | 1 - src/common/scene-helpers.c | 19 ++++++++++++------- src/theme.c | 3 --- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/docs/labwc-theme.5.scd b/docs/labwc-theme.5.scd index f6f04b1a..7d54d23d 100644 --- a/docs/labwc-theme.5.scd +++ b/docs/labwc-theme.5.scd @@ -279,9 +279,11 @@ elements are not listed here, but are supported. *magnifier.width* Width of magnifier window in pixels. Default is 400. + Set to -1 to use fullscreen magnifier. *magnifier.height* Height of magnifier window in pixels. Default is 400. + Set to -1 to use fullscreen magnifier. *magnifier.border.width* Width of magnifier window border in pixels. Default is 1. diff --git a/include/theme.h b/include/theme.h index 1f2c1ef3..e1e884a2 100644 --- a/include/theme.h +++ b/include/theme.h @@ -147,7 +147,6 @@ struct theme { float mag_border_color[4]; int mag_border_width; int mag_filter; - int mag_fullscreen; }; struct server; diff --git a/src/common/scene-helpers.c b/src/common/scene-helpers.c index ab7d450e..7fd94d3a 100644 --- a/src/common/scene-helpers.c +++ b/src/common/scene-helpers.c @@ -44,7 +44,7 @@ lab_wlr_scene_get_prev_node(struct wlr_scene_node *node) return prev; } -static double constrain (double lower, double in, double upper) +static double constrain(double lower, double in, double upper) { if (in < lower) { return lower; @@ -62,6 +62,7 @@ magnify(struct output *output, struct wlr_buffer *output_buffer, struct wlr_box double x, y; struct wlr_box border_box, dst_box; struct wlr_fbox src_box; + bool fullscreen = false; /* Reuse a single scratch buffer */ static struct wlr_buffer *tmp_buffer = NULL; @@ -91,7 +92,11 @@ magnify(struct output *output, struct wlr_buffer *output_buffer, struct wlr_box wlr_output_layout_output_coords(server->output_layout, output->wlr_output, &ox, &oy); ox *= output->wlr_output->scale; oy *= output->wlr_output->scale; - if (ox < 0 || oy < 0 || ox > output_buffer->width || oy > output_buffer->height) { + if (theme->mag_width == -1 || theme->mag_height == -1) { + fullscreen = true; + } + if ((ox < 0 || oy < 0 || ox >= output_buffer->width || oy >= output_buffer->height) + && fullscreen) { return; } @@ -99,7 +104,7 @@ magnify(struct output *output, struct wlr_buffer *output_buffer, struct wlr_box mag_scale = theme->mag_scale; } - if (theme->mag_fullscreen) { + if (fullscreen) { // The lines below were the first attempt at enabling fullscreen (with no // other changes required). They appeared to work with a 4K monitor set to // 1080p, but when the monitor was set to native 4K, they resulted in a @@ -187,7 +192,7 @@ magnify(struct output *output, struct wlr_buffer *output_buffer, struct wlr_box server->renderer, output_buffer, NULL); /* Borders */ - if (theme->mag_fullscreen) { + if (fullscreen) { border_box.x = 0; border_box.y = 0; border_box.width = width; @@ -221,10 +226,10 @@ magnify(struct output *output, struct wlr_buffer *output_buffer, struct wlr_box dst_box.width = width; dst_box.height = height; - if (theme->mag_fullscreen) { - src_box.x = constrain (0.0, ox - (ox / mag_scale), + if (fullscreen) { + 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), + 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; diff --git a/src/theme.c b/src/theme.c index 6c6cae8d..71d35a9e 100644 --- a/src/theme.c +++ b/src/theme.c @@ -853,9 +853,6 @@ entry(struct theme *theme, const char *key, const char *value) if (match_glob(key, "magnifier.filter")) { theme->mag_filter = atoi(value); } - if (match_glob(key, "magnifier.fullscreen")) { - theme->mag_fullscreen = atoi(value); - } } static void