From a68af4be605816a2bbb2b32030ad55fa71401735 Mon Sep 17 00:00:00 2001
From: Alexander Tuxen <tuxen@silpion.de>
Date: Fri, 23 Sep 2022 21:03:06 +0200
Subject: [PATCH] Improved logWindows to include iviIds.

---
 multiscreen-compositor/qml/main.qml | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/multiscreen-compositor/qml/main.qml b/multiscreen-compositor/qml/main.qml
index b825556..16629dc 100644
--- a/multiscreen-compositor/qml/main.qml
+++ b/multiscreen-compositor/qml/main.qml
@@ -191,6 +191,8 @@ WaylandCompositor {
     // Remove destroyed surface from the suface list
     // =============================================
     onSurfaceAboutToBeDestroyed: {
+        // Removing this seems to have fixed the crashes.
+        //Also, with the new way to keep the applist clean of undefined objects, it is unnecessary.
         /*
         console.log("Surface will be destroyed", surface);
         console.log("appList length: ", activeSurfaces.length);
@@ -305,13 +307,20 @@ WaylandCompositor {
             windowVisibility(windowid, true)
         }
         function onLogWindows(){
+            cleanUpApplist();
             console.log("Active surfaces:")
             for (var i=0; i < activeSurfaces.length; i++) {
                 var item = activeSurfaces[i];
-                console.log("- Surface", i, ": ", item.surface, "on", item.screen)
+                if (item.surface.surface) {
+                    console.log("- Surface", i, item.surface, "pid", item.surface.surface.client.processId, "on screen", item.screen);
+                }
+                else if (item.surface.shellSurface) {
+                    console.log("- Surface", i, "iviId:", item.surface.shellSurface.iviId, item.surface, "on screen", item.screen);
+                }
             }
         }
         function onGetScreen(windowid){
+            cleanUpApplist();
             console.log("Received a getScreen Signal for window ID: ", windowid)
             var screenId = -1;
             for (var i=0; i < activeSurfaces.length; i++) {
@@ -322,7 +331,7 @@ WaylandCompositor {
                         screenId = item.screen;
                     }
                     else if ((item.surface.shellSurface) && ( windowid === item.surface.shellSurface.iviId)) {
-                        console.log("Surface", i, item.surface, "on screen", item.screen)
+                        console.log("- Surface", i, "iviId:", item.surface.shellSurface.iviId, item.surface, "on screen", item.screen)
                         screenId = item.screen;
                     }
                 }
-- 
GitLab