Changeset View
Changeset View
Standalone View
Standalone View
src/server/surfacerole.cpp
Show All 12 Lines | |||||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | Lesser General Public License for more details. | 15 | Lesser General Public License for more details. | ||
16 | 16 | | |||
17 | You should have received a copy of the GNU Lesser General Public | 17 | You should have received a copy of the GNU Lesser General Public | ||
18 | License along with this library. If not, see <http://www.gnu.org/licenses/>. | 18 | License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
19 | ****************************************************************************/ | 19 | ****************************************************************************/ | ||
20 | 20 | | |||
21 | #include "surfacerole_p.h" | 21 | #include "surfacerole.h" | ||
22 | #include "surface_interface_p.h" | 22 | #include "surface_interface_p.h" | ||
23 | #include "surface_interface.h" | 23 | #include "surface_interface.h" | ||
24 | 24 | | |||
25 | #include <QPointer> | ||||
26 | | ||||
25 | namespace KWayland | 27 | namespace KWayland | ||
26 | { | 28 | { | ||
27 | namespace Server | 29 | namespace Server | ||
28 | { | 30 | { | ||
29 | 31 | | |||
32 | class SurfaceRolePrivate | ||||
33 | { | ||||
34 | public: | ||||
35 | QPointer<SurfaceInterface> surface; | ||||
36 | }; | ||||
37 | | ||||
30 | SurfaceRole::SurfaceRole(SurfaceInterface *surface) | 38 | SurfaceRole::SurfaceRole(SurfaceInterface *surface) | ||
31 | : m_surface(surface) | 39 | : d(new SurfaceRolePrivate) | ||
32 | { | 40 | { | ||
33 | m_surface->d_func()->role = this; | 41 | d->surface = surface; | ||
42 | surface->d_func()->role = this; | ||||
34 | } | 43 | } | ||
35 | 44 | | |||
36 | SurfaceRole::~SurfaceRole() | 45 | SurfaceRole::~SurfaceRole() | ||
37 | { | 46 | { | ||
38 | // Lifetime of the surface role is not bounded to the associated surface. | 47 | // Lifetime of the surface role is not bounded to the associated surface. | ||
39 | if (m_surface) { | 48 | if (d->surface) { | ||
40 | m_surface->d_func()->role = nullptr; | 49 | d->surface->d_func()->role = nullptr; | ||
50 | } | ||||
51 | } | ||||
52 | | ||||
53 | SurfaceRole *SurfaceRole::get(SurfaceInterface *surface) | ||||
54 | { | ||||
55 | if (surface) { | ||||
56 | return surface->d_func()->role; | ||||
41 | } | 57 | } | ||
58 | return nullptr; | ||||
42 | } | 59 | } | ||
43 | 60 | | |||
44 | } | 61 | } | ||
45 | } | 62 | } |