2 * Copyright (C) 2014-2017 Canonical Ltd.
3 * Copyright (C) 2021 UBports Foundation
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 3.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19import QtQuick.Window 2.2
20import Lomiri.Components 1.3
21import QtMir.Application 0.1
22import "../Components/PanelState"
25import Lomiri.Gestures 0.1
26import GlobalShortcut 1.0
29import "Spread/MathUtils.js" as MathUtils
30import WindowManager 1.0
36 property QtObject applicationManager
37 property QtObject topLevelSurfaceList
38 property bool altTabPressed
39 property url background
40 property alias backgroundSourceSize: wallpaper.sourceSize
41 property int dragAreaWidth
42 property real nativeHeight
43 property real nativeWidth
44 property QtObject orientations
45 property int shellOrientation
46 property int shellOrientationAngle
47 property bool spreadEnabled: true // If false, animations and right edge will be disabled
48 property bool suspended
49 property bool oskEnabled: false
50 property rect inputMethodRect
51 property real rightEdgePushProgress: 0
52 property Item availableDesktopArea
53 property PanelState panelState
55 // Whether outside forces say that the Stage may have focus
56 property bool allowInteractivity
58 readonly property bool interactive: (state === "staged" || state === "stagedWithSideStage" || state === "windowed") && allowInteractivity
61 property string mode: "staged"
63 readonly property var temporarySelectedWorkspace: state == "spread" ? screensAndWorkspaces.activeWorkspace : null
64 property bool workspaceEnabled: (mode == "windowed" && settings.enableWorkspace) || settings.forceEnableWorkspace
66 // Used by the tutorial code
67 readonly property real rightEdgeDragProgress: rightEdgeDragArea.dragging ? rightEdgeDragArea.progress : 0 // How far left the stage has been dragged
69 // used by the snap windows (edge maximize) feature
70 readonly property alias previewRectangle: fakeRectangle
72 readonly property bool spreadShown: state == "spread"
73 readonly property var mainApp: priv.focusedAppDelegate ? priv.focusedAppDelegate.application : null
75 // application windows never rotate independently
76 property int mainAppWindowOrientationAngle: shellOrientationAngle
78 property bool orientationChangesEnabled: !priv.focusedAppDelegate || priv.focusedAppDelegate.orientationChangesEnabled
80 property int supportedOrientations: {
84 return mainApp.supportedOrientations;
85 case "stagedWithSideStage":
86 var orientations = mainApp.supportedOrientations;
87 orientations |= Qt.LandscapeOrientation | Qt.InvertedLandscapeOrientation;
88 if (priv.sideStageItemId) {
89 // If we have a sidestage app, support Portrait orientation
90 // so that it will switch the sidestage app to mainstage on rotate to portrait
91 orientations |= Qt.PortraitOrientation|Qt.InvertedPortraitOrientation;
97 return Qt.PortraitOrientation |
98 Qt.LandscapeOrientation |
99 Qt.InvertedPortraitOrientation |
100 Qt.InvertedLandscapeOrientation;
105 schema.id: "com.lomiri.Shell"
108 property int launcherLeftMargin : 0
111 target: topLevelSurfaceList
112 property: "rootFocus"
116 onInteractiveChanged: {
117 // Stage must have focus before activating windows, including null
123 onAltTabPressedChanged: {
126 if (root.spreadEnabled) {
127 altTabDelayTimer.start();
130 // Alt Tab has been released, did we already go to spread?
131 if (priv.goneToSpread) {
132 priv.goneToSpread = false;
134 // No we didn't, do a quick alt-tab
135 if (appRepeater.count > 1) {
136 appRepeater.itemAt(1).activate();
137 } else if (appRepeater.count > 0) {
138 appRepeater.itemAt(0).activate(); // quick alt-tab to the only (minimized) window should still activate it
149 if (root.altTabPressed) {
150 priv.goneToSpread = true;
155 // For MirAL window management
157 normal: Qt.rect(0, root.mode === "windowed" ? priv.windowDecorationHeight : 0, 0, 0)
161 property Item itemConfiningMouseCursor: !spreadShown && priv.focusedAppDelegate && priv.focusedAppDelegate.window.confinesMousePointer ?
162 priv.focusedAppDelegate.clientAreaItem : null;
164 signal itemSnapshotRequested(Item item)
166 // functions to be called from outside
167 function updateFocusedAppOrientation() { /* TODO */ }
168 function updateFocusedAppOrientationAnimated() { /* TODO */}
170 function closeSpread() {
171 spreadItem.highlightedIndex = -1;
172 priv.goneToSpread = false;
175 onSpreadEnabledChanged: {
176 if (!spreadEnabled && spreadShown) {
181 onRightEdgePushProgressChanged: {
182 if (spreadEnabled && rightEdgePushProgress >= 1) {
183 priv.goneToSpread = true
188 id: lifecycleExceptions
189 schema.id: "com.canonical.qtmir"
192 function isExemptFromLifecycle(appId) {
193 var shortAppId = appId.split('_')[0];
194 for (var i = 0; i < lifecycleExceptions.lifecycleExemptAppids.length; i++) {
195 if (shortAppId === lifecycleExceptions.lifecycleExemptAppids[i]) {
203 id: closeFocusedShortcut
204 shortcut: Qt.AltModifier|Qt.Key_F4
206 if (priv.focusedAppDelegate) {
207 priv.focusedAppDelegate.close();
213 id: showSpreadShortcut
214 shortcut: Qt.MetaModifier|Qt.Key_W
215 active: root.spreadEnabled
216 onTriggered: priv.goneToSpread = true
220 id: minimizeAllShortcut
221 shortcut: Qt.MetaModifier|Qt.ControlModifier|Qt.Key_D
222 onTriggered: priv.minimizeAllWindows()
223 active: root.state == "windowed"
227 id: maximizeWindowShortcut
228 shortcut: Qt.MetaModifier|Qt.ControlModifier|Qt.Key_Up
229 onTriggered: priv.focusedAppDelegate.requestMaximize()
230 active: root.state == "windowed" && priv.focusedAppDelegate && priv.focusedAppDelegate.canBeMaximized
234 id: maximizeWindowLeftShortcut
235 shortcut: Qt.MetaModifier|Qt.ControlModifier|Qt.Key_Left
236 onTriggered: priv.focusedAppDelegate.requestMaximizeLeft()
237 active: root.state == "windowed" && priv.focusedAppDelegate && priv.focusedAppDelegate.canBeMaximizedLeftRight
241 id: maximizeWindowRightShortcut
242 shortcut: Qt.MetaModifier|Qt.ControlModifier|Qt.Key_Right
243 onTriggered: priv.focusedAppDelegate.requestMaximizeRight()
244 active: root.state == "windowed" && priv.focusedAppDelegate && priv.focusedAppDelegate.canBeMaximizedLeftRight
248 id: minimizeRestoreShortcut
249 shortcut: Qt.MetaModifier|Qt.ControlModifier|Qt.Key_Down
251 if (priv.focusedAppDelegate.anyMaximized) {
252 priv.focusedAppDelegate.requestRestore();
254 priv.focusedAppDelegate.requestMinimize();
257 active: root.state == "windowed" && priv.focusedAppDelegate
261 shortcut: Qt.AltModifier|Qt.Key_Print
262 onTriggered: root.itemSnapshotRequested(priv.focusedAppDelegate)
263 active: priv.focusedAppDelegate !== null
267 shortcut: Qt.ControlModifier|Qt.AltModifier|Qt.Key_T
269 // try in this order: snap pkg, new deb name, old deb name
270 var candidates = ["lomiri-terminal-app_lomiri-terminal-app", "lomiri-terminal-app", "com.lomiri.terminal_terminal"];
271 for (var i = 0; i < candidates.length; i++) {
272 if (priv.startApp(candidates[i]))
279 id: showWorkspaceSwitcherShortcutLeft
280 shortcut: Qt.AltModifier|Qt.ControlModifier|Qt.Key_Left
281 active: !workspaceSwitcher.active
284 workspaceSwitcher.showLeft()
288 id: showWorkspaceSwitcherShortcutRight
289 shortcut: Qt.AltModifier|Qt.ControlModifier|Qt.Key_Right
290 active: !workspaceSwitcher.active
293 workspaceSwitcher.showRight()
297 id: showWorkspaceSwitcherShortcutUp
298 shortcut: Qt.AltModifier|Qt.ControlModifier|Qt.Key_Up
299 active: !workspaceSwitcher.active
302 workspaceSwitcher.showUp()
306 id: showWorkspaceSwitcherShortcutDown
307 shortcut: Qt.AltModifier|Qt.ControlModifier|Qt.Key_Down
308 active: !workspaceSwitcher.active
311 workspaceSwitcher.showDown()
317 objectName: "DesktopStagePrivate"
319 function startApp(appId) {
320 if (root.applicationManager.findApplication(appId)) {
321 return root.applicationManager.requestFocusApplication(appId);
323 return root.applicationManager.startApplication(appId) !== null;
327 property var focusedAppDelegate: null
328 property var foregroundMaximizedAppDelegate: null // for stuff like drop shadow and focusing maximized app by clicking panel
330 property bool goneToSpread: false
331 property int closingIndex: -1
332 property int animationDuration: LomiriAnimation.FastDuration
334 function updateForegroundMaximizedApp() {
336 for (var i = 0; i < appRepeater.count && !found; i++) {
337 var item = appRepeater.itemAt(i);
338 if (item && item.visuallyMaximized) {
339 foregroundMaximizedAppDelegate = item;
344 foregroundMaximizedAppDelegate = null;
348 function minimizeAllWindows() {
349 for (var i = appRepeater.count - 1; i >= 0; i--) {
350 var appDelegate = appRepeater.itemAt(i);
351 if (appDelegate && !appDelegate.minimized) {
352 appDelegate.requestMinimize();
357 readonly property bool sideStageEnabled: root.mode === "stagedWithSideStage" &&
358 (root.shellOrientation == Qt.LandscapeOrientation ||
359 root.shellOrientation == Qt.InvertedLandscapeOrientation)
360 onSideStageEnabledChanged: {
361 for (var i = 0; i < appRepeater.count; i++) {
362 appRepeater.itemAt(i).refreshStage();
364 priv.updateMainAndSideStageIndexes();
367 property var mainStageDelegate: null
368 property var sideStageDelegate: null
369 property int mainStageItemId: 0
370 property int sideStageItemId: 0
371 property string mainStageAppId: ""
372 property string sideStageAppId: ""
374 onSideStageDelegateChanged: {
375 if (!sideStageDelegate) {
380 function updateMainAndSideStageIndexes() {
381 if (root.mode != "stagedWithSideStage") {
382 priv.sideStageDelegate = null;
383 priv.sideStageItemId = 0;
384 priv.sideStageAppId = "";
385 priv.mainStageDelegate = appRepeater.itemAt(0);
386 priv.mainStageItemId = topLevelSurfaceList.idAt(0);
387 priv.mainStageAppId = topLevelSurfaceList.applicationAt(0) ? topLevelSurfaceList.applicationAt(0).appId : ""
391 var choseMainStage = false;
392 var choseSideStage = false;
394 if (!root.topLevelSurfaceList)
397 for (var i = 0; i < appRepeater.count && (!choseMainStage || !choseSideStage); ++i) {
398 var appDelegate = appRepeater.itemAt(i);
400 // This might happen during startup phase... If the delegate appears and claims focus
401 // things are updated and appRepeater.itemAt(x) still returns null while appRepeater.count >= x
402 // Lets just skip it, on startup it will be generated at a later point too...
405 if (sideStage.shown && appDelegate.stage == ApplicationInfoInterface.SideStage
406 && !choseSideStage) {
407 priv.sideStageDelegate = appDelegate
408 priv.sideStageItemId = root.topLevelSurfaceList.idAt(i);
409 priv.sideStageAppId = root.topLevelSurfaceList.applicationAt(i).appId;
410 choseSideStage = true;
411 } else if (!choseMainStage && appDelegate.stage == ApplicationInfoInterface.MainStage) {
412 priv.mainStageDelegate = appDelegate;
413 priv.mainStageItemId = root.topLevelSurfaceList.idAt(i);
414 priv.mainStageAppId = root.topLevelSurfaceList.applicationAt(i).appId;
415 choseMainStage = true;
418 if (!choseMainStage && priv.mainStageDelegate) {
419 priv.mainStageDelegate = null;
420 priv.mainStageItemId = 0;
421 priv.mainStageAppId = "";
423 if (!choseSideStage && priv.sideStageDelegate) {
424 priv.sideStageDelegate = null;
425 priv.sideStageItemId = 0;
426 priv.sideStageAppId = "";
430 property int nextInStack: {
431 var mainStageIndex = priv.mainStageDelegate ? priv.mainStageDelegate.itemIndex : -1;
432 var sideStageIndex = priv.sideStageDelegate ? priv.sideStageDelegate.itemIndex : -1;
433 if (sideStageIndex == -1) {
434 return topLevelSurfaceList.count > 1 ? 1 : -1;
436 if (mainStageIndex == 0 || sideStageIndex == 0) {
437 if (mainStageIndex == 1 || sideStageIndex == 1) {
438 return topLevelSurfaceList.count > 2 ? 2 : -1;
445 readonly property real virtualKeyboardHeight: root.inputMethodRect.height
447 readonly property real windowDecorationHeight: units.gu(3)
450 Component.onCompleted: priv.updateMainAndSideStageIndexes()
454 onCloseClicked: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.close(); } }
455 onMinimizeClicked: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.requestMinimize(); } }
456 onRestoreClicked: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.requestRestore(); } }
461 property: "decorationsVisible"
462 value: mode == "windowed" && priv.focusedAppDelegate && priv.focusedAppDelegate.maximized && !root.spreadShown
469 if (priv.focusedAppDelegate !== null) {
470 if (priv.focusedAppDelegate.maximized)
471 return priv.focusedAppDelegate.title
473 return priv.focusedAppDelegate.appName
477 when: priv.focusedAppDelegate
482 property: "focusedPersistentSurfaceId"
484 if (priv.focusedAppDelegate !== null) {
485 if (priv.focusedAppDelegate.surface) {
486 return priv.focusedAppDelegate.surface.persistentId;
491 when: priv.focusedAppDelegate
496 property: "dropShadow"
497 value: priv.focusedAppDelegate && !priv.focusedAppDelegate.maximized && priv.foregroundMaximizedAppDelegate !== null && mode == "windowed"
502 property: "closeButtonShown"
503 value: priv.focusedAppDelegate && priv.focusedAppDelegate.maximized
506 Component.onDestruction: {
507 panelState.title = "";
508 panelState.decorationsVisible = false;
509 panelState.dropShadow = false;
513 model: root.applicationManager
515 property var stateBinding: Binding {
516 target: model.application
517 property: "requestedState"
519 // TODO: figure out some lifecycle policy, like suspending minimized apps
520 // or something if running windowed.
521 // TODO: If the device has a dozen suspended apps because it was running
522 // in staged mode, when it switches to Windowed mode it will suddenly
523 // resume all those apps at once. We might want to avoid that.
524 value: root.mode === "windowed"
525 || (!root.suspended && model.application && priv.focusedAppDelegate &&
526 (priv.focusedAppDelegate.appId === model.application.appId ||
527 priv.mainStageAppId === model.application.appId ||
528 priv.sideStageAppId === model.application.appId))
529 ? ApplicationInfoInterface.RequestedRunning
530 : ApplicationInfoInterface.RequestedSuspended
533 property var lifecycleBinding: Binding {
534 target: model.application
535 property: "exemptFromLifecycle"
536 value: model.application
537 ? (!model.application.isTouchApp || isExemptFromLifecycle(model.application.appId))
541 property var focusRequestedConnection: Connections {
542 target: model.application
545 // Application emits focusRequested when it has no surface (i.e. their processes died).
546 // Find the topmost window for this application and activate it, after which the app
547 // will be requested to be running.
549 for (var i = 0; i < appRepeater.count; i++) {
550 var appDelegate = appRepeater.itemAt(i);
551 if (appDelegate.application.appId === model.application.appId) {
552 appDelegate.activate();
557 console.warn("Application requested te be focused but no window for it. What should we do?");
565 name: "spread"; when: priv.goneToSpread
566 PropertyChanges { target: floatingFlickable; enabled: true }
567 PropertyChanges { target: root; focus: true }
568 PropertyChanges { target: spreadItem; focus: true }
569 PropertyChanges { target: hoverMouseArea; enabled: true }
570 PropertyChanges { target: rightEdgeDragArea; enabled: false }
571 PropertyChanges { target: cancelSpreadMouseArea; enabled: true }
572 PropertyChanges { target: noAppsRunningHint; visible: (root.topLevelSurfaceList.count < 1) }
573 PropertyChanges { target: blurLayer; visible: true; blurRadius: 32; brightness: .65; opacity: 1 }
574 PropertyChanges { target: wallpaper; visible: false }
575 PropertyChanges { target: screensAndWorkspaces; opacity: 1 }
578 name: "stagedRightEdge"; when: root.spreadEnabled && (rightEdgeDragArea.dragging || rightEdgePushProgress > 0) && root.mode == "staged"
586 PropertyChanges { target: noAppsRunningHint; visible: (root.topLevelSurfaceList.count < 1) }
589 name: "sideStagedRightEdge"; when: root.spreadEnabled && (rightEdgeDragArea.dragging || rightEdgePushProgress > 0) && root.mode == "stagedWithSideStage"
590 extend: "stagedRightEdge"
593 opacity: priv.sideStageDelegate && priv.sideStageDelegate.x === sideStage.x ? 1 : 0
598 name: "windowedRightEdge"; when: root.spreadEnabled && (rightEdgeDragArea.dragging || rightEdgePushProgress > 0) && root.mode == "windowed"
604 opacity: MathUtils.linearAnimation(spreadItem.rightEdgeBreakPoint, 1, 0, 1, Math.max(rightEdgeDragArea.dragging ? rightEdgeDragArea.progress : 0, rightEdgePushProgress))
608 name: "staged"; when: root.mode === "staged"
609 PropertyChanges { target: wallpaper; visible: !priv.focusedAppDelegate || priv.focusedAppDelegate.x !== 0 }
610 PropertyChanges { target: root; focus: true }
611 PropertyChanges { target: appContainer; focus: true }
614 name: "stagedWithSideStage"; when: root.mode === "stagedWithSideStage"
615 PropertyChanges { target: triGestureArea; enabled: priv.sideStageEnabled }
616 PropertyChanges { target: sideStage; visible: true }
617 PropertyChanges { target: root; focus: true }
618 PropertyChanges { target: appContainer; focus: true }
621 name: "windowed"; when: root.mode === "windowed"
622 PropertyChanges { target: root; focus: true }
623 PropertyChanges { target: appContainer; focus: true }
628 from: "stagedRightEdge,sideStagedRightEdge,windowedRightEdge"; to: "spread"
629 PropertyAction { target: spreadItem; property: "highlightedIndex"; value: -1 }
630 PropertyAction { target: screensAndWorkspaces; property: "activeWorkspace"; value: WMScreen.currentWorkspace }
631 PropertyAnimation { target: blurLayer; properties: "brightness,blurRadius"; duration: priv.animationDuration }
632 LomiriNumberAnimation { target: screensAndWorkspaces; property: "opacity"; duration: priv.animationDuration }
636 PropertyAction { target: screensAndWorkspaces; property: "activeWorkspace"; value: WMScreen.currentWorkspace }
637 PropertyAction { target: spreadItem; property: "highlightedIndex"; value: appRepeater.count > 1 ? 1 : 0 }
638 PropertyAction { target: floatingFlickable; property: "contentX"; value: 0 }
639 LomiriNumberAnimation { target: screensAndWorkspaces; property: "opacity"; duration: priv.animationDuration }
643 SequentialAnimation {
646 var item = appRepeater.itemAt(Math.max(0, spreadItem.highlightedIndex));
647 if (item.stage == ApplicationInfoInterface.SideStage && !sideStage.shown) {
650 item.playFocusAnimation();
653 PropertyAction { target: spreadItem; property: "highlightedIndex"; value: -1 }
654 PropertyAction { target: floatingFlickable; property: "contentX"; value: 0 }
658 to: "stagedRightEdge,sideStagedRightEdge"
659 PropertyAction { target: floatingFlickable; property: "contentX"; value: 0 }
662 to: "stagedWithSideStage"
663 ScriptAction { script: priv.updateMainAndSideStageIndexes(); }
669 id: cancelSpreadMouseArea
672 onClicked: priv.goneToSpread = false
677 objectName: "appContainer"
683 objectName: "stageBackground"
685 source: root.background
686 // Make sure it's the lowest item. Due to the left edge drag we sometimes need
687 // to put the dash at -1 and we don't want it behind the Wallpaper
698 ScreensAndWorkspaces {
699 id: screensAndWorkspaces
700 anchors { left: parent.left; top: parent.top; right: parent.right; leftMargin: root.launcherLeftMargin }
701 height: Math.max(units.gu(30), parent.height * .3)
702 background: root.background
704 visible: workspaceEnabled ? opacity > 0 : false
705 enabled: workspaceEnabled
707 onCloseSpread: priv.goneToSpread = false;
712 objectName: "spreadItem"
715 bottom: parent.bottom;
717 top: workspaceEnabled ? screensAndWorkspaces.bottom : parent.top;
719 leftMargin: root.availableDesktopArea.x
720 model: root.topLevelSurfaceList
721 spreadFlickable: floatingFlickable
725 priv.goneToSpread = false;
729 appRepeater.itemAt(highlightedIndex).close();
733 id: floatingFlickable
734 objectName: "spreadFlickable"
737 contentWidth: spreadItem.spreadTotalWidth
739 function snap(toIndex) {
740 var delegate = appRepeater.itemAt(toIndex)
741 var targetContentX = floatingFlickable.contentWidth / spreadItem.totalItemCount * toIndex;
742 if (targetContentX - floatingFlickable.contentX > spreadItem.rightStackXPos - (spreadItem.spreadItemWidth / 2)) {
743 var offset = (spreadItem.rightStackXPos - (spreadItem.spreadItemWidth / 2)) - (targetContentX - floatingFlickable.contentX)
744 snapAnimation.to = floatingFlickable.contentX - offset;
745 snapAnimation.start();
746 } else if (targetContentX - floatingFlickable.contentX < spreadItem.leftStackXPos + units.gu(1)) {
747 var offset = (spreadItem.leftStackXPos + units.gu(1)) - (targetContentX - floatingFlickable.contentX);
748 snapAnimation.to = floatingFlickable.contentX - offset;
749 snapAnimation.start();
752 LomiriNumberAnimation {id: snapAnimation; target: floatingFlickable; property: "contentX"}
757 objectName: "hoverMouseArea"
759 propagateComposedEvents: true
763 property bool wasTouchPress: false
765 property int scrollAreaWidth: width / 3
766 property bool progressiveScrollingEnabled: false
769 mouse.accepted = false
771 if (hoverMouseArea.pressed || wasTouchPress) {
775 // Find the hovered item and mark it active
776 for (var i = appRepeater.count - 1; i >= 0; i--) {
777 var appDelegate = appRepeater.itemAt(i);
778 var mapped = mapToItem(appDelegate, hoverMouseArea.mouseX, hoverMouseArea.mouseY)
779 var itemUnder = appDelegate.childAt(mapped.x, mapped.y);
780 if (itemUnder && (itemUnder.objectName === "dragArea" || itemUnder.objectName === "windowInfoItem" || itemUnder.objectName == "closeMouseArea")) {
781 spreadItem.highlightedIndex = i;
786 if (floatingFlickable.contentWidth > floatingFlickable.width) {
787 var margins = floatingFlickable.width * 0.05;
789 if (!progressiveScrollingEnabled && mouseX < floatingFlickable.width - scrollAreaWidth) {
790 progressiveScrollingEnabled = true
793 // do we need to scroll?
794 if (mouseX < scrollAreaWidth + margins) {
795 var progress = Math.min(1, (scrollAreaWidth + margins - mouseX) / (scrollAreaWidth - margins));
796 var contentX = (1 - progress) * (floatingFlickable.contentWidth - floatingFlickable.width)
797 floatingFlickable.contentX = Math.max(0, Math.min(floatingFlickable.contentX, contentX))
799 if (mouseX > floatingFlickable.width - scrollAreaWidth && progressiveScrollingEnabled) {
800 var progress = Math.min(1, (mouseX - (floatingFlickable.width - scrollAreaWidth)) / (scrollAreaWidth - margins))
801 var contentX = progress * (floatingFlickable.contentWidth - floatingFlickable.width)
802 floatingFlickable.contentX = Math.min(floatingFlickable.contentWidth - floatingFlickable.width, Math.max(floatingFlickable.contentX, contentX))
808 mouse.accepted = false;
809 wasTouchPress = mouse.source === Qt.MouseEventSynthesizedByQt;
812 onExited: wasTouchPress = false;
817 id: noAppsRunningHint
819 anchors.horizontalCenter: parent.horizontalCenter
820 anchors.verticalCenter: parent.verticalCenter
822 horizontalAlignment: Qt.AlignHCenter
823 verticalAlignment: Qt.AlignVCenter
824 anchors.leftMargin: root.launcherLeftMargin
825 wrapMode: Label.WordWrap
827 text: i18n.tr("No running apps")
831 target: root.topLevelSurfaceList
832 onListChanged: priv.updateMainAndSideStageIndexes()
837 objectName: "MainStageDropArea"
841 bottom: parent.bottom
843 width: appContainer.width - sideStage.width
844 enabled: priv.sideStageEnabled
847 drop.source.appDelegate.saveStage(ApplicationInfoInterface.MainStage);
848 drop.source.appDelegate.focus = true;
855 objectName: "sideStage"
857 height: appContainer.height
858 x: appContainer.width - width
860 Behavior on opacity { LomiriNumberAnimation {} }
862 if (!priv.mainStageItemId) return 0;
864 if (priv.sideStageItemId && priv.nextInStack > 0) {
866 // Due the order in which bindings are evaluated, this might be triggered while shuffling
867 // the list and index doesn't yet match with itemIndex (even though itemIndex: index)
868 // Let's walk the list and compare itemIndex to make sure we have the correct one.
869 var nextDelegateInStack = -1;
870 for (var i = 0; i < appRepeater.count; i++) {
871 if (appRepeater.itemAt(i).itemIndex == priv.nextInStack) {
872 nextDelegateInStack = appRepeater.itemAt(i);
877 if (nextDelegateInStack.stage === ApplicationInfoInterface.MainStage) {
878 // if the next app in stack is a main stage app, put the sidestage on top of it.
888 if (!shown && priv.mainStageDelegate && !root.spreadShown) {
889 priv.mainStageDelegate.activate();
894 id: sideStageDropArea
895 objectName: "SideStageDropArea"
898 property bool dropAllowed: true
901 dropAllowed = drag.keys != "Disabled";
907 if (drop.keys == "MainStage") {
908 drop.source.appDelegate.saveStage(ApplicationInfoInterface.SideStage);
909 drop.source.appDelegate.focus = true;
914 if (!sideStageDropArea.drag.source) {
924 property real previewScale: .5
925 height: (screensAndWorkspaces.height - units.gu(8)) / 2
927 width: implicitWidth * height / implicitHeight
930 opacity: surface != null ? 1 : 0
931 Behavior on opacity { LomiriNumberAnimation {} }
933 enabled: workspaceSwitcher
935 Drag.active: surface != null
936 Drag.keys: ["application"]
943 model: topLevelSurfaceList
944 objectName: "appRepeater"
946 function indexOf(delegateItem) {
947 for (var i = 0; i < count; i++) {
948 if (itemAt(i) === delegateItem) {
955 delegate: FocusScope {
957 objectName: "appDelegate_" + model.window.id
958 property int itemIndex: index // We need this from outside the repeater
959 // z might be overriden in some cases by effects, but we need z ordering
960 // to calculate occlusion detection
961 property int normalZ: topLevelSurfaceList.count - index
963 if (visuallyMaximized) {
964 priv.updateForegroundMaximizedApp();
969 opacity: fakeDragItem.surface == model.window.surface && fakeDragItem.Drag.active ? 0 : 1
970 Behavior on opacity { LomiriNumberAnimation {} }
972 // Set these as propertyes as they wont update otherwise
973 property real screenOffsetX: Screen.virtualX
974 property real screenOffsetY: Screen.virtualY
976 // Normally we want x/y where the surface thinks it is. Width/height of our delegate will
977 // match what the actual surface size is.
978 // Don't write to those, they will be set by states
980 // Here we will also need to remove the screen offset from miral's results
981 // as lomiri x,y will be relative to the current screen only
982 // FIXME: when proper multiscreen lands
983 x: model.window.position.x - clientAreaItem.x - screenOffsetX
984 y: model.window.position.y - clientAreaItem.y - screenOffsetY
985 width: decoratedWindow.implicitWidth
986 height: decoratedWindow.implicitHeight
988 // requestedX/Y/width/height is what we ask the actual surface to be.
989 // Do not write to those, they will be set by states
990 property real requestedX: windowedX
991 property real requestedY: windowedY
992 property real requestedWidth: windowedWidth
993 property real requestedHeight: windowedHeight
995 // For both windowed and staged need to tell miral what screen we are on,
996 // so we need to add the screen offset to the position we tell miral
997 // FIXME: when proper multiscreen lands
999 target: model.window; property: "requestedPosition"
1000 // miral doesn't know about our window decorations. So we have to deduct them
1001 value: Qt.point(appDelegate.requestedX + appDelegate.clientAreaItem.x + screenOffsetX,
1002 appDelegate.requestedY + appDelegate.clientAreaItem.y + screenOffsetY)
1003 when: root.mode == "windowed"
1006 target: model.window; property: "requestedPosition"
1007 value: Qt.point(screenOffsetX, screenOffsetY)
1008 when: root.mode != "windowed"
1011 // In those are for windowed mode. Those values basically store the window's properties
1012 // when having a floating window. If you want to move/resize a window in normal mode, this is what you want to write to.
1013 property real windowedX
1014 property real windowedY
1015 property real windowedWidth
1016 property real windowedHeight
1018 // unlike windowedX/Y, this is the last known grab position before being pushed against edges/corners
1019 // when restoring, the window should return to these, not to the place where it was dropped near the edge
1020 property real restoredX
1021 property real restoredY
1023 // Keeps track of the window geometry while in normal or restored state
1024 // Useful when returning from some maxmized state or when saving the geometry while maximized
1025 // FIXME: find a better solution
1026 property real normalX: 0
1027 property real normalY: 0
1028 property real normalWidth: 0
1029 property real normalHeight: 0
1030 function updateNormalGeometry() {
1031 if (appDelegate.state == "normal" || appDelegate.state == "restored") {
1032 normalX = appDelegate.requestedX;
1033 normalY = appDelegate.requestedY;
1034 normalWidth = appDelegate.width;
1035 normalHeight = appDelegate.height;
1038 function updateRestoredGeometry() {
1039 if (appDelegate.state == "normal" || appDelegate.state == "restored") {
1040 // save the x/y to restore to
1041 restoredX = appDelegate.x;
1042 restoredY = appDelegate.y;
1048 onXChanged: appDelegate.updateNormalGeometry();
1049 onYChanged: appDelegate.updateNormalGeometry();
1050 onWidthChanged: appDelegate.updateNormalGeometry();
1051 onHeightChanged: appDelegate.updateNormalGeometry();
1054 // True when the Stage is focusing this app and playing its own animation.
1055 // Stays true until the app is unfocused.
1056 // If it is, we don't want to play the slide in/out transition from StageMaths.
1057 // Setting it imperatively is not great, but any declarative solution hits
1058 // race conditions, causing two animations to play for one focus event.
1059 property bool inhibitSlideAnimation: false
1064 value: appDelegate.requestedY -
1065 Math.min(appDelegate.requestedY - root.availableDesktopArea.y,
1066 Math.max(0, priv.virtualKeyboardHeight - (appContainer.height - (appDelegate.requestedY + appDelegate.height))))
1067 when: root.oskEnabled && appDelegate.focus && (appDelegate.state == "normal" || appDelegate.state == "restored")
1068 && root.inputMethodRect.height > 0
1071 Behavior on x { id: xBehavior; enabled: priv.closingIndex >= 0; LomiriNumberAnimation { onRunningChanged: if (!running) priv.closingIndex = -1} }
1075 onShellOrientationAngleChanged: {
1076 // at this point decoratedWindow.surfaceOrientationAngle is the old shellOrientationAngle
1077 if (application && application.rotatesWindowContents) {
1078 if (root.state == "windowed") {
1079 var angleDiff = decoratedWindow.surfaceOrientationAngle - shellOrientationAngle;
1080 angleDiff = (360 + angleDiff) % 360;
1081 if (angleDiff === 90 || angleDiff === 270) {
1082 var aux = decoratedWindow.requestedHeight;
1083 decoratedWindow.requestedHeight = decoratedWindow.requestedWidth + decoratedWindow.actualDecorationHeight;
1084 decoratedWindow.requestedWidth = aux - decoratedWindow.actualDecorationHeight;
1087 decoratedWindow.surfaceOrientationAngle = shellOrientationAngle;
1089 decoratedWindow.surfaceOrientationAngle = 0;
1094 readonly property alias application: decoratedWindow.application
1095 readonly property alias minimumWidth: decoratedWindow.minimumWidth
1096 readonly property alias minimumHeight: decoratedWindow.minimumHeight
1097 readonly property alias maximumWidth: decoratedWindow.maximumWidth
1098 readonly property alias maximumHeight: decoratedWindow.maximumHeight
1099 readonly property alias widthIncrement: decoratedWindow.widthIncrement
1100 readonly property alias heightIncrement: decoratedWindow.heightIncrement
1102 readonly property bool maximized: windowState === WindowStateStorage.WindowStateMaximized
1103 readonly property bool maximizedLeft: windowState === WindowStateStorage.WindowStateMaximizedLeft
1104 readonly property bool maximizedRight: windowState === WindowStateStorage.WindowStateMaximizedRight
1105 readonly property bool maximizedHorizontally: windowState === WindowStateStorage.WindowStateMaximizedHorizontally
1106 readonly property bool maximizedVertically: windowState === WindowStateStorage.WindowStateMaximizedVertically
1107 readonly property bool maximizedTopLeft: windowState === WindowStateStorage.WindowStateMaximizedTopLeft
1108 readonly property bool maximizedTopRight: windowState === WindowStateStorage.WindowStateMaximizedTopRight
1109 readonly property bool maximizedBottomLeft: windowState === WindowStateStorage.WindowStateMaximizedBottomLeft
1110 readonly property bool maximizedBottomRight: windowState === WindowStateStorage.WindowStateMaximizedBottomRight
1111 readonly property bool anyMaximized: maximized || maximizedLeft || maximizedRight || maximizedHorizontally || maximizedVertically ||
1112 maximizedTopLeft || maximizedTopRight || maximizedBottomLeft || maximizedBottomRight
1114 readonly property bool minimized: windowState & WindowStateStorage.WindowStateMinimized
1115 readonly property bool fullscreen: windowState === WindowStateStorage.WindowStateFullscreen
1117 readonly property bool canBeMaximized: canBeMaximizedHorizontally && canBeMaximizedVertically
1118 readonly property bool canBeMaximizedLeftRight: (maximumWidth == 0 || maximumWidth >= appContainer.width/2) &&
1119 (maximumHeight == 0 || maximumHeight >= appContainer.height)
1120 readonly property bool canBeCornerMaximized: (maximumWidth == 0 || maximumWidth >= appContainer.width/2) &&
1121 (maximumHeight == 0 || maximumHeight >= appContainer.height/2)
1122 readonly property bool canBeMaximizedHorizontally: maximumWidth == 0 || maximumWidth >= appContainer.width
1123 readonly property bool canBeMaximizedVertically: maximumHeight == 0 || maximumHeight >= appContainer.height
1124 readonly property alias orientationChangesEnabled: decoratedWindow.orientationChangesEnabled
1126 // TODO drop our own windowType once Mir/Miral/Qtmir gets in sync with ours
1127 property int windowState: WindowStateStorage.WindowStateNormal
1128 property int prevWindowState: WindowStateStorage.WindowStateRestored
1130 property bool animationsEnabled: true
1131 property alias title: decoratedWindow.title
1132 readonly property string appName: model.application ? model.application.name : ""
1133 property bool visuallyMaximized: false
1134 property bool visuallyMinimized: false
1135 readonly property alias windowedTransitionRunning: windowedTransition.running
1137 property int stage: ApplicationInfoInterface.MainStage
1138 function saveStage(newStage) {
1139 appDelegate.stage = newStage;
1140 WindowStateStorage.saveStage(appId, newStage);
1141 priv.updateMainAndSideStageIndexes()
1144 readonly property var surface: model.window.surface
1145 readonly property var window: model.window
1147 readonly property alias focusedSurface: decoratedWindow.focusedSurface
1148 readonly property bool dragging: touchControls.overlayShown ? touchControls.dragging : decoratedWindow.dragging
1150 readonly property string appId: model.application.appId
1151 readonly property alias clientAreaItem: decoratedWindow.clientAreaItem
1153 // It is Lomiri policy to close any window but the last one during OOM teardown
1156 target: model.window.surface
1158 if ((!surface.live && application && application.surfaceCount > 1) || !application)
1159 topLevelSurfaceList.removeAt(appRepeater.indexOf(appDelegate));
1164 function activate() {
1165 if (model.window.focused) {
1166 updateQmlFocusFromMirSurfaceFocus();
1169 // Activate the window since it has a surface (with a running app) backing it
1170 model.window.activate();
1172 // Otherwise, cause a respawn of the app, and trigger it's refocusing as the last window
1173 topLevelSurfaceList.raiseId(model.window.id);
1177 function requestMaximize() { model.window.requestState(Mir.MaximizedState); }
1178 function requestMaximizeVertically() { model.window.requestState(Mir.VertMaximizedState); }
1179 function requestMaximizeHorizontally() { model.window.requestState(Mir.HorizMaximizedState); }
1180 function requestMaximizeLeft() { model.window.requestState(Mir.MaximizedLeftState); }
1181 function requestMaximizeRight() { model.window.requestState(Mir.MaximizedRightState); }
1182 function requestMaximizeTopLeft() { model.window.requestState(Mir.MaximizedTopLeftState); }
1183 function requestMaximizeTopRight() { model.window.requestState(Mir.MaximizedTopRightState); }
1184 function requestMaximizeBottomLeft() { model.window.requestState(Mir.MaximizedBottomLeftState); }
1185 function requestMaximizeBottomRight() { model.window.requestState(Mir.MaximizedBottomRightState); }
1186 function requestMinimize() { model.window.requestState(Mir.MinimizedState); }
1187 function requestRestore() { model.window.requestState(Mir.RestoredState); }
1189 function claimFocus() {
1190 if (root.state == "spread") {
1191 spreadItem.highlightedIndex = index
1193 if (root.mode == "stagedWithSideStage") {
1194 if (appDelegate.stage == ApplicationInfoInterface.SideStage && !sideStage.shown) {
1197 priv.updateMainAndSideStageIndexes();
1199 appDelegate.focus = true;
1201 // Don't set focusedAppDelegate (and signal mainAppChanged) unnecessarily
1202 // which can happen after getting interactive again.
1203 if (priv.focusedAppDelegate !== appDelegate)
1204 priv.focusedAppDelegate = appDelegate;
1207 function updateQmlFocusFromMirSurfaceFocus() {
1208 if (model.window.focused) {
1210 decoratedWindow.focus = true;
1215 id: windowStateSaver
1217 screenWidth: appContainer.width
1218 screenHeight: appContainer.height
1219 leftMargin: root.availableDesktopArea.x
1220 minimumY: root.availableDesktopArea.y
1224 target: model.window
1226 updateQmlFocusFromMirSurfaceFocus();
1227 if (!model.window.focused) {
1228 inhibitSlideAnimation = false;
1232 appDelegate.activate();
1235 if (value == Mir.MinimizedState) {
1236 appDelegate.minimize();
1237 } else if (value == Mir.MaximizedState) {
1238 appDelegate.maximize();
1239 } else if (value == Mir.VertMaximizedState) {
1240 appDelegate.maximizeVertically();
1241 } else if (value == Mir.HorizMaximizedState) {
1242 appDelegate.maximizeHorizontally();
1243 } else if (value == Mir.MaximizedLeftState) {
1244 appDelegate.maximizeLeft();
1245 } else if (value == Mir.MaximizedRightState) {
1246 appDelegate.maximizeRight();
1247 } else if (value == Mir.MaximizedTopLeftState) {
1248 appDelegate.maximizeTopLeft();
1249 } else if (value == Mir.MaximizedTopRightState) {
1250 appDelegate.maximizeTopRight();
1251 } else if (value == Mir.MaximizedBottomLeftState) {
1252 appDelegate.maximizeBottomLeft();
1253 } else if (value == Mir.MaximizedBottomRightState) {
1254 appDelegate.maximizeBottomRight();
1255 } else if (value == Mir.RestoredState) {
1256 if (appDelegate.fullscreen && appDelegate.prevWindowState != WindowStateStorage.WindowStateRestored
1257 && appDelegate.prevWindowState != WindowStateStorage.WindowStateNormal) {
1258 model.window.requestState(WindowStateStorage.toMirState(appDelegate.prevWindowState));
1260 appDelegate.restore();
1262 } else if (value == Mir.FullscreenState) {
1263 appDelegate.prevWindowState = appDelegate.windowState;
1264 appDelegate.windowState = WindowStateStorage.WindowStateFullscreen;
1269 readonly property bool windowReady: clientAreaItem.surfaceInitialized
1270 onWindowReadyChanged: {
1272 var loadedMirState = WindowStateStorage.toMirState(windowStateSaver.loadedState);
1273 var state = loadedMirState;
1275 if (window.state == Mir.FullscreenState) {
1276 // If the app is fullscreen at startup, we should not use saved state
1277 // Example of why: if you open game that only requests fullscreen at
1278 // Statup, this will automaticly be set to "restored state" since
1279 // thats the default value of stateStorage, this will result in the app
1280 // having the "restored state" as it will not make a fullscreen
1281 // call after the app has started.
1282 console.log("Initial window state is fullscreen, not using saved state.");
1283 state = window.state;
1284 } else if (loadedMirState == Mir.FullscreenState) {
1285 // If saved state is fullscreen, we should use app initial state
1286 // Example of why: if you open browser with youtube video at fullscreen
1287 // and close this app, it will be fullscreen next time you open the app.
1288 console.log("Saved window state is fullscreen, using initial window state");
1289 state = window.state;
1292 // need to apply the shell chrome policy on top the saved window state
1294 if (root.mode == "windowed") {
1295 policy = windowedFullscreenPolicy;
1297 policy = stagedFullscreenPolicy
1299 window.requestState(policy.applyPolicy(state, surface.shellChrome));
1303 Component.onCompleted: {
1304 if (application && application.rotatesWindowContents) {
1305 decoratedWindow.surfaceOrientationAngle = shellOrientationAngle;
1307 decoratedWindow.surfaceOrientationAngle = 0;
1310 // First, cascade the newly created window, relative to the currently/old focused window.
1311 windowedX = priv.focusedAppDelegate ? priv.focusedAppDelegate.windowedX + units.gu(3) : (normalZ - 1) * units.gu(3)
1312 windowedY = priv.focusedAppDelegate ? priv.focusedAppDelegate.windowedY + units.gu(3) : normalZ * units.gu(3)
1313 // Now load any saved state. This needs to happen *after* the cascading!
1314 windowStateSaver.load();
1316 updateQmlFocusFromMirSurfaceFocus();
1319 _constructing = false;
1321 Component.onDestruction: {
1322 windowStateSaver.save();
1325 // This stage is about to be destroyed. Don't mess up with the model at this point
1329 if (visuallyMaximized) {
1330 priv.updateForegroundMaximizedApp();
1334 onVisuallyMaximizedChanged: priv.updateForegroundMaximizedApp()
1336 property bool _constructing: true;
1338 if (!_constructing) {
1339 priv.updateMainAndSideStageIndexes();
1345 && !greeter.fullyShown
1346 && (priv.foregroundMaximizedAppDelegate === null || priv.foregroundMaximizedAppDelegate.normalZ <= z)
1348 || appDelegate.fullscreen
1349 || focusAnimation.running || rightEdgeFocusAnimation.running || hidingAnimation.running
1352 model.window.close();
1355 function maximize(animated) {
1356 animationsEnabled = (animated === undefined) || animated;
1357 windowState = WindowStateStorage.WindowStateMaximized;
1359 function maximizeLeft(animated) {
1360 animationsEnabled = (animated === undefined) || animated;
1361 windowState = WindowStateStorage.WindowStateMaximizedLeft;
1363 function maximizeRight(animated) {
1364 animationsEnabled = (animated === undefined) || animated;
1365 windowState = WindowStateStorage.WindowStateMaximizedRight;
1367 function maximizeHorizontally(animated) {
1368 animationsEnabled = (animated === undefined) || animated;
1369 windowState = WindowStateStorage.WindowStateMaximizedHorizontally;
1371 function maximizeVertically(animated) {
1372 animationsEnabled = (animated === undefined) || animated;
1373 windowState = WindowStateStorage.WindowStateMaximizedVertically;
1375 function maximizeTopLeft(animated) {
1376 animationsEnabled = (animated === undefined) || animated;
1377 windowState = WindowStateStorage.WindowStateMaximizedTopLeft;
1379 function maximizeTopRight(animated) {
1380 animationsEnabled = (animated === undefined) || animated;
1381 windowState = WindowStateStorage.WindowStateMaximizedTopRight;
1383 function maximizeBottomLeft(animated) {
1384 animationsEnabled = (animated === undefined) || animated;
1385 windowState = WindowStateStorage.WindowStateMaximizedBottomLeft;
1387 function maximizeBottomRight(animated) {
1388 animationsEnabled = (animated === undefined) || animated;
1389 windowState = WindowStateStorage.WindowStateMaximizedBottomRight;
1391 function minimize(animated) {
1392 animationsEnabled = (animated === undefined) || animated;
1393 windowState |= WindowStateStorage.WindowStateMinimized; // add the minimized bit
1395 function restore(animated,state) {
1396 animationsEnabled = (animated === undefined) || animated;
1397 windowState = state || WindowStateStorage.WindowStateRestored;
1398 windowState &= ~WindowStateStorage.WindowStateMinimized; // clear the minimized bit
1399 prevWindowState = windowState;
1402 function playFocusAnimation() {
1403 if (state == "stagedRightEdge") {
1404 // TODO: Can we drop this if and find something that always works?
1405 if (root.mode == "staged") {
1406 rightEdgeFocusAnimation.targetX = 0
1407 rightEdgeFocusAnimation.start()
1408 } else if (root.mode == "stagedWithSideStage") {
1409 rightEdgeFocusAnimation.targetX = appDelegate.stage == ApplicationInfoInterface.SideStage ? sideStage.x : 0
1410 rightEdgeFocusAnimation.start()
1412 } else if (state == "windowedRightEdge" || state == "windowed") {
1415 focusAnimation.start()
1418 function playHidingAnimation() {
1419 if (state != "windowedRightEdge") {
1420 hidingAnimation.start()
1424 function refreshStage() {
1425 var newStage = ApplicationInfoInterface.MainStage;
1426 if (priv.sideStageEnabled) { // we're in lanscape rotation.
1427 if (application && application.supportedOrientations & (Qt.PortraitOrientation|Qt.InvertedPortraitOrientation)) {
1428 var defaultStage = ApplicationInfoInterface.SideStage; // if application supports portrait, it defaults to sidestage.
1429 if (application.supportedOrientations & (Qt.LandscapeOrientation|Qt.InvertedLandscapeOrientation)) {
1430 // if it supports lanscape, it defaults to mainstage.
1431 defaultStage = ApplicationInfoInterface.MainStage;
1433 newStage = WindowStateStorage.getStage(application.appId, defaultStage);
1438 if (focus && stage == ApplicationInfoInterface.SideStage && !sideStage.shown) {
1443 LomiriNumberAnimation {
1449 duration: LomiriAnimation.SnapDuration
1451 topLevelSurfaceList.pendingActivation();
1452 topLevelSurfaceList.raiseId(model.window.id);
1455 appDelegate.activate();
1459 id: rightEdgeFocusAnimation
1460 property int targetX: 0
1461 LomiriNumberAnimation { target: appDelegate; properties: "x"; to: rightEdgeFocusAnimation.targetX; duration: priv.animationDuration }
1462 LomiriNumberAnimation { target: decoratedWindow; properties: "angle"; to: 0; duration: priv.animationDuration }
1463 LomiriNumberAnimation { target: decoratedWindow; properties: "itemScale"; to: 1; duration: priv.animationDuration }
1465 topLevelSurfaceList.pendingActivation();
1466 inhibitSlideAnimation = true;
1469 appDelegate.activate();
1474 LomiriNumberAnimation { target: appDelegate; property: "opacity"; to: 0; duration: priv.animationDuration }
1475 onStopped: appDelegate.opacity = 1
1482 flickable: floatingFlickable
1486 sceneWidth: root.width
1487 stage: appDelegate.stage
1488 thisDelegate: appDelegate
1489 mainStageDelegate: priv.mainStageDelegate
1490 sideStageDelegate: priv.sideStageDelegate
1491 sideStageWidth: sideStage.panelWidth
1492 sideStageHandleWidth: sideStage.handleWidth
1493 sideStageX: sideStage.x
1494 itemIndex: appDelegate.itemIndex
1495 nextInStack: priv.nextInStack
1496 animationDuration: priv.animationDuration
1499 StagedRightEdgeMaths {
1500 id: stagedRightEdgeMaths
1501 sceneWidth: root.availableDesktopArea.width
1502 sceneHeight: appContainer.height
1503 isMainStageApp: priv.mainStageDelegate == appDelegate
1504 isSideStageApp: priv.sideStageDelegate == appDelegate
1505 sideStageWidth: sideStage.width
1506 sideStageOpen: sideStage.shown
1508 nextInStack: priv.nextInStack
1510 targetHeight: spreadItem.stackHeight
1511 targetX: spreadMaths.targetX
1512 startY: appDelegate.fullscreen ? 0 : root.availableDesktopArea.y
1513 targetY: spreadMaths.targetY
1514 targetAngle: spreadMaths.targetAngle
1515 targetScale: spreadMaths.targetScale
1516 shuffledZ: stageMaths.itemZ
1517 breakPoint: spreadItem.rightEdgeBreakPoint
1520 WindowedRightEdgeMaths {
1521 id: windowedRightEdgeMaths
1523 startWidth: appDelegate.requestedWidth
1524 startHeight: appDelegate.requestedHeight
1525 targetHeight: spreadItem.stackHeight
1526 targetX: spreadMaths.targetX
1527 targetY: spreadMaths.targetY
1528 normalZ: appDelegate.normalZ
1529 targetAngle: spreadMaths.targetAngle
1530 targetScale: spreadMaths.targetScale
1531 breakPoint: spreadItem.rightEdgeBreakPoint
1536 name: "spread"; when: root.state == "spread"
1537 StateChangeScript { script: { decoratedWindow.cancelDrag(); } }
1539 target: decoratedWindow;
1540 showDecoration: false;
1541 angle: spreadMaths.targetAngle
1542 itemScale: spreadMaths.targetScale
1543 scaleToPreviewSize: spreadItem.stackHeight
1544 scaleToPreviewProgress: 1
1545 hasDecoration: root.mode === "windowed"
1546 shadowOpacity: spreadMaths.shadowOpacity
1547 showHighlight: spreadItem.highlightedIndex === index
1548 darkening: spreadItem.highlightedIndex >= 0
1549 anchors.topMargin: dragArea.distance
1553 x: spreadMaths.targetX
1554 y: spreadMaths.targetY
1556 height: spreadItem.spreadItemHeight
1557 visible: spreadMaths.itemVisible
1559 PropertyChanges { target: dragArea; enabled: true }
1560 PropertyChanges { target: windowInfoItem; opacity: spreadMaths.tileInfoOpacity; visible: spreadMaths.itemVisible }
1561 PropertyChanges { target: touchControls; enabled: false }
1564 name: "stagedRightEdge"
1565 when: (root.mode == "staged" || root.mode == "stagedWithSideStage") && (root.state == "sideStagedRightEdge" || root.state == "stagedRightEdge" || rightEdgeFocusAnimation.running || hidingAnimation.running)
1567 target: stagedRightEdgeMaths
1568 progress: Math.max(rightEdgePushProgress, rightEdgeDragArea.draggedProgress)
1572 x: stagedRightEdgeMaths.animatedX
1573 y: stagedRightEdgeMaths.animatedY
1574 z: stagedRightEdgeMaths.animatedZ
1575 height: stagedRightEdgeMaths.animatedHeight
1576 visible: appDelegate.x < root.width
1579 target: decoratedWindow
1580 hasDecoration: false
1581 angle: stagedRightEdgeMaths.animatedAngle
1582 itemScale: stagedRightEdgeMaths.animatedScale
1583 scaleToPreviewSize: spreadItem.stackHeight
1584 scaleToPreviewProgress: stagedRightEdgeMaths.scaleToPreviewProgress
1587 // make sure it's visible but transparent so it fades in when we transition to spread
1588 PropertyChanges { target: windowInfoItem; opacity: 0; visible: true }
1591 name: "windowedRightEdge"
1592 when: root.mode == "windowed" && (root.state == "windowedRightEdge" || rightEdgeFocusAnimation.running || hidingAnimation.running || rightEdgePushProgress > 0)
1594 target: windowedRightEdgeMaths
1595 swipeProgress: rightEdgeDragArea.dragging ? rightEdgeDragArea.progress : 0
1596 pushProgress: rightEdgePushProgress
1600 x: windowedRightEdgeMaths.animatedX
1601 y: windowedRightEdgeMaths.animatedY
1602 z: windowedRightEdgeMaths.animatedZ
1603 height: stagedRightEdgeMaths.animatedHeight
1606 target: decoratedWindow
1607 showDecoration: windowedRightEdgeMaths.decorationHeight
1608 angle: windowedRightEdgeMaths.animatedAngle
1609 itemScale: windowedRightEdgeMaths.animatedScale
1610 scaleToPreviewSize: spreadItem.stackHeight
1611 scaleToPreviewProgress: windowedRightEdgeMaths.scaleToPreviewProgress
1615 target: opacityEffect;
1616 opacityValue: windowedRightEdgeMaths.opacityMask
1617 sourceItem: windowedRightEdgeMaths.opacityMask < 1 ? decoratedWindow : null
1621 name: "staged"; when: root.state == "staged"
1625 y: root.availableDesktopArea.y
1626 visuallyMaximized: true
1627 visible: appDelegate.x < root.width
1631 requestedWidth: appContainer.width
1632 requestedHeight: root.availableDesktopArea.height
1633 restoreEntryValues: false
1636 target: decoratedWindow
1637 hasDecoration: false
1645 animateX: !focusAnimation.running && !rightEdgeFocusAnimation.running && itemIndex !== spreadItem.highlightedIndex && !inhibitSlideAnimation
1648 target: appDelegate.window
1649 allowClientResize: false
1653 name: "stagedWithSideStage"; when: root.state == "stagedWithSideStage"
1661 y: root.availableDesktopArea.y
1663 visuallyMaximized: true
1664 visible: appDelegate.x < root.width
1668 requestedWidth: stageMaths.itemWidth
1669 requestedHeight: root.availableDesktopArea.height
1670 restoreEntryValues: false
1673 target: decoratedWindow
1674 hasDecoration: false
1681 target: appDelegate.window
1682 allowClientResize: false
1686 name: "maximized"; when: appDelegate.maximized && !appDelegate.minimized
1688 target: appDelegate;
1689 requestedX: root.availableDesktopArea.x;
1691 visuallyMinimized: false;
1692 visuallyMaximized: true
1696 requestedWidth: root.availableDesktopArea.width;
1697 requestedHeight: appContainer.height;
1698 restoreEntryValues: false
1700 PropertyChanges { target: touchControls; enabled: true }
1701 PropertyChanges { target: decoratedWindow; windowControlButtonsVisible: false }
1704 name: "fullscreen"; when: appDelegate.fullscreen && !appDelegate.minimized
1706 target: appDelegate;
1712 requestedWidth: appContainer.width
1713 requestedHeight: appContainer.height
1714 restoreEntryValues: false
1716 PropertyChanges { target: decoratedWindow; hasDecoration: false }
1720 when: appDelegate.windowState == WindowStateStorage.WindowStateNormal
1723 visuallyMinimized: false
1725 PropertyChanges { target: touchControls; enabled: true }
1726 PropertyChanges { target: resizeArea; enabled: true }
1727 PropertyChanges { target: decoratedWindow; shadowOpacity: .3; windowControlButtonsVisible: true}
1730 requestedWidth: windowedWidth
1731 requestedHeight: windowedHeight
1732 restoreEntryValues: false
1737 when: appDelegate.windowState == WindowStateStorage.WindowStateRestored
1740 restoreEntryValues: false
1741 target: appDelegate;
1742 windowedX: restoredX;
1743 windowedY: restoredY;
1747 name: "maximizedLeft"; when: appDelegate.maximizedLeft && !appDelegate.minimized
1751 windowedX: root.availableDesktopArea.x
1752 windowedY: root.availableDesktopArea.y
1753 windowedWidth: root.availableDesktopArea.width / 2
1754 windowedHeight: root.availableDesktopArea.height
1758 name: "maximizedRight"; when: appDelegate.maximizedRight && !appDelegate.minimized
1759 extend: "maximizedLeft"
1761 target: appDelegate;
1762 windowedX: root.availableDesktopArea.x + (root.availableDesktopArea.width / 2)
1766 name: "maximizedTopLeft"; when: appDelegate.maximizedTopLeft && !appDelegate.minimized
1770 windowedX: root.availableDesktopArea.x
1771 windowedY: root.availableDesktopArea.y
1772 windowedWidth: root.availableDesktopArea.width / 2
1773 windowedHeight: root.availableDesktopArea.height / 2
1777 name: "maximizedTopRight"; when: appDelegate.maximizedTopRight && !appDelegate.minimized
1778 extend: "maximizedTopLeft"
1781 windowedX: root.availableDesktopArea.x + (root.availableDesktopArea.width / 2)
1785 name: "maximizedBottomLeft"; when: appDelegate.maximizedBottomLeft && !appDelegate.minimized
1789 windowedX: root.availableDesktopArea.x
1790 windowedY: root.availableDesktopArea.y + (root.availableDesktopArea.height / 2)
1791 windowedWidth: root.availableDesktopArea.width / 2
1792 windowedHeight: root.availableDesktopArea.height / 2
1796 name: "maximizedBottomRight"; when: appDelegate.maximizedBottomRight && !appDelegate.minimized
1797 extend: "maximizedBottomLeft"
1800 windowedX: root.availableDesktopArea.x + (root.availableDesktopArea.width / 2)
1804 name: "maximizedHorizontally"; when: appDelegate.maximizedHorizontally && !appDelegate.minimized
1808 windowedX: root.availableDesktopArea.x; windowedY: windowedY
1809 windowedWidth: root.availableDesktopArea.width; windowedHeight: windowedHeight
1813 name: "maximizedVertically"; when: appDelegate.maximizedVertically && !appDelegate.minimized
1817 windowedX: windowedX; windowedY: root.availableDesktopArea.y
1818 windowedWidth: windowedWidth; windowedHeight: root.availableDesktopArea.height
1822 name: "minimized"; when: appDelegate.minimized
1825 scale: units.gu(5) / appDelegate.width
1827 visuallyMinimized: true
1828 visuallyMaximized: false
1829 x: -appDelegate.width / 2
1837 // These two animate applications into position from Staged to Desktop and back
1839 from: "staged,stagedWithSideStage"
1840 to: "normal,restored,maximized,maximizedHorizontally,maximizedVertically,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedBottomLeft,maximizedTopRight,maximizedBottomRight"
1841 enabled: appDelegate.animationsEnabled
1842 PropertyAction { target: appDelegate; properties: "visuallyMinimized,visuallyMaximized" }
1843 LomiriNumberAnimation { target: appDelegate; properties: "x,y,requestedX,requestedY,opacity,requestedWidth,requestedHeight,scale"; duration: priv.animationDuration }
1846 from: "normal,restored,maximized,maximizedHorizontally,maximizedVertically,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedBottomLeft,maximizedTopRight,maximizedBottomRight"
1847 to: "staged,stagedWithSideStage"
1848 LomiriNumberAnimation { target: appDelegate; properties: "x,y,requestedX,requestedY,requestedWidth,requestedHeight"; duration: priv.animationDuration}
1852 from: "normal,restored,maximized,maximizedHorizontally,maximizedVertically,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedBottomLeft,maximizedTopRight,maximizedBottomRight,staged,stagedWithSideStage,windowedRightEdge,stagedRightEdge";
1854 // DecoratedWindow wants the scaleToPreviewSize set before enabling scaleToPreview
1855 PropertyAction { target: appDelegate; properties: "z,visible" }
1856 PropertyAction { target: decoratedWindow; property: "scaleToPreviewSize" }
1857 LomiriNumberAnimation { target: appDelegate; properties: "x,y,height"; duration: priv.animationDuration }
1858 LomiriNumberAnimation { target: decoratedWindow; properties: "width,height,itemScale,angle,scaleToPreviewProgress"; duration: priv.animationDuration }
1859 LomiriNumberAnimation { target: windowInfoItem; properties: "opacity"; duration: priv.animationDuration }
1862 from: "normal,staged"; to: "stagedWithSideStage"
1863 LomiriNumberAnimation { target: appDelegate; properties: "x,y,requestedWidth,requestedHeight"; duration: priv.animationDuration }
1866 to: "windowedRightEdge"
1869 windowedRightEdgeMaths.startX = appDelegate.requestedX
1870 windowedRightEdgeMaths.startY = appDelegate.requestedY
1873 var thisRect = { x: appDelegate.windowedX, y: appDelegate.windowedY, width: appDelegate.requestedWidth, height: appDelegate.requestedHeight }
1874 var otherDelegate = appRepeater.itemAt(0);
1875 var otherRect = { x: otherDelegate.windowedX, y: otherDelegate.windowedY, width: otherDelegate.requestedWidth, height: otherDelegate.requestedHeight }
1876 var intersectionRect = MathUtils.intersectionRect(thisRect, otherRect)
1877 var mappedInterSectionRect = appDelegate.mapFromItem(root, intersectionRect.x, intersectionRect.y)
1878 opacityEffect.maskX = mappedInterSectionRect.x
1879 opacityEffect.maskY = mappedInterSectionRect.y
1880 opacityEffect.maskWidth = intersectionRect.width
1881 opacityEffect.maskHeight = intersectionRect.height
1887 from: "stagedRightEdge"; to: "staged"
1888 enabled: rightEdgeDragArea.cancelled // only transition back to state if the gesture was cancelled, in the other cases we play the focusAnimations.
1889 SequentialAnimation {
1891 LomiriNumberAnimation { target: appDelegate; properties: "x,y,height,width,scale"; duration: priv.animationDuration }
1892 LomiriNumberAnimation { target: decoratedWindow; properties: "width,height,itemScale,angle,scaleToPreviewProgress"; duration: priv.animationDuration }
1894 // We need to release scaleToPreviewSize at last
1895 PropertyAction { target: decoratedWindow; property: "scaleToPreviewSize" }
1896 PropertyAction { target: appDelegate; property: "visible" }
1900 from: ",normal,restored,maximized,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedTopRight,maximizedBottomLeft,maximizedBottomRight,maximizedHorizontally,maximizedVertically,fullscreen"
1902 SequentialAnimation {
1903 ScriptAction { script: { fakeRectangle.stop(); } }
1904 PropertyAction { target: appDelegate; property: "visuallyMaximized" }
1905 PropertyAction { target: appDelegate; property: "visuallyMinimized" }
1906 LomiriNumberAnimation { target: appDelegate; properties: "x,y,scale,opacity"; duration: priv.animationDuration }
1907 PropertyAction { target: appDelegate; property: "visuallyMinimized" }
1912 to: ",normal,restored,maximized,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedTopRight,maximizedBottomLeft,maximizedBottomRight,maximizedHorizontally,maximizedVertically,fullscreen"
1913 SequentialAnimation {
1914 PropertyAction { target: appDelegate; property: "visuallyMinimized,z" }
1916 LomiriNumberAnimation { target: appDelegate; properties: "x"; from: -appDelegate.width / 2; duration: priv.animationDuration }
1917 LomiriNumberAnimation { target: appDelegate; properties: "y,opacity"; duration: priv.animationDuration }
1918 LomiriNumberAnimation { target: appDelegate; properties: "scale"; from: 0; duration: priv.animationDuration }
1920 PropertyAction { target: appDelegate; property: "visuallyMaximized" }
1924 id: windowedTransition
1925 from: ",normal,restored,maximized,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedTopRight,maximizedBottomLeft,maximizedBottomRight,maximizedHorizontally,maximizedVertically,fullscreen,minimized"
1926 to: ",normal,restored,maximized,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedTopRight,maximizedBottomLeft,maximizedBottomRight,maximizedHorizontally,maximizedVertically,fullscreen"
1927 enabled: appDelegate.animationsEnabled
1928 SequentialAnimation {
1929 ScriptAction { script: {
1930 if (appDelegate.visuallyMaximized) visuallyMaximized = false; // maximized before -> going to restored
1933 PropertyAction { target: appDelegate; property: "visuallyMinimized" }
1934 LomiriNumberAnimation { target: appDelegate; properties: "requestedX,requestedY,windowedX,windowedY,opacity,scale,requestedWidth,requestedHeight,windowedWidth,windowedHeight";
1935 duration: priv.animationDuration }
1936 ScriptAction { script: {
1937 fakeRectangle.stop();
1938 appDelegate.visuallyMaximized = appDelegate.maximized; // reflect the target state
1947 property: "decorationsAlwaysVisible"
1948 value: appDelegate && appDelegate.maximized && touchControls.overlayShown
1953 objectName: "windowResizeArea"
1955 anchors.fill: appDelegate
1957 // workaround so that it chooses the correct resize borders when you drag from a corner ResizeGrip
1958 anchors.margins: touchControls.overlayShown ? borderThickness/2 : -borderThickness
1961 boundsItem: root.availableDesktopArea
1962 minWidth: units.gu(10)
1963 minHeight: units.gu(10)
1964 borderThickness: units.gu(2)
1967 readyToAssesBounds: !appDelegate._constructing
1970 appDelegate.activate();
1976 objectName: "decoratedWindow"
1977 anchors.left: appDelegate.left
1978 anchors.top: appDelegate.top
1979 application: model.application
1980 surface: model.window.surface
1981 active: model.window.focused
1983 interactive: root.interactive
1985 decorationHeight: priv.windowDecorationHeight
1986 maximizeButtonShown: appDelegate.canBeMaximized
1987 overlayShown: touchControls.overlayShown
1988 width: implicitWidth
1989 height: implicitHeight
1990 highlightSize: windowInfoItem.iconMargin / 2
1991 boundsItem: root.availableDesktopArea
1992 panelState: root.panelState
1993 altDragEnabled: root.mode == "windowed"
1995 requestedWidth: appDelegate.requestedWidth
1996 requestedHeight: appDelegate.requestedHeight
1998 onCloseClicked: { appDelegate.close(); }
1999 onMaximizeClicked: {
2000 if (appDelegate.canBeMaximized) {
2001 appDelegate.anyMaximized ? appDelegate.requestRestore() : appDelegate.requestMaximize();
2004 onMaximizeHorizontallyClicked: {
2005 if (appDelegate.canBeMaximizedHorizontally) {
2006 appDelegate.maximizedHorizontally ? appDelegate.requestRestore() : appDelegate.requestMaximizeHorizontally()
2009 onMaximizeVerticallyClicked: {
2010 if (appDelegate.canBeMaximizedVertically) {
2011 appDelegate.maximizedVertically ? appDelegate.requestRestore() : appDelegate.requestMaximizeVertically()
2014 onMinimizeClicked: { appDelegate.requestMinimize(); }
2015 onDecorationPressed: { appDelegate.activate(); }
2016 onDecorationReleased: fakeRectangle.visible ? fakeRectangle.commit() : appDelegate.updateRestoredGeometry()
2018 property real angle: 0
2019 Behavior on angle { enabled: priv.closingIndex >= 0; LomiriNumberAnimation {} }
2020 property real itemScale: 1
2021 Behavior on itemScale { enabled: priv.closingIndex >= 0; LomiriNumberAnimation {} }
2026 origin.y: decoratedWindow.implicitHeight / 2
2027 xScale: decoratedWindow.itemScale
2028 yScale: decoratedWindow.itemScale
2031 origin { x: 0; y: (decoratedWindow.height / 2) }
2032 axis { x: 0; y: 1; z: 0 }
2033 angle: decoratedWindow.angle
2040 anchors.fill: decoratedWindow
2043 WindowControlsOverlay {
2045 anchors.fill: appDelegate
2047 resizeArea: resizeArea
2050 boundsItem: root.availableDesktopArea
2052 onFakeMaximizeAnimationRequested: if (!appDelegate.maximized) fakeRectangle.maximize(amount, true)
2053 onFakeMaximizeLeftAnimationRequested: if (!appDelegate.maximizedLeft) fakeRectangle.maximizeLeft(amount, true)
2054 onFakeMaximizeRightAnimationRequested: if (!appDelegate.maximizedRight) fakeRectangle.maximizeRight(amount, true)
2055 onFakeMaximizeTopLeftAnimationRequested: if (!appDelegate.maximizedTopLeft) fakeRectangle.maximizeTopLeft(amount, true);
2056 onFakeMaximizeTopRightAnimationRequested: if (!appDelegate.maximizedTopRight) fakeRectangle.maximizeTopRight(amount, true);
2057 onFakeMaximizeBottomLeftAnimationRequested: if (!appDelegate.maximizedBottomLeft) fakeRectangle.maximizeBottomLeft(amount, true);
2058 onFakeMaximizeBottomRightAnimationRequested: if (!appDelegate.maximizedBottomRight) fakeRectangle.maximizeBottomRight(amount, true);
2059 onStopFakeAnimation: fakeRectangle.stop();
2060 onDragReleased: fakeRectangle.visible ? fakeRectangle.commit() : appDelegate.updateRestoredGeometry()
2063 WindowedFullscreenPolicy {
2064 id: windowedFullscreenPolicy
2066 StagedFullscreenPolicy {
2067 id: stagedFullscreenPolicy
2068 active: root.mode == "staged" || root.mode == "stagedWithSideStage"
2069 surface: model.window.surface
2072 SpreadDelegateInputArea {
2074 objectName: "dragArea"
2075 anchors.fill: decoratedWindow
2079 dragDelegate: fakeDragItem
2082 spreadItem.highlightedIndex = index;
2083 if (distance == 0) {
2084 priv.goneToSpread = false;
2088 priv.closingIndex = index
2089 appDelegate.close();
2095 objectName: "windowInfoItem"
2096 anchors { left: parent.left; top: decoratedWindow.bottom; topMargin: units.gu(1) }
2097 title: model.application.name
2098 iconSource: model.application.icon
2099 height: spreadItem.appInfoHeight
2102 visible: opacity > 0
2104 var nextApp = appRepeater.itemAt(index + 1);
2106 return Math.max(iconHeight, nextApp.x - appDelegate.x - units.gu(1))
2108 return appDelegate.width;
2112 spreadItem.highlightedIndex = index;
2113 priv.goneToSpread = false;
2119 objectName: "closeMouseArea"
2120 anchors { left: parent.left; top: parent.top; leftMargin: -height / 2; topMargin: -height / 2 + spreadMaths.closeIconOffset }
2121 readonly property var mousePos: hoverMouseArea.mapToItem(appDelegate, hoverMouseArea.mouseX, hoverMouseArea.mouseY)
2122 readonly property bool shown: dragArea.distance == 0
2123 && index == spreadItem.highlightedIndex
2124 && mousePos.y < (decoratedWindow.height / 3)
2125 && mousePos.y > -units.gu(4)
2126 && mousePos.x > -units.gu(4)
2127 && mousePos.x < (decoratedWindow.width * 2 / 3)
2128 opacity: shown ? 1 : 0
2129 visible: opacity > 0
2130 Behavior on opacity { LomiriNumberAnimation { duration: LomiriAnimation.SnapDuration } }
2135 priv.closingIndex = index;
2136 appDelegate.close();
2140 source: "graphics/window-close.svg"
2141 anchors.fill: closeMouseArea
2142 anchors.margins: units.gu(2)
2143 sourceSize.width: width
2144 sourceSize.height: height
2149 // Group all child windows in this item so that we can fade them out together when going to the spread
2150 // (and fade them in back again when returning from it)
2151 readonly property bool stageOnProperState: root.state === "windowed"
2152 || root.state === "staged"
2153 || root.state === "stagedWithSideStage"
2155 // TODO: Is it worth the extra cost of layering to avoid the opacity artifacts of intersecting children?
2156 // Btw, will involve more than uncommenting the line below as children won't necessarily fit this item's
2157 // geometry. This is just a reference.
2158 //layer.enabled: opacity !== 0.0 && opacity !== 1.0
2160 opacity: stageOnProperState ? 1.0 : 0.0
2161 visible: opacity !== 0.0 // make it transparent to input as well
2162 Behavior on opacity { LomiriNumberAnimation {} }
2165 id: childWindowRepeater
2166 model: appDelegate.surface ? appDelegate.surface.childSurfaceList : null
2168 delegate: ChildWindowTree {
2169 surface: model.surface
2171 // Account for the displacement caused by window decoration in the top-level surface
2172 // Ie, the top-level surface is not positioned at (0,0) of this ChildWindow's parent (appDelegate)
2173 displacementX: appDelegate.clientAreaItem.x
2174 displacementY: appDelegate.clientAreaItem.y
2176 boundsItem: root.availableDesktopArea
2177 decorationHeight: priv.windowDecorationHeight
2179 z: childWindowRepeater.count - model.index
2183 // some child surface in this tree got focus.
2184 // Ensure we also have it at the top-level hierarchy
2185 appDelegate.claimFocus();
2195 FakeMaximizeDelegate {
2197 target: priv.focusedAppDelegate
2198 leftMargin: root.availableDesktopArea.x
2199 appContainerWidth: appContainer.width
2200 appContainerHeight: appContainer.height
2201 panelState: root.panelState
2205 id: workspaceSwitcher
2206 enabled: workspaceEnabled
2207 anchors.centerIn: parent
2208 height: units.gu(20)
2209 width: root.width - units.gu(8)
2210 background: root.background
2213 appContainer.focus = true;
2219 id: shortRightEdgeSwipeAnimation
2222 duration: priv.animationDuration
2226 id: rightEdgeDragArea
2227 objectName: "rightEdgeDragArea"
2228 direction: Direction.Leftwards
2229 anchors { top: parent.top; right: parent.right; bottom: parent.bottom }
2230 width: root.dragAreaWidth
2231 enabled: root.spreadEnabled
2233 property var gesturePoints: []
2234 property bool cancelled: false
2236 property real progress: -touchPosition.x / root.width
2237 onProgressChanged: {
2239 draggedProgress = progress;
2243 property real draggedProgress: 0
2245 onTouchPositionChanged: {
2246 gesturePoints.push(touchPosition.x);
2247 if (gesturePoints.length > 10) {
2248 gesturePoints.splice(0, gesturePoints.length - 10)
2252 onDraggingChanged: {
2254 // A potential edge-drag gesture has started. Start recording it
2257 draggedProgress = 0;
2259 // Ok. The user released. Did he drag far enough to go to full spread?
2260 if (gesturePoints[gesturePoints.length - 1] < -spreadItem.rightEdgeBreakPoint * spreadItem.width ) {
2262 // He dragged far enough, but if the last movement was a flick to the right again, he wants to cancel the spread again.
2263 var oneWayFlickToRight = true;
2264 var smallestX = gesturePoints[0]-1;
2265 for (var i = 0; i < gesturePoints.length; i++) {
2266 if (gesturePoints[i] <= smallestX) {
2267 oneWayFlickToRight = false;
2270 smallestX = gesturePoints[i];
2273 if (!oneWayFlickToRight) {
2274 // Ok, the user made it, let's go to spread!
2275 priv.goneToSpread = true;
2280 // Ok, the user didn't drag far enough to cross the breakPoint
2281 // Find out if it was a one-way movement to the left, in which case we just switch directly to next app.
2282 var oneWayFlick = true;
2283 var smallestX = rightEdgeDragArea.width;
2284 for (var i = 0; i < gesturePoints.length; i++) {
2285 if (gesturePoints[i] >= smallestX) {
2286 oneWayFlick = false;
2289 smallestX = gesturePoints[i];
2292 if (appRepeater.count > 1 &&
2293 (oneWayFlick && rightEdgeDragArea.distance > units.gu(2) || rightEdgeDragArea.distance > spreadItem.rightEdgeBreakPoint * spreadItem.width)) {
2294 var nextStage = appRepeater.itemAt(priv.nextInStack).stage
2295 for (var i = 0; i < appRepeater.count; i++) {
2296 if (i != priv.nextInStack && appRepeater.itemAt(i).stage == nextStage) {
2297 appRepeater.itemAt(i).playHidingAnimation()
2301 appRepeater.itemAt(priv.nextInStack).playFocusAnimation()
2302 if (appRepeater.itemAt(priv.nextInStack).stage == ApplicationInfoInterface.SideStage && !sideStage.shown) {
2316 TabletSideStageTouchGesture {
2318 objectName: "triGestureArea"
2319 anchors.fill: parent
2321 property Item appDelegate
2323 dragComponent: dragComponent
2324 dragComponentProperties: { "appDelegate": appDelegate }
2327 function matchDelegate(obj) { return String(obj.objectName).indexOf("appDelegate") >= 0; }
2329 var delegateAtCenter = Functions.itemAt(appContainer, x, y, matchDelegate);
2330 if (!delegateAtCenter) return;
2332 appDelegate = delegateAtCenter;
2336 if (sideStage.shown) {
2340 priv.updateMainAndSideStageIndexes()
2345 // If we're dragging to the sidestage.
2346 if (!sideStage.shown) {
2354 property Item appDelegate
2356 surface: appDelegate ? appDelegate.surface : null
2358 consumesInput: false
2361 requestedWidth: appDelegate ? appDelegate.requestedWidth : 0
2362 requestedHeight: appDelegate ? appDelegate.requestedHeight : 0
2365 height: units.gu(40)
2367 Drag.hotSpot.x: width/2
2368 Drag.hotSpot.y: height/2
2369 // only accept opposite stage.
2371 if (!surface) return "Disabled";
2373 if (appDelegate.stage === ApplicationInfo.MainStage) {
2374 if (appDelegate.application.supportedOrientations
2375 & (Qt.PortraitOrientation|Qt.InvertedPortraitOrientation)) {