core/screen: expose x and y positions

This commit is contained in:
outfoxxed 2024-03-29 05:41:39 -07:00
parent 439788fce0
commit 83afce7f68
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E
2 changed files with 22 additions and 0 deletions

View file

@ -42,6 +42,24 @@ QString QuickshellScreenInfo::name() const {
return this->screen->name(); 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 { qint32 QuickshellScreenInfo::width() const {
if (this->screen == nullptr) { if (this->screen == nullptr) {
this->warnDangling(); this->warnDangling();

View file

@ -32,6 +32,8 @@ class QuickshellScreenInfo: public QObject {
/// ///
/// Usually something like `DP-1`, `HDMI-1`, `eDP-1`. /// Usually something like `DP-1`, `HDMI-1`, `eDP-1`.
Q_PROPERTY(QString name READ name CONSTANT); 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 width READ width NOTIFY geometryChanged);
Q_PROPERTY(qint32 height READ height NOTIFY geometryChanged); Q_PROPERTY(qint32 height READ height NOTIFY geometryChanged);
/// The number of physical pixels per millimeter. /// The number of physical pixels per millimeter.
@ -50,6 +52,8 @@ public:
bool operator==(QuickshellScreenInfo& other) const; bool operator==(QuickshellScreenInfo& other) const;
[[nodiscard]] QString name() const; [[nodiscard]] QString name() const;
[[nodiscard]] qint32 x() const;
[[nodiscard]] qint32 y() const;
[[nodiscard]] qint32 width() const; [[nodiscard]] qint32 width() const;
[[nodiscard]] qint32 height() const; [[nodiscard]] qint32 height() const;
[[nodiscard]] qreal physicalPixelDensity() const; [[nodiscard]] qreal physicalPixelDensity() const;