diff --git a/multiscreen-compositor/compositor-messages.cpp b/multiscreen-compositor/compositor-messages.cpp index 07a9adc0edf04922fca609fa9a6a55c6f8cc69be..8f44b5fb72d59edbc547fcb1bcad1363b0241a14 100644 --- a/multiscreen-compositor/compositor-messages.cpp +++ b/multiscreen-compositor/compositor-messages.cpp @@ -12,6 +12,7 @@ void CompositorMessages::messageReceived(QString message, quint32 windowId, quin if(message == "moveWindowToScreen"){ emit moveWindowToScreen(windowId, screenId); + emit sendStatus(screenId); }else if(message == "hideWindow"){ emit hideWindow(windowId); diff --git a/multiscreen-compositor/main.cpp b/multiscreen-compositor/main.cpp index 26fd0cbe649387b756ff1e9de880e4ba0e49f6b6..555506f44dd638af3e55d852d4a73fc2fcefaea7 100644 --- a/multiscreen-compositor/main.cpp +++ b/multiscreen-compositor/main.cpp @@ -100,15 +100,5 @@ int main(int argc, char *argv[]) appEngine.rootContext()->setContextProperty("commands", &commands); appEngine.load(QUrl("qrc:///qml/main.qml")); - /* - QQmlEngine engine; - QQmlComponent component(&engine, QUrl("qrc:///qml/main.qml"), nullptr); - QObject *object = component.create(); - - QObject *object = appEngine.rootObjects().constFirst()->findChild<QObject *>("screenSignal"); - QObject::connect(object, SIGNAL(sendStatus(int)), - &commands, SLOT(screenInfoReceived(int))); - */ - return app.exec(); } diff --git a/multiscreen-compositor/message-server.cpp b/multiscreen-compositor/message-server.cpp index 532be30787a608251a17897e3a6514f27a088bbd..e75ab0c9c89b605127479324b9bda226c19c5897 100644 --- a/multiscreen-compositor/message-server.cpp +++ b/multiscreen-compositor/message-server.cpp @@ -52,7 +52,6 @@ void MessageServer::handleConnection() MessageServerConnection *c = new MessageServerConnection(server->nextPendingConnection(), this); connect(c, &MessageServerConnection::disconnected, this, &MessageServer::connectionGone); connect(c, &MessageServerConnection::newMessage, this, &MessageServer::messageReceived); - //connect(c, &MessageServerConnection::newMessage, this, &MessageServer::messageReceived); connect(this, &MessageServer::sendStatus, c, &MessageServerConnection::sendStatus); connections.append(c); } diff --git a/multiscreen-compositor/qml/main.qml b/multiscreen-compositor/qml/main.qml index 822ad06542b13ac324799240fc5842b23afa5a4e..b8255568a1e01afa20d7b8b32fa0a878de476f2b 100644 --- a/multiscreen-compositor/qml/main.qml +++ b/multiscreen-compositor/qml/main.qml @@ -128,6 +128,7 @@ WaylandCompositor { function createShellSurfaceItem(shellSurface, output) { console.log("createShellSurfaceItem: Creating surface", shellSurface, "on output", output); + cleanUpApplist(); var item = chromeComponent.createObject(output.surfaceArea, { "shellSurface": shellSurface, }); @@ -158,6 +159,7 @@ WaylandCompositor { // if more than one screen is present. // If the unique ivi id is greater or equal 2000 we select screen 2 console.log("handleIviSurfaceCreated: surface", iviSurface, "id", iviSurface.iviId); + cleanUpApplist(); var item; if (screens.count > 1) { if (iviSurface.iviId > 1999) @@ -169,14 +171,27 @@ WaylandCompositor { } console.log("Add to applist: ", item, "id", iviSurface.iviId); - var surfaceOnScreen = ({ 'surface': item, 'screen': active_screen }); + var surfaceOnScreen = ({ 'surface': item, 'screen': (iviSurface.iviId > 1999) ? 1 : 0 }); activeSurfaces.push(surfaceOnScreen); } + function cleanUpApplist() + { + for (var i=0; i < activeSurfaces.length; i++) { + var item = activeSurfaces[i]; + if ((!item.surface.shellSurface) && (!item.surface.surface)) + { + console.log("Removing lost surface from applist!") + activeSurfaces = Array.from(activeSurfaces).filter((e, idx) => idx !== i) + } + } + } + // ============================================= // Remove destroyed surface from the suface list // ============================================= onSurfaceAboutToBeDestroyed: { + /* console.log("Surface will be destroyed", surface); console.log("appList length: ", activeSurfaces.length); for (var i=0; i < activeSurfaces.length; i++) { @@ -213,6 +228,7 @@ WaylandCompositor { console.log("surface not defined!", item.surface); } } + */ } // ============================================= @@ -222,12 +238,12 @@ WaylandCompositor { console.log("Lookung for surface with id", id); for (var i=0; i < activeSurfaces.length; i++) { var item = activeSurfaces[i]; - if( id === item.surface.shellSurface.iviId){ + if ((item.surface.shellSurface) && ( id === item.surface.shellSurface.iviId)) { console.log("found IVI Shell Surface", i, id, item.surface.shellSurface, item.surface.shellSurface.surface) return item.surface; } - else if( id === item.surface.surface.client.processId){ - console.log("found XDG Shell Surface", i, id, item.surface.shellSurface, item.surface.shellSurface.surface) + else if ((item.surface.surface) && ( id === item.surface.surface.client.processId)) { + console.log("found XDG Shell Surface", i, id, item.surface) return item.surface; } } @@ -235,6 +251,17 @@ WaylandCompositor { return; } + function updateScreenAssignment(surface, screen) + { + console.log("Updating screen for surface", surface); + for (var i=0; i < activeSurfaces.length; i++) { + var item = activeSurfaces[i]; + if (surface === item.surface) { + item.screen = screen; + } + } + } + // ============================================= // Handle the signals emmitted by the external // compositor commands class @@ -255,11 +282,15 @@ WaylandCompositor { console.log("Move", surface, "to screen", screenid) surface.parent = screens.objectAt(screenid).surfaceArea; + updateScreenAssignment(surface, screenid); } function windowVisibility(windowid, show){ var surface = findSurfaceById(windowid) if( !surface ) return; + if (surface.shellSurface){ + console.log("Set visable to", show,"for", surface.shellSurface) + } console.log("Set visable to", show,"for", surface) surface.visible = show } @@ -286,10 +317,14 @@ WaylandCompositor { for (var i=0; i < activeSurfaces.length; i++) { var item = activeSurfaces[i]; if (item.surface) { - if( windowid === item.surface.surface.client.processId){ + if ((item.surface.surface) && ( windowid === item.surface.surface.client.processId)) { console.log("Surface", i, item.surface, "pid", item.surface.surface.client.processId, "on screen", item.screen) screenId = item.screen; } + else if ((item.surface.shellSurface) && ( windowid === item.surface.shellSurface.iviId)) { + console.log("Surface", i, item.surface, "on screen", item.screen) + screenId = item.screen; + } } }