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