Commit ee7597de authored by Pier Luigi Fiorini's avatar Pier Luigi Fiorini

Add button to close application windows

parent 5c916daa
......@@ -18,6 +18,7 @@
*/
import QtQuick 2.0
import QtQuick.Layouts 1.0
import org.kde.plasma.core 2.0 as PlasmaCore
import "WindowManagement.js" as WindowManagement
......@@ -27,6 +28,7 @@ Rectangle {
readonly property alias layers: layers
readonly property real topBarHeight: units.iconSizes.small
readonly property real bottomBarHeight: units.iconSizes.medium
property var currentWindow: null
id: compositorRoot
color: "black"
......@@ -89,16 +91,40 @@ Rectangle {
}
}
PlasmaCore.IconItem {
anchors.centerIn: parent
colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
width: units.iconSizes.smallMedium
height: width
source: "go-home"
ColumnLayout {
anchors.fill: parent
MouseArea {
anchors.fill: parent
onClicked: showHome = true
PlasmaCore.IconItem {
colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
width: units.iconSizes.smallMedium
height: width
source: "window-close"
Layout.alignment: Qt.AlignHCenter
MouseArea {
anchors.fill: parent
onClicked: {
if (currentWindow) {
currentWindow.close();
currentWindow = null;
}
}
}
}
PlasmaCore.IconItem {
colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
width: units.iconSizes.smallMedium
height: width
source: "go-home"
Layout.alignment: Qt.AlignHCenter
MouseArea {
anchors.fill: parent
onClicked: showHome = true
}
}
}
}
......
......@@ -131,6 +131,7 @@ function mapApplicationSurface(surface) {
// Switch to the applications layer and take focus
compositorRoot.showHome = false;
compositorRoot.currentWindow = window;
window.child.takeFocus();
// Run map animation
......@@ -160,6 +161,7 @@ function mapShellSurface(surface, child) {
// Switch to the desktop layer and take focus
compositorRoot.showHome = true;
compositorRoot.currentWindow = null;
entry.window.child.takeFocus();
return;
......@@ -202,6 +204,7 @@ function mapShellSurface(surface, child) {
function unmapApplicationSurface(surface) {
// Reactivate home layer as soon as an application window is unmapped
compositorRoot.showHome = true;
compositorRoot.currentWindow = null;
}
function unmapShellSurface(surface) {
......
......@@ -37,4 +37,11 @@ Item {
anchors.fill: parent
source: child
}
function close() {
if (!child || !child.surface)
return;
child.surface.client.close();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment