mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
Add button to close application windows
This commit is contained in:
parent
5c916daa98
commit
ee7597de7b
3 changed files with 45 additions and 9 deletions
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue