2 * Copyright 2014-2015 Canonical Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 import Ubuntu.Components 1.3
19 import Ubuntu.Gestures 0.1 // For TouchGate
20 import Utils 0.1 // for InputWatcher
21 import Unity.Application 0.1 // for MirSurfaceItem
22 import AccountsService 0.1
26 objectName: "surfaceContainer"
28 property var surface: null
29 property bool hadSurface: false
30 property bool interactive
31 property int surfaceOrientationAngle: 0
32 property string name: surface ? surface.name : ""
33 property bool resizeSurface: true
35 property int requestedWidth: -1
36 property int requestedHeight: -1
38 property string savedKeymap: AccountsService.keymaps[0] // start with the user default
42 surfaceItem.surface = surface;
43 root.hadSurface = false;
44 switchToKeymap(savedKeymap);
48 function switchToKeymap(keymap) {
49 var finalKeymap = keymap.split("+");
50 savedKeymap = keymap; // save the keymap in case the surface changes later
53 surface.setKeymap(finalKeymap[0], finalKeymap[1] || "");
59 onTargetPressedChanged: {
60 if (targetPressed && root.interactive) {
62 root.forceActiveFocus();
69 objectName: "surfaceItem"
71 fillMode: MirSurfaceItem.PadOrCrop
75 if (root.resizeSurface) {
76 if (root.requestedWidth >= 0) {
77 return root.requestedWidth;
87 if (root.resizeSurface) {
88 if (root.requestedHeight >= 0) {
89 return root.requestedHeight;
98 enabled: root.interactive
100 antialiasing: !root.interactive
101 orientationAngle: root.surfaceOrientationAngle
104 // MirSurface size drives SurfaceContainer size
106 target: surfaceItem; property: "width"; value: root.surface ? root.surface.size.width : 0
107 when: root.requestedWidth >= 0 && root.surface
110 target: surfaceItem; property: "height"; value: root.surface ? root.surface.size.height : 0
111 when: root.requestedHeight >= 0 && root.surface
114 target: root; property: "width"; value: surfaceItem.width
115 when: root.requestedWidth >= 0
118 target: root; property: "height"; value: surfaceItem.height
119 when: root.requestedHeight >= 0
122 // SurfaceContainer size drives MirSurface size
124 target: surfaceItem; property: "width"; value: root.width
125 when: root.requestedWidth < 0
128 target: surfaceItem; property: "height"; value: root.height
129 when: root.requestedHeight < 0
134 objectName: "touchGate-"+name
135 targetItem: surfaceItem
137 enabled: surfaceItem.enabled
143 when: surfaceItem.surface && !surfaceItem.live
148 from: ""; to: "zombie"
149 SequentialAnimation {
150 UbuntuNumberAnimation { target: surfaceItem; property: "opacity"; to: 0.0
151 duration: UbuntuAnimation.BriskDuration }
152 PropertyAction { target: surfaceItem; property: "visible"; value: false }
153 ScriptAction { script: {
154 surfaceItem.surface = null;
155 root.hadSurface = true;
160 from: "zombie"; to: ""
161 ScriptAction { script: {
162 surfaceItem.opacity = 1.0;
163 surfaceItem.visible = true;