From 582825eda792c2612ab6f43a14ccb2bea3aee5d4 Mon Sep 17 00:00:00 2001 From: Phil Jones Date: Mon, 6 Mar 2023 21:27:16 +0000 Subject: Add fractional scaling support. The main change is that we now always have to set up the dummy surface which was previously only used when multiple monitors were present. This is because there's no way to determine an output's fractional scale factor without displaying a surface on it, and we need to know the scale factor before we create our main window surface. The extra compositor round-trips lead to a slight slowdown for single monitor setups (to the same speed as multi-monitor setups), but it's currently unavoidable as far as I know. --- src/config.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/config.c') diff --git a/src/config.c b/src/config.c index 31db79d..d831267 100644 --- a/src/config.c +++ b/src/config.c @@ -10,6 +10,7 @@ #include "config.h" #include "log.h" #include "nelem.h" +#include "scale.h" #include "unicode.h" #include "xmalloc.h" @@ -762,17 +763,22 @@ uint32_t fixup_percentage(uint32_t value, uint32_t base, bool is_percent) void config_fixup_values(struct tofi *tofi) { - uint32_t scale = tofi->window.scale; uint32_t base_width = tofi->output_width; uint32_t base_height = tofi->output_height; + uint32_t scale; + if (tofi->window.fractional_scale != 0) { + scale = tofi->window.fractional_scale; + } else { + scale = tofi->window.scale * 120; + } /* * If we're going to be scaling these values in Cairo, * we need to apply the inverse scale here. */ if (tofi->use_scale) { - base_width /= scale; - base_height /= scale; + base_width = scale_apply_inverse(base_width, scale); + base_height = scale_apply_inverse(base_height, scale); } tofi->window.margin_top = fixup_percentage( @@ -823,10 +829,10 @@ void config_fixup_values(struct tofi *tofi) tofi->output_height, tofi->window.height_is_percent); if (tofi->window.width_is_percent || !tofi->use_scale) { - tofi->window.width /= scale; + tofi->window.width = scale_apply_inverse(tofi->window.width, scale); } if (tofi->window.height_is_percent || !tofi->use_scale) { - tofi->window.height /= scale; + tofi->window.height = scale_apply_inverse(tofi->window.height, scale); } /* Don't attempt percentage handling if exclusive_zone is set to -1. */ -- cgit v1.2.3