/* * Copyright 2014 Pier Luigi Fiorini * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* * Main procedures */ function surfaceMapped(surface) { // Get the first view and if it has a role property than this // is definitely a shell window var firstView = compositor.firstViewOf(surface); if (typeof(firstView.role) == "undefined") { console.debug("Application surface", surface, "mapped"); console.debug("\tappId:", surface.className); console.debug("\ttitle:", surface.title); console.debug("\tsize:", surface.size.width + "x" + surface.size.height); } else { console.debug("Shell surface", surface, "mapped"); console.debug("\trole:", firstView.role); console.debug("\tsize:", surface.size.width + "x" + surface.size.height); } // Call a specialized method to deal with application or // shell windows if (typeof(firstView.role) == "undefined") mapApplicationSurface(surface); else mapShellSurface(surface, firstView); } function surfaceUnmapped(surface) { // Get the first view and if it has a role property than this // is definitely a shell window var firstView = compositor.firstViewOf(surface); if (typeof(firstView.role) == "undefined") { console.debug("Application surface", surface, "unmapped"); console.debug("\tappId:", surface.className); console.debug("\ttitle:", surface.title); } else { console.debug("Shell surface", surface, "unmapped"); console.debug("\trole:", firstView.role); console.debug("\tsize:", surface.size.width + "x" + surface.size.height); } // Call a specialized method to deal with application or // shell windows if (typeof(firstView.role) == "undefined") unmapApplicationSurface(surface); else unmapShellSurface(surface); } function surfaceDestroyed(surface) { console.debug("Surface", surface, "destroyed"); // Remove surface from model var i; for (i = 0; i < surfaceModel.count; i++) { var entry = surfaceModel.get(i); if (entry.surface === surface) { // Destroy window representation and // remove the surface from the model if (entry.window.chrome) entry.window.chrome.destroy(); entry.window.destroy(); surfaceModel.remove(i, 1); break; } } } /* * Map surfaces */ function mapApplicationSurface(surface) { // Just exit if we already created a window representation var i; for (i = 0; i < surfaceModel.count; i++) { var entry = surfaceModel.get(i); if (entry.surface === surface) return; } // Create surface item var component = Qt.createComponent("ClientWindowWrapper.qml"); if (component.status !== Component.Ready) { console.error(component.errorString()); return; } // Window position: y is hard coded to the top bar height var pos = Qt.point(0, compositorRoot.topBarHeight); // Request a view for this output although with phones will // likely have just one output var child = compositor.viewForOutput(surface, _greenisland_output); // Create and setup window container var window = component.createObject(compositorRoot, {"child": child}); window.child.parent = window; window.child.touchEventsEnabled = true; window.width = surface.size.width; window.height = surface.size.height; // Move window window.x = pos.x; window.y = pos.y; // Reparent and give focus window.parent = compositorRoot.layers.windows; window.child.takeFocus(); // Set size to parent (windows layer) window.child.resizeSurfaceToItem = true; window.width = window.parent.width; window.height = window.parent.height; // Log coordinates for debugging purpose console.debug("\tposition:", window.x + "," + window.y); // Run map animation if (typeof(window.runMapAnimation) != "undefined") window.runMapAnimation(); // Add surface to the model surfaceModel.append({"surface": surface, "window": window}); } function mapShellSurface(surface, child) { // Shell surfaces have only one view which is passed to us // as an argument, check whether it's a view for this output // or not if (child.output !== _greenisland_output) return; // Create surface item var component = Qt.createComponent("ShellWindowWrapper.qml"); if (component.status !== Component.Ready) { console.error(component.errorString()); return; } // Create and setup window container var window = component.createObject(compositorRoot, {"child": child}); window.child.parent = window; window.child.touchEventsEnabled = true; window.width = surface.size.width; window.height = surface.size.height; // Set initial position // XXX: We only support desktop roles for now window.x = window.y = 0; // Set appropriate parent // XXX: We only support desktop roles for now window.parent = compositorRoot.layers.desktop; // Log coordinates for debugging purpose console.debug("\tposition:", window.x + "," + window.y); // Add surface to the model surfaceModel.append({"surface": surface, "window": window}); } /* * Unmap surfaces */ function unmapApplicationSurface(surface) { } function unmapShellSurface(surface) { }