diff --git a/multiscreen-compositor/compositor-messages.cpp b/multiscreen-compositor/compositor-messages.cpp index 8f44b5fb72d59edbc547fcb1bcad1363b0241a14..3dee7462e37ce387deec3a19dcaaff9dd455a8b5 100644 --- a/multiscreen-compositor/compositor-messages.cpp +++ b/multiscreen-compositor/compositor-messages.cpp @@ -34,6 +34,7 @@ void CompositorMessages::messageReceived(QString message, quint32 windowId, quin emit sendStatus(screenId); }else{ qWarning() << "Unknown message received: " << message; + emit sendStatus(-1); } } diff --git a/multiscreen-compositor/qml/main.qml b/multiscreen-compositor/qml/main.qml index a84858f4bef6d79bde4741809e15aae8e619e569..87d7653145c7982414531be8f0768c7c996d370f 100644 --- a/multiscreen-compositor/qml/main.qml +++ b/multiscreen-compositor/qml/main.qml @@ -55,20 +55,19 @@ import QtQuick.Window 2.3 as Window import QtWayland.Compositor 1.3 import QtQml.Models 2.1 -//import WindowAssignment 1.0 - WaylandCompositor { id: comp property int active_screen: 0 property var activeSurfaces: [] + property var frozenSurfaceIds: [] Instantiator { id: screens model: Qt.application.screens delegate: Screen { - surfaceArea.color: "black" + surfaceArea.color: "limegreen" text: name compositor: comp screen: modelData @@ -171,24 +170,30 @@ WaylandCompositor { //createShellSurfaceItem(shellSurface, moveItem, screens.objectAt(active_screen)); } - - /* - function createShellSurfaceItem(shellSurface, output) { - console.log("createShellSurfaceItem: Creating surface", shellSurface, "on output", output); - cleanUpApplist(); - var item = chromeComponent.createObject(output.surfaceArea, { - "shellSurface": shellSurface, - }); - } - - function handleShellSurfaceCreated(shellSurface) { - console.log("handleShellSurfaceCreated: Adding surface to applist", shellSurface, "on screen", active_screen, - "pid", shellSurface.surface.client.processId); - createShellSurfaceItem(shellSurface, screens.objectAt(active_screen)); - var surfaceOnScreen = ({ 'surface': shellSurface, 'screen': active_screen }); - activeSurfaces.push(surfaceOnScreen); + function getParentScreenId(iviId) + { + for (var i=0; i < activeSurfaces.length; i++) + { + var item = activeSurfaces[i].surface; + console.log("testing active surface", item.shellSurface.iviId, "for potential parenthood"); + if ((item.shellSurface.iviId + 1) === iviId) + { + console.log("Found active parent surface", item.shellSurface.iviId, "on screen", activeSurfaces[i].screen); + return activeSurfaces[i].screen; + } + } + for (i=0; i < frozenSurfaceIds.length; i++) + { + console.log("testing frozen surface id", frozenSurfaceIds[i].id, "for potential parenthood"); + if ((frozenSurfaceIds[i].id + 1) === iviId) + { + console.log("Found dead parent surface id", frozenSurfaceIds[i].id, "on screen", frozenSurfaceIds[i].screen); + return frozenSurfaceIds[i].screen; + } + } + console.log("no parent found for iviId", iviId); + return -1; } - */ function createIviSurfaceItem(iviSurface, output) { console.log("createIviSurfaceItem: surface", iviSurface, "output", output); @@ -209,18 +214,40 @@ WaylandCompositor { console.log("handleIviSurfaceCreated: surface", iviSurface, "id", iviSurface.iviId); cleanUpApplist(); var item; + var screenId = 0; if (screens.count > 1) { - if (iviSurface.iviId > 1999) - item = createIviSurfaceItem(iviSurface, screens.objectAt(1)); + var parentScreenId = getParentScreenId(iviSurface.iviId); + if (parentScreenId >= 0) + { + // associate new surface with parent ID's screen + screenId = parentScreenId; + } else - item = createIviSurfaceItem(iviSurface, screens.objectAt(0)); + { + if (iviSurface.iviId > 1999) +// item = createIviSurfaceItem(iviSurface, screens.objectAt(1)); + screenId = 1; + else +// item = createIviSurfaceItem(iviSurface, screens.objectAt(0)); + screenId = 0; + } } else { - item = createIviSurfaceItem(iviSurface, screens.objectAt(0)); +// item = createIviSurfaceItem(iviSurface, screens.objectAt(0)); + screenId = 0; } + item = createIviSurfaceItem(iviSurface, screens.objectAt(screenId)); - console.log("Add to applist: ", item, "id", iviSurface.iviId); - var surfaceOnScreen = ({ 'surface': item, 'screen': (iviSurface.iviId > 1999) ? 1 : 0 }); + console.log("Created IVI surface: ", item, "id", iviSurface.iviId, "screen", screenId); +// var surfaceOnScreen = ({ 'surface': item, 'screen': (iviSurface.iviId > 1999) ? 1 : 0 }); + var surfaceOnScreen = ({ 'surface': item, 'screen': screenId }); activeSurfaces.push(surfaceOnScreen); + freezeIviId(iviSurface.iviId, screenId); + } + + function freezeIviId(iviId, screen) + { + var frozenSurface = ({ 'id': iviId, 'screen': screen }); + frozenSurfaceIds.push(frozenSurface); } function cleanUpApplist() @@ -239,48 +266,7 @@ WaylandCompositor { // Remove destroyed surface from the suface list // ============================================= onSurfaceAboutToBeDestroyed: { - // Removing this seems to have fixed the crashes. - // no, it didn't. cleanUpApplist(); - //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); - for (var i=0; i < activeSurfaces.length; i++) { - var item = activeSurfaces[i]; - if (item.surface){ - var id; - - if (item.surface.shellSurface){ - id = item.surface.shellSurface.iviId; - console.log("Testing IVI surface", i, id, item.surface) - if( item.surface.shellSurface.surface === surface){ - console.log("Removing IVI surface from list", surface) - activeSurfaces = Array.from(activeSurfaces).filter(e => e !== item) - console.log("Removed surface from Applist:", surface); - } - } - else if ((item.surface.surface) && (item.surface.surface.client.processId)){ - id = item.surface.surface.client.processId; - console.log("Testing XDG surface", i, item.surface) - if( item.surface.surface === surface){ - console.log("Removing XDG surface from list", surface) - activeSurfaces = Array.from(activeSurfaces).filter(e => e !== item) - } - } - else - { - console.log("ERROR! applist index", i, "object has vanished!"); - console.log("Removing lost surface from applist!") - activeSurfaces = Array.from(activeSurfaces).filter((e, idx) => idx !== i) - } - - - }else{ - console.log("surface not defined!", item.surface); - } - } - */ } // ============================================= @@ -313,6 +299,11 @@ WaylandCompositor { item.screen = screen; } } + for (i=0; i < frozenSurfaceIds.length; i++) { + if (surface.shellSurface.iviId === frozenSurfaceIds[i].id) { + frozenSurfaceIds[i].screen = screen; + } + } } // =============================================