File indexing completed on 2024-05-19 16:35:29
0001 /* 0002 SPDX-FileCopyrightText: 2019 Vlad Zahorodnii <vlad.zahorodnii@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #include "surface_interface.h" 0008 #include "surface_interface_p.h" 0009 #include "surfacerole_p.h" 0010 0011 namespace KWaylandServer 0012 { 0013 SurfaceRole::SurfaceRole(SurfaceInterface *surface, const QByteArray &name) 0014 : m_surface(surface) 0015 , m_name(name) 0016 { 0017 SurfaceInterfacePrivate *surfacePrivate = SurfaceInterfacePrivate::get(surface); 0018 surfacePrivate->role = this; 0019 } 0020 0021 SurfaceRole::~SurfaceRole() 0022 { 0023 // Lifetime of the surface role is not bounded to the associated surface. 0024 if (m_surface) { 0025 SurfaceInterfacePrivate *surfacePrivate = SurfaceInterfacePrivate::get(m_surface); 0026 surfacePrivate->role = nullptr; 0027 } 0028 } 0029 0030 QByteArray SurfaceRole::name() const 0031 { 0032 return m_name; 0033 } 0034 0035 SurfaceRole *SurfaceRole::get(SurfaceInterface *surface) 0036 { 0037 if (surface) { 0038 SurfaceInterfacePrivate *surfacePrivate = SurfaceInterfacePrivate::get(surface); 0039 return surfacePrivate->role; 0040 } 0041 0042 return nullptr; 0043 } 0044 0045 }