diff options
author | Dave Davenport <qball@blame.services> | 2022-05-15 17:58:02 +0200 |
---|---|---|
committer | Dave Davenport <qball@blame.services> | 2022-05-15 17:58:02 +0200 |
commit | 9c3d1415118ae284808b6eed85b306519c0fcaa3 (patch) | |
tree | 164bbe5da1b6ecb6066aa82933bb4c019a2a1106 | |
parent | 141bd3d197c405c0cabd7b6d76b8105ffd514094 (diff) |
[View] Scaling via GDK_SCALE messgdk-scale-mess
-rw-r--r-- | config/config.c | 3 | ||||
-rw-r--r-- | include/settings.h | 2 | ||||
-rw-r--r-- | source/rofi.c | 11 | ||||
-rw-r--r-- | source/theme.c | 2 | ||||
-rw-r--r-- | source/view.c | 7 |
5 files changed, 20 insertions, 5 deletions
diff --git a/config/config.c b/config/config.c index c1610453..d17ecaf4 100644 --- a/config/config.c +++ b/config/config.c @@ -155,4 +155,5 @@ Settings config = { /** fallback icon */ .application_fallback_icon = NULL, /** refilter limit */ - .refilter_timeout_limit = 8192}; + .refilter_timeout_limit = 8192, + .scale = 1.0}; diff --git a/include/settings.h b/include/settings.h index 5128a379..32003ba9 100644 --- a/include/settings.h +++ b/include/settings.h @@ -181,6 +181,8 @@ typedef struct { /** refilter timeout limit, when more then these entries,go into timeout mode. */ unsigned int refilter_timeout_limit; + + double scale; } Settings; /** Default number of lines in the list view */ diff --git a/source/rofi.c b/source/rofi.c index db91f9e9..badf86fc 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -415,7 +415,8 @@ static void help_print_mode_not_found(const char *mode) { } static void help_print_no_arguments(void) { - GString *emesg = g_string_new("<span size=\"x-large\">Rofi is unsure what to show.</span>\n\n"); + GString *emesg = g_string_new( + "<span size=\"x-large\">Rofi is unsure what to show.</span>\n\n"); g_string_append(emesg, "Please specify the mode you want to show.\n\n"); g_string_append( emesg, " <b>rofi</b> -show <span color=\"green\">{mode}</span>\n\n"); @@ -786,6 +787,14 @@ int main(int argc, char *argv[]) { #endif return EXIT_SUCCESS; } + if (g_getenv("GDK_SCALE") != NULL) { + const char *scale = g_getenv("GDK_SCALE"); + errno = 0; + double scaled = g_ascii_strtod(scale, NULL); + if (scaled > 0 && errno == 0) { + config.scale = scaled; + } + } if (find_arg("-rasi-validate") >= 0) { char *str = NULL; diff --git a/source/theme.c b/source/theme.c index 3a9a19b8..253846ea 100644 --- a/source/theme.c +++ b/source/theme.c @@ -1319,7 +1319,7 @@ RofiHighlightColorStyle rofi_theme_get_highlight(widget *widget, } static int get_pixels(RofiDistanceUnit *unit, RofiOrientation ori) { int val = unit->distance; - + val *= config.scale; if (unit->type == ROFI_PU_EM) { val = unit->distance * textbox_get_estimated_char_height(); } else if (unit->type == ROFI_PU_CH) { diff --git a/source/view.c b/source/view.c index ae707190..811f9ea7 100644 --- a/source/view.c +++ b/source/view.c @@ -812,10 +812,10 @@ void __create_window(MenuFlags menu_flags) { if (config.dpi > 1) { PangoFontMap *font_map = pango_cairo_font_map_get_default(); pango_cairo_font_map_set_resolution((PangoCairoFontMap *)font_map, - (double)config.dpi); + (double)config.dpi * config.scale); } else if (config.dpi == 0 || config.dpi == 1) { // Auto-detect mode. - double dpi = 96; + double dpi = 96 * config.scale; if (CacheState.mon.mh > 0 && config.dpi == 1) { dpi = (CacheState.mon.h * 25.4) / (double)(CacheState.mon.mh); } else { @@ -832,6 +832,9 @@ void __create_window(MenuFlags menu_flags) { PangoFontMap *font_map = pango_cairo_font_map_get_default(); config.dpi = pango_cairo_font_map_get_resolution((PangoCairoFontMap *)font_map); + config.dpi *= config.scale; + pango_cairo_font_map_set_resolution((PangoCairoFontMap *)font_map, + (double)config.dpi * config.scale); } // Setup font. // Dummy widget. |