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
qwaylandsessionmanager.cpp
Go to the documentation of this file.
1
// Copyright (C) 2024 David Edmundson <davidedmundson@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
"qwaylandsessionmanager_p.h"
5
6
#
ifndef
QT_NO_SESSIONMANAGER
7
8
#
include
"qwaylanddisplay_p.h"
9
#
include
"qwaylandwindow_p.h"
10
11
#
include
<
private
/
qsessionmanager_p
.
h
>
12
#
include
<
private
/
qguiapplication_p
.
h
>
13
14
#
include
<
QtCore
/
QDebug
>
15
16
QT_BEGIN_NAMESPACE
17
18
namespace
QtWaylandClient
{
19
20
QWaylandSessionManager
::
QWaylandSessionManager
(
QWaylandDisplay
*
display
,
const
QString
&
id
)
21
:
QObject
(
nullptr
)
22
,
QPlatformSessionManager
(
id
,
QString
())
23
,
mDisplay
(
display
)
24
{
25
if
(!
display
->
xxSessionManager
())
26
return
;
27
28
// The protocol also exposes a way of supporting crash handling to expose later
29
startSession
();
30
}
31
32
QWaylandSession
*
QWaylandSessionManager
::
session
()
const
33
{
34
return
mSession
.
data
();
35
}
36
37
QWaylandSessionManager
*
QWaylandSessionManager
::
instance
()
38
{
39
auto
*
qGuiAppPriv
=
QGuiApplicationPrivate
::
instance
();
40
auto
*
managerPrivate
=
static_cast
<
QSessionManagerPrivate
*>(
QObjectPrivate
::
get
(
qGuiAppPriv
->
session_manager
));
41
return
static_cast
<
QWaylandSessionManager
*>(
managerPrivate
->
platformSessionManager
);
42
}
43
44
void
QWaylandSessionManager
::
setSessionId
(
const
QString
&
id
)
45
{
46
m_sessionId
=
id
;
47
}
48
49
void
QWaylandSessionManager
::
startSession
()
50
{
51
QtWayland
::
xx_session_manager_v1
::
reason
restoreReason
=
QtWayland
::
xx_session_manager_v1
::
reason_launch
;
52
if
(!
sessionId
().
isEmpty
()) {
53
restoreReason
=
QtWayland
::
xx_session_manager_v1
::
reason_session_restore
;
54
}
55
mSession
.
reset
(
new
QWaylandSession
(
this
));
56
mSession
->
init
(
mDisplay
->
xxSessionManager
()->
get_session
(
restoreReason
,
sessionId
()));
57
mDisplay
->
forceRoundTrip
();
58
}
59
60
QWaylandSession
::
QWaylandSession
(
QWaylandSessionManager
*
sessionManager
)
61
:
mSessionManager
(
sessionManager
)
62
{
63
}
64
65
QWaylandSession
::~
QWaylandSession
() {
66
// There's also remove which is another dtor
67
// depending on whether we're meant to clean up server side or not
68
// we might need to expose that later
69
destroy
();
70
}
71
72
void
QWaylandSession
::
xx_session_v1_created
(
const
QString
&
id
) {
73
qCDebug
(
lcQpaWayland
) <<
"Session created"
<<
id
;
74
mSessionManager
->
setSessionId
(
id
);
75
}
76
77
void
QWaylandSession
::
xx_session_v1_restored
() {
78
qCDebug
(
lcQpaWayland
) <<
"Session restored"
;
79
// session Id won't have change, do nothing
80
}
81
82
void
QWaylandSession
::
xx_session_v1_replaced
() {
83
qCDebug
(
lcQpaWayland
) <<
"Session replaced"
;
84
mSessionManager
->
setSessionId
(
QString
());
85
}
86
87
}
88
89
QT_END_NAMESPACE
90
91
#
endif
QPlatformGraphicsBufferHelper
\inmodule QtGui
QtWaylandClient
Definition
qwaylandclientextension.h:15
qtbase
src
plugins
platforms
wayland
qwaylandsessionmanager.cpp
Generated on
for Qt by
1.14.0