From 6e67badfabb420a49f90e7be01aa0bd2bacef6b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 19 Jan 2015 09:24:54 +0100 Subject: [PATCH] Handle case that XCURSOR_SIZE environment variable is not set In a default startup startkde does not set XCURSOR_SIZE environment variable. Only XCURSOR_THEME is set. The size should be DPI dependent. With this patch Cursor is able to handle this situation and does not fall back to loading the config from file. Logic is taken from KHintsSettings in frameworkintegration which in turn is from KApplication. REVIEW: 122139 --- cursor.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/cursor.cpp b/cursor.cpp index 1207483313..f68437dc16 100644 --- a/cursor.cpp +++ b/cursor.cpp @@ -31,6 +31,7 @@ along with this program. If not, see . #include // Qt #include +#include #include // Xlib #include @@ -78,7 +79,17 @@ void Cursor::loadThemeSettings() { QString themeName = QString::fromUtf8(qgetenv("XCURSOR_THEME")); bool ok = false; - uint themeSize = qgetenv("XCURSOR_SIZE").toUInt(&ok); + // XCURSOR_SIZE might not be set (e.g. by startkde) + uint themeSize = 0; + if (qEnvironmentVariableIsSet("XCURSOR_SIZE")) { + themeSize = qgetenv("XCURSOR_SIZE").toUInt(&ok); + } + if (!ok) { + if (QScreen *s = QGuiApplication::primaryScreen()) { + themeSize = s->logicalDotsPerInchY() * 16 / 72; + ok = true; + } + } if (!themeName.isEmpty() && ok) { updateTheme(themeName, themeSize); return;