mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-17 18:45:10 +00:00
Fix XGetDefault DPI handling.
XGetDefault doesn't always return a value, check that it returns something before assuming it's valid. This fixes #1088.
This commit is contained in:
parent
d966e8522a
commit
9970c07aeb
@ -278,7 +278,7 @@ static int text_width = 1,
|
|||||||
text_height = 1; /* initially 1 so no zero-sized window is created */
|
text_height = 1; /* initially 1 so no zero-sized window is created */
|
||||||
|
|
||||||
#ifdef BUILD_XFT
|
#ifdef BUILD_XFT
|
||||||
static int xft_dpi;
|
static int xft_dpi = -1;
|
||||||
#endif /* BUILD_XFT */
|
#endif /* BUILD_XFT */
|
||||||
#endif /* BUILD_X11 */
|
#endif /* BUILD_X11 */
|
||||||
|
|
||||||
@ -503,7 +503,7 @@ int calc_text_width(const char *s) {
|
|||||||
|
|
||||||
int xft_dpi_scale(int value) {
|
int xft_dpi_scale(int value) {
|
||||||
#if defined(BUILD_X11) && defined(BUILD_XFT)
|
#if defined(BUILD_X11) && defined(BUILD_XFT)
|
||||||
if (use_xft.get(*state)) {
|
if (use_xft.get(*state) && xft_dpi > 0) {
|
||||||
return (value * xft_dpi + (value > 0 ? 48 : -48)) / 96;
|
return (value * xft_dpi + (value > 0 ? 48 : -48)) / 96;
|
||||||
} else {
|
} else {
|
||||||
return value;
|
return value;
|
||||||
@ -2562,7 +2562,8 @@ static void X11_create_window() {
|
|||||||
load_fonts(utf8_mode.get(*state));
|
load_fonts(utf8_mode.get(*state));
|
||||||
#ifdef BUILD_XFT
|
#ifdef BUILD_XFT
|
||||||
if (use_xft.get(*state)) {
|
if (use_xft.get(*state)) {
|
||||||
xft_dpi = atoi(XGetDefault(display, "Xft", "dpi"));
|
auto dpi = XGetDefault(display, "Xft", "dpi");
|
||||||
|
if (dpi) { xft_dpi = atoi(dpi); }
|
||||||
}
|
}
|
||||||
#endif /* BUILD_XFT */
|
#endif /* BUILD_XFT */
|
||||||
update_text_area(); /* to position text/window on screen */
|
update_text_area(); /* to position text/window on screen */
|
||||||
|
Loading…
Reference in New Issue
Block a user