From 83afce7f68f8ffc74f53642d2bac9e604bd64dfc Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Fri, 29 Mar 2024 05:41:39 -0700 Subject: [PATCH] core/screen: expose x and y positions --- src/core/qmlscreen.cpp | 18 ++++++++++++++++++ src/core/qmlscreen.hpp | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/src/core/qmlscreen.cpp b/src/core/qmlscreen.cpp index 26d791d..34588b7 100644 --- a/src/core/qmlscreen.cpp +++ b/src/core/qmlscreen.cpp @@ -42,6 +42,24 @@ QString QuickshellScreenInfo::name() const { return this->screen->name(); } +qint32 QuickshellScreenInfo::x() const { + if (this->screen == nullptr) { + this->warnDangling(); + return 0; + } + + return this->screen->geometry().x(); +} + +qint32 QuickshellScreenInfo::y() const { + if (this->screen == nullptr) { + this->warnDangling(); + return 0; + } + + return this->screen->geometry().y(); +} + qint32 QuickshellScreenInfo::width() const { if (this->screen == nullptr) { this->warnDangling(); diff --git a/src/core/qmlscreen.hpp b/src/core/qmlscreen.hpp index 759d83e..dfebf33 100644 --- a/src/core/qmlscreen.hpp +++ b/src/core/qmlscreen.hpp @@ -32,6 +32,8 @@ class QuickshellScreenInfo: public QObject { /// /// Usually something like `DP-1`, `HDMI-1`, `eDP-1`. Q_PROPERTY(QString name READ name CONSTANT); + Q_PROPERTY(qint32 x READ x NOTIFY geometryChanged); + Q_PROPERTY(qint32 y READ y NOTIFY geometryChanged); Q_PROPERTY(qint32 width READ width NOTIFY geometryChanged); Q_PROPERTY(qint32 height READ height NOTIFY geometryChanged); /// The number of physical pixels per millimeter. @@ -50,6 +52,8 @@ public: bool operator==(QuickshellScreenInfo& other) const; [[nodiscard]] QString name() const; + [[nodiscard]] qint32 x() const; + [[nodiscard]] qint32 y() const; [[nodiscard]] qint32 width() const; [[nodiscard]] qint32 height() const; [[nodiscard]] qreal physicalPixelDensity() const;