diff --git a/CHANGELOG.md b/CHANGELOG.md index a027110..5a33acf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ - Support for per-urgency frame colours - `markup` setting for more fine-grained control over how markup is handled - `history_ignore` rule action to exclude a notification from being added to the history +- Support for setting the dpi value dunst will use for font rendering via the `Xft.dpi` X resource +- Experimental support for per-monitor dpi calculation ### Changed - Text and icons are now centred vertically diff --git a/dunstrc b/dunstrc index b7c6f40..8536bc1 100644 --- a/dunstrc +++ b/dunstrc @@ -181,6 +181,13 @@ # Always run rule-defined scripts, even if the notification is suppressed always_run_script = true +# Experimental features that may or may not work correctly. Do not expect them +# to have a consistent behaviour across releases. +[experimental] + # Calculate the dpi to use on a per-monitor basis. + # Please note that this setting will not work if Xft.dpi X resource is set. + per_monitor_dpi = false + [frame] width = 3 color = "#aaaaaa" diff --git a/src/settings.c b/src/settings.c index 9bf3e2b..01016e9 100644 --- a/src/settings.c +++ b/src/settings.c @@ -97,6 +97,12 @@ void load_settings(char *cmdline_config_path) load_ini_file(config_file); #endif + settings.per_monitor_dpi = option_get_bool( + "experimental", + "per_monitor_dpi", NULL, false, + "" + ); + settings.font = option_get_string( "global", "font", "-fn", font, diff --git a/src/settings.h b/src/settings.h index a5097f6..f2d2c93 100644 --- a/src/settings.h +++ b/src/settings.h @@ -14,6 +14,7 @@ enum markup_mode { MARKUP_NULL, MARKUP_NO, MARKUP_STRIP, MARKUP_FULL }; typedef struct _settings { bool print_notifications; + bool per_monitor_dpi; enum markup_mode markup; bool stack_duplicates; bool hide_duplicate_count; diff --git a/src/x11/screen.c b/src/x11/screen.c index 1852bc5..49abb82 100644 --- a/src/x11/screen.c +++ b/src/x11/screen.c @@ -56,7 +56,6 @@ static double get_xft_dpi_value() } XrmDestroyDatabase(xDB); } - return dpi; } @@ -106,7 +105,7 @@ void x_update_screens() XRRFreeMonitors(m); } -static double autodetect_dpi(screen_info *scr) +static int autodetect_dpi(screen_info *scr) { return (double)scr->dim.h * 25.4 / (double)scr->dim.mmh; } @@ -256,9 +255,12 @@ sc_cleanup: double get_dpi_for_screen(screen_info *scr) { double dpi = 0; - if ((dpi = get_xft_dpi_value()) || (dpi = autodetect_dpi(scr))) + if ((dpi = get_xft_dpi_value())) return dpi; - return 0; + else if (settings.per_monitor_dpi && (dpi = autodetect_dpi(scr))) + return dpi; + else + return 96; } /*