diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt
index 12f192d002..819864cea8 100644
--- a/autotests/CMakeLists.txt
+++ b/autotests/CMakeLists.txt
@@ -49,6 +49,7 @@ target_link_libraries( testClientMachine
Qt5::Test
Qt5::X11Extras
Qt5::Widgets
+ KF5::ConfigCore
KF5::WindowSystem
XCB::XCB
XCB::XFIXES
diff --git a/cursor.cpp b/cursor.cpp
index 7d440a08bf..9e4796d007 100644
--- a/cursor.cpp
+++ b/cursor.cpp
@@ -24,6 +24,9 @@ along with this program. If not, see .
#include "input.h"
#include "main.h"
#include "utils.h"
+// KDE
+#include
+#include
// Qt
#include
// Xlib
@@ -53,7 +56,13 @@ Cursor::Cursor(QObject *parent)
: QObject(parent)
, m_mousePollingCounter(0)
, m_cursorTrackingCounter(0)
+ , m_themeName("default")
+ , m_themeSize(24)
{
+ loadThemeSettings();
+ // TODO: we need to connect for cursor theme changes
+ // in KDE4 times this was done through KGlobaSettings::cursorChanged
+ // which got emitted from the cursors KCM, this needs porting
}
Cursor::~Cursor()
@@ -61,6 +70,18 @@ Cursor::~Cursor()
s_self = NULL;
}
+void Cursor::loadThemeSettings()
+{
+ KConfigGroup mousecfg(KSharedConfig::openConfig("kcminputrc", KConfig::NoGlobals), "Mouse");
+ m_themeName = mousecfg.readEntry("cursorTheme", "default");
+ bool ok = false;
+ m_themeSize = mousecfg.readEntry("cursorSize", QString("24")).toUInt(&ok);
+ if (!ok) {
+ m_themeSize = 24;
+ }
+ emit themeChanged();
+}
+
QPoint Cursor::pos()
{
s_self->doGetPos();
@@ -269,9 +290,7 @@ xcb_cursor_t X11Cursor::createCursor(Qt::CursorShape shape)
return XCB_CURSOR_NONE;
}
// XCursor is an XLib only lib
- const char *theme = XcursorGetTheme(display());
- const int size = XcursorGetDefaultSize(display());
- XcursorImage *ximg = XcursorLibraryLoadImage(name.constData(), theme, size);
+ XcursorImage *ximg = XcursorLibraryLoadImage(name.constData(), themeName().toUtf8().constData(), themeSize());
if (!ximg) {
return XCB_CURSOR_NONE;
}
diff --git a/cursor.h b/cursor.h
index 1e3d2c04fe..f255ca596d 100644
--- a/cursor.h
+++ b/cursor.h
@@ -87,6 +87,19 @@ public:
*/
void notifyCursorChanged(uint32_t serial);
+ /**
+ * @brief The name of the currently used Cursor theme.
+ *
+ * @return const QString&
+ */
+ const QString &themeName() const;
+ /**
+ * @brief The size of the currently used Cursor theme.
+ *
+ * @return int
+ */
+ int themeSize() const;
+
/**
* Returns the current cursor position. This method does an update of the mouse position if
* needed. It's save to call it multiple times.
@@ -117,6 +130,7 @@ Q_SIGNALS:
* @see stopCursorTracking
*/
void cursorChanged(uint32_t serial);
+ void themeChanged();
protected:
/**
@@ -167,10 +181,15 @@ protected:
void updatePos(const QPoint &pos);
void updatePos(int x, int y);
+private Q_SLOTS:
+ void loadThemeSettings();
+
private:
QPoint m_pos;
int m_mousePollingCounter;
int m_cursorTrackingCounter;
+ QString m_themeName;
+ int m_themeSize;
KWIN_SINGLETON(Cursor)
};
@@ -244,6 +263,16 @@ inline void Cursor::updatePos(int x, int y)
updatePos(QPoint(x, y));
}
+inline const QString& Cursor::themeName() const
+{
+ return m_themeName;
+}
+
+inline int Cursor::themeSize() const
+{
+ return m_themeSize;
+}
+
}
#endif // KWIN_CURSOR_H