Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qwaylandwindow_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QWAYLANDWINDOW_H
5#define QWAYLANDWINDOW_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/QWaitCondition>
19#include <QtCore/QMutex>
20#include <QtCore/QReadWriteLock>
21
22#include <QtGui/QIcon>
23#include <QtGui/QEventPoint>
24#include <QtCore/QVariant>
25#include <QtCore/QLoggingCategory>
26#include <QtCore/QElapsedTimer>
27#include <QtCore/QList>
28#include <QtCore/QMap> // for QVariantMap
29
30#include <qpa/qplatformwindow.h>
31#include <qpa/qplatformwindow_p.h>
32
33#include <QtWaylandClient/private/qwayland-wayland.h>
34#include <QtWaylandClient/private/qwaylanddisplay_p.h>
35#include <QtWaylandClient/qtwaylandclientglobal.h>
36#include <QtWaylandClient/private/qwaylandshellsurface_p.h>
37
38#include <QtCore/qpointer.h>
39
40struct wl_egl_window;
41
42QT_BEGIN_NAMESPACE
43
44namespace QtWaylandClient {
45
46Q_DECLARE_LOGGING_CATEGORY(lcWaylandBackingstore)
47
48class QWaylandDisplay;
49class QWaylandBuffer;
50class QWaylandShellSurface;
51class QWaylandSubSurface;
52class QWaylandAbstractDecoration;
53class QWaylandInputDevice;
54class QWaylandScreen;
55class QWaylandShellIntegration;
56class QWaylandShmBackingStore;
60class QWaylandSurface;
65
66class Q_WAYLANDCLIENT_EXPORT QWaylandWindow : public QNativeInterface::Private::QWaylandWindow,
67 public QPlatformWindow
68{
70public:
76
85
88
89 // Keep Toplevels position on the top left corner of their screen
90 static inline bool fixedToplevelPositions = true;
91
92 virtual WindowType windowType() const = 0;
93 virtual void ensureSize();
94 WId winId() const override;
95 void setVisible(bool visible) override;
97
100
101 inline QIcon windowIcon() const;
102 void setWindowIcon(const QIcon &icon) override;
103
104 void setGeometry(const QRect &rect) override;
105
107
108 void resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset = {0, 0});
111
112 void applyConfigureWhenPossible(); //rename to possible?
113
114 void attach(QWaylandBuffer *buffer, int x, int y);
116 QPoint attachOffset() const;
117
118 void damage(const QRect &rect);
119
122
123 void commit();
124
125 bool waitForFrameSync(int timeout);
126
130 QSize surfaceSize() const;
134
136 ::wl_surface *wlSurface() const;
138 {
139 return wlSurface();
140 }
142
143 QWaylandDisplay *display() const { return mDisplay; }
145 std::any _surfaceRole() const override;
148
152
155
159 Qt::WindowFlags windowFlags() const;
161
162 void raise() override;
163 void lower() override;
164
165 void setMask(const QRegion &region) override;
166
167 void setAlertState(bool enabled) override;
168 bool isAlertState() const override;
169
170 qreal scale() const;
172
174 bool isExposed() const override;
175 bool isActive() const override;
176
178
180#ifndef QT_NO_GESTURES
185#endif
186
192
193 virtual bool createDecoration();
194
195#if QT_CONFIG(cursor)
197 void setStoredCursor(const QCursor &cursor);
198 void resetStoredCursor();
200#endif
201
203
205 static QWaylandWindow *mouseGrab() { return mMouseGrab; }
206
207 void sendProperty(const QString &name, const QVariant &value);
208 void setProperty(const QString &name, const QVariant &value);
209
210 QVariantMap properties() const;
213
214#ifdef QT_PLATFORM_WINDOW_HAS_VIRTUAL_SET_BACKING_STORE
216#else
218#endif
220
223
224 bool setKeyboardGrabEnabled(bool) override { return false; }
226 void addAttachOffset(const QPoint point);
227
230
232 void requestUpdate() override;
233 void handleUpdate();
235
238
239 void beginFrame();
240 void endFrame();
241
242 void closeChildPopups();
243
244 // should be invoked whenever a property that potentially affects
245 // exposure changes
246 void updateExposure();
247
248 virtual void reinit();
249 void reset();
250 void initializeWlSurface();
251
253
257
258public Q_SLOTS:
259 void applyConfigure();
260
264
265protected:
266 virtual void doHandleFrameCallback();
267 virtual QRect defaultGeometry() const;
268 void setFormat(const QSurfaceFormat &format);
269
270 // this should be called directly for buffer size changes only
271 // use updateExposure for anything affecting the on/off state
272 void sendExposeEvent(const QRect &rect);
273
275
276 // mSurface can be written by the main thread. Other threads should claim a read lock for access
281
286
291
292#ifndef QT_NO_GESTURES
298
299 // We want gestures started in the decoration area to be completely ignored even if the mouse
300 // pointer is later moved to content area. Likewise, gestures started in the content area should
301 // keep sending events even if the mouse pointer is moved over the decoration (consider that
302 // the events for that gesture will be sent to us even if it's moved outside the window).
303 // So we track the gesture state and accept or ignore events based on that. Note that
304 // concurrent gestures of different types are not allowed in the protocol, so single state is
305 // enough
307#endif
308
309 std::atomic_bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
312
313 bool mWaitingForFrameCallback = false; // Protected by mFrameSyncMutex
314 QElapsedTimer mFrameCallbackElapsedTimer; // Protected by mFrameSyncMutex
315 struct ::wl_callback *mFrameCallback = nullptr; // Protected by mFrameSyncMutex
318
319 bool mExposed = false;
321
322 // written from the main thread, read by the render thread
324 // written from the render thread, read by the main thread
326
329
330 bool mSentInitialResize = false;
333
336
339
340 // Empty QRegion maps to "infinite" input region, needs a dedicated "deliberately empty" state.
343
347
349
352
355
357
360
361#if QT_CONFIG(cursor)
363 bool mHasStoredCursor = false;
364#endif
365
366private:
367 void setGeometry_helper(const QRect &rect);
369 void initWindow();
370 bool shouldCreateShellSurface() const;
371 bool shouldCreateSubSurface() const;
372 void resetSurfaceRole();
373 void resetFrameCallback();
375 void setOpaqueArea(const QRegion &opaqueArea);
376 bool isOpaque() const;
377 void updateInputRegion();
378 void updateViewport();
379 bool calculateExposure() const;
381
384 void updateScale();
385 void setScale(qreal newScale);
386
390
391 bool mInResizeFromApplyConfigure = false;
392 bool lastVisible = false;
395
398 const QPlatformWindow *lastParent = nullptr;
399
402
403 friend class QWaylandSubSurface;
404};
405
407
409{
410 return mWindowIcon;
411}
412
414{
415 return mOffset;
416}
417
418}
419
420QT_END_NAMESPACE
421
422#endif // QWAYLANDWINDOW_H
friend class QPainter
static QRegion marginsRegion(const QSize &size, const QMargins &margins)