KWin
Loading...
Searching...
No Matches
subsurfacemonitor.cpp
Go to the documentation of this file.
1/*
2 KWin - the KDE window manager
3 This file is part of the KDE project.
4
5 SPDX-FileCopyrightText: 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8*/
9
10#include "subsurfacemonitor.h"
11
13#include "wayland/surface.h"
14
15namespace KWin
16{
17
19 : QObject(parent)
20{
21 registerSurface(surface);
22}
23
24void SubSurfaceMonitor::registerSubSurface(SubSurfaceInterface *subSurface)
25{
26 SurfaceInterface *surface = subSurface->surface();
27
28 connect(subSurface, &SubSurfaceInterface::positionChanged,
30 connect(surface, &SurfaceInterface::sizeChanged,
32 connect(surface, &SurfaceInterface::mapped,
34 connect(surface, &SurfaceInterface::unmapped,
38 connect(surface, &SurfaceInterface::committed,
39 this, [this, subSurface]() {
40 Q_EMIT subSurfaceCommitted(subSurface);
41 });
42
43 registerSurface(surface);
44}
45
46void SubSurfaceMonitor::unregisterSubSurface(SubSurfaceInterface *subSurface)
47{
48 SurfaceInterface *surface = subSurface->surface();
49 if (!surface) {
50 return;
51 }
52
53 disconnect(subSurface, nullptr, this, nullptr);
54
55 unregisterSurface(surface);
56}
57
58void SubSurfaceMonitor::registerSurface(SurfaceInterface *surface)
59{
65 this, &SubSurfaceMonitor::registerSubSurface);
67 this, &SubSurfaceMonitor::unregisterSubSurface);
68
69 const QList<SubSurfaceInterface *> below = surface->below();
70 for (SubSurfaceInterface *childSubSurface : below) {
71 registerSubSurface(childSubSurface);
72 }
73
74 const QList<SubSurfaceInterface *> above = surface->above();
75 for (SubSurfaceInterface *childSubSurface : above) {
76 registerSubSurface(childSubSurface);
77 }
78}
79
80void SubSurfaceMonitor::unregisterSurface(SurfaceInterface *surface)
81{
82 disconnect(surface, nullptr, this, nullptr);
83}
84
85} // namespace KWin
86
87#include "moc_subsurfacemonitor.cpp"
SurfaceInterface * surface() const
void positionChanged(const QPoint &position)
void subSurfaceCommitted(SubSurfaceInterface *subSurface)
SubSurfaceMonitor(SurfaceInterface *surface, QObject *parent)
Resource representing a wl_surface.
Definition surface.h:80
void childSubSurfaceRemoved(SubSurfaceInterface *subSurface)
void childSubSurfaceAdded(SubSurfaceInterface *subSurface)