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
qwaylandplatformservices.cpp
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
#
include
"qwaylandappmenu_p.h"
6
#
include
"qwaylandplatformservices_p.h"
7
#
include
"qwaylandwindow_p.h"
8
#
include
"qwaylanddisplay_p.h"
9
#
include
"qwaylandshellsurface_p.h"
10
#
include
"qwaylandwindowmanagerintegration_p.h"
11
12
QT_BEGIN_NAMESPACE
13
14
namespace
QtWaylandClient
{
15
16
QWaylandPlatformServices
::
QWaylandPlatformServices
(
QWaylandDisplay
*
display
)
17
:
m_display
(
display
) { }
18
19
QWaylandPlatformServices
::~
QWaylandPlatformServices
()
20
{
21
qDeleteAll
(
m_appMenus
);
22
}
23
24
bool
QWaylandPlatformServices
::
openUrl
(
const
QUrl
&
url
)
25
{
26
if
(
auto
windowManagerIntegration
=
m_display
->
windowManagerIntegration
()) {
27
windowManagerIntegration
->
openUrl
(
url
);
28
return
true
;
29
}
30
return
QDesktopUnixServices
::
openUrl
(
url
);
31
}
32
33
bool
QWaylandPlatformServices
::
openDocument
(
const
QUrl
&
url
)
34
{
35
if
(
auto
windowManagerIntegration
=
m_display
->
windowManagerIntegration
()) {
36
windowManagerIntegration
->
openUrl
(
url
);
37
return
true
;
38
}
39
return
QDesktopUnixServices
::
openDocument
(
url
);
40
}
41
42
QString
QWaylandPlatformServices
::
portalWindowIdentifier
(
QWindow
*
window
)
43
{
44
if
(
window
&&
window
->
handle
()) {
45
auto
shellSurface
=
static_cast
<
QWaylandWindow
*>(
window
->
handle
())->
shellSurface
();
46
if
(
shellSurface
) {
47
const
QString
handle
=
shellSurface
->
externWindowHandle
();
48
return
QLatin1String
(
"wayland:"
) +
handle
;
49
}
50
}
51
return
QString
();
52
}
53
54
void
QWaylandPlatformServices
::
registerDBusMenuForWindow
(
QWindow
*
window
,
const
QString
&
service
,
55
const
QString
&
path
)
56
{
57
if
(!
m_display
->
appMenuManager
())
58
return
;
59
if
(!
window
)
60
return
;
61
if
(!
window
->
handle
())
62
window
->
create
();
63
auto
waylandWindow
=
static_cast
<
QWaylandWindow
*>(
window
->
handle
());
64
auto
menu
= *
m_appMenus
.
insert
(
window
,
new
QWaylandAppMenu
);
65
66
auto
createAppMenu
= [
waylandWindow
,
menu
,
service
,
path
] {
67
menu
->
init
(
waylandWindow
->
display
()->
appMenuManager
()->
create
(
waylandWindow
->
wlSurface
()));
68
menu
->
set_address
(
service
,
path
);
69
};
70
71
if
(
waylandWindow
->
wlSurface
())
72
createAppMenu
();
73
74
QObject
::
connect
(
waylandWindow
, &
QWaylandWindow
::
wlSurfaceCreated
,
menu
,
createAppMenu
);
75
QObject
::
connect
(
waylandWindow
, &
QWaylandWindow
::
wlSurfaceDestroyed
,
menu
,
76
[
menu
] {
menu
->
release
(); });
77
}
78
79
void
QWaylandPlatformServices
::
unregisterDBusMenuForWindow
(
QWindow
*
window
)
80
{
81
delete
m_appMenus
.
take
(
window
);
82
}
83
}
// namespace QtWaylandClient
84
85
QT_END_NAMESPACE
QtWaylandClient
Definition
qwaylandclientextension.h:16
qtbase
src
plugins
platforms
wayland
qwaylandplatformservices.cpp
Generated on
for Qt by
1.16.1