core/window: add implicit size properties to window types

This commit is contained in:
outfoxxed 2025-05-12 19:42:46 -07:00
parent ead9141aca
commit 6a8284dae3
Signed by untrusted user: outfoxxed
GPG key ID: 4C88A185FB89301E
10 changed files with 140 additions and 57 deletions

View file

@ -71,21 +71,17 @@ bool WlrLayershell::deleteOnInvisible() const {
return true;
}
void WlrLayershell::setWidth(qint32 width) {
this->mWidth = width;
void WlrLayershell::trySetWidth(qint32 implicitWidth) {
// only update the actual size if not blocked by anchors
if (!this->ext->anchors().horizontalConstraint()) {
this->ProxyWindowBase::setWidth(width);
this->ProxyWindowBase::trySetWidth(implicitWidth);
}
}
void WlrLayershell::setHeight(qint32 height) {
this->mHeight = height;
void WlrLayershell::trySetHeight(qint32 implicitHeight) {
// only update the actual size if not blocked by anchors
if (!this->ext->anchors().verticalConstraint()) {
this->ProxyWindowBase::setHeight(height);
this->ProxyWindowBase::trySetHeight(implicitHeight);
}
}
@ -108,10 +104,11 @@ Anchors WlrLayershell::anchors() const { return this->ext->anchors(); }
void WlrLayershell::setAnchors(Anchors anchors) {
this->ext->setAnchors(anchors);
if (!this->window) return;
// explicitly set width values are tracked so the entire screen isn't covered if an anchor is removed.
if (!anchors.horizontalConstraint()) this->ProxyWindowBase::setWidth(this->mWidth);
if (!anchors.verticalConstraint()) this->ProxyWindowBase::setHeight(this->mHeight);
if (!anchors.horizontalConstraint()) this->ProxyWindowBase::trySetWidth(this->implicitWidth());
if (!anchors.verticalConstraint()) this->ProxyWindowBase::trySetHeight(this->implicitHeight());
}
bool WlrLayershell::aboveWindows() const { return this->layer() > WlrLayer::Bottom; }
@ -190,6 +187,8 @@ WaylandPanelInterface::WaylandPanelInterface(QObject* parent)
QObject::connect(this->layer, &ProxyWindowBase::windowConnected, this, &WaylandPanelInterface::windowConnected);
QObject::connect(this->layer, &ProxyWindowBase::visibleChanged, this, &WaylandPanelInterface::visibleChanged);
QObject::connect(this->layer, &ProxyWindowBase::backerVisibilityChanged, this, &WaylandPanelInterface::backingWindowVisibleChanged);
QObject::connect(this->layer, &ProxyWindowBase::implicitHeightChanged, this, &WaylandPanelInterface::implicitHeightChanged);
QObject::connect(this->layer, &ProxyWindowBase::implicitWidthChanged, this, &WaylandPanelInterface::implicitWidthChanged);
QObject::connect(this->layer, &ProxyWindowBase::heightChanged, this, &WaylandPanelInterface::heightChanged);
QObject::connect(this->layer, &ProxyWindowBase::widthChanged, this, &WaylandPanelInterface::widthChanged);
QObject::connect(this->layer, &ProxyWindowBase::devicePixelRatioChanged, this, &WaylandPanelInterface::devicePixelRatioChanged);
@ -232,6 +231,8 @@ qreal WaylandPanelInterface::devicePixelRatio() const { return this->layer->devi
void WaylandPanelInterface::set(type value) { this->layer->set(value); }
proxyPair(bool, isVisible, setVisible);
proxyPair(qint32, implicitWidth, setImplicitWidth);
proxyPair(qint32, implicitHeight, setImplicitHeight);
proxyPair(qint32, width, setWidth);
proxyPair(qint32, height, setHeight);
proxyPair(QuickshellScreenInfo*, screen, setScreen);

View file

@ -69,8 +69,8 @@ public:
void connectWindow() override;
[[nodiscard]] bool deleteOnInvisible() const override;
void setWidth(qint32 width) override;
void setHeight(qint32 height) override;
void trySetWidth(qint32 implicitWidth) override;
void trySetHeight(qint32 implicitHeight) override;
void setScreen(QuickshellScreenInfo* screen) override;
@ -140,6 +140,12 @@ public:
[[nodiscard]] bool isBackingWindowVisible() const override;
void setVisible(bool visible) override;
[[nodiscard]] qint32 implicitWidth() const override;
void setImplicitWidth(qint32 implicitWidth) override;
[[nodiscard]] qint32 implicitHeight() const override;
void setImplicitHeight(qint32 implicitHeight) override;
[[nodiscard]] qint32 width() const override;
void setWidth(qint32 width) override;

View file

@ -1,4 +1,5 @@
#include "surface.hpp"
#include <algorithm>
#include <any>
#include <private/qhighdpiscaling_p.h>
@ -61,8 +62,8 @@ toWaylandKeyboardFocus(const WlrKeyboardFocus::Enum& focus) noexcept {
[[nodiscard]] QSize constrainedSize(const Anchors& anchors, const QSize& size) noexcept {
return QSize(
anchors.horizontalConstraint() ? 0 : size.width(),
anchors.verticalConstraint() ? 0 : size.height()
anchors.horizontalConstraint() ? 0 : std::max(1, size.width()),
anchors.verticalConstraint() ? 0 : std::max(1, size.height())
);
}