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