Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qwaylandcutouts.cpp
Go to the documentation of this file.
1
// Copyright (C) 2026 Volker Krause <vkrause@kde.org>
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
"qwaylandcutouts_p.h"
5
#
include
"qwaylandwindow_p.h"
6
7
#
include
<
QtCore
/
qdebug
.
h
>
8
9
QT_BEGIN_NAMESPACE
10
11
namespace
QtWaylandClient
{
12
13
Cutouts
::
Cutouts
(::xx_cutouts_v1 *object, QWaylandWindow *window)
14
:
QtWayland
::
xx_cutouts_v1
(
object
)
15
, m_window(window)
16
{
17
}
18
19
Cutouts
::~
Cutouts
()
20
{
21
destroy();
22
}
23
24
void
Cutouts
::
xx_cutouts_v1_cutout_box
(int32_t x, int32_t y, int32_t width, int32_t height, [[
maybe_unused
]] uint32_t type, [[
maybe_unused
]] uint32_t id)
25
{
26
// compute the minimum screen area we would lose on each side, and pick the minimum one
27
// this produces optimal/expected results also for less-obvious cases like square cutouts towards
28
// a screen corner, but you can find a set of multiple cutouts where it wont, as it doesn't do
29
// a global optimization. That's not a practically relevant scenario so far though.
30
std::array<int32_t, 4> areas;
// top, left, bottom, right
31
areas[0] = (y + height) * m_window->window()->width();
32
areas[1] = (x + width) * m_window->window()->height();
33
areas[2] = (m_window->window()->height() - y) * m_window->window()->width();
34
areas[3] = (m_window->window()->width() - x) * m_window->window()->height();
35
const
auto
minSide =
std
::distance(areas.begin(), std::min_element(areas.begin(), areas.end()));
36
37
switch
(minSide) {
38
case
0:
39
m_margins.setTop(std::max(m_margins.top(), y + height));
40
break
;
41
case
1:
42
m_margins.setLeft(std::max(m_margins.left(), x + width));
43
break
;
44
case
2:
45
m_margins.setBottom(std::max(m_margins.bottom(), y));
46
break
;
47
case
3:
48
m_margins.setRight(std::max(m_margins.right(), x));
49
break
;
50
}
51
}
52
53
void
Cutouts
::
xx_cutouts_v1_cutout_corner
([[
maybe_unused
]] uint32_t position, [[
maybe_unused
]] uint32_t radius, uint32_t id)
54
{
55
// corners are currently not considered as the impact on screen area
56
// loss is disproportianl to the risk of covering relevant application details.
57
// This matches behavior observed on Android.
58
// If we want to change this we should also do global optimziation over all cutouts,
59
// as a notch on one side can effectively cover corners already as well, reducing
60
// the amount of margin needed on their respective other sides.
61
62
m_unhandled.push_back(id);
63
}
64
65
void
Cutouts
::
xx_cutouts_v1_configure
()
66
{
67
m_window->setSafeAreaMargins(m_margins);
68
m_margins = {};
69
70
if
(!m_unhandled.empty()) {
71
const
auto
data = QByteArray::fromRawData(
reinterpret_cast
<
const
char
*>(m_unhandled.data()),
sizeof
(uint32_t) * m_unhandled.size());
72
set_unhandled(data);
73
m_unhandled.clear();
74
}
75
}
76
77
}
// namespace QtWaylandClient
78
79
QT_END_NAMESPACE
QtWaylandClient::Cutouts
Definition
qwaylandcutouts_p.h:28
QtWaylandClient::Cutouts::xx_cutouts_v1_configure
void xx_cutouts_v1_configure() override
Definition
qwaylandcutouts.cpp:65
QtWaylandClient::Cutouts::xx_cutouts_v1_cutout_corner
void xx_cutouts_v1_cutout_corner(uint32_t position, uint32_t radius, uint32_t id) override
Definition
qwaylandcutouts.cpp:53
QtWaylandClient::Cutouts::Cutouts
Cutouts(::xx_cutouts_v1 *object, QWaylandWindow *window)
Definition
qwaylandcutouts.cpp:13
QtWaylandClient::Cutouts::xx_cutouts_v1_cutout_box
void xx_cutouts_v1_cutout_box(int32_t x, int32_t y, int32_t width, int32_t height, uint32_t type, uint32_t id) override
Definition
qwaylandcutouts.cpp:24
QtWaylandClient::Cutouts::~Cutouts
~Cutouts() override
Definition
qwaylandcutouts.cpp:19
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
QtWaylandClient
Definition
qwaylandclientextension.h:16
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
qtbase
src
plugins
platforms
wayland
qwaylandcutouts.cpp
Generated on
for Qt by
1.18.0