Skip to content

Commit 5706c09

Browse files
committed
core/window: clean up window interface property proxies
1 parent 5ac9096 commit 5706c09

File tree

8 files changed

+87
-233
lines changed

8 files changed

+87
-233
lines changed

src/wayland/wlr_layershell/wlr_layershell.cpp

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include <qobject.h>
66
#include <qqmllist.h>
77
#include <qquickitem.h>
8-
#include <qquickwindow.h>
98
#include <qtypes.h>
109

1110
#include "../../core/qmlscreen.hpp"
@@ -173,23 +172,9 @@ WlrLayershell* WlrLayershell::qmlAttachedProperties(QObject* object) {
173172
WaylandPanelInterface::WaylandPanelInterface(QObject* parent)
174173
: PanelWindowInterface(parent)
175174
, layer(new WlrLayershell(this)) {
175+
this->connectSignals();
176176

177177
// clang-format off
178-
QObject::connect(this->layer, &ProxyWindowBase::windowConnected, this, &WaylandPanelInterface::windowConnected);
179-
QObject::connect(this->layer, &ProxyWindowBase::visibleChanged, this, &WaylandPanelInterface::visibleChanged);
180-
QObject::connect(this->layer, &ProxyWindowBase::backerVisibilityChanged, this, &WaylandPanelInterface::backingWindowVisibleChanged);
181-
QObject::connect(this->layer, &ProxyWindowBase::implicitHeightChanged, this, &WaylandPanelInterface::implicitHeightChanged);
182-
QObject::connect(this->layer, &ProxyWindowBase::implicitWidthChanged, this, &WaylandPanelInterface::implicitWidthChanged);
183-
QObject::connect(this->layer, &ProxyWindowBase::heightChanged, this, &WaylandPanelInterface::heightChanged);
184-
QObject::connect(this->layer, &ProxyWindowBase::widthChanged, this, &WaylandPanelInterface::widthChanged);
185-
QObject::connect(this->layer, &ProxyWindowBase::devicePixelRatioChanged, this, &WaylandPanelInterface::devicePixelRatioChanged);
186-
QObject::connect(this->layer, &ProxyWindowBase::screenChanged, this, &WaylandPanelInterface::screenChanged);
187-
QObject::connect(this->layer, &ProxyWindowBase::windowTransformChanged, this, &WaylandPanelInterface::windowTransformChanged);
188-
QObject::connect(this->layer, &ProxyWindowBase::colorChanged, this, &WaylandPanelInterface::colorChanged);
189-
QObject::connect(this->layer, &ProxyWindowBase::maskChanged, this, &WaylandPanelInterface::maskChanged);
190-
QObject::connect(this->layer, &ProxyWindowBase::surfaceFormatChanged, this, &WaylandPanelInterface::surfaceFormatChanged);
191-
192-
// panel specific
193178
QObject::connect(this->layer, &WlrLayershell::anchorsChanged, this, &WaylandPanelInterface::anchorsChanged);
194179
QObject::connect(this->layer, &WlrLayershell::marginsChanged, this, &WaylandPanelInterface::marginsChanged);
195180
QObject::connect(this->layer, &WlrLayershell::exclusiveZoneChanged, this, &WaylandPanelInterface::exclusiveZoneChanged);
@@ -206,32 +191,13 @@ void WaylandPanelInterface::onReload(QObject* oldInstance) {
206191
this->layer->reload(old != nullptr ? old->layer : nullptr);
207192
}
208193

209-
QQmlListProperty<QObject> WaylandPanelInterface::data() { return this->layer->data(); }
210194
ProxyWindowBase* WaylandPanelInterface::proxyWindow() const { return this->layer; }
211-
QQuickItem* WaylandPanelInterface::contentItem() const { return this->layer->contentItem(); }
212-
213-
bool WaylandPanelInterface::isBackingWindowVisible() const {
214-
return this->layer->isVisibleDirect();
215-
}
216-
217-
qreal WaylandPanelInterface::devicePixelRatio() const { return this->layer->devicePixelRatio(); }
218195

219196
// NOLINTBEGIN
220197
#define proxyPair(type, get, set) \
221198
type WaylandPanelInterface::get() const { return this->layer->get(); } \
222199
void WaylandPanelInterface::set(type value) { this->layer->set(value); }
223200

224-
proxyPair(bool, isVisible, setVisible);
225-
proxyPair(qint32, implicitWidth, setImplicitWidth);
226-
proxyPair(qint32, implicitHeight, setImplicitHeight);
227-
proxyPair(qint32, width, setWidth);
228-
proxyPair(qint32, height, setHeight);
229-
proxyPair(QuickshellScreenInfo*, screen, setScreen);
230-
proxyPair(QColor, color, setColor);
231-
proxyPair(PendingRegion*, mask, setMask);
232-
proxyPair(QsSurfaceFormat, surfaceFormat, setSurfaceFormat);
233-
234-
// panel specific
235201
proxyPair(Anchors, anchors, setAnchors);
236202
proxyPair(Margins, margins, setMargins);
237203
proxyPair(qint32, exclusiveZone, setExclusiveZone);

src/wayland/wlr_layershell/wlr_layershell.hpp

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -216,43 +216,8 @@ class WaylandPanelInterface: public PanelWindowInterface {
216216
void onReload(QObject* oldInstance) override;
217217

218218
[[nodiscard]] ProxyWindowBase* proxyWindow() const override;
219-
[[nodiscard]] QQuickItem* contentItem() const override;
220219

221220
// NOLINTBEGIN
222-
[[nodiscard]] bool isVisible() const override;
223-
[[nodiscard]] bool isBackingWindowVisible() const override;
224-
void setVisible(bool visible) override;
225-
226-
[[nodiscard]] qint32 implicitWidth() const override;
227-
void setImplicitWidth(qint32 implicitWidth) override;
228-
229-
[[nodiscard]] qint32 implicitHeight() const override;
230-
void setImplicitHeight(qint32 implicitHeight) override;
231-
232-
[[nodiscard]] qint32 width() const override;
233-
void setWidth(qint32 width) override;
234-
235-
[[nodiscard]] qint32 height() const override;
236-
void setHeight(qint32 height) override;
237-
238-
[[nodiscard]] virtual qreal devicePixelRatio() const override;
239-
240-
[[nodiscard]] QuickshellScreenInfo* screen() const override;
241-
void setScreen(QuickshellScreenInfo* screen) override;
242-
243-
[[nodiscard]] QColor color() const override;
244-
void setColor(QColor color) override;
245-
246-
[[nodiscard]] PendingRegion* mask() const override;
247-
void setMask(PendingRegion* mask) override;
248-
249-
[[nodiscard]] QsSurfaceFormat surfaceFormat() const override;
250-
void setSurfaceFormat(QsSurfaceFormat mask) override;
251-
252-
[[nodiscard]] QQmlListProperty<QObject> data() override;
253-
254-
// panel specific
255-
256221
[[nodiscard]] Anchors anchors() const override;
257222
void setAnchors(Anchors anchors) override;
258223

src/window/floatingwindow.cpp

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include <qobject.h>
44
#include <qqmlengine.h>
55
#include <qqmllist.h>
6-
#include <qquickitem.h>
76
#include <qtmetamacros.h>
87
#include <qtypes.h>
98

@@ -50,21 +49,9 @@ void ProxyFloatingWindow::onMaximumSizeChanged() {
5049
FloatingWindowInterface::FloatingWindowInterface(QObject* parent)
5150
: WindowInterface(parent)
5251
, window(new ProxyFloatingWindow(this)) {
53-
// clang-format off
54-
QObject::connect(this->window, &ProxyWindowBase::windowConnected, this, &FloatingWindowInterface::windowConnected);
55-
QObject::connect(this->window, &ProxyWindowBase::visibleChanged, this, &FloatingWindowInterface::visibleChanged);
56-
QObject::connect(this->window, &ProxyWindowBase::backerVisibilityChanged, this, &FloatingWindowInterface::backingWindowVisibleChanged);
57-
QObject::connect(this->window, &ProxyWindowBase::heightChanged, this, &FloatingWindowInterface::heightChanged);
58-
QObject::connect(this->window, &ProxyWindowBase::widthChanged, this, &FloatingWindowInterface::widthChanged);
59-
QObject::connect(this->window, &ProxyWindowBase::implicitHeightChanged, this, &FloatingWindowInterface::implicitHeightChanged);
60-
QObject::connect(this->window, &ProxyWindowBase::implicitWidthChanged, this, &FloatingWindowInterface::implicitWidthChanged);
61-
QObject::connect(this->window, &ProxyWindowBase::devicePixelRatioChanged, this, &FloatingWindowInterface::devicePixelRatioChanged);
62-
QObject::connect(this->window, &ProxyWindowBase::screenChanged, this, &FloatingWindowInterface::screenChanged);
63-
QObject::connect(this->window, &ProxyWindowBase::windowTransformChanged, this, &FloatingWindowInterface::windowTransformChanged);
64-
QObject::connect(this->window, &ProxyWindowBase::colorChanged, this, &FloatingWindowInterface::colorChanged);
65-
QObject::connect(this->window, &ProxyWindowBase::maskChanged, this, &FloatingWindowInterface::maskChanged);
66-
QObject::connect(this->window, &ProxyWindowBase::surfaceFormatChanged, this, &FloatingWindowInterface::surfaceFormatChanged);
52+
this->connectSignals();
6753

54+
// clang-format off
6855
QObject::connect(this->window, &ProxyFloatingWindow::titleChanged, this, &FloatingWindowInterface::titleChanged);
6956
QObject::connect(this->window, &ProxyFloatingWindow::minimumSizeChanged, this, &FloatingWindowInterface::minimumSizeChanged);
7057
QObject::connect(this->window, &ProxyFloatingWindow::maximumSizeChanged, this, &FloatingWindowInterface::maximumSizeChanged);
@@ -78,30 +65,4 @@ void FloatingWindowInterface::onReload(QObject* oldInstance) {
7865
this->window->reload(old != nullptr ? old->window : nullptr);
7966
}
8067

81-
QQmlListProperty<QObject> FloatingWindowInterface::data() { return this->window->data(); }
8268
ProxyWindowBase* FloatingWindowInterface::proxyWindow() const { return this->window; }
83-
QQuickItem* FloatingWindowInterface::contentItem() const { return this->window->contentItem(); }
84-
85-
bool FloatingWindowInterface::isBackingWindowVisible() const {
86-
return this->window->isVisibleDirect();
87-
}
88-
89-
qreal FloatingWindowInterface::devicePixelRatio() const { return this->window->devicePixelRatio(); }
90-
91-
// NOLINTBEGIN
92-
#define proxyPair(type, get, set) \
93-
type FloatingWindowInterface::get() const { return this->window->get(); } \
94-
void FloatingWindowInterface::set(type value) { this->window->set(value); }
95-
96-
proxyPair(bool, isVisible, setVisible);
97-
proxyPair(qint32, implicitWidth, setImplicitWidth);
98-
proxyPair(qint32, implicitHeight, setImplicitHeight);
99-
proxyPair(qint32, width, setWidth);
100-
proxyPair(qint32, height, setHeight);
101-
proxyPair(QuickshellScreenInfo*, screen, setScreen);
102-
proxyPair(QColor, color, setColor);
103-
proxyPair(PendingRegion*, mask, setMask);
104-
proxyPair(QsSurfaceFormat, surfaceFormat, setSurfaceFormat);
105-
106-
#undef proxyPair
107-
// NOLINTEND

src/window/floatingwindow.hpp

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -77,41 +77,6 @@ class FloatingWindowInterface: public WindowInterface {
7777
void onReload(QObject* oldInstance) override;
7878

7979
[[nodiscard]] ProxyWindowBase* proxyWindow() const override;
80-
[[nodiscard]] QQuickItem* contentItem() const override;
81-
82-
// NOLINTBEGIN
83-
[[nodiscard]] bool isVisible() const override;
84-
[[nodiscard]] bool isBackingWindowVisible() const override;
85-
void setVisible(bool visible) override;
86-
87-
[[nodiscard]] qint32 implicitWidth() const override;
88-
void setImplicitWidth(qint32 implicitWidth) override;
89-
90-
[[nodiscard]] qint32 implicitHeight() const override;
91-
void setImplicitHeight(qint32 implicitHeight) override;
92-
93-
[[nodiscard]] qint32 width() const override;
94-
void setWidth(qint32 width) override;
95-
96-
[[nodiscard]] qint32 height() const override;
97-
void setHeight(qint32 height) override;
98-
99-
[[nodiscard]] virtual qreal devicePixelRatio() const override;
100-
101-
[[nodiscard]] QuickshellScreenInfo* screen() const override;
102-
void setScreen(QuickshellScreenInfo* screen) override;
103-
104-
[[nodiscard]] QColor color() const override;
105-
void setColor(QColor color) override;
106-
107-
[[nodiscard]] PendingRegion* mask() const override;
108-
void setMask(PendingRegion* mask) override;
109-
110-
[[nodiscard]] QsSurfaceFormat surfaceFormat() const override;
111-
void setSurfaceFormat(QsSurfaceFormat mask) override;
112-
113-
[[nodiscard]] QQmlListProperty<QObject> data() override;
114-
// NOLINTEND
11580

11681
QBindable<QSize> bindableMinimumSize() { return &this->window->bMinimumSize; }
11782
QBindable<QSize> bindableMaximumSize() { return &this->window->bMaximumSize; }

src/window/windowinterface.cpp

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
#include <qlogging.h>
44
#include <qobject.h>
5+
#include <qqmllist.h>
56
#include <qquickitem.h>
67
#include <qtypes.h>
78

9+
#include "../core/qmlscreen.hpp"
10+
#include "../core/region.hpp"
811
#include "proxywindow.hpp"
912

1013
QPointF WindowInterface::itemPosition(QQuickItem* item) const {
@@ -91,6 +94,61 @@ QsWindowAttached::mapFromItem(QQuickItem* item, qreal x, qreal y, qreal width, q
9194
}
9295
}
9396

97+
// clang-format off
98+
QQuickItem* WindowInterface::contentItem() const { return this->proxyWindow()->contentItem(); }
99+
100+
bool WindowInterface::isVisible() const { return this->proxyWindow()->isVisible(); };
101+
bool WindowInterface::isBackingWindowVisible() const { return this->proxyWindow()->isVisibleDirect(); };
102+
void WindowInterface::setVisible(bool visible) const { this->proxyWindow()->setVisible(visible); };
103+
104+
qint32 WindowInterface::implicitWidth() const { return this->proxyWindow()->implicitWidth(); };
105+
void WindowInterface::setImplicitWidth(qint32 implicitWidth) const { this->proxyWindow()->setImplicitWidth(implicitWidth); };
106+
107+
qint32 WindowInterface::implicitHeight() const { return this->proxyWindow()->implicitHeight(); };
108+
void WindowInterface::setImplicitHeight(qint32 implicitHeight) const { this->proxyWindow()->setImplicitHeight(implicitHeight); };
109+
110+
qint32 WindowInterface::width() const { return this->proxyWindow()->width(); };
111+
void WindowInterface::setWidth(qint32 width) const { this->proxyWindow()->setWidth(width); };
112+
113+
qint32 WindowInterface::height() const { return this->proxyWindow()->height(); };
114+
void WindowInterface::setHeight(qint32 height) const { this->proxyWindow()->setHeight(height); };
115+
116+
qreal WindowInterface::devicePixelRatio() const { return this->proxyWindow()->devicePixelRatio(); };
117+
118+
QuickshellScreenInfo* WindowInterface::screen() const { return this->proxyWindow()->screen(); };
119+
void WindowInterface::setScreen(QuickshellScreenInfo* screen) const { this->proxyWindow()->setScreen(screen); };
120+
121+
QColor WindowInterface::color() const { return this->proxyWindow()->color(); };
122+
void WindowInterface::setColor(QColor color) const { this->proxyWindow()->setColor(color); };
123+
124+
PendingRegion* WindowInterface::mask() const { return this->proxyWindow()->mask(); };
125+
void WindowInterface::setMask(PendingRegion* mask) const { this->proxyWindow()->setMask(mask); };
126+
127+
QsSurfaceFormat WindowInterface::surfaceFormat() const { return this->proxyWindow()->surfaceFormat(); };
128+
void WindowInterface::setSurfaceFormat(QsSurfaceFormat format) const { this->proxyWindow()->setSurfaceFormat(format); };
129+
130+
QQmlListProperty<QObject> WindowInterface::data() const { return this->proxyWindow()->data(); };
131+
// clang-format on
132+
133+
void WindowInterface::connectSignals() const {
134+
auto* window = this->proxyWindow();
135+
// clang-format off
136+
QObject::connect(window, &ProxyWindowBase::windowConnected, this, &WindowInterface::windowConnected);
137+
QObject::connect(window, &ProxyWindowBase::visibleChanged, this, &WindowInterface::visibleChanged);
138+
QObject::connect(window, &ProxyWindowBase::backerVisibilityChanged, this, &WindowInterface::backingWindowVisibleChanged);
139+
QObject::connect(window, &ProxyWindowBase::implicitHeightChanged, this, &WindowInterface::implicitHeightChanged);
140+
QObject::connect(window, &ProxyWindowBase::implicitWidthChanged, this, &WindowInterface::implicitWidthChanged);
141+
QObject::connect(window, &ProxyWindowBase::heightChanged, this, &WindowInterface::heightChanged);
142+
QObject::connect(window, &ProxyWindowBase::widthChanged, this, &WindowInterface::widthChanged);
143+
QObject::connect(window, &ProxyWindowBase::devicePixelRatioChanged, this, &WindowInterface::devicePixelRatioChanged);
144+
QObject::connect(window, &ProxyWindowBase::screenChanged, this, &WindowInterface::screenChanged);
145+
QObject::connect(window, &ProxyWindowBase::windowTransformChanged, this, &WindowInterface::windowTransformChanged);
146+
QObject::connect(window, &ProxyWindowBase::colorChanged, this, &WindowInterface::colorChanged);
147+
QObject::connect(window, &ProxyWindowBase::maskChanged, this, &WindowInterface::maskChanged);
148+
QObject::connect(window, &ProxyWindowBase::surfaceFormatChanged, this, &WindowInterface::surfaceFormatChanged);
149+
// clang-format on
150+
}
151+
94152
QsWindowAttached* WindowInterface::qmlAttachedProperties(QObject* object) {
95153
while (object && !qobject_cast<QQuickItem*>(object)) {
96154
object = object->parent();

src/window/windowinterface.hpp

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -197,41 +197,41 @@ class WindowInterface: public Reloadable {
197197
// clang-format on
198198

199199
[[nodiscard]] virtual ProxyWindowBase* proxyWindow() const = 0;
200-
[[nodiscard]] virtual QQuickItem* contentItem() const = 0;
200+
[[nodiscard]] QQuickItem* contentItem() const;
201201

202-
[[nodiscard]] virtual bool isVisible() const = 0;
203-
[[nodiscard]] virtual bool isBackingWindowVisible() const = 0;
204-
virtual void setVisible(bool visible) = 0;
202+
[[nodiscard]] bool isVisible() const;
203+
[[nodiscard]] bool isBackingWindowVisible() const;
204+
void setVisible(bool visible) const;
205205

206-
[[nodiscard]] virtual qint32 implicitWidth() const = 0;
207-
virtual void setImplicitWidth(qint32 implicitWidth) = 0;
206+
[[nodiscard]] qint32 implicitWidth() const;
207+
void setImplicitWidth(qint32 implicitWidth) const;
208208

209-
[[nodiscard]] virtual qint32 implicitHeight() const = 0;
210-
virtual void setImplicitHeight(qint32 implicitHeight) = 0;
209+
[[nodiscard]] qint32 implicitHeight() const;
210+
void setImplicitHeight(qint32 implicitHeight) const;
211211

212-
[[nodiscard]] virtual qint32 width() const = 0;
213-
virtual void setWidth(qint32 width) = 0;
212+
[[nodiscard]] qint32 width() const;
213+
void setWidth(qint32 width) const;
214214

215-
[[nodiscard]] virtual qint32 height() const = 0;
216-
virtual void setHeight(qint32 height) = 0;
215+
[[nodiscard]] qint32 height() const;
216+
void setHeight(qint32 height) const;
217217

218-
[[nodiscard]] virtual qreal devicePixelRatio() const = 0;
218+
[[nodiscard]] qreal devicePixelRatio() const;
219219

220-
[[nodiscard]] virtual QuickshellScreenInfo* screen() const = 0;
221-
virtual void setScreen(QuickshellScreenInfo* screen) = 0;
220+
[[nodiscard]] QuickshellScreenInfo* screen() const;
221+
void setScreen(QuickshellScreenInfo* screen) const;
222222

223223
[[nodiscard]] QObject* windowTransform() const { return nullptr; } // NOLINT
224224

225-
[[nodiscard]] virtual QColor color() const = 0;
226-
virtual void setColor(QColor color) = 0;
225+
[[nodiscard]] QColor color() const;
226+
void setColor(QColor color) const;
227227

228-
[[nodiscard]] virtual PendingRegion* mask() const = 0;
229-
virtual void setMask(PendingRegion* mask) = 0;
228+
[[nodiscard]] PendingRegion* mask() const;
229+
void setMask(PendingRegion* mask) const;
230230

231-
[[nodiscard]] virtual QsSurfaceFormat surfaceFormat() const = 0;
232-
virtual void setSurfaceFormat(QsSurfaceFormat format) = 0;
231+
[[nodiscard]] QsSurfaceFormat surfaceFormat() const;
232+
void setSurfaceFormat(QsSurfaceFormat format) const;
233233

234-
[[nodiscard]] virtual QQmlListProperty<QObject> data() = 0;
234+
[[nodiscard]] QQmlListProperty<QObject> data() const;
235235

236236
static QsWindowAttached* qmlAttachedProperties(QObject* object);
237237

@@ -249,6 +249,9 @@ class WindowInterface: public Reloadable {
249249
void colorChanged();
250250
void maskChanged();
251251
void surfaceFormatChanged();
252+
253+
protected:
254+
void connectSignals() const;
252255
};
253256

254257
class QsWindowAttached: public QObject {

0 commit comments

Comments
 (0)