2020-03-15 15:19:28 +00:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2019 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
2019-09-05 10:57:35 +00:00
|
|
|
|
2020-03-15 15:19:28 +00:00
|
|
|
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
|
|
|
*/
|
2019-09-05 10:57:35 +00:00
|
|
|
|
|
|
|
#include "surface_interface.h"
|
2021-08-29 05:11:06 +00:00
|
|
|
#include "surface_interface_p.h"
|
|
|
|
#include "surfacerole_p.h"
|
2019-09-05 10:57:35 +00:00
|
|
|
|
2020-04-29 14:56:38 +00:00
|
|
|
namespace KWaylandServer
|
2019-09-05 10:57:35 +00:00
|
|
|
{
|
2020-10-30 18:40:14 +00:00
|
|
|
SurfaceRole::SurfaceRole(SurfaceInterface *surface, const QByteArray &name)
|
2019-09-05 10:57:35 +00:00
|
|
|
: m_surface(surface)
|
2020-10-30 18:40:14 +00:00
|
|
|
, m_name(name)
|
2019-09-05 10:57:35 +00:00
|
|
|
{
|
2020-07-04 07:51:33 +00:00
|
|
|
SurfaceInterfacePrivate *surfacePrivate = SurfaceInterfacePrivate::get(surface);
|
|
|
|
surfacePrivate->role = this;
|
2019-09-05 10:57:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SurfaceRole::~SurfaceRole()
|
|
|
|
{
|
|
|
|
// Lifetime of the surface role is not bounded to the associated surface.
|
|
|
|
if (m_surface) {
|
2020-07-04 07:51:33 +00:00
|
|
|
SurfaceInterfacePrivate *surfacePrivate = SurfaceInterfacePrivate::get(m_surface);
|
|
|
|
surfacePrivate->role = nullptr;
|
2019-09-05 10:57:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-30 18:40:14 +00:00
|
|
|
QByteArray SurfaceRole::name() const
|
|
|
|
{
|
|
|
|
return m_name;
|
|
|
|
}
|
|
|
|
|
2020-05-04 13:32:23 +00:00
|
|
|
SurfaceRole *SurfaceRole::get(SurfaceInterface *surface)
|
|
|
|
{
|
|
|
|
if (surface) {
|
2020-07-04 07:51:33 +00:00
|
|
|
SurfaceInterfacePrivate *surfacePrivate = SurfaceInterfacePrivate::get(surface);
|
|
|
|
return surfacePrivate->role;
|
2020-05-04 13:32:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2019-09-05 10:57:35 +00:00
|
|
|
}
|