diff --git a/src/wayland/toplevel_management/qml.cpp b/src/wayland/toplevel_management/qml.cpp index 9f9850c..0d14d4d 100644 --- a/src/wayland/toplevel_management/qml.cpp +++ b/src/wayland/toplevel_management/qml.cpp @@ -1,9 +1,11 @@ #include "qml.hpp" +#include #include #include #include "../../core/model.hpp" +#include "../../core/qmlglobal.hpp" #include "../../core/qmlscreen.hpp" #include "../../core/util.hpp" #include "../../window/proxywindow.hpp" @@ -20,6 +22,8 @@ Toplevel::Toplevel(impl::ToplevelHandle* handle, QObject* parent): QObject(paren QObject::connect(handle, &impl::ToplevelHandle::titleChanged, this, &Toplevel::titleChanged); QObject::connect(handle, &impl::ToplevelHandle::parentChanged, this, &Toplevel::parentChanged); QObject::connect(handle, &impl::ToplevelHandle::activatedChanged, this, &Toplevel::activatedChanged); + QObject::connect(handle, &impl::ToplevelHandle::visibleScreenAdded, this, &Toplevel::screensChanged); + QObject::connect(handle, &impl::ToplevelHandle::visibleScreenRemoved, this, &Toplevel::screensChanged); QObject::connect(handle, &impl::ToplevelHandle::maximizedChanged, this, &Toplevel::maximizedChanged); QObject::connect(handle, &impl::ToplevelHandle::minimizedChanged, this, &Toplevel::minimizedChanged); QObject::connect(handle, &impl::ToplevelHandle::fullscreenChanged, this, &Toplevel::fullscreenChanged); @@ -43,6 +47,16 @@ Toplevel* Toplevel::parent() const { bool Toplevel::activated() const { return this->handle->activated(); } +QList Toplevel::screens() const { + QList screens; + + for (auto* screen: this->handle->visibleScreens()) { + screens.push_back(QuickshellTracked::instance()->screenInfo(screen)); + } + + return screens; +} + bool Toplevel::maximized() const { return this->handle->maximized(); } void Toplevel::setMaximized(bool maximized) { this->handle->setMaximized(maximized); } diff --git a/src/wayland/toplevel_management/qml.hpp b/src/wayland/toplevel_management/qml.hpp index 2a05067..5ca189b 100644 --- a/src/wayland/toplevel_management/qml.hpp +++ b/src/wayland/toplevel_management/qml.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include @@ -30,6 +31,11 @@ class Toplevel: public QObject { /// /// Activation can be requested with the @@activate() function. Q_PROPERTY(bool activated READ activated NOTIFY activatedChanged); + /// Screens the toplevel is currently visible on. + /// Screens are listed in the order they have been added by the compositor. + /// + /// > [!NOTE] Some compositors only list a single screen, even if a window is visible on multiple. + Q_PROPERTY(QList screens READ screens NOTIFY screensChanged); /// If the window is currently maximized. /// /// Maximization can be requested by setting this property, though it may @@ -74,6 +80,7 @@ public: [[nodiscard]] QString title() const; [[nodiscard]] Toplevel* parent() const; [[nodiscard]] bool activated() const; + [[nodiscard]] QList screens() const; [[nodiscard]] bool maximized() const; void setMaximized(bool maximized); @@ -92,6 +99,7 @@ signals: void titleChanged(); void parentChanged(); void activatedChanged(); + void screensChanged(); void maximizedChanged(); void minimizedChanged(); void fullscreenChanged();