Add per_monitor_dpi experimental setting

Calculating the screen dpi on a per-monitor basis can cause
inconsistencies if multiple monitors with slightly different dpis are
used and in some cases it might not be the expected behaviour.

As such, the per-monitor dpi calculation was changed from a default
fallback to an opt in experimental feature and the default value of 96
will be used for the dpi if Xft.dpi is not set.

In the future, depending on how we decide to continue, we can either
move this setting in the global configuration section and fall back to
the X11 display dpi as the default or simply always use the per-monitor
dpi calculation. But to preserve backwards compatibility, this decision
can wait until the next major release.
This commit is contained in:
Nikos Tsipinakis 2017-03-18 13:34:55 +02:00
parent 52600cdfb0
commit 43b4d4bb41
5 changed files with 22 additions and 4 deletions

View File

@ -10,6 +10,8 @@
- Support for per-urgency frame colours - Support for per-urgency frame colours
- `markup` setting for more fine-grained control over how markup is handled - `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 - `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 ### Changed
- Text and icons are now centred vertically - Text and icons are now centred vertically

View File

@ -181,6 +181,13 @@
# Always run rule-defined scripts, even if the notification is suppressed # Always run rule-defined scripts, even if the notification is suppressed
always_run_script = true 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] [frame]
width = 3 width = 3
color = "#aaaaaa" color = "#aaaaaa"

View File

@ -97,6 +97,12 @@ void load_settings(char *cmdline_config_path)
load_ini_file(config_file); load_ini_file(config_file);
#endif #endif
settings.per_monitor_dpi = option_get_bool(
"experimental",
"per_monitor_dpi", NULL, false,
""
);
settings.font = option_get_string( settings.font = option_get_string(
"global", "global",
"font", "-fn", font, "font", "-fn", font,

View File

@ -14,6 +14,7 @@ enum markup_mode { MARKUP_NULL, MARKUP_NO, MARKUP_STRIP, MARKUP_FULL };
typedef struct _settings { typedef struct _settings {
bool print_notifications; bool print_notifications;
bool per_monitor_dpi;
enum markup_mode markup; enum markup_mode markup;
bool stack_duplicates; bool stack_duplicates;
bool hide_duplicate_count; bool hide_duplicate_count;

View File

@ -56,7 +56,6 @@ static double get_xft_dpi_value()
} }
XrmDestroyDatabase(xDB); XrmDestroyDatabase(xDB);
} }
return dpi; return dpi;
} }
@ -106,7 +105,7 @@ void x_update_screens()
XRRFreeMonitors(m); 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; 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 get_dpi_for_screen(screen_info *scr)
{ {
double dpi = 0; double dpi = 0;
if ((dpi = get_xft_dpi_value()) || (dpi = autodetect_dpi(scr))) if ((dpi = get_xft_dpi_value()))
return dpi; return dpi;
return 0; else if (settings.per_monitor_dpi && (dpi = autodetect_dpi(scr)))
return dpi;
else
return 96;
} }
/* /*