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