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(bool colorSpace = true);
251
253
255
259
264
265public Q_SLOTS:
266 void applyConfigure();
267
271
272protected:
273 virtual void doHandleFrameCallback();
274 virtual QRect defaultGeometry() const;
275 void setFormat(const QSurfaceFormat &format);
276
277 // this should be called directly for buffer size changes only
278 // use updateExposure for anything affecting the on/off state
279 void sendExposeEvent(const QRect &rect);
280
282
283 // mSurface can be written by the main thread. Other threads should claim a read lock for access
288
293
298
299#ifndef QT_NO_GESTURES
305
306 // We want gestures started in the decoration area to be completely ignored even if the mouse
307 // pointer is later moved to content area. Likewise, gestures started in the content area should
308 // keep sending events even if the mouse pointer is moved over the decoration (consider that
309 // the events for that gesture will be sent to us even if it's moved outside the window).
310 // So we track the gesture state and accept or ignore events based on that. Note that
311 // concurrent gestures of different types are not allowed in the protocol, so single state is
312 // enough
314#endif
315
316 std::atomic_bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
319
320 bool mWaitingForFrameCallback = false; // Protected by mFrameSyncMutex
321 QElapsedTimer mFrameCallbackElapsedTimer; // Protected by mFrameSyncMutex
322 struct ::wl_callback *mFrameCallback = nullptr; // Protected by mFrameSyncMutex
325
326 bool mExposed = false;
328
329 // written from the main thread, read by the render thread
331 // written from the render thread, read by the main thread
333
336
337 bool mSentInitialResize = false;
340
343
346
347 // Empty QRegion maps to "infinite" input region, needs a dedicated "deliberately empty" state.
350
354
356
359
362
364
367
368#if QT_CONFIG(cursor)
370 bool mHasStoredCursor = false;
371#endif
372
373private:
374 void setGeometry_helper(const QRect &rect);
376 void initWindow();
377 bool shouldCreateShellSurface() const;
378 bool shouldCreateSubSurface() const;
379 void resetSurfaceRole();
380 void resetFrameCallback();
382 void setOpaqueArea(const QRegion &opaqueArea);
383 bool isOpaque() const;
384 void updateInputRegion();
385 void updateViewport();
386 bool calculateExposure() const;
388
391 void updateScale();
392 void setScale(qreal newScale);
393
397
398 bool mInResizeFromApplyConfigure = false;
399 bool lastVisible = false;
402
405 const QPlatformWindow *lastParent = nullptr;
406
407 struct {
410 } m_popupInfo;
411
414
415 friend class QWaylandSubSurface;
416};
417
419
421{
422 return mWindowIcon;
423}
424
426{
427 return mOffset;
428}
429
430}
431
432QT_END_NAMESPACE
433
434#endif // QWAYLANDWINDOW_H
friend class QPainter
Combined button and popup list for selecting options.
static QRegion marginsRegion(const QSize &size, const QMargins &margins)