Commit 724389fa authored by Vishesh Handa's avatar Vishesh Handa

Remove the compositor

Made obsolete by kwin
parent 25ae67d7
......@@ -41,13 +41,6 @@ plasma_install_package(look-and-feel org.kde.plasma.phone look-and-feel)
plasma_install_package(shell org.kde.plasma.phone shells)
install(DIRECTORY wallpaper/ DESTINATION "${WALLPAPER_INSTALL_DIR}/org.kde.plasma.phone.lockers")
install(DIRECTORY compositor/
DESTINATION ${DATA_INSTALL_DIR}/greenisland/org.kde.plasma.phone.compositor
PATTERN .svn EXCLUDE
PATTERN CMakeLists.txt EXCLUDE
PATTERN Messages.sh EXCLUDE
PATTERN dummydata EXCLUDE)
kpackage_install_package(phonebook org.kde.phone.phonebook genericqml)
install(FILES phonebook/metadata.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} RENAME org.kde.phone.phonebook.desktop)
......
/*
* Copyright 2014 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
*
* 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.
*/
import QtQuick 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
WindowWrapper {
id: window
objectName: "clientWindow"
onXChanged: {
if (compositorRoot.currentWindow == window) {
compositorRoot.layers.windows.contentX = x;
}
}
Behavior on y {
enabled: !mouse.active
SequentialAnimation {
NumberAnimation {
easing.type: "InOutQuad"
duration: units.longDuration
}
ScriptAction {
script: {
if (window.opacity < 0.3) {
window.close();
}
}
}
}
}
opacity: 1 - (Math.abs(y) / height)
MouseArea {
id: mouse
z: 99
anchors.fill: parent
enabled: compositorRoot.layers.windows.switchMode
property bool active
onPressed: {
active = true;
}
onClicked: {
compositorRoot.currentWindow = window;
window.child.takeFocus();
}
onReleased: {
active = false;
if (window.opacity < 0.3) {
window.y = (window.y > 0 ? +1 : -1) * window.height;
} else {
window.y = 0;
}
}
drag {
axis: Drag.YAxis
target: window
}
}
}
/*
* Copyright 2014 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
*
* 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.
*/
import QtQuick 2.0
import QtQuick.Layouts 1.0
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
property var currentWindow: null
property var shellWindow: null;
onCurrentWindowChanged: {
if (!currentWindow) {
compositorRoot.state = "homeScreen";
return;
}
compositorRoot.state = "application";
}
id: compositorRoot
color: "black"
state: "homeScreen"
Image {
id: splash
anchors.fill: parent
source: "klogo.png"
sourceSize.width: width
sourceSize.height: height
fillMode: Image.PreserveAspectFit
z: 1000
}
ListModel {
id: surfaceModel
}
Connections {
target: compositor
onSurfaceMapped: WindowManagement.surfaceMapped(surface)
onSurfaceUnmapped: WindowManagement.surfaceUnmapped(surface)
onSurfaceDestroyed: WindowManagement.surfaceDestroyed(surface)
}
QtObject {
readonly property alias desktop: desktopLayer
readonly property alias windows: windowsLayerBackground
readonly property alias panel: panelLayer
readonly property alias keyboard: keyboardLayer
id: layers
}
Item {
id: desktopLayer
anchors.fill: parent
visible: true
}
Rectangle {
id: windowsLayerBackground
anchors {
fill: parent
topMargin: topBarHeight
bottomMargin: bottomBarHeight
}
color: Qt.rgba(0, 0, 0, 0.9)
function addWindow (window) {
window.parent = windowsLayout
}
property bool switchMode: windowsZoom.scale < 1
Item {
id: windowsZoom
anchors.fill: parent
Flickable {
id: windowsLayer
anchors.centerIn: parent
flickableDirection: Flickable.HorizontalFlick
height: windowsZoom.height * 2
width: windowsZoom.width * 2
interactive: windowsLayerBackground.switchMode
contentWidth: windowsLayout.width
contentHeight: windowsLayout.height
MouseArea {
height: windowsLayer.height
width: windowsLayout.width
onClicked: {
compositorRoot.state = "homeScreen";
}
Row {
id: windowsLayout
anchors.centerIn: parent
height: windowsLayerBackground.height
transformOrigin: Item.Left
onChildrenChanged: {
if (children.length == 0) {
compositorRoot.state = "homeScreen";
}
}
}
}
}
}
}
Item {
id: panelLayer
anchors.fill: parent
visible: showPanel
z: 3
}
Item {
id: keyboardLayer
anchors.fill: parent
z: 800
onVisibleChanged: {
if (!visible && compositorRoot.shellWindow) {
compositorRoot.shellWindow.child.takeFocus();
}
}
}
Rectangle {
id: bottomBar
z: 4
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
height: bottomBarHeight
color: Qt.rgba(0, 0, 0, 0.9)
Behavior on height {
NumberAnimation {
easing.type: "InOutQuad"
duration: units.shortDuration
}
}
RowLayout {
anchors.fill: parent
PlasmaCore.IconItem {
colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
width: units.iconSizes.smallMedium
height: width
source: "distribute-horizontal-x"
enabled: compositorRoot.state != "switcher" && windowsLayout.children.length > 0
opacity: enabled ? 1 : 0.2
Layout.alignment: Qt.AlignHCenter
Layout.preferredWidth: units.iconSizes.medium
Layout.preferredHeight: units.iconSizes.medium
MouseArea {
anchors.fill: parent
onClicked: {
compositorRoot.state = "switcher";
}
}
}
PlasmaCore.IconItem {
colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
width: units.iconSizes.smallMedium
height: width
source: "go-home"
enabled: compositorRoot.state != "homeScreen";
opacity: enabled ? 1 : 0.2
Layout.alignment: Qt.AlignHCenter
Layout.preferredWidth: units.iconSizes.medium
Layout.preferredHeight: units.iconSizes.medium
MouseArea {
anchors.fill: parent
onClicked: {
compositorRoot.state = "homeScreen";
}
}
}
PlasmaCore.IconItem {
colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
width: units.iconSizes.smallMedium
height: width
source: "window-close"
enabled: compositorRoot.currentWindow
opacity: enabled ? 1 : 0.2
Layout.alignment: Qt.AlignHCenter
Layout.preferredWidth: units.iconSizes.medium
Layout.preferredHeight: units.iconSizes.medium
MouseArea {
anchors.fill: parent
onClicked: {
compositorRoot.state = "homeScreen";
compositorRoot.currentWindow.close();
}
}
}
}
}
MouseArea {
id: taskSwitchEdge
z: 1000
anchors {
left: parent.left
right: parent.right
bottom: parent.bottom
}
height: 8
enabled: windowsLayout.children.length > 0 && compositorRoot.state != "switcher"
property int oldX: 0
onPressed: {
oldX = mouse.x;
}
onPositionChanged: {
compositorRoot.state = "changing";
compositorRoot.showKeyboard = false;
var newScale = (1-Math.abs(mouse.y)/(compositorRoot.height/2))
if (newScale > 0.3) {
windowsZoom.scale = newScale
}
windowsLayer.contentX -= (mouse.x - oldX);
oldX = mouse.x;
}
onReleased: {
if (windowsZoom.scale > 0.7) {
compositorRoot.state = compositorRoot.currentWindow ? "application" : "homeScreen";
} else {
compositorRoot.state = "switcher";
}
}
}
states: [
State {
name: "homeScreen"
PropertyChanges {
target: windowsLayerBackground
opacity: 0
}
PropertyChanges {
target: windowsZoom
scale: 1
}
},
State {
name: "application"
PropertyChanges {
target: windowsLayerBackground
opacity: 1
}
PropertyChanges {
target: windowsZoom
scale: 1
}
PropertyChanges {
target: windowsLayer
contentX: compositorRoot.currentWindow ? compositorRoot.currentWindow.x - windowsLayerBackground.width/2 : 0
}
},
State {
name: "switcher"
PropertyChanges {
target: windowsLayerBackground
opacity: 1
}
PropertyChanges {
target: windowsZoom
scale: 0.5
}
PropertyChanges {
target: windowsLayer
contentX: compositorRoot.currentWindow ? compositorRoot.currentWindow.x - windowsLayerBackground.width/2 : 0
}
},
State {
name: "changing"
PropertyChanges {
target: windowsLayerBackground
opacity: 1
}
PropertyChanges {
target: windowsLayer
contentX: compositorRoot.currentWindow ? compositorRoot.currentWindow.x - windowsLayerBackground.width/2 : 0
}
}
]
transitions: [
Transition {
to: "changing"
SequentialAnimation {
ScriptAction {
script: {
desktopLayer.z = 1
windowsLayerBackground.z = 800
}
}
PropertyAnimation {
target: windowsLayerBackground
duration: units.longDuration
easing.type: Easing.InOutQuad
properties: "opacity"
}
}
},
Transition {
SequentialAnimation {
ParallelAnimation {
PropertyAnimation {
target: windowsLayerBackground
duration: units.longDuration
easing.type: Easing.InOutQuad
properties: "opacity"
}
PropertyAnimation {
target: windowsZoom
duration: units.shortDuration
easing.type: Easing.InOutQuad
properties: "scale"
}
PropertyAnimation {
target: windowsLayer
duration: units.shortDuration
easing.type: Easing.InOutQuad
properties: "contentX"
}
}
ScriptAction {
script: {
if (compositorRoot.state == "homeScreen") {
desktopLayer.z = 2;
windowsLayerBackground.z = 1;
compositorRoot.currentWindow = null;
} else {
desktopLayer.z = 1;
windowsLayerBackground.z = 800;
if (compositorRoot.currentWindow) {
compositorRoot.currentWindow.child.takeFocus();
}
}
}
}
}
}
]
}
/*
* Copyright 2014 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
*
* 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.
*/
import QtQuick 2.0
WindowWrapper {
objectName: "shellWindow"
}
/*
* Copyright 2014 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
*
* 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) {
// Determine if it's a shell window
var firstView = compositor.firstViewOf(surface);
var isShellWindow =
(typeof(firstView.role) != "undefined") ||
(surface.className == "plasmashell.desktop");
// Print some information
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);
} else {
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);
}
if (surface.className == "maliit-server.desktop") {
mapKeyboardSurface(surface);
// Call a specialized method to deal with application or
// shell windows
} else if (isShellWindow)
mapShellSurface(surface, firstView);
else
mapApplicationSurface(surface);
}
function surfaceUnmapped(surface) {
// Determine if it's a shell window
var firstView = compositor.firstViewOf(surface);
var isShellWindow =
(typeof(firstView.role) != "undefined") ||
(surface.className == "plasmashell.desktop");
// Print some information
if (typeof(firstView.role) == "undefined") {
console.debug("Shell surface", surface, "unmapped");
console.debug("\trole:", firstView.role);
console.debug("\tsize:", surface.size.width + "x" + surface.size.height);
} else {
console.debug("Application surface", surface, "unmapped");
console.debug("\tappId:", surface.className);
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
} else if (isShellWindow)
unmapShellSurface(surface);
else
unmapApplicationSurface(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) {
// Ask the client to resize
surface.requestSize(window.parent.width, window.parent.height);
return;
}
}
// Create surface item
var component = Qt.createComponent("ClientWindowWrapper.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);
child.resizeSurfaceToItem = true;
child.width = compositorRoot.layers.windows.width;
child.height = compositorRoot.layers.windows.height;
// Create and setup window container
var window = component.createObject(compositorRoot.layers.windows, {"child": child});
compositorRoot.layers.windows.addWindow(window);
window.child.parent = window;
window.child.touchEventsEnabled = true;
window.width = surface.size.width;
window.height = surface.size.height;
// Switch to the applications layer and take focus
compositorRoot.state = "application";
compositorRoot.currentWindow = window;
window.child.takeFocus();
// 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;
// Just set z-index and 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) {
// Switch to layer and take focus
if (surface.className == "plasmashell.desktop") {
compositorRoot.showPanel = true;
} else {
compositorRoot.state = "homeScreen";
}
entry.window.child.takeFocus();
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
// XXX: We only support desktop roles for now
var window = component.createObject(compositorRoot, {"child": child});
window.parent = (surface.className == "plasmashell.desktop") ? compositorRoot.layers.panel : compositorRoot.layers.desktop;
window.child.parent = window;
window.child.touchEventsEnabled = true;
window.x = window.y = 0;
window.width = surface.size.width;
window.height = surface.size.height;
// Switch to the desktop layer and take focus
compositorRoot.showSplash = false;
if (surface.className == "plasmashell.desktop") {
compositorRoot.showPanel = true;
} else {
compositorRoot.state = "homeScreen";
compositorRoot.shellWindow = window;
}
window.child.takeFocus();
// Add surface to the model
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) {
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