Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
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
43
struct
wl_egl_window;
44
45
QT_BEGIN_NAMESPACE
46
47
namespace
QtWaylandClient
{
48
49
Q_DECLARE_LOGGING_CATEGORY(lcWaylandBackingstore)
50
51
class
QWaylandDisplay;
52
class
QWaylandBuffer;
53
class
QWaylandShellSurface;
54
class
QWaylandSubSurface;
55
class
QWaylandAbstractDecoration;
56
class
QWaylandInputDevice;
57
class
QWaylandScreen;
58
class
QWaylandShellIntegration;
59
class
QWaylandShmBackingStore;
60
class
QWaylandPointerEvent
;
61
class
QWaylandPointerGestureSwipeEvent
;
62
class
QWaylandPointerGesturePinchEvent
;
63
class
QWaylandSurface
;
64
class
QWaylandFractionalScale
;
65
class
QWaylandViewport
;
66
class
ColorManagementSurface
;
67
class
Cutouts
;
68
class
ImageDescription
;
69
class
QWaylandDecorationHandler;
70
71
class
Q_WAYLANDCLIENT_EXPORT
QWaylandWindow
:
public
QNativeInterface
::
Private
::
QWaylandWindow
,
72
public
QPlatformWindow
73
{
74
Q_OBJECT
75
public
:
76
enum
WindowType
{
77
Shm
,
78
Egl
,
79
Vulkan
80
};
81
82
enum
ToplevelWindowTilingState
{
83
WindowNoState
= 0,
84
WindowTiledLeft
= 1,
85
WindowTiledRight
= 2,
86
WindowTiledTop
= 4,
87
WindowTiledBottom
= 8
88
};
89
Q_DECLARE_FLAGS
(
ToplevelWindowTilingStates
,
ToplevelWindowTilingState
)
90
91
QWaylandWindow
(
QWindow
*
window
,
QWaylandDisplay
*
display
);
92
~
QWaylandWindow
()
override
;
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
;
101
void
setParent
(
const
QPlatformWindow
*
parent
)
override
;
102
103
QString
windowTitle
()
const
override
;
104
void
setWindowTitle
(
const
QString
&
title
)
override
;
105
106
inline
QIcon
windowIcon
()
const
;
107
void
setWindowIcon
(
const
QIcon
&
icon
)
override
;
108
109
void
setGeometry
(
const
QRect
&
rect
)
override
;
110
111
bool
allowsIndependentThreadedRendering
()
const
override
;
112
113
void
resizeFromApplyConfigure
(
const
QSize
&
sizeWithMargins
,
const
QPoint
&
offset
= {0, 0});
114
void
repositionFromApplyConfigure
(
const
QPoint
&
position
);
115
void
setGeometryFromApplyConfigure
(
const
QPoint
&
globalPosition
,
const
QSize
&
sizeWithMargins
);
116
117
void
applyConfigureWhenPossible
();
//rename to possible?
118
119
void
attach
(
QWaylandBuffer
*
buffer
,
int
x
,
int
y
);
120
void
attachOffset
(
QWaylandBuffer
*
buffer
);
121
QPoint
attachOffset
()
const
;
122
123
void
damage
(
const
QRect
&
rect
);
124
125
void
safeCommit
(
QWaylandBuffer
*
buffer
,
const
QRegion
&
damage
);
126
void
commit
(
QWaylandBuffer
*
buffer
,
const
QRegion
&
damage
);
127
128
void
commit
();
129
130
bool
waitForFrameSync
(
int
timeout
);
131
132
QMargins
frameMargins
()
const
override
;
133
QMargins
clientSideMargins
()
const
;
134
void
setCustomMargins
(
const
QMargins
&
margins
)
override
;
135
QMargins
windowContentMargins
()
const
;
136
QRect
windowContentGeometry
()
const
;
137
138
QMargins
safeAreaMargins
()
const
override
;
139
void
setSafeAreaMargins
(
const
QMargins
&
margins
);
140
141
QWaylandSurface
*
waylandSurface
()
const
{
return
mSurface
.
get
(); }
142
::
wl_surface
*
wlSurface
()
const
;
143
::
wl_surface
*
surface
()
const
override
144
{
145
return
wlSurface
();
146
}
147
static
QWaylandWindow
*
fromWlSurface
(::
wl_surface
*
surface
);
148
149
QWaylandDisplay
*
display
()
const
{
return
mDisplay
; }
150
QWaylandShellSurface
*
shellSurface
()
const
;
151
std
::
any
_surfaceRole
()
const
override
;
152
QWaylandSubSurface
*
subSurfaceWindow
()
const
;
153
QWaylandScreen
*
waylandScreen
()
const
;
154
155
void
handleContentOrientationChange
(
Qt
::
ScreenOrientation
orientation
)
override
;
156
void
updateBufferTransform
();
157
void
setOrientationMask
(
Qt
::
ScreenOrientations
mask
);
158
159
ToplevelWindowTilingStates
toplevelWindowTilingStates
()
const
;
160
void
handleToplevelWindowTilingStatesChanged
(
ToplevelWindowTilingStates
states
);
161
162
Qt
::
WindowStates
windowStates
()
const
;
163
void
setWindowState
(
Qt
::
WindowStates
states
)
override
;
164
void
setWindowFlags
(
Qt
::
WindowFlags
flags
)
override
;
165
Qt
::
WindowFlags
windowFlags
()
const
;
166
void
handleWindowStatesChanged
(
Qt
::
WindowStates
states
);
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
;
177
qreal
devicePixelRatio
()
const
override
;
178
179
void
requestActivateWindow
()
override
;
180
bool
isExposed
()
const
override
;
181
bool
isActive
()
const
override
;
182
183
QWaylandAbstractDecoration
*
decoration
()
const
;
184
185
void
handleMouse
(
QWaylandInputDevice
*
inputDevice
,
const
QWaylandPointerEvent
&
e
);
186
#
ifndef
QT_NO_GESTURES
187
void
handleSwipeGesture
(
QWaylandInputDevice
*
inputDevice
,
188
const
QWaylandPointerGestureSwipeEvent
&
e
);
189
void
handlePinchGesture
(
QWaylandInputDevice
*
inputDevice
,
190
const
QWaylandPointerGesturePinchEvent
&
e
);
191
#
endif
192
QPointF
mapInputToGlobal
(
const
QPointF
&
pointIn
);
193
194
void
updateNeedsDecoration
();
195
196
#
if
QT_CONFIG
(
cursor
)
197
void
restoreMouseCursor
(
QWaylandInputDevice
*
device
);
198
void
setStoredCursor
(
const
QCursor
&
cursor
);
199
void
resetStoredCursor
();
200
void
applyCursor
(
QWaylandInputDevice
*
device
,
const
QCursor
&
cursor
);
201
#
endif
202
203
QWaylandWindow
*
transientParent
()
const
;
204
205
bool
setMouseGrabEnabled
(
bool
grab
)
override
;
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
;
212
QVariant
property
(
const
QString
&
name
);
213
QVariant
property
(
const
QString
&
name
,
const
QVariant
&
defaultValue
);
214
215
#
ifdef
QT_PLATFORM_WINDOW_HAS_VIRTUAL_SET_BACKING_STORE
216
void
setBackingStore
(
QPlatformBackingStore
*
store
)
override
;
217
#
else
218
void
setBackingStore
(
QWaylandShmBackingStore
*
backingStore
) {
mBackingStore
=
backingStore
; }
219
#
endif
220
QWaylandShmBackingStore
*
backingStore
()
const
{
return
mBackingStore
; }
221
222
void
setShellIntegration
(
QWaylandShellIntegration
*
shellIntegration
);
223
QWaylandShellIntegration
*
shellIntegration
()
const
{
return
mShellIntegration
; }
224
225
bool
setKeyboardGrabEnabled
(
bool
)
override
{
return
false
; }
226
void
propagateSizeHints
()
override
;
227
void
addAttachOffset
(
const
QPoint
point
);
228
229
bool
startSystemResize
(
Qt
::
Edges
edges
)
override
;
230
bool
startSystemMove
()
override
;
231
232
void
timerEvent
(
QTimerEvent
*
event
)
override
;
233
void
requestUpdate
()
override
;
234
void
handleUpdate
();
235
void
requestForcedUpdate
();
236
void
deliverUpdateRequest
()
override
;
237
238
void
setXdgActivationToken
(
const
QString
&
token
);
239
void
requestXdgActivationToken
(
uint
serial
)
override
;
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
254
void
initializeColorSpace
();
255
256
bool
windowEvent
(
QEvent
*
event
)
override
;
257
258
QSurfaceFormat
format
()
const
override
;
259
void
setSessionRestoreId
(
const
QString
&
role
)
override
;
260
QString
sessionRestoreId
()
const
;
261
262
void
setExtendedWindowType
(
QNativeInterface
::
Private
::
QWaylandWindow
::
WindowType
)
override
;
263
QNativeInterface
::
Private
::
QWaylandWindow
::
WindowType
extendedWindowType
()
const
;
264
void
setParentControlGeometry
(
const
QRect
&
parentAnchor
)
override
;
265
QRect
parentControlGeometry
()
const
;
266
267
void
handleMousePressActivation
();
268
269
public
Q_SLOTS
:
270
void
applyConfigure
();
271
272
Q_SIGNALS
:
273
void
wlSurfaceCreated
();
274
void
wlSurfaceDestroyed
();
275
276
protected
:
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
285
QWaylandDisplay
*
mDisplay
=
nullptr
;
286
287
// mSurface can be written by the main thread. Other threads should claim a read lock for access
288
mutable
QReadWriteLock
mSurfaceLock
;
289
std
::
unique_ptr
<
QWaylandSurface
>
mSurface
;
290
std
::
unique_ptr
<
QWaylandFractionalScale
>
mFractionalScale
;
291
std
::
unique_ptr
<
QWaylandViewport
>
mViewport
;
292
293
QWaylandShellIntegration
*
mShellIntegration
=
nullptr
;
294
QWaylandShellSurface
*
mShellSurface
=
nullptr
;
295
QWaylandSubSurface
*
mSubSurfaceWindow
=
nullptr
;
296
QList
<
QWaylandSubSurface
*>
mChildren
;
297
298
std
::
unique_ptr
<
QWaylandDecorationHandler
>
mWindowDecorationHandler
;
299
bool
mMouseEventsInContentArea
=
false
;
300
Qt
::
MouseButtons
mMousePressedInContentArea
=
Qt
::
NoButton
;
301
302
#
ifndef
QT_NO_GESTURES
303
enum
GestureState
{
304
GestureNotActive
,
305
GestureActiveInContentArea
,
306
};
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
315
GestureState
mGestureState
=
GestureNotActive
;
316
#
endif
317
318
std
::
atomic_bool
mFrameCallbackTimedOut
=
false
;
// Whether the frame callback has timed out
319
int
mFrameCallbackCheckIntervalTimerId
= -1;
320
QAtomicInt
mWaitingForUpdateDelivery
=
false
;
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
325
QMutex
mFrameSyncMutex
;
326
QWaitCondition
mFrameSyncWait
;
327
328
bool
mExposed
=
false
;
329
std
::
atomic_bool
mExposeEventNeedsAttachedBuffer
=
false
;
330
331
// written from the main thread, read by the render thread
332
std
::
atomic_bool
mWaitingToApplyConfigure
=
false
;
333
// written from the render thread, read by the main thread
334
std
::
atomic_bool
mInFrameRender
=
false
;
335
336
int
mFrameCallbackTimeout
= 100;
337
QVariantMap
m_properties
;
338
339
QPoint
mOffset
;
340
std
::
optional
<
qreal
>
mScale
=
std
::
nullopt
;
341
342
QString
mWindowTitle
;
343
QIcon
mWindowIcon
;
344
345
Qt
::
WindowFlags
mFlags
;
346
QRegion
mMask
;
347
348
// Empty QRegion maps to "infinite" input region, needs a dedicated "deliberately empty" state.
349
QRegion
mInputRegion
;
350
bool
mTransparentInputRegion
=
false
;
351
352
QRegion
mOpaqueArea
;
353
Qt
::
WindowStates
mLastReportedWindowStates
=
Qt
::
WindowNoState
;
354
ToplevelWindowTilingStates
mLastReportedToplevelWindowTilingStates
=
WindowNoState
;
355
356
QWaylandShmBackingStore
*
mBackingStore
=
nullptr
;
357
358
QMargins
mCustomMargins
;
359
QMargins
m_safeAreaMargins
;
360
QString
mSessionRestoreId
;
361
362
QPointer
<
QWaylandWindow
>
mTransientParent
;
363
QList
<
QPointer
<
QWaylandWindow
>>
mChildPopups
;
364
365
Qt
::
ScreenOrientation
mLastReportedContentOrientation
=
Qt
::
PrimaryOrientation
;
366
367
std
::
unique_ptr
<
ColorManagementSurface
>
mColorManagementSurface
;
368
QSurfaceFormat
mSurfaceFormat
;
369
370
#
if
QT_CONFIG
(
cursor
)
371
QCursor
mStoredCursor
;
372
bool
mHasStoredCursor
=
false
;
373
#
endif
374
375
private
:
376
void
setGeometry_helper
(
const
QRect
&
rect
);
377
void
synthesizeExposeOnGeometryChange
();
378
void
initWindow
();
379
bool
shouldCreateShellSurface
()
const
;
380
bool
shouldCreateSubSurface
()
const
;
381
void
resetSurfaceRole
();
382
void
resetFrameCallback
();
383
QPlatformScreen
*
calculateScreenFromSurfaceEvents
()
const
;
384
void
setOpaqueArea
(
const
QRegion
&
opaqueArea
);
385
bool
isOpaque
()
const
;
386
void
updateInputRegion
();
387
void
updateViewport
();
388
bool
calculateExposure
()
const
;
389
void
setPendingImageDescription
();
390
391
void
handleScreensChanged
();
392
void
updateScale
();
393
void
setScale
(
qreal
newScale
);
394
395
QWaylandWindow
*
guessTransientParent
()
const
;
396
void
addChildPopup
(
QWaylandWindow
*
child
);
397
void
removeChildPopup
(
QWaylandWindow
*
child
);
398
399
bool
mInResizeFromApplyConfigure
=
false
;
400
bool
lastVisible
=
false
;
401
QRect
mLastExposeGeometry
;
402
std
::
unique_ptr
<
ImageDescription
>
mPendingImageDescription
;
403
404
static
const
wl_callback_listener
callbackListener
;
405
void
handleFrameCallback
(
struct
::
wl_callback
*
callback
);
406
const
QPlatformWindow
*
lastParent
=
nullptr
;
407
408
struct
{
409
QRect
parentControlGeometry
;
410
QNativeInterface
::
Private
::
QWaylandWindow
::
WindowType
extendedWindowType
=
QNativeInterface
::
Private
::
QWaylandWindow
::
Default
;
411
}
m_popupInfo
;
412
413
static
QWaylandWindow
*
mMouseGrab
;
414
static
QWaylandWindow
*
mTopPopup
;
415
416
std
::
unique_ptr
<
QtWaylandClient
::
Cutouts
>
m_cutouts
;
417
418
friend
class
QWaylandSubSurface
;
419
};
420
421
Q_DECLARE_OPERATORS_FOR_FLAGS
(
QWaylandWindow
::
ToplevelWindowTilingStates
)
422
423
inline
QIcon
QWaylandWindow
::
windowIcon
()
const
424
{
425
return
mWindowIcon
;
426
}
427
428
inline
QPoint
QWaylandWindow
::
attachOffset
()
const
429
{
430
return
mOffset
;
431
}
432
433
}
434
435
QT_END_NAMESPACE
436
437
#
endif
// QWAYLANDWINDOW_H
QPaintEngine::QPainter
friend class QPainter
Definition
qpaintengine.h:220
QtWaylandClient::ColorManagementSurface
Definition
qwaylandcolormanagement_p.h:136
QtWaylandClient::Cutouts
Definition
qwaylandcutouts_p.h:28
QtWaylandClient::ImageDescription
Definition
qwaylandcolormanagement_p.h:102
QtWaylandClient::QWaylandAbstractDecorationPrivate
Definition
qwaylandabstractdecoration.cpp:21
QtWaylandClient::QWaylandAbstractDecorationPrivate::m_isDirty
bool m_isDirty
Definition
qwaylandabstractdecoration.cpp:31
QtWaylandClient::QWaylandAbstractDecorationPrivate::m_wayland_window
QWaylandWindow * m_wayland_window
Definition
qwaylandabstractdecoration.cpp:29
QtWaylandClient::QWaylandAbstractDecorationPrivate::m_mouseButtons
Qt::MouseButtons m_mouseButtons
Definition
qwaylandabstractdecoration.cpp:34
QtWaylandClient::QWaylandAbstractDecorationPrivate::~QWaylandAbstractDecorationPrivate
~QWaylandAbstractDecorationPrivate() override
Definition
qwaylandabstractdecoration.cpp:42
QtWaylandClient::QWaylandAbstractDecorationPrivate::m_window
QWindow * m_window
Definition
qwaylandabstractdecoration.cpp:28
QtWaylandClient::QWaylandAbstractDecorationPrivate::m_decorationContentImage
QImage m_decorationContentImage
Definition
qwaylandabstractdecoration.cpp:32
QtWaylandClient::QWaylandAbstractDecoration
Definition
qwaylandabstractdecoration_p.h:48
QtWaylandClient::QWaylandFractionalScale
Definition
qwaylandfractionalscale_p.h:31
QtWaylandClient::QWaylandPointerEvent
Definition
qwaylandinputdevice_p.h:443
QtWaylandClient::QWaylandPointerGesturePinchEvent
Definition
qwaylandinputdevice_p.h:520
QtWaylandClient::QWaylandPointerGestureSwipeEvent
Definition
qwaylandinputdevice_p.h:495
QtWaylandClient::QWaylandSurface
Definition
qwaylandsurface_p.h:37
QtWaylandClient::QWaylandViewport
Definition
qwaylandviewport_p.h:29
QtWaylandClient::QWaylandWindow
Definition
qwaylandwindow_p.h:73
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
QtWaylandClient
Definition
qwaylandclientextension.h:16
qtbase
src
plugins
platforms
wayland
qwaylandwindow_p.h
Generated on
for Qt by
1.18.0