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

@ -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);
}