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
ImageDescription
;
68
69
class
Q_WAYLANDCLIENT_EXPORT
QWaylandWindow
:
public
QNativeInterface
::
Private
::
QWaylandWindow
,
70
public
QPlatformWindow
71
{
72
Q_OBJECT
73
public
:
74
enum
WindowType
{
75
Shm
,
76
Egl
,
77
Vulkan
78
};
79
80
enum
ToplevelWindowTilingState
{
81
WindowNoState
= 0,
82
WindowTiledLeft
= 1,
83
WindowTiledRight
= 2,
84
WindowTiledTop
= 4,
85
WindowTiledBottom
= 8
86
};
87
Q_DECLARE_FLAGS
(
ToplevelWindowTilingStates
,
ToplevelWindowTilingState
)
88
89
QWaylandWindow
(
QWindow
*
window
,
QWaylandDisplay
*
display
);
90
~
QWaylandWindow
()
override
;
91
92
// Keep Toplevels position on the top left corner of their screen
93
static
inline
bool
fixedToplevelPositions
=
true
;
94
95
virtual
WindowType
windowType
()
const
= 0;
96
virtual
void
ensureSize
();
97
WId
winId
()
const
override
;
98
void
setVisible
(
bool
visible
)
override
;
99
void
setParent
(
const
QPlatformWindow
*
parent
)
override
;
100
101
QString
windowTitle
()
const
override
;
102
void
setWindowTitle
(
const
QString
&
title
)
override
;
103
104
inline
QIcon
windowIcon
()
const
;
105
void
setWindowIcon
(
const
QIcon
&
icon
)
override
;
106
107
void
setGeometry
(
const
QRect
&
rect
)
override
;
108
109
bool
allowsIndependentThreadedRendering
()
const
override
;
110
111
void
resizeFromApplyConfigure
(
const
QSize
&
sizeWithMargins
,
const
QPoint
&
offset
= {0, 0});
112
void
repositionFromApplyConfigure
(
const
QPoint
&
position
);
113
void
setGeometryFromApplyConfigure
(
const
QPoint
&
globalPosition
,
const
QSize
&
sizeWithMargins
);
114
115
void
applyConfigureWhenPossible
();
//rename to possible?
116
117
void
attach
(
QWaylandBuffer
*
buffer
,
int
x
,
int
y
);
118
void
attachOffset
(
QWaylandBuffer
*
buffer
);
119
QPoint
attachOffset
()
const
;
120
121
void
damage
(
const
QRect
&
rect
);
122
123
void
safeCommit
(
QWaylandBuffer
*
buffer
,
const
QRegion
&
damage
);
124
void
commit
(
QWaylandBuffer
*
buffer
,
const
QRegion
&
damage
);
125
126
void
commit
();
127
128
bool
waitForFrameSync
(
int
timeout
);
129
130
QMargins
frameMargins
()
const
override
;
131
QMargins
clientSideMargins
()
const
;
132
void
setCustomMargins
(
const
QMargins
&
margins
)
override
;
133
QSize
surfaceSize
()
const
;
134
QMargins
windowContentMargins
()
const
;
135
QRect
windowContentGeometry
()
const
;
136
QPointF
mapFromWlSurface
(
const
QPointF
&
surfacePosition
)
const
;
137
138
QWaylandSurface
*
waylandSurface
()
const
{
return
mSurface
.
get
(); }
139
::
wl_surface
*
wlSurface
()
const
;
140
::
wl_surface
*
surface
()
const
override
141
{
142
return
wlSurface
();
143
}
144
static
QWaylandWindow
*
fromWlSurface
(::
wl_surface
*
surface
);
145
146
QWaylandDisplay
*
display
()
const
{
return
mDisplay
; }
147
QWaylandShellSurface
*
shellSurface
()
const
;
148
std
::
any
_surfaceRole
()
const
override
;
149
QWaylandSubSurface
*
subSurfaceWindow
()
const
;
150
QWaylandScreen
*
waylandScreen
()
const
;
151
152
void
handleContentOrientationChange
(
Qt
::
ScreenOrientation
orientation
)
override
;
153
void
updateBufferTransform
();
154
void
setOrientationMask
(
Qt
::
ScreenOrientations
mask
);
155
156
ToplevelWindowTilingStates
toplevelWindowTilingStates
()
const
;
157
void
handleToplevelWindowTilingStatesChanged
(
ToplevelWindowTilingStates
states
);
158
159
Qt
::
WindowStates
windowStates
()
const
;
160
void
setWindowState
(
Qt
::
WindowStates
states
)
override
;
161
void
setWindowFlags
(
Qt
::
WindowFlags
flags
)
override
;
162
Qt
::
WindowFlags
windowFlags
()
const
;
163
void
handleWindowStatesChanged
(
Qt
::
WindowStates
states
);
164
165
void
raise
()
override
;
166
void
lower
()
override
;
167
168
void
setMask
(
const
QRegion
&
region
)
override
;
169
170
void
setAlertState
(
bool
enabled
)
override
;
171
bool
isAlertState
()
const
override
;
172
173
qreal
scale
()
const
;
174
qreal
devicePixelRatio
()
const
override
;
175
176
void
requestActivateWindow
()
override
;
177
bool
isExposed
()
const
override
;
178
bool
isActive
()
const
override
;
179
180
QWaylandAbstractDecoration
*
decoration
()
const
;
181
182
void
handleMouse
(
QWaylandInputDevice
*
inputDevice
,
const
QWaylandPointerEvent
&
e
);
183
#
ifndef
QT_NO_GESTURES
184
void
handleSwipeGesture
(
QWaylandInputDevice
*
inputDevice
,
185
const
QWaylandPointerGestureSwipeEvent
&
e
);
186
void
handlePinchGesture
(
QWaylandInputDevice
*
inputDevice
,
187
const
QWaylandPointerGesturePinchEvent
&
e
);
188
#
endif
189
190
bool
touchDragDecoration
(
QWaylandInputDevice
*
inputDevice
,
const
QPointF
&
local
,
const
QPointF
&
global
,
191
QEventPoint
::
State
state
,
Qt
::
KeyboardModifiers
mods
);
192
bool
handleTabletEventDecoration
(
QWaylandInputDevice
*
inputDevice
,
const
QPointF
&
local
,
193
const
QPointF
&
global
,
Qt
::
MouseButtons
buttons
,
194
Qt
::
KeyboardModifiers
modifiers
);
195
196
virtual
bool
createDecoration
();
197
198
#
if
QT_CONFIG
(
cursor
)
199
void
restoreMouseCursor
(
QWaylandInputDevice
*
device
);
200
void
setStoredCursor
(
const
QCursor
&
cursor
);
201
void
resetStoredCursor
();
202
void
applyCursor
(
QWaylandInputDevice
*
device
,
const
QCursor
&
cursor
);
203
#
endif
204
205
QWaylandWindow
*
transientParent
()
const
;
206
207
bool
setMouseGrabEnabled
(
bool
grab
)
override
;
208
static
QWaylandWindow
*
mouseGrab
() {
return
mMouseGrab
; }
209
210
void
sendProperty
(
const
QString
&
name
,
const
QVariant
&
value
);
211
void
setProperty
(
const
QString
&
name
,
const
QVariant
&
value
);
212
213
QVariantMap
properties
()
const
;
214
QVariant
property
(
const
QString
&
name
);
215
QVariant
property
(
const
QString
&
name
,
const
QVariant
&
defaultValue
);
216
217
#
ifdef
QT_PLATFORM_WINDOW_HAS_VIRTUAL_SET_BACKING_STORE
218
void
setBackingStore
(
QPlatformBackingStore
*
store
)
override
;
219
#
else
220
void
setBackingStore
(
QWaylandShmBackingStore
*
backingStore
) {
mBackingStore
=
backingStore
; }
221
#
endif
222
QWaylandShmBackingStore
*
backingStore
()
const
{
return
mBackingStore
; }
223
224
void
setShellIntegration
(
QWaylandShellIntegration
*
shellIntegration
);
225
QWaylandShellIntegration
*
shellIntegration
()
const
{
return
mShellIntegration
; }
226
227
bool
setKeyboardGrabEnabled
(
bool
)
override
{
return
false
; }
228
void
propagateSizeHints
()
override
;
229
void
addAttachOffset
(
const
QPoint
point
);
230
231
bool
startSystemResize
(
Qt
::
Edges
edges
)
override
;
232
bool
startSystemMove
()
override
;
233
234
void
timerEvent
(
QTimerEvent
*
event
)
override
;
235
void
requestUpdate
()
override
;
236
void
handleUpdate
();
237
void
deliverUpdateRequest
()
override
;
238
239
void
setXdgActivationToken
(
const
QString
&
token
);
240
void
requestXdgActivationToken
(
uint
serial
)
override
;
241
242
void
beginFrame
();
243
void
endFrame
();
244
245
void
closeChildPopups
();
246
247
// should be invoked whenever a property that potentially affects
248
// exposure changes
249
void
updateExposure
();
250
251
virtual
void
reinit
();
252
void
reset
();
253
void
initializeWlSurface
(
bool
colorSpace
=
true
);
254
255
void
initializeColorSpace
();
256
257
bool
windowEvent
(
QEvent
*
event
)
override
;
258
259
QSurfaceFormat
format
()
const
override
;
260
void
setSessionRestoreId
(
const
QString
&
role
)
override
;
261
QString
sessionRestoreId
()
const
;
262
263
void
setExtendedWindowType
(
QNativeInterface
::
Private
::
QWaylandWindow
::
WindowType
)
override
;
264
QNativeInterface
::
Private
::
QWaylandWindow
::
WindowType
extendedWindowType
()
const
;
265
void
setParentControlGeometry
(
const
QRect
&
parentAnchor
)
override
;
266
QRect
parentControlGeometry
()
const
;
267
268
void
handleMousePressActivation
();
269
270
public
Q_SLOTS
:
271
void
applyConfigure
();
272
273
Q_SIGNALS
:
274
void
wlSurfaceCreated
();
275
void
wlSurfaceDestroyed
();
276
277
protected
:
278
virtual
void
doHandleFrameCallback
();
279
virtual
QRect
defaultGeometry
()
const
;
280
void
setFormat
(
const
QSurfaceFormat
&
format
);
281
282
// this should be called directly for buffer size changes only
283
// use updateExposure for anything affecting the on/off state
284
void
sendExposeEvent
(
const
QRect
&
rect
);
285
286
QWaylandDisplay
*
mDisplay
=
nullptr
;
287
288
// mSurface can be written by the main thread. Other threads should claim a read lock for access
289
mutable
QReadWriteLock
mSurfaceLock
;
290
std
::
unique_ptr
<
QWaylandSurface
>
mSurface
;
291
std
::
unique_ptr
<
QWaylandFractionalScale
>
mFractionalScale
;
292
std
::
unique_ptr
<
QWaylandViewport
>
mViewport
;
293
294
QWaylandShellIntegration
*
mShellIntegration
=
nullptr
;
295
QWaylandShellSurface
*
mShellSurface
=
nullptr
;
296
QWaylandSubSurface
*
mSubSurfaceWindow
=
nullptr
;
297
QList
<
QWaylandSubSurface
*>
mChildren
;
298
299
std
::
unique_ptr
<
QWaylandAbstractDecoration
>
mWindowDecoration
;
300
bool
mWindowDecorationEnabled
=
false
;
301
bool
mMouseEventsInContentArea
=
false
;
302
Qt
::
MouseButtons
mMousePressedInContentArea
=
Qt
::
NoButton
;
303
304
#
ifndef
QT_NO_GESTURES
305
enum
GestureState
{
306
GestureNotActive
,
307
GestureActiveInContentArea
,
308
GestureActiveInDecoration
309
};
310
311
// We want gestures started in the decoration area to be completely ignored even if the mouse
312
// pointer is later moved to content area. Likewise, gestures started in the content area should
313
// keep sending events even if the mouse pointer is moved over the decoration (consider that
314
// the events for that gesture will be sent to us even if it's moved outside the window).
315
// So we track the gesture state and accept or ignore events based on that. Note that
316
// concurrent gestures of different types are not allowed in the protocol, so single state is
317
// enough
318
GestureState
mGestureState
=
GestureNotActive
;
319
#
endif
320
321
std
::
atomic_bool
mFrameCallbackTimedOut
=
false
;
// Whether the frame callback has timed out
322
int
mFrameCallbackCheckIntervalTimerId
= -1;
323
QAtomicInt
mWaitingForUpdateDelivery
=
false
;
324
325
QElapsedTimer
mFrameCallbackElapsedTimer
;
// Protected by mFrameSyncMutex
326
struct
::
wl_callback
*
mFrameCallback
=
nullptr
;
// Protected by mFrameSyncMutex
327
QMutex
mFrameSyncMutex
;
328
QWaitCondition
mFrameSyncWait
;
329
330
bool
mExposed
=
false
;
331
std
::
atomic_bool
mExposeEventNeedsAttachedBuffer
=
false
;
332
333
// written from the main thread, read by the render thread
334
std
::
atomic_bool
mWaitingToApplyConfigure
=
false
;
335
// written from the render thread, read by the main thread
336
std
::
atomic_bool
mInFrameRender
=
false
;
337
338
int
mFrameCallbackTimeout
= 100;
339
QVariantMap
m_properties
;
340
341
QPoint
mOffset
;
342
std
::
optional
<
qreal
>
mScale
=
std
::
nullopt
;
343
344
QString
mWindowTitle
;
345
QIcon
mWindowIcon
;
346
347
Qt
::
WindowFlags
mFlags
;
348
QRegion
mMask
;
349
350
// Empty QRegion maps to "infinite" input region, needs a dedicated "deliberately empty" state.
351
QRegion
mInputRegion
;
352
bool
mTransparentInputRegion
=
false
;
353
354
QRegion
mOpaqueArea
;
355
Qt
::
WindowStates
mLastReportedWindowStates
=
Qt
::
WindowNoState
;
356
ToplevelWindowTilingStates
mLastReportedToplevelWindowTilingStates
=
WindowNoState
;
357
358
QWaylandShmBackingStore
*
mBackingStore
=
nullptr
;
359
360
QMargins
mCustomMargins
;
361
QString
mSessionRestoreId
;
362
363
QPointer
<
QWaylandWindow
>
mTransientParent
;
364
QList
<
QPointer
<
QWaylandWindow
>>
mChildPopups
;
365
366
Qt
::
ScreenOrientation
mLastReportedContentOrientation
=
Qt
::
PrimaryOrientation
;
367
368
std
::
unique_ptr
<
ColorManagementSurface
>
mColorManagementSurface
;
369
QSurfaceFormat
mSurfaceFormat
;
370
371
#
if
QT_CONFIG
(
cursor
)
372
QCursor
mStoredCursor
;
373
bool
mHasStoredCursor
=
false
;
374
#
endif
375
376
private
:
377
void
setGeometry_helper
(
const
QRect
&
rect
);
378
void
synthesizeExposeOnGeometryChange
();
379
void
initWindow
();
380
bool
shouldCreateShellSurface
()
const
;
381
bool
shouldCreateSubSurface
()
const
;
382
void
resetSurfaceRole
();
383
void
resetFrameCallback
();
384
QPlatformScreen
*
calculateScreenFromSurfaceEvents
()
const
;
385
void
setOpaqueArea
(
const
QRegion
&
opaqueArea
);
386
bool
isOpaque
()
const
;
387
void
updateInputRegion
();
388
void
updateViewport
();
389
bool
calculateExposure
()
const
;
390
void
setPendingImageDescription
();
391
392
void
handleMouseEventWithDecoration
(
QWaylandInputDevice
*
inputDevice
,
const
QWaylandPointerEvent
&
e
);
393
void
handleScreensChanged
();
394
void
updateScale
();
395
void
setScale
(
qreal
newScale
);
396
397
QWaylandWindow
*
guessTransientParent
()
const
;
398
void
addChildPopup
(
QWaylandWindow
*
child
);
399
void
removeChildPopup
(
QWaylandWindow
*
child
);
400
401
bool
mInResizeFromApplyConfigure
=
false
;
402
bool
lastVisible
=
false
;
403
QRect
mLastExposeGeometry
;
404
std
::
unique_ptr
<
ImageDescription
>
mPendingImageDescription
;
405
406
static
const
wl_callback_listener
callbackListener
;
407
void
handleFrameCallback
(
struct
::
wl_callback
*
callback
);
408
const
QPlatformWindow
*
lastParent
=
nullptr
;
409
410
struct
{
411
QRect
parentControlGeometry
;
412
QNativeInterface
::
Private
::
QWaylandWindow
::
WindowType
extendedWindowType
=
QNativeInterface
::
Private
::
QWaylandWindow
::
Default
;
413
}
m_popupInfo
;
414
415
static
QWaylandWindow
*
mMouseGrab
;
416
static
QWaylandWindow
*
mTopPopup
;
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::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:441
QtWaylandClient::QWaylandPointerGesturePinchEvent
Definition
qwaylandinputdevice_p.h:518
QtWaylandClient::QWaylandPointerGestureSwipeEvent
Definition
qwaylandinputdevice_p.h:493
QtWaylandClient::QWaylandSurface
Definition
qwaylandsurface_p.h:33
QtWaylandClient::QWaylandViewport
Definition
qwaylandviewport_p.h:29
QtWaylandClient::QWaylandWindow
Definition
qwaylandwindow_p.h:71
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qrandomaccessasyncfile_darwin.mm:17
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