core/window: add min/max/fullscreen properties, and move/resize fns to FloatingWindow
Some checks failed
Build / Nix (push) Has been cancelled
Build / Nix-1 (push) Has been cancelled
Build / Nix-2 (push) Has been cancelled
Build / Nix-3 (push) Has been cancelled
Build / Nix-4 (push) Has been cancelled
Build / Nix-5 (push) Has been cancelled
Build / Nix-6 (push) Has been cancelled
Build / Nix-7 (push) Has been cancelled
Build / Nix-8 (push) Has been cancelled
Build / Nix-9 (push) Has been cancelled
Build / Nix-10 (push) Has been cancelled
Build / Nix-11 (push) Has been cancelled
Build / Nix-12 (push) Has been cancelled
Build / Nix-13 (push) Has been cancelled
Build / Nix-14 (push) Has been cancelled
Build / Nix-15 (push) Has been cancelled
Build / Nix-16 (push) Has been cancelled
Build / Nix-17 (push) Has been cancelled
Build / Nix-18 (push) Has been cancelled
Build / Nix-19 (push) Has been cancelled
Build / Nix-20 (push) Has been cancelled
Build / Nix-21 (push) Has been cancelled
Build / Nix-22 (push) Has been cancelled
Build / Nix-23 (push) Has been cancelled
Build / Nix-24 (push) Has been cancelled
Build / Nix-25 (push) Has been cancelled
Build / Nix-26 (push) Has been cancelled
Build / Nix-27 (push) Has been cancelled
Build / Nix-28 (push) Has been cancelled
Build / Nix-29 (push) Has been cancelled
Build / Nix-30 (push) Has been cancelled
Build / Nix-31 (push) Has been cancelled
Build / Archlinux (push) Has been cancelled
Lint / Lint (push) Has been cancelled

This commit is contained in:
bbedward 2025-11-26 09:54:32 -05:00 committed by outfoxxed
parent 26531fc46e
commit 3918290c1b
No known key found for this signature in database
GPG key ID: 4C88A185FB89301E
3 changed files with 140 additions and 3 deletions

View file

@ -16,6 +16,8 @@ set shell id.
- Added support for wayland idle timeouts.
- Added support for inhibiting wayland compositor shortcuts for focused windows.
- Added the ability to override Quickshell.cacheDir with a custom path.
- Added minimized, maximized, and fullscreen properties to FloatingWindow.
- Added the ability to handle move and resize events to FloatingWindow.
## Other Changes

View file

@ -1,10 +1,12 @@
#include "floatingwindow.hpp"
#include <qnamespace.h>
#include <qobject.h>
#include <qqmlengine.h>
#include <qqmllist.h>
#include <qtmetamacros.h>
#include <qtypes.h>
#include <qwindow.h>
#include "proxywindow.hpp"
#include "windowinterface.hpp"
@ -55,6 +57,7 @@ FloatingWindowInterface::FloatingWindowInterface(QObject* parent)
QObject::connect(this->window, &ProxyFloatingWindow::titleChanged, this, &FloatingWindowInterface::titleChanged);
QObject::connect(this->window, &ProxyFloatingWindow::minimumSizeChanged, this, &FloatingWindowInterface::minimumSizeChanged);
QObject::connect(this->window, &ProxyFloatingWindow::maximumSizeChanged, this, &FloatingWindowInterface::maximumSizeChanged);
QObject::connect(this->window, &ProxyWindowBase::windowConnected, this, &FloatingWindowInterface::onWindowConnected);
// clang-format on
}
@ -66,3 +69,103 @@ void FloatingWindowInterface::onReload(QObject* oldInstance) {
}
ProxyWindowBase* FloatingWindowInterface::proxyWindow() const { return this->window; }
void FloatingWindowInterface::onWindowConnected() {
auto* qw = this->window->backingWindow();
if (qw) {
QObject::connect(
qw,
&QWindow::windowStateChanged,
this,
&FloatingWindowInterface::onWindowStateChanged
);
this->setMinimized(this->mMinimized);
this->setMaximized(this->mMaximized);
this->setFullscreen(this->mFullscreen);
this->onWindowStateChanged();
}
}
void FloatingWindowInterface::onWindowStateChanged() {
auto* qw = this->window->backingWindow();
auto states = qw ? qw->windowStates() : Qt::WindowStates();
auto minimized = states.testFlag(Qt::WindowMinimized);
auto maximized = states.testFlag(Qt::WindowMaximized);
auto fullscreen = states.testFlag(Qt::WindowFullScreen);
if (minimized != this->mWasMinimized) {
this->mWasMinimized = minimized;
emit this->minimizedChanged();
}
if (maximized != this->mWasMaximized) {
this->mWasMaximized = maximized;
emit this->maximizedChanged();
}
if (fullscreen != this->mWasFullscreen) {
this->mWasFullscreen = fullscreen;
emit this->fullscreenChanged();
}
}
bool FloatingWindowInterface::isMinimized() const {
auto* qw = this->window->backingWindow();
if (!qw) return this->mWasMinimized;
return qw->windowStates().testFlag(Qt::WindowMinimized);
}
void FloatingWindowInterface::setMinimized(bool minimized) {
this->mMinimized = minimized;
if (auto* qw = this->window->backingWindow()) {
auto states = qw->windowStates();
states.setFlag(Qt::WindowMinimized, minimized);
qw->setWindowStates(states);
}
}
bool FloatingWindowInterface::isMaximized() const {
auto* qw = this->window->backingWindow();
if (!qw) return this->mWasMaximized;
return qw->windowStates().testFlag(Qt::WindowMaximized);
}
void FloatingWindowInterface::setMaximized(bool maximized) {
this->mMaximized = maximized;
if (auto* qw = this->window->backingWindow()) {
auto states = qw->windowStates();
states.setFlag(Qt::WindowMaximized, maximized);
qw->setWindowStates(states);
}
}
bool FloatingWindowInterface::isFullscreen() const {
auto* qw = this->window->backingWindow();
if (!qw) return this->mWasFullscreen;
return qw->windowStates().testFlag(Qt::WindowFullScreen);
}
void FloatingWindowInterface::setFullscreen(bool fullscreen) {
this->mFullscreen = fullscreen;
if (auto* qw = this->window->backingWindow()) {
auto states = qw->windowStates();
states.setFlag(Qt::WindowFullScreen, fullscreen);
qw->setWindowStates(states);
}
}
bool FloatingWindowInterface::startSystemMove() const {
auto* qw = this->window->backingWindow();
if (!qw) return false;
return qw->startSystemMove();
}
bool FloatingWindowInterface::startSystemResize(Qt::Edges edges) const {
auto* qw = this->window->backingWindow();
if (!qw) return false;
return qw->startSystemResize(edges);
}

