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// Qt-Security score:significant reason:default
4
5#ifndef QWAYLANDWINDOW_H
6#define QWAYLANDWINDOW_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtCore/QWaitCondition>
20#include <QtCore/QMutex>
21#include <QtCore/QReadWriteLock>
22
23#include <QtGui/QIcon>
24#include <QtGui/QEventPoint>
25#include <QtCore/QVariant>
26#include <QtCore/QLoggingCategory>
27#include <QtCore/QElapsedTimer>
28#include <QtCore/QList>
29#include <QtCore/QMap> // for QVariantMap
30
31#include <qpa/qplatformwindow.h>
32#include <qpa/qplatformwindow_p.h>
33
34#include <QtWaylandClient/private/qwayland-wayland.h>
35#include <QtWaylandClient/private/qwaylanddisplay_p.h>
36#include <QtWaylandClient/qtwaylandclientglobal.h>
37#include <QtWaylandClient/private/qwaylandshellsurface_p.h>
38
39#include <QtCore/qpointer.h>
40
41struct wl_egl_window;
42
43QT_BEGIN_NAMESPACE
44
45namespace QtWaylandClient {
46
47Q_DECLARE_LOGGING_CATEGORY(lcWaylandBackingstore)
48
49class QWaylandDisplay;
50class QWaylandBuffer;
51class QWaylandShellSurface;
52class QWaylandSubSurface;
53class QWaylandAbstractDecoration;
54class QWaylandInputDevice;
55class QWaylandScreen;
56class QWaylandShellIntegration;
57class QWaylandShmBackingStore;
61class QWaylandSurface;
66
67class Q_WAYLANDCLIENT_EXPORT QWaylandWindow : public QNativeInterface::Private::QWaylandWindow,
68 public QPlatformWindow
69{
71public:
77
86
89
90 // Keep Toplevels position on the top left corner of their screen
91 static inline bool fixedToplevelPositions = true;
92
93 virtual WindowType windowType() const = 0;
94 virtual void ensureSize();
95 WId winId() const override;
96 void setVisible(bool visible) override;
98
101
102 inline QIcon windowIcon() const;
103 void setWindowIcon(const QIcon &icon) override;
104
105 void setGeometry(const QRect &rect) override;
106
108
109 void resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset = {0, 0});
112
113 void applyConfigureWhenPossible(); //rename to possible?
114
115 void attach(QWaylandBuffer *buffer, int x, int y);
117 QPoint attachOffset() const;
118
119 void damage(const QRect &rect);
120
123
124 void commit();
125
126 bool waitForFrameSync(int timeout);
127
131 QSize surfaceSize() const;
135
137 ::wl_surface *wlSurface() const;
139 {
140 return wlSurface();
141 }
143
144 QWaylandDisplay *display() const { return mDisplay; }
146 std::any _surfaceRole() const override;
149
153
156
160 Qt::WindowFlags windowFlags() const;
162
163 void raise() override;
164 void lower() override;
165
166 void setMask(const QRegion &region) override;
167
168 void setAlertState(bool enabled) override;
169 bool isAlertState() const override;
170
171 qreal scale() const;
173
175 bool isExposed() const override;
176 bool isActive() const override;
177
179
181#ifndef QT_NO_GESTURES
186#endif
187
193
194 virtual bool createDecoration();
195
196#if QT_CONFIG(cursor)
198 void setStoredCursor(const QCursor &cursor);
199 void resetStoredCursor();
201#endif
202
204
206 static QWaylandWindow *mouseGrab() { return mMouseGrab; }
207
208 void sendProperty(const QString &name, const QVariant &value);
209 void setProperty(const QString &name, const QVariant &value);
210
211 QVariantMap properties() const;
214
215#ifdef QT_PLATFORM_WINDOW_HAS_VIRTUAL_SET_BACKING_STORE
217#else
219#endif
221
224
225 bool setKeyboardGrabEnabled(bool) override { return false; }
227 void addAttachOffset(const QPoint point);
228
231
233 void requestUpdate() override;
234 void handleUpdate();
236
239
240 void beginFrame();
241 void endFrame();
242
243 void closeChildPopups();
244
245 // should be invoked whenever a property that potentially affects
246 // exposure changes
247 void updateExposure();
248
249 virtual void reinit();
250 void reset();
251 void initializeWlSurface(bool colorSpace = true);
252
254
256
260
265
266public Q_SLOTS:
267 void applyConfigure();
268
272
273protected:
274 virtual void doHandleFrameCallback();
275 virtual QRect defaultGeometry() const;
276 void setFormat(const QSurfaceFormat &format);
277
278 // this should be called directly for buffer size changes only
279 // use updateExposure for anything affecting the on/off state
280 void sendExposeEvent(const QRect &rect);
281
283
284 // mSurface can be written by the main thread. Other threads should claim a read lock for access
289
294
299
300#ifndef QT_NO_GESTURES
306
307 // We want gestures started in the decoration area to be completely ignored even if the mouse
308 // pointer is later moved to content area. Likewise, gestures started in the content area should
309 // keep sending events even if the mouse pointer is moved over the decoration (consider that
310 // the events for that gesture will be sent to us even if it's moved outside the window).
311 // So we track the gesture state and accept or ignore events based on that. Note that
312 // concurrent gestures of different types are not allowed in the protocol, so single state is
313 // enough
315#endif
316
317 std::atomic_bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
320
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
339
342
345
346 // Empty QRegion maps to "infinite" input region, needs a dedicated "deliberately empty" state.
349
353
355
358
361
363
366
367#if QT_CONFIG(cursor)
369 bool mHasStoredCursor = false;
370#endif
371
372private:
373 void setGeometry_helper(const QRect &rect);
375 void initWindow();
376 bool shouldCreateShellSurface() const;
377 bool shouldCreateSubSurface() const;
378 void resetSurfaceRole();
379 void resetFrameCallback();
381 void setOpaqueArea(const QRegion &opaqueArea);
382 bool isOpaque() const;
383 void updateInputRegion();
384 void updateViewport();
385 bool calculateExposure() const;
387
390 void updateScale();
391 void setScale(qreal newScale);
392
396
397 bool mInResizeFromApplyConfigure = false;
398 bool lastVisible = false;
401
404 const QPlatformWindow *lastParent = nullptr;
405
406 struct {
409 } m_popupInfo;
410
413
414 friend class QWaylandSubSurface;
415};
416
418
420{
421 return mWindowIcon;
422}
423
425{
426 return mOffset;
427}
428
429}
430
431QT_END_NAMESPACE
432
433#endif // QWAYLANDWINDOW_H
friend class QPainter
Combined button and popup list for selecting options.
static QRegion marginsRegion(const QSize &size, const QMargins &margins)