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