diff options
author | Phil Jones <philj56@gmail.com> | 2023-03-06 21:27:16 +0000 |
---|---|---|
committer | Phil Jones <philj56@gmail.com> | 2023-03-06 21:27:16 +0000 |
commit | 582825eda792c2612ab6f43a14ccb2bea3aee5d4 (patch) | |
tree | 413aed213ce35d91a69a6bd073a6461cc26dad8e /src/config.c | |
parent | c4c32f63617f612e91e5a4b3b0012d922e5104df (diff) |
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.
Diffstat (limited to 'src/config.c')
-rw-r--r-- | src/config.c | 16 |
1 files changed, 11 insertions, 5 deletions
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. */ |