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: 122139icc-effect-5.14.5
parent
4a260c6f42
commit
6e67badfab
13
cursor.cpp
13
cursor.cpp
|
@ -31,6 +31,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include <KSharedConfig>
|
||||
// Qt
|
||||
#include <QDBusConnection>
|
||||
#include <QScreen>
|
||||
#include <QTimer>
|
||||
// Xlib
|
||||
#include <X11/Xcursor/Xcursor.h>
|
||||
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue