Skip to content
Snippets Groups Projects
Commit 51557a6a authored by Alexander Tuxen's avatar Alexander Tuxen Committed by Felix Gerking
Browse files

fixed hanging on unknown compositor-message and added feature to open new...

fixed hanging on unknown compositor-message and added feature to open new surfaces on the same screen as their parents, even if they have been moved or destroyed by then.
parent 19670b60
No related branches found
No related tags found
1 merge request!48Rework Compositor
...@@ -34,6 +34,7 @@ void CompositorMessages::messageReceived(QString message, quint32 windowId, quin ...@@ -34,6 +34,7 @@ void CompositorMessages::messageReceived(QString message, quint32 windowId, quin
emit sendStatus(screenId); emit sendStatus(screenId);
}else{ }else{
qWarning() << "Unknown message received: " << message; qWarning() << "Unknown message received: " << message;
emit sendStatus(-1);
} }
} }
......
...@@ -55,20 +55,19 @@ import QtQuick.Window 2.3 as Window ...@@ -55,20 +55,19 @@ import QtQuick.Window 2.3 as Window
import QtWayland.Compositor 1.3 import QtWayland.Compositor 1.3
import QtQml.Models 2.1 import QtQml.Models 2.1
//import WindowAssignment 1.0
WaylandCompositor { WaylandCompositor {
id: comp id: comp
property int active_screen: 0 property int active_screen: 0
property var activeSurfaces: [] property var activeSurfaces: []
property var frozenSurfaceIds: []
Instantiator { Instantiator {
id: screens id: screens
model: Qt.application.screens model: Qt.application.screens
delegate: Screen { delegate: Screen {
surfaceArea.color: "black" surfaceArea.color: "limegreen"
text: name text: name
compositor: comp compositor: comp
screen: modelData screen: modelData
...@@ -171,24 +170,30 @@ WaylandCompositor { ...@@ -171,24 +170,30 @@ WaylandCompositor {
//createShellSurfaceItem(shellSurface, moveItem, screens.objectAt(active_screen)); //createShellSurfaceItem(shellSurface, moveItem, screens.objectAt(active_screen));
} }
function getParentScreenId(iviId)
/* {
function createShellSurfaceItem(shellSurface, output) { for (var i=0; i < activeSurfaces.length; i++)
console.log("createShellSurfaceItem: Creating surface", shellSurface, "on output", output); {
cleanUpApplist(); var item = activeSurfaces[i].surface;
var item = chromeComponent.createObject(output.surfaceArea, { console.log("testing active surface", item.shellSurface.iviId, "for potential parenthood");
"shellSurface": shellSurface, if ((item.shellSurface.iviId + 1) === iviId)
}); {
} console.log("Found active parent surface", item.shellSurface.iviId, "on screen", activeSurfaces[i].screen);
return activeSurfaces[i].screen;
function handleShellSurfaceCreated(shellSurface) { }
console.log("handleShellSurfaceCreated: Adding surface to applist", shellSurface, "on screen", active_screen, }
"pid", shellSurface.surface.client.processId); for (i=0; i < frozenSurfaceIds.length; i++)
createShellSurfaceItem(shellSurface, screens.objectAt(active_screen)); {
var surfaceOnScreen = ({ 'surface': shellSurface, 'screen': active_screen }); console.log("testing frozen surface id", frozenSurfaceIds[i].id, "for potential parenthood");
activeSurfaces.push(surfaceOnScreen); 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) { function createIviSurfaceItem(iviSurface, output) {
console.log("createIviSurfaceItem: surface", iviSurface, "output", output); console.log("createIviSurfaceItem: surface", iviSurface, "output", output);
...@@ -209,18 +214,40 @@ WaylandCompositor { ...@@ -209,18 +214,40 @@ WaylandCompositor {
console.log("handleIviSurfaceCreated: surface", iviSurface, "id", iviSurface.iviId); console.log("handleIviSurfaceCreated: surface", iviSurface, "id", iviSurface.iviId);
cleanUpApplist(); cleanUpApplist();
var item; var item;
var screenId = 0;
if (screens.count > 1) { if (screens.count > 1) {
if (iviSurface.iviId > 1999) var parentScreenId = getParentScreenId(iviSurface.iviId);
item = createIviSurfaceItem(iviSurface, screens.objectAt(1)); if (parentScreenId >= 0)
{
// associate new surface with parent ID's screen
screenId = parentScreenId;
}
else 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 { } 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); 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': (iviSurface.iviId > 1999) ? 1 : 0 });
var surfaceOnScreen = ({ 'surface': item, 'screen': screenId });
activeSurfaces.push(surfaceOnScreen); activeSurfaces.push(surfaceOnScreen);
freezeIviId(iviSurface.iviId, screenId);
}
function freezeIviId(iviId, screen)
{
var frozenSurface = ({ 'id': iviId, 'screen': screen });
frozenSurfaceIds.push(frozenSurface);
} }
function cleanUpApplist() function cleanUpApplist()
...@@ -239,48 +266,7 @@ WaylandCompositor { ...@@ -239,48 +266,7 @@ WaylandCompositor {
// Remove destroyed surface from the suface list // Remove destroyed surface from the suface list
// ============================================= // =============================================
onSurfaceAboutToBeDestroyed: { onSurfaceAboutToBeDestroyed: {
// Removing this seems to have fixed the crashes.
// no, it didn't.
cleanUpApplist(); 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 { ...@@ -313,6 +299,11 @@ WaylandCompositor {
item.screen = screen; item.screen = screen;
} }
} }
for (i=0; i < frozenSurfaceIds.length; i++) {
if (surface.shellSurface.iviId === frozenSurfaceIds[i].id) {
frozenSurfaceIds[i].screen = screen;
}
}
} }
// ============================================= // =============================================
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment