From ea64fc43a6a321fcc7417f35d5ce50a2c7ee9d7e Mon Sep 17 00:00:00 2001 From: Phil Jones Date: Sat, 20 Aug 2022 09:37:40 +0100 Subject: Add scale option. Previously, tofi wouldn't scale pixel values by the output's scale factor. This allows pixel-perfect sizes on displays with scale factors >1, but means that configs need to be changed on a per-monitor basis, and is at odds with how other applications (notable Sway) behave. This commit adds a new option, --scale, to scale pixel values by the output's scale factor. For backwards compatibility, this currently defaults to false, and font scaling is performed regardless (the existing behaviour). In the next release, this will default to true, and font scaling will follow the same behaviour as everything else. --- src/main.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 8cc913d..7d861b4 100644 --- a/src/main.c +++ b/src/main.c @@ -763,6 +763,7 @@ static void usage() " --height Height of the window.\n" " --corner-radius Radius of window corners.\n" " --output Name of output to display window on.\n" +" --scale Follow the output's scale factor.\n" " --anchor Location on screen to anchor window.\n" " --margin-top Offset from top of screen.\n" " --margin-bottom Offset from bottom of screen.\n" @@ -827,6 +828,7 @@ const struct option long_options[] = { {"drun-print-exec", required_argument, NULL, 0}, {"hint-font", required_argument, NULL, 0}, {"output", required_argument, NULL, 0}, + {"scale", required_argument, NULL, 0}, {"late-keyboard-init", optional_argument, NULL, 'k'}, {NULL, 0, NULL, 0} }; @@ -1139,11 +1141,11 @@ int main(int argc, char *argv[]) log_debug("Selected output %s.\n", el->name); } - /* We can now calculate any percentages, as we know the output size. */ - config_fix_percentages(&tofi); - - /* Scale fonts to the correct size. */ - tofi.window.entry.font_size *= tofi.window.scale; + /* + * We can now scale values and calculate any percentages, as we know + * the output size and scale. + */ + config_fixup_values(&tofi); /* * If we were invoked as tofi-run, generate the command list. -- cgit v1.2.3