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;
69
70class Q_WAYLANDCLIENT_EXPORT QWaylandWindow : public QNativeInterface::Private::QWaylandWindow,
71 public QPlatformWindow
72{
74public:
80
89
92
93 // Keep Toplevels position on the top left corner of their screen
94 static inline bool fixedToplevelPositions = true;
95
96 virtual WindowType windowType() const = 0;
97 virtual void ensureSize();
98 WId winId() const override;
99 void setVisible(bool visible) override;
101
104
105 inline QIcon windowIcon() const;
106 void setWindowIcon(const QIcon &icon) override;
107
108 void setGeometry(const QRect &rect) override;
109
111
112 void resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset = {0, 0});
115
116 void applyConfigureWhenPossible(); //rename to possible?
117
118 void attach(QWaylandBuffer *buffer, int x, int y);
120 QPoint attachOffset() const;
121
122 void damage(const QRect &rect);
123
126
127 void commit();
128
129 bool waitForFrameSync(int timeout);
130
134 QSize surfaceSize() const;
138
141
143 ::wl_surface *wlSurface() const;
145 {
146 return wlSurface();
147 }
149
150 QWaylandDisplay *display() const { return mDisplay; }
152 std::any _surfaceRole() const override;
155
159
162
166 Qt::WindowFlags windowFlags() const;
168
169 void raise() override;
170 void lower() override;
171
172 void setMask(const QRegion &region) override;
173
174 void setAlertState(bool enabled) override;
175 bool isAlertState() const override;
176
177 qreal scale() const;
179
181 bool isExposed() const override;
182 bool isActive() const override;
183
185
187#ifndef QT_NO_GESTURES
192#endif
193
199
200 virtual bool createDecoration();
201
202#if QT_CONFIG(cursor)
204 void setStoredCursor(const QCursor &cursor);
205 void resetStoredCursor();
207#endif
208
210
212 static QWaylandWindow *mouseGrab() { return mMouseGrab; }
213
214 void sendProperty(const QString &name, const QVariant &value);
215 void setProperty(const QString &name, const QVariant &value);
216
217 QVariantMap properties() const;
220
221#ifdef QT_PLATFORM_WINDOW_HAS_VIRTUAL_SET_BACKING_STORE
223#else
225#endif
227
230
231 bool setKeyboardGrabEnabled(bool) override { return false; }
233 void addAttachOffset(const QPoint point);
234
237
239 void requestUpdate() override;
240 void handleUpdate();
241 void requestForcedUpdate();
243
246
247 void beginFrame();
248 void endFrame();
249
250 void closeChildPopups();
251
252 // should be invoked whenever a property that potentially affects
253 // exposure changes
254 void updateExposure();
255
256 virtual void reinit();
257 void reset();
258 void initializeWlSurface(bool colorSpace = true);
259
261
263
267
272
274
275public Q_SLOTS:
276 void applyConfigure();
277
281
282protected:
283 virtual void doHandleFrameCallback();
284 virtual QRect defaultGeometry() const;
285 void setFormat(const QSurfaceFormat &format);
286
287 // this should be called directly for buffer size changes only
288 // use updateExposure for anything affecting the on/off state
289 void sendExposeEvent(const QRect &rect);
290
292
293 // mSurface can be written by the main thread. Other threads should claim a read lock for access
298
303
308
309#ifndef QT_NO_GESTURES
315
316 // We want gestures started in the decoration area to be completely ignored even if the mouse
317 // pointer is later moved to content area. Likewise, gestures started in the content area should
318 // keep sending events even if the mouse pointer is moved over the decoration (consider that
319 // the events for that gesture will be sent to us even if it's moved outside the window).
320 // So we track the gesture state and accept or ignore events based on that. Note that
321 // concurrent gestures of different types are not allowed in the protocol, so single state is
322 // enough
324#endif
325
326 std::atomic_bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
329 bool mPendingForcedUpdate = false; // The window should force a redraw at the next fame callback
330
331 QElapsedTimer mFrameCallbackElapsedTimer; // Protected by mFrameSyncMutex
332 struct ::wl_callback *mFrameCallback = nullptr; // Protected by mFrameSyncMutex
335
336 bool mExposed = false;
338
339 // written from the main thread, read by the render thread
341 // written from the render thread, read by the main thread
343
346
349
352
355
356 // Empty QRegion maps to "infinite" input region, needs a dedicated "deliberately empty" state.
359
363
365
369
372
374
377
378#if QT_CONFIG(cursor)
380 bool mHasStoredCursor = false;
381#endif
382
383private:
384 void setGeometry_helper(const QRect &rect);
386 void initWindow();
387 bool shouldCreateShellSurface() const;
388 bool shouldCreateSubSurface() const;
389 void resetSurfaceRole();
390 void resetFrameCallback();
392 void setOpaqueArea(const QRegion &opaqueArea);
393 bool isOpaque() const;
394 void updateInputRegion();
395 void updateViewport();
396 bool calculateExposure() const;
398
401 void updateScale();
402 void setScale(qreal newScale);
403
407
408 bool mInResizeFromApplyConfigure = false;
409 bool lastVisible = false;
412
415 const QPlatformWindow *lastParent = nullptr;
416
417 struct {
420 } m_popupInfo;
421
424
426
427 friend class QWaylandSubSurface;
428};
429
431
433{
434 return mWindowIcon;
435}
436
438{
439 return mOffset;
440}
441
442}
443
444QT_END_NAMESPACE
445
446#endif // QWAYLANDWINDOW_H
friend class QPainter
Combined button and popup list for selecting options.
static QRegion marginsRegion(const QSize &size, const QMargins &margins)