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
41#include <memory>
42
43struct wl_egl_window;
44
45QT_BEGIN_NAMESPACE
46
47namespace QtWaylandClient {
48
49Q_DECLARE_LOGGING_CATEGORY(lcWaylandBackingstore)
50
51class QWaylandDisplay;
52class QWaylandBuffer;
53class QWaylandShellSurface;
54class QWaylandSubSurface;
55class QWaylandAbstractDecoration;
56class QWaylandInputDevice;
57class QWaylandScreen;
58class QWaylandShellIntegration;
59class QWaylandShmBackingStore;
63class QWaylandSurface;
67class Cutouts;
69class QWaylandDecorationHandler;
70
71class Q_WAYLANDCLIENT_EXPORT QWaylandWindow : public QNativeInterface::Private::QWaylandWindow,
72 public QPlatformWindow
73{
75public:
81
90
93
94 // Keep Toplevels position on the top left corner of their screen
95 static inline bool fixedToplevelPositions = true;
96
97 virtual WindowType windowType() const = 0;
98 virtual void ensureSize();
99 WId winId() const override;
100 void setVisible(bool visible) override;
102
105
106 inline QIcon windowIcon() const;
107 void setWindowIcon(const QIcon &icon) override;
108
109 void setGeometry(const QRect &rect) override;
110
112
113 void resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset = {0, 0});
116
117 void applyConfigureWhenPossible(); //rename to possible?
118
119 void attach(QWaylandBuffer *buffer, int x, int y);
121 QPoint attachOffset() const;
122
123 void damage(const QRect &rect);
124
127
128 void commit();
129
130 bool waitForFrameSync(int timeout);
131
137
140
142 ::wl_surface *wlSurface() const;
144 {
145 return wlSurface();
146 }
148
149 QWaylandDisplay *display() const { return mDisplay; }
151 std::any _surfaceRole() const override;
154
158
161
165 Qt::WindowFlags windowFlags() const;
167
168 void raise() override;
169 void lower() override;
170
171 void setMask(const QRegion &region) override;
172
173 void setAlertState(bool enabled) override;
174 bool isAlertState() const override;
175
176 qreal scale() const;
178
180 bool isExposed() const override;
181 bool isActive() const override;
182
184
186#ifndef QT_NO_GESTURES
191#endif
193
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();
235 void requestForcedUpdate();
237
240
241 void beginFrame();
242 void endFrame();
243
244 void closeChildPopups();
245
246 // should be invoked whenever a property that potentially affects
247 // exposure changes
248 void updateExposure();
249
250 virtual void reinit();
251 void reset();
252 void initializeWlSurface(bool colorSpace = true);
253
255
257
261
266
268
269public Q_SLOTS:
270 void applyConfigure();
271
275
276protected:
277 virtual void doHandleFrameCallback();
278 virtual QRect defaultGeometry() const;
279 void setFormat(const QSurfaceFormat &format);
280
281 // this should be called directly for buffer size changes only
282 // use updateExposure for anything affecting the on/off state
283 void sendExposeEvent(const QRect &rect);
284
286
287 // mSurface can be written by the main thread. Other threads should claim a read lock for access
292
297
301
302#ifndef QT_NO_GESTURES
307
308 // We want gestures started in the decoration area to be completely ignored even if the mouse
309 // pointer is later moved to content area. Likewise, gestures started in the content area should
310 // keep sending events even if the mouse pointer is moved over the decoration (consider that
311 // the events for that gesture will be sent to us even if it's moved outside the window).
312 // So we track the gesture state and accept or ignore events based on that. Note that
313 // concurrent gestures of different types are not allowed in the protocol, so single state is
314 // enough
316#endif
317
318 std::atomic_bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
321 bool mPendingForcedUpdate = false; // The window should force a redraw at the next fame callback
322
323 QElapsedTimer mFrameCallbackElapsedTimer; // Protected by mFrameSyncMutex
324 struct ::wl_callback *mFrameCallback = nullptr; // Protected by mFrameSyncMutex
327
328 bool mExposed = false;
330
331 // written from the main thread, read by the render thread
333 // written from the render thread, read by the main thread
335
338
341
344
347
348 // Empty QRegion maps to "infinite" input region, needs a dedicated "deliberately empty" state.
351
355
357
361
364
366
369
370#if QT_CONFIG(cursor)
372 bool mHasStoredCursor = false;
373#endif
374
375private:
376 void setGeometry_helper(const QRect &rect);
378 void initWindow();
379 bool shouldCreateShellSurface() const;
380 bool shouldCreateSubSurface() const;
381 void resetSurfaceRole();
382 void resetFrameCallback();
384 void setOpaqueArea(const QRegion &opaqueArea);
385 bool isOpaque() const;
386 void updateInputRegion();
387 void updateViewport();
388 bool calculateExposure() const;
390
392 void updateScale();
393 void setScale(qreal newScale);
394
398
399 bool mInResizeFromApplyConfigure = false;
400 bool lastVisible = false;
403
406 const QPlatformWindow *lastParent = nullptr;
407
408 struct {
411 } m_popupInfo;
412
415
417
418 friend class QWaylandSubSurface;
419};
420
422
424{
425 return mWindowIcon;
426}
427
429{
430 return mOffset;
431}
432
433}
434
435QT_END_NAMESPACE
436
437#endif // QWAYLANDWINDOW_H
friend class QPainter
Combined button and popup list for selecting options.