Skip to content

Commit 95820e9

Browse files
committed
core/window: startSystemMove and startSystemResize to QsWindow
1 parent e9bad67 commit 95820e9

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

src/window/windowinterface.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
#include "windowinterface.hpp"
22

3+
#include <qcolor.h>
34
#include <qlogging.h>
5+
#include <qnamespace.h>
46
#include <qobject.h>
7+
#include <qpoint.h>
58
#include <qqmllist.h>
69
#include <qquickitem.h>
10+
#include <qrect.h>
711
#include <qtypes.h>
812

913
#include "../core/qmlscreen.hpp"
@@ -94,6 +98,30 @@ QsWindowAttached::mapFromItem(QQuickItem* item, qreal x, qreal y, qreal width, q
9498
}
9599
}
96100

101+
bool QsWindowAttached::startSystemMove() const {
102+
auto* pw = this->proxyWindow();
103+
if (!pw) {
104+
qCritical() << "Cannot call startSystemMove before item is a member of a window.";
105+
return false;
106+
}
107+
108+
auto* qw = pw->backingWindow();
109+
if (!qw) return false;
110+
return qw->startSystemMove();
111+
}
112+
113+
bool QsWindowAttached::startSystemResize(Qt::Edges edges) const {
114+
auto* pw = this->proxyWindow();
115+
if (!pw) {
116+
qCritical() << "Cannot call startSystemResize before item is a member of a window.";
117+
return false;
118+
}
119+
120+
auto* qw = pw->backingWindow();
121+
if (!qw) return false;
122+
return qw->startSystemResize(edges);
123+
}
124+
97125
// clang-format off
98126
QQuickItem* WindowInterface::contentItem() const { return this->proxyWindow()->contentItem(); }
99127

src/window/windowinterface.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,11 @@ class QsWindowAttached: public QObject {
283283
Q_INVOKABLE [[nodiscard]] QRectF
284284
mapFromItem(QQuickItem* item, qreal x, qreal y, qreal width, qreal height) const;
285285

286+
/// Start a system move operation. Must be called during a pointer press/drag.
287+
Q_INVOKABLE [[nodiscard]] bool startSystemMove() const;
288+
/// Start a system resize operation. Must be called during a pointer press/drag.
289+
Q_INVOKABLE [[nodiscard]] bool startSystemResize(Qt::Edges edges) const;
290+
286291
signals:
287292
void windowChanged();
288293

0 commit comments

Comments
 (0)