2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2020-04-22 11:59:42 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
2020-04-22 11:59:42 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2020-04-22 11:59:42 +00:00
|
|
|
|
|
|
|
#include "subsurfacemonitor.h"
|
|
|
|
|
|
|
|
#include <KWaylandServer/subcompositor_interface.h>
|
|
|
|
#include <KWaylandServer/surface_interface.h>
|
|
|
|
|
|
|
|
using namespace KWaylandServer;
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
SubSurfaceMonitor::SubSurfaceMonitor(SurfaceInterface *surface, QObject *parent)
|
|
|
|
: QObject(parent)
|
|
|
|
{
|
|
|
|
registerSurface(surface);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SubSurfaceMonitor::registerSubSurface(SubSurfaceInterface *subSurface)
|
|
|
|
{
|
|
|
|
SurfaceInterface *surface = subSurface->surface();
|
|
|
|
|
|
|
|
connect(subSurface, &SubSurfaceInterface::positionChanged,
|
|
|
|
this, &SubSurfaceMonitor::subSurfaceMoved);
|
|
|
|
connect(surface, &SurfaceInterface::sizeChanged,
|
|
|
|
this, &SubSurfaceMonitor::subSurfaceResized);
|
|
|
|
connect(surface, &SurfaceInterface::mapped,
|
|
|
|
this, &SubSurfaceMonitor::subSurfaceMapped);
|
|
|
|
connect(surface, &SurfaceInterface::unmapped,
|
|
|
|
this, &SubSurfaceMonitor::subSurfaceUnmapped);
|
2020-06-10 16:40:44 +00:00
|
|
|
connect(surface, &SurfaceInterface::surfaceToBufferMatrixChanged,
|
|
|
|
this, &SubSurfaceMonitor::subSurfaceSurfaceToBufferMatrixChanged);
|
2020-06-30 06:33:45 +00:00
|
|
|
connect(surface, &SurfaceInterface::bufferSizeChanged,
|
|
|
|
this, &SubSurfaceMonitor::subSurfaceBufferSizeChanged);
|
2021-02-02 13:16:33 +00:00
|
|
|
connect(surface, &SurfaceInterface::committed,
|
2021-06-08 07:02:14 +00:00
|
|
|
this, [this, subSurface]() { Q_EMIT subSurfaceCommitted(subSurface); });
|
2020-04-22 11:59:42 +00:00
|
|
|
|
|
|
|
registerSurface(surface);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SubSurfaceMonitor::unregisterSubSurface(SubSurfaceInterface *subSurface)
|
|
|
|
{
|
|
|
|
SurfaceInterface *surface = subSurface->surface();
|
|
|
|
if (!surface)
|
|
|
|
return;
|
|
|
|
|
2021-02-02 13:16:33 +00:00
|
|
|
disconnect(subSurface, nullptr, this, nullptr);
|
2020-04-22 11:59:42 +00:00
|
|
|
|
|
|
|
unregisterSurface(surface);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SubSurfaceMonitor::registerSurface(SurfaceInterface *surface)
|
|
|
|
{
|
|
|
|
connect(surface, &SurfaceInterface::childSubSurfaceAdded,
|
|
|
|
this, &SubSurfaceMonitor::subSurfaceAdded);
|
|
|
|
connect(surface, &SurfaceInterface::childSubSurfaceRemoved,
|
|
|
|
this, &SubSurfaceMonitor::subSurfaceRemoved);
|
|
|
|
connect(surface, &SurfaceInterface::childSubSurfaceAdded,
|
|
|
|
this, &SubSurfaceMonitor::registerSubSurface);
|
|
|
|
connect(surface, &SurfaceInterface::childSubSurfaceRemoved,
|
|
|
|
this, &SubSurfaceMonitor::unregisterSubSurface);
|
2021-02-24 08:21:44 +00:00
|
|
|
|
|
|
|
const QList<SubSurfaceInterface *> childSubSurfaces = surface->childSubSurfaces();
|
|
|
|
for (SubSurfaceInterface *childSubSurface : childSubSurfaces) {
|
|
|
|
registerSubSurface(childSubSurface);
|
|
|
|
}
|
2020-04-22 11:59:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SubSurfaceMonitor::unregisterSurface(SurfaceInterface *surface)
|
|
|
|
{
|
2021-02-02 13:16:33 +00:00
|
|
|
disconnect(surface, nullptr, this, nullptr);
|
2020-04-22 11:59:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace KWin
|