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
qwaylandqtsurface.cpp
Go to the documentation of this file.
1
// Copyright (C) 2021 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:critical reason:network-protocol
4
5
#
include
"qwaylandqtsurface_p.h"
6
#
include
<
qpa
/
qwindowsysteminterface
.
h
>
7
#
include
<
qpa
/
qplatformwindow
.
h
>
8
9
QT_BEGIN_NAMESPACE
10
11
namespace
QtWaylandClient
{
12
13
QWaylandQtSurface
::
QWaylandQtSurface
(
struct
::zqt_shell_surface_v1 *
shell_surface
,
QWaylandWindow
*
window
)
14
:
QWaylandShellSurface
(
window
)
15
,
QtWayland
::
zqt_shell_surface_v1
(
shell_surface
)
16
{
17
sendSizeHints
();
18
}
19
20
QWaylandQtSurface
::~
QWaylandQtSurface
()
21
{
22
zqt_shell_surface_v1
::
destroy
();
23
}
24
25
void
QWaylandQtSurface
::
resetConfiguration
()
26
{
27
m_pendingPosition
=
QPoint
(-1, -1);
28
m_pendingSize
=
QSize
();
29
m_pendingPositionValid
=
false
;
30
m_pendingStates
=
m_currentStates
;
31
}
32
33
void
QWaylandQtSurface
::
applyConfigure
()
34
{
35
ack_configure
(
m_currentConfigureSerial
);
36
37
if
(
m_pendingSize
.
isValid
() &&
m_pendingPositionValid
)
38
setGeometryFromApplyConfigure
(
m_pendingPosition
,
m_pendingSize
);
39
else
if
(
m_pendingSize
.
isValid
())
40
resizeFromApplyConfigure
(
m_pendingSize
);
41
else
if
(
m_pendingPositionValid
)
42
repositionFromApplyConfigure
(
m_pendingPosition
);
43
44
if
(
m_pendingStates
!=
m_currentStates
) {
45
QWindowSystemInterface
::
handleWindowStateChanged
(
platformWindow
()->
window
(),
m_pendingStates
);
46
m_currentStates
=
m_pendingStates
;
47
}
48
49
resetConfiguration
();
50
m_currentConfigureSerial
=
UINT32_MAX
;
51
}
52
53
void
QWaylandQtSurface
::
setTitle
(
const
QString
&
title
)
54
{
55
set_window_title
(
title
);
56
}
57
58
void
QWaylandQtSurface
::
zqt_shell_surface_v1_set_capabilities
(
uint32_t
capabilities
)
59
{
60
m_capabilities
=
capabilities
;
61
}
62
63
void
QWaylandQtSurface
::
zqt_shell_surface_v1_set_position
(
uint32_t
serial
,
int32_t
x
,
int32_t
y
)
64
{
65
if
(
serial
<
m_currentConfigureSerial
&&
m_currentConfigureSerial
!=
UINT32_MAX
)
66
return
;
67
68
if
(
serial
!=
m_currentConfigureSerial
) {
69
m_currentConfigureSerial
=
serial
;
70
resetConfiguration
();
71
}
72
73
m_pendingPosition
=
QPoint
(
x
,
y
);
74
m_pendingPositionValid
=
true
;
75
}
76
77
void
QWaylandQtSurface
::
zqt_shell_surface_v1_resize
(
uint32_t
serial
,
int32_t
width
,
int32_t
height
)
78
{
79
if
(
serial
<
m_currentConfigureSerial
&&
m_currentConfigureSerial
!=
UINT32_MAX
)
80
return
;
81
82
if
(
serial
!=
m_currentConfigureSerial
) {
83
m_currentConfigureSerial
=
serial
;
84
resetConfiguration
();
85
}
86
87
m_pendingSize
=
QSize
(
width
,
height
);
88
}
89
90
void
QWaylandQtSurface
::
zqt_shell_surface_v1_configure
(
uint32_t
serial
)
91
{
92
if
(
serial
<
m_currentConfigureSerial
)
93
return
;
94
95
if
(
serial
>
m_currentConfigureSerial
) {
96
m_currentConfigureSerial
=
serial
;
97
resetConfiguration
();
98
}
99
100
applyConfigureWhenPossible
();
101
}
102
103
void
QWaylandQtSurface
::
zqt_shell_surface_v1_close
()
104
{
105
platformWindow
()->
window
()->
close
();
106
}
107
108
void
QWaylandQtSurface
::
zqt_shell_surface_v1_set_frame_margins
(
uint32_t
left
,
uint32_t
right
,
109
uint32_t
top
,
uint32_t
bottom
)
110
{
111
QPlatformWindow
*
win
=
platformWindow
();
112
m_frameMargins
=
QMargins
(
left
,
top
,
right
,
bottom
);
113
m_pendingPosition
=
win
->
geometry
().
topLeft
();
114
m_pendingPositionValid
=
true
;
115
m_pendingSize
=
win
->
geometry
().
size
();
116
applyConfigureWhenPossible
();
117
}
118
119
bool
QWaylandQtSurface
::
requestActivate
()
120
{
121
request_activate
();
122
return
true
;
123
}
124
125
void
QWaylandQtSurface
::
propagateSizeHints
()
126
{
127
sendSizeHints
();
128
}
129
130
void
QWaylandQtSurface
::
sendSizeHints
()
131
{
132
QPlatformWindow
*
win
=
platformWindow
();
133
if
(
win
) {
134
const
int
minWidth
=
qMax
(0,
win
->
windowMinimumSize
().
width
());
135
const
int
minHeight
=
qMax
(0,
win
->
windowMinimumSize
().
height
());
136
set_minimum_size
(
minWidth
,
minHeight
);
137
138
int
maxWidth
=
qMax
(0,
win
->
windowMaximumSize
().
width
());
139
if
(
maxWidth
==
QWINDOWSIZE_MAX
)
140
maxWidth
= -1;
141
int
maxHeight
=
qMax
(0,
win
->
windowMaximumSize
().
height
());
142
if
(
maxHeight
==
QWINDOWSIZE_MAX
)
143
maxHeight
= -1;
144
set_maximum_size
(
maxWidth
,
maxHeight
);
145
}
146
}
147
148
void
QWaylandQtSurface
::
zqt_shell_surface_v1_set_window_state
(
uint32_t
serial
,
uint32_t
state
)
149
{
150
if
(
serial
<
m_currentConfigureSerial
&&
m_currentConfigureSerial
!=
UINT32_MAX
)
151
return
;
152
153
if
(
serial
!=
m_currentConfigureSerial
) {
154
m_currentConfigureSerial
=
serial
;
155
resetConfiguration
();
156
}
157
m_pendingStates
=
Qt
::
WindowStates
(
state
);
158
}
159
160
void
QWaylandQtSurface
::
setWindowPosition
(
const
QPoint
&
position
)
161
{
162
reposition
(
position
.
x
(),
position
.
y
());
163
}
164
165
void
QWaylandQtSurface
::
setWindowSize
(
const
QSize
&
size
)
166
{
167
set_size
(
size
.
width
(),
size
.
height
());
168
}
169
170
void
QWaylandQtSurface
::
setWindowFlags
(
Qt
::
WindowFlags
flags
)
171
{
172
set_window_flags
(
flags
);
173
}
174
175
void
QWaylandQtSurface
::
requestWindowStates
(
Qt
::
WindowStates
states
)
176
{
177
change_window_state
(
states
& ~
Qt
::
WindowActive
);
178
}
179
180
bool
QWaylandQtSurface
::
resize
(
QWaylandInputDevice
*
inputDevice
,
Qt
::
Edges
edge
)
181
{
182
if
(
m_capabilities
&
ZQT_SHELL_SURFACE_V1_CAPABILITIES_INTERACTIVE_RESIZE
) {
183
start_system_resize
(
getSerial
(
inputDevice
),
uint
(
edge
));
184
return
true
;
185
}
186
187
return
false
;
188
}
189
190
bool
QWaylandQtSurface
::
move
(
QWaylandInputDevice
*
inputDevice
)
191
{
192
if
(
m_capabilities
&
ZQT_SHELL_SURFACE_V1_CAPABILITIES_INTERACTIVE_RESIZE
) {
193
start_system_move
(
getSerial
(
inputDevice
));
194
return
true
;
195
}
196
197
return
false
;
198
}
199
200
QMargins
QWaylandQtSurface
::
serverSideFrameMargins
()
const
201
{
202
return
m_frameMargins
;
203
}
204
205
void
QWaylandQtSurface
::
raise
()
206
{
207
QtWayland
::
zqt_shell_surface_v1
::
raise
();
208
}
209
210
void
QWaylandQtSurface
::
lower
()
211
{
212
QtWayland
::
zqt_shell_surface_v1
::
lower
();
213
}
214
215
}
216
217
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
QtWaylandClient
Definition
qwaylandclientextension.h:16
qtwayland
src
plugins
shellintegration
qt-shell
qwaylandqtsurface.cpp
Generated on
for Qt by
1.16.1