diff --git a/src/scripting/workspace_wrapper.cpp b/src/scripting/workspace_wrapper.cpp index 0dbabba96e..47c1a5973f 100644 --- a/src/scripting/workspace_wrapper.cpp +++ b/src/scripting/workspace_wrapper.cpp @@ -10,6 +10,7 @@ #include "workspace_wrapper.h" #include "core/output.h" +#include "cursor.h" #include "outline.h" #include "virtualdesktops.h" #include "workspace.h" @@ -61,6 +62,7 @@ WorkspaceWrapper::WorkspaceWrapper(QObject *parent) #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) connect(QApplication::desktop(), &QDesktopWidget::resized, this, &WorkspaceWrapper::screenResized); #endif + connect(Cursors::self()->mouse(), &Cursor::posChanged, this, &WorkspaceWrapper::cursorPosChanged); const QList clients = ws->allClientList(); for (Window *client : clients) { @@ -138,6 +140,11 @@ QStringList WorkspaceWrapper::activityList() const #endif } +QPoint WorkspaceWrapper::cursorPos() const +{ + return Cursors::self()->mouse()->pos(); +} + #define SLOTWRAPPER(name) \ void WorkspaceWrapper::name() \ { \ diff --git a/src/scripting/workspace_wrapper.h b/src/scripting/workspace_wrapper.h index 69ed5528db..879a56455f 100644 --- a/src/scripting/workspace_wrapper.h +++ b/src/scripting/workspace_wrapper.h @@ -77,6 +77,10 @@ class WorkspaceWrapper : public QObject * @see virtualScreenSize */ Q_PROPERTY(QRect virtualScreenGeometry READ virtualScreenGeometry NOTIFY virtualScreenGeometryChanged) + /** + * The current position of the cursor. + */ + Q_PROPERTY(QPoint cursorPos READ cursorPos NOTIFY cursorPosChanged) private: Q_DISABLE_COPY(WorkspaceWrapper) @@ -160,13 +164,17 @@ class WorkspaceWrapper : public QObject * @since 5.0 */ void virtualScreenGeometryChanged(); - /** * This signal is emitted when the current virtual desktop changes. * * @since 5.23 */ void currentVirtualDesktopChanged(); + /** + * This signal is emitted when the cursor position changes. + * @see cursorPos() + */ + void cursorPosChanged(); public: //------------------------------------------------------------------ @@ -231,6 +239,7 @@ class WorkspaceWrapper : public QObject QStringList activityList() const; QSize virtualScreenSize() const; QRect virtualScreenGeometry() const; + QPoint cursorPos() const; VirtualDesktop *currentVirtualDesktop() const; void setCurrentVirtualDesktop(VirtualDesktop *desktop);