diff --git a/cursor.cpp b/cursor.cpp index 3296633b77..909090d8e7 100644 --- a/cursor.cpp +++ b/cursor.cpp @@ -66,16 +66,7 @@ void Cursor::loadThemeSettings() QString themeName = QString::fromUtf8(qgetenv("XCURSOR_THEME")); bool ok = false; // 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; - } - } + const uint themeSize = qEnvironmentVariableIntValue("XCURSOR_SIZE", &ok); if (!themeName.isEmpty() && ok) { updateTheme(themeName, themeSize); return; @@ -88,11 +79,7 @@ void Cursor::loadThemeFromKConfig() { KConfigGroup mousecfg(kwinApp()->inputConfig(), "Mouse"); const QString themeName = mousecfg.readEntry("cursorTheme", "default"); - bool ok = false; - uint themeSize = mousecfg.readEntry("cursorSize", QString("24")).toUInt(&ok); - if (!ok) { - themeSize = 24; - } + const uint themeSize = mousecfg.readEntry("cursorSize", 0); updateTheme(themeName, themeSize); } diff --git a/wayland_cursor_theme.cpp b/wayland_cursor_theme.cpp index 42b3bc445b..d8dcc3c803 100644 --- a/wayland_cursor_theme.cpp +++ b/wayland_cursor_theme.cpp @@ -56,13 +56,15 @@ void WaylandCursorTheme::loadTheme() // as we don't support per screen cursor sizes yet, we use the first screen KWayland::Server::Display *display = waylandServer()->display(); auto output = display->outputs().first(); - // calculate dots per inch, multiplied with magic constants from Cursor::loadThemeSettings() + // calculate dots per inch, multiplied with magic constants if (output->physicalSize().height()) { size = qreal(output->pixelSize().height()) / (qreal(output->physicalSize().height()) * 0.0393701) * 16.0 / 72.0; } else { // use sensible default size = 24; } + size *= output->scale(); + connect(output, &KWayland::Server::OutputInterface::scaleChanged, this, &WaylandCursorTheme::loadTheme, Qt::UniqueConnection); } auto theme = wl_cursor_theme_load(c->themeName().toUtf8().constData(), size, m_shm->shm());