View file

@ -1,5 +1,6 @@
#pragma once
#include <qnamespace.h>
#include <qobject.h>
#include <qproperty.h>
#include <qsize.h>
@ -68,6 +69,12 @@ class FloatingWindowInterface: public WindowInterface {
Q_PROPERTY(QSize minimumSize READ default WRITE default NOTIFY minimumSizeChanged BINDABLE bindableMinimumSize);
/// Maximum window size given to the window system.
Q_PROPERTY(QSize maximumSize READ default WRITE default NOTIFY maximumSizeChanged BINDABLE bindableMaximumSize);
/// Whether the window is currently minimized.
Q_PROPERTY(bool minimized READ isMinimized WRITE setMinimized NOTIFY minimizedChanged);
/// Whether the window is currently maximized.
Q_PROPERTY(bool maximized READ isMaximized WRITE setMaximized NOTIFY maximizedChanged);
/// Whether the window is currently fullscreen.
Q_PROPERTY(bool fullscreen READ isFullscreen WRITE setFullscreen NOTIFY fullscreenChanged);
// clang-format on
QML_NAMED_ELEMENT(FloatingWindow);
@ -78,15 +85,40 @@ public:
[[nodiscard]] ProxyWindowBase* proxyWindow() const override;
QBindable<QSize> bindableMinimumSize() { return &this->window->bMinimumSize; }
QBindable<QSize> bindableMaximumSize() { return &this->window->bMaximumSize; }
QBindable<QString> bindableTitle() { return &this->window->bTitle; }
[[nodiscard]] QBindable<QSize> bindableMinimumSize() { return &this->window->bMinimumSize; }
[[nodiscard]] QBindable<QSize> bindableMaximumSize() { return &this->window->bMaximumSize; }
[[nodiscard]] QBindable<QString> bindableTitle() { return &this->window->bTitle; }
[[nodiscard]] bool isMinimized() const;
void setMinimized(bool minimized);
[[nodiscard]] bool isMaximized() const;
void setMaximized(bool maximized);
[[nodiscard]] bool isFullscreen() const;
void setFullscreen(bool fullscreen);
/// Start a system move operation. Must be called during a pointer press/drag.
Q_INVOKABLE [[nodiscard]] bool startSystemMove() const;
/// Start a system resize operation. Must be called during a pointer press/drag.
Q_INVOKABLE [[nodiscard]] bool startSystemResize(Qt::Edges edges) const;
signals:
void minimumSizeChanged();
void maximumSizeChanged();
void titleChanged();
void minimizedChanged();
void maximizedChanged();
void fullscreenChanged();
private slots:
void onWindowConnected();
void onWindowStateChanged();
private:
ProxyFloatingWindow* window;
bool mMinimized = false;
bool mMaximized = false;
bool mFullscreen = false;
bool mWasMinimized = false;
bool mWasMaximized = false;
bool mWasFullscreen = false;
};