KWaylandServer

surfacerole.cpp
1 /*
2  SPDX-FileCopyrightText: 2019 Vlad Zahorodnii <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6 
7 #include "surface_interface.h"
8 #include "surface_interface_p.h"
9 #include "surfacerole_p.h"
10 
11 namespace KWaylandServer
12 {
13 SurfaceRole::SurfaceRole(SurfaceInterface *surface, const QByteArray &name)
14  : m_surface(surface)
15  , m_name(name)
16 {
17  SurfaceInterfacePrivate *surfacePrivate = SurfaceInterfacePrivate::get(surface);
18  surfacePrivate->role = this;
19 }
20 
21 SurfaceRole::~SurfaceRole()
22 {
23  // Lifetime of the surface role is not bounded to the associated surface.
24  if (m_surface) {
25  SurfaceInterfacePrivate *surfacePrivate = SurfaceInterfacePrivate::get(m_surface);
26  surfacePrivate->role = nullptr;
27  }
28 }
29 
30 QByteArray SurfaceRole::name() const
31 {
32  return m_name;
33 }
34 
35 SurfaceRole *SurfaceRole::get(SurfaceInterface *surface)
36 {
37  if (surface) {
38  SurfaceInterfacePrivate *surfacePrivate = SurfaceInterfacePrivate::get(surface);
39  return surfacePrivate->role;
40  }
41 
42  return nullptr;
43 }
44 
45 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Oct 23 2021 23:08:28 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.