diff --git a/compositor/contents/Compositor.qml b/compositor/contents/Compositor.qml index 5e086764..69150147 100644 --- a/compositor/contents/Compositor.qml +++ b/compositor/contents/Compositor.qml @@ -23,10 +23,10 @@ import QtQml.Models 2.1 import org.kde.plasma.core 2.0 as PlasmaCore import "WindowManagement.js" as WindowManagement - Rectangle { property alias showSplash: splash.visible property bool showPanel: true + property alias showKeyboard: keyboardLayer.visible readonly property alias layers: layers readonly property real topBarHeight: units.iconSizes.small readonly property real bottomBarHeight: units.iconSizes.medium @@ -69,6 +69,7 @@ Rectangle { readonly property alias desktop: desktopLayer readonly property alias windows: windowsLayer readonly property alias panel: panelLayer + readonly property alias keyboard: keyboardLayer id: layers } @@ -128,12 +129,18 @@ Rectangle { id: panelLayer anchors.fill: parent visible: showPanel - z: 4 + z: 3 + } + + Item { + id: keyboardLayer + anchors.fill: parent + z: 5 } Rectangle { id: bottomBar - z: 3 + z: 4 anchors.left: parent.left anchors.right: parent.right anchors.bottom: parent.bottom diff --git a/compositor/contents/WindowManagement.js b/compositor/contents/WindowManagement.js index 0a3df907..cec90f61 100644 --- a/compositor/contents/WindowManagement.js +++ b/compositor/contents/WindowManagement.js @@ -26,11 +26,15 @@ function surfaceMapped(surface) { var firstView = compositor.firstViewOf(surface); var isShellWindow = (typeof(firstView.role) != "undefined") || - (surface.className == "plasmashell.desktop") || - (surface.className == "maliit-server.desktop"); + (surface.className == "plasmashell.desktop"); // Print some information - if (isShellWindow) { + if (surface.className == "maliit-server.desktop") { + console.debug("Keyboard surface", surface, "mapped"); + console.debug("\tappId:", surface.className); + console.debug("\ttitle:", surface.title); + console.debug("\tsize:", surface.size.width + "x" + surface.size.height); + } else if (isShellWindow) { console.debug("Shell surface", surface, "mapped"); console.debug("\trole:", firstView.role); console.debug("\tsize:", surface.size.width + "x" + surface.size.height); @@ -41,9 +45,11 @@ function surfaceMapped(surface) { console.debug("\tsize:", surface.size.width + "x" + surface.size.height); } + if (surface.className == "maliit-server.desktop") { + mapKeyboardSurface(surface); // Call a specialized method to deal with application or // shell windows - if (isShellWindow) + } else if (isShellWindow) mapShellSurface(surface, firstView); else mapApplicationSurface(surface); @@ -54,8 +60,7 @@ function surfaceUnmapped(surface) { var firstView = compositor.firstViewOf(surface); var isShellWindow = (typeof(firstView.role) != "undefined") || - (surface.className == "plasmashell.desktop") || - (surface.className == "maliit-server.desktop"); + (surface.className == "plasmashell.desktop"); // Print some information if (typeof(firstView.role) == "undefined") { @@ -68,9 +73,12 @@ function surfaceUnmapped(surface) { console.debug("\ttitle:", surface.title); } + //Is it maliit? + if (surface.className == "maliit-server.desktop") { + unmapKeyboardSurface(surface); // Call a specialized method to deal with application or // shell windows - if (isShellWindow) + } else if (isShellWindow) unmapShellSurface(surface); else unmapApplicationSurface(surface); @@ -215,6 +223,52 @@ function mapShellSurface(surface, child) { surfaceModel.append({"surface": surface, "window": window}); } +function mapKeyboardSurface(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) { + if (compositorRoot.currentWindow) { + compositorRoot.currentWindow.child.height = compositorRoot.layers.windows.height - 500; + } + compositorRoot.showKeyboard = true; + + return; + } + } + + // Create surface item + var component = Qt.createComponent("ShellWindowWrapper.qml"); + if (component.status !== Component.Ready) { + console.error(component.errorString()); + return; + } + + // 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.layers.keyboard, {"child": child}); + window.parent = compositorRoot.layers.keyboard; + window.child.parent = window; + window.child.touchEventsEnabled = true; + window.width = surface.size.width; + window.height = surface.size.height; + window.y = compositorRoot.layers.keyboard.height - window.height; + + if (compositorRoot.currentWindow) { + compositorRoot.currentWindow.child.height = compositorRoot.layers.windows.height - 500; + } + + // Add surface to the model + surfaceModel.append({"surface": surface, "window": window}); + compositorRoot.showKeyboard = true; +} + + /* * Unmap surfaces */ @@ -234,3 +288,11 @@ function unmapShellSurface(surface) { compositorRoot.showPanel = false; } } + +function unmapShellSurface(surface) { + if (compositorRoot.currentWindow) { + compositorRoot.currentWindow.child.height = compositorRoot.layers.windows.height; + } + + compositorRoot.showKeyboard = false; +}