From 578287ec95db1e278faa1183ec794e25bc62b03b Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Tue, 15 Sep 2020 17:36:10 +0100 Subject: [PATCH] Reduce resets in DebugConsole when viewing subsurfaces subsurfaceTreeChanged is emitted on every damage event. This makes it very noisy and the model constantly resets. This makes it impossible to expand the tree (as it resets immediately after). SubSurfaceMonitor gives us more granular signals whilst handling the recursive aspect. Also there are no unmanaged windows that are wayland surfaces, so they are simplified. --- debug_console.cpp | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/debug_console.cpp b/debug_console.cpp index 49d3064ae8..90d1a1b06b 100644 --- a/debug_console.cpp +++ b/debug_console.cpp @@ -19,6 +19,7 @@ #include "workspace.h" #include "keyboard_input.h" #include "input_event.h" +#include "subsurfacemonitor.h" #include "libinput/connection.h" #include "libinput/device.h" #include @@ -1267,36 +1268,27 @@ SurfaceTreeModel::SurfaceTreeModel(QObject *parent) }; using namespace KWaylandServer; - const auto unmangeds = workspace()->unmanagedList(); - for (auto u : unmangeds) { - if (!u->surface()) { - continue; - } - connect(u->surface(), &SurfaceInterface::subSurfaceTreeChanged, this, reset); - } - for (auto c : workspace()->allClientList()) { + auto watchSubsurfaces = [this, reset](AbstractClient *c) { if (!c->surface()) { - continue; + return; } - connect(c->surface(), &SurfaceInterface::subSurfaceTreeChanged, this, reset); + auto monitor = new SubSurfaceMonitor(c->surface(), this); + connect(monitor, &SubSurfaceMonitor::subSurfaceAdded, this, reset); + connect(monitor, &SubSurfaceMonitor::subSurfaceRemoved, this, reset); + connect (c, &QObject::destroyed, monitor, &QObject::deleteLater); + }; + + for (auto c : workspace()->allClientList()) { + watchSubsurfaces(c); } connect(workspace(), &Workspace::clientAdded, this, - [this, reset] (AbstractClient *c) { - if (c->surface()) { - connect(c->surface(), &SurfaceInterface::subSurfaceTreeChanged, this, reset); - } + [this, reset, watchSubsurfaces] (AbstractClient *c) { + watchSubsurfaces(c); reset(); } ); connect(workspace(), &Workspace::clientRemoved, this, reset); - connect(workspace(), &Workspace::unmanagedAdded, this, - [this, reset] (Unmanaged *u) { - if (u->surface()) { - connect(u->surface(), &SurfaceInterface::subSurfaceTreeChanged, this, reset); - } - reset(); - } - ); + connect(workspace(), &Workspace::unmanagedAdded, this, reset); connect(workspace(), &Workspace::unmanagedRemoved, this, reset); }