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/>.
20import QtQuick.Window 2.2
21import Lomiri.Components 1.3
22import QtMir.Application 0.1
23import "../Components/PanelState"
26import Lomiri.Gestures 0.1
27import GlobalShortcut 1.0
30import "Spread/MathUtils.js" as MathUtils
31import ProcessControl 0.1
32import WindowManager 1.0
38 property QtObject applicationManager
39 property QtObject topLevelSurfaceList
40 property bool altTabPressed
41 property url background
42 property alias backgroundSourceSize: wallpaper.sourceSize
43 property int dragAreaWidth
44 property real nativeHeight
45 property real nativeWidth
46 property QtObject orientations
47 property int shellOrientation
48 property int shellOrientationAngle
49 property bool spreadEnabled: true // If false, animations and right edge will be disabled
50 property bool suspended
51 property bool oskEnabled: false
52 property rect inputMethodRect
53 property real rightEdgePushProgress: 0
54 property Item availableDesktopArea
55 property PanelState panelState
57 // Whether outside forces say that the Stage may have focus
58 property bool allowInteractivity
60 readonly property bool interactive: (state === "staged" || state === "stagedWithSideStage" || state === "windowed") && allowInteractivity
63 property string mode: "staged"
65 readonly property var temporarySelectedWorkspace: state == "spread" ? screensAndWorkspaces.activeWorkspace : null
66 property bool workspaceEnabled: (mode == "windowed" && settings.enableWorkspace) || settings.forceEnableWorkspace
68 // Used by the tutorial code
69 readonly property real rightEdgeDragProgress: rightEdgeDragArea.dragging ? rightEdgeDragArea.progress : 0 // How far left the stage has been dragged
71 // used by the snap windows (edge maximize) feature
72 readonly property alias previewRectangle: fakeRectangle
74 readonly property bool spreadShown: state == "spread"
75 readonly property var mainApp: priv.focusedAppDelegate ? priv.focusedAppDelegate.application : null
77 // application windows never rotate independently
78 property int mainAppWindowOrientationAngle: shellOrientationAngle
80 property bool orientationChangesEnabled: !priv.focusedAppDelegate || priv.focusedAppDelegate.orientationChangesEnabled
82 property int supportedOrientations: {
86 return mainApp.supportedOrientations;
87 case "stagedWithSideStage":
88 var orientations = mainApp.supportedOrientations;
89 orientations |= Qt.LandscapeOrientation | Qt.InvertedLandscapeOrientation;
90 if (priv.sideStageItemId) {
91 // If we have a sidestage app, support Portrait orientation
92 // so that it will switch the sidestage app to mainstage on rotate to portrait
93 orientations |= Qt.PortraitOrientation|Qt.InvertedPortraitOrientation;
99 return Qt.PortraitOrientation |
100 Qt.LandscapeOrientation |
101 Qt.InvertedPortraitOrientation |
102 Qt.InvertedLandscapeOrientation;
107 schema.id: "com.lomiri.Shell"
110 property int launcherLeftMargin : 0
113 target: topLevelSurfaceList
114 restoreMode: Binding.RestoreBinding
115 property: "rootFocus"
119 onInteractiveChanged: {
120 // Stage must have focus before activating windows, including null
126 onAltTabPressedChanged: {
129 if (root.spreadEnabled) {
130 altTabDelayTimer.start();
133 // Alt Tab has been released, did we already go to spread?
134 if (priv.goneToSpread) {
135 priv.goneToSpread = false;
137 // No we didn't, do a quick alt-tab
138 if (appRepeater.count > 1) {
139 appRepeater.itemAt(1).activate();
140 } else if (appRepeater.count > 0) {
141 appRepeater.itemAt(0).activate(); // quick alt-tab to the only (minimized) window should still activate it
152 if (root.altTabPressed) {
153 priv.goneToSpread = true;
158 // For MirAL window management
160 normal: Qt.rect(0, root.mode === "windowed" ? priv.windowDecorationHeight : 0, 0, 0)
164 property Item itemConfiningMouseCursor: !spreadShown && priv.focusedAppDelegate && priv.focusedAppDelegate.window && priv.focusedAppDelegate.window.confinesMousePointer ?
165 priv.focusedAppDelegate.clientAreaItem : null;
167 signal itemSnapshotRequested(Item item)
169 // functions to be called from outside
170 function updateFocusedAppOrientation() { /* TODO */ }
171 function updateFocusedAppOrientationAnimated() { /* TODO */}
173 function closeSpread() {
174 spreadItem.highlightedIndex = -1;
175 priv.goneToSpread = false;
178 onSpreadEnabledChanged: {
179 if (!spreadEnabled && spreadShown) {
184 onRightEdgePushProgressChanged: {
185 if (spreadEnabled && rightEdgePushProgress >= 1) {
186 priv.goneToSpread = true
191 id: lifecycleExceptions
192 schema.id: "com.canonical.qtmir"
195 function isExemptFromLifecycle(appId) {
196 var shortAppId = appId.split('_')[0];
197 for (var i = 0; i < lifecycleExceptions.lifecycleExemptAppids.length; i++) {
198 if (shortAppId === lifecycleExceptions.lifecycleExemptAppids[i]) {
206 id: closeFocusedShortcut
207 shortcut: Qt.AltModifier|Qt.Key_F4
209 if (priv.focusedAppDelegate) {
210 priv.focusedAppDelegate.close();
216 id: showSpreadShortcut
217 shortcut: Qt.MetaModifier|Qt.Key_W
218 active: root.spreadEnabled
219 onTriggered: priv.goneToSpread = true
223 id: toggleSideStageShortcut
224 shortcut: Qt.MetaModifier|Qt.Key_S
225 active: priv.sideStageEnabled
227 priv.toggleSideStage()
232 id: minimizeAllShortcut
233 shortcut: Qt.MetaModifier|Qt.ControlModifier|Qt.Key_D
234 onTriggered: priv.minimizeAllWindows()
235 active: root.state == "windowed"
239 id: maximizeWindowShortcut
240 shortcut: Qt.MetaModifier|Qt.ControlModifier|Qt.Key_Up
241 onTriggered: priv.focusedAppDelegate.requestMaximize()
242 active: root.state == "windowed" && priv.focusedAppDelegate && priv.focusedAppDelegate.canBeMaximized
246 id: maximizeWindowLeftShortcut
247 shortcut: Qt.MetaModifier|Qt.ControlModifier|Qt.Key_Left
250 case "stagedWithSideStage":
251 if ( priv.focusedAppDelegate
252 && priv.focusedAppDelegate.stage == ApplicationInfoInterface.SideStage
254 priv.focusedAppDelegate.saveStage(ApplicationInfoInterface.MainStage);
255 priv.focusedAppDelegate.focus = true;
259 if (priv.focusedAppDelegate) {
260 priv.focusedAppDelegate.requestMaximizeLeft();
266 switch (root.state) {
267 case "stagedWithSideStage":
268 return priv.focusedAppDelegate
269 && priv.focusedAppDelegate.stage == ApplicationInfoInterface.SideStage
270 && priv.sideStageEnabled;
272 return priv.focusedAppDelegate
273 && priv.focusedAppDelegate.canBeMaximizedLeftRight;
281 id: maximizeWindowRightShortcut
282 shortcut: Qt.MetaModifier|Qt.ControlModifier|Qt.Key_Right
285 case "stagedWithSideStage":
286 if ( priv.focusedAppDelegate
287 && priv.focusedAppDelegate.stage == ApplicationInfoInterface.MainStage
289 priv.focusedAppDelegate.saveStage(ApplicationInfoInterface.SideStage);
290 priv.focusedAppDelegate.focus = true;
292 priv.updateMainAndSideStageIndexes();
296 if (priv.focusedAppDelegate) {
297 priv.focusedAppDelegate.requestMaximizeRight();
303 switch (root.state) {
304 case "stagedWithSideStage":
305 return priv.focusedAppDelegate
306 && priv.focusedAppDelegate.stage == ApplicationInfoInterface.MainStage
307 && priv.sideStageEnabled;
309 return priv.focusedAppDelegate
310 && priv.focusedAppDelegate.canBeMaximizedLeftRight;
318 id: minimizeRestoreShortcut
319 shortcut: Qt.MetaModifier|Qt.ControlModifier|Qt.Key_Down
321 if (priv.focusedAppDelegate.anyMaximized) {
322 priv.focusedAppDelegate.requestRestore();
324 priv.focusedAppDelegate.requestMinimize();
327 active: root.state == "windowed" && priv.focusedAppDelegate
331 shortcut: Qt.AltModifier|Qt.Key_Print
332 onTriggered: root.itemSnapshotRequested(priv.focusedAppDelegate)
333 active: priv.focusedAppDelegate !== null
337 shortcut: Qt.ControlModifier|Qt.AltModifier|Qt.Key_T
339 // try in this order: snap pkg, new deb name, old deb name
340 var candidates = ["lomiri-terminal-app_lomiri-terminal-app", "lomiri-terminal-app", "com.lomiri.terminal_terminal"];
341 for (var i = 0; i < candidates.length; i++) {
342 if (priv.startApp(candidates[i]))
349 id: showWorkspaceSwitcherShortcutLeft
350 shortcut: Qt.AltModifier|Qt.ControlModifier|Qt.Key_Left
351 active: !workspaceSwitcher.active && root.workspaceEnabled
354 workspaceSwitcher.showLeft()
358 id: showWorkspaceSwitcherShortcutRight
359 shortcut: Qt.AltModifier|Qt.ControlModifier|Qt.Key_Right
360 active: !workspaceSwitcher.active && root.workspaceEnabled
363 workspaceSwitcher.showRight()
367 id: showWorkspaceSwitcherShortcutUp
368 shortcut: Qt.AltModifier|Qt.ControlModifier|Qt.Key_Up
369 active: !workspaceSwitcher.active && root.workspaceEnabled
372 workspaceSwitcher.showUp()
376 id: showWorkspaceSwitcherShortcutDown
377 shortcut: Qt.AltModifier|Qt.ControlModifier|Qt.Key_Down
378 active: !workspaceSwitcher.active && root.workspaceEnabled
381 workspaceSwitcher.showDown()
386 id: moveAppShowWorkspaceSwitcherShortcutLeft
387 shortcut: Qt.AltModifier|Qt.ControlModifier|Qt.ShiftModifier|Qt.Key_Left
388 active: !workspaceSwitcher.active && root.workspaceEnabled && priv.focusedAppDelegate !== null
391 workspaceSwitcher.showLeftMoveApp(priv.focusedAppDelegate.surface)
395 id: moveAppShowWorkspaceSwitcherShortcutRight
396 shortcut: Qt.AltModifier|Qt.ControlModifier|Qt.ShiftModifier|Qt.Key_Right
397 active: !workspaceSwitcher.active && root.workspaceEnabled && priv.focusedAppDelegate !== null
400 workspaceSwitcher.showRightMoveApp(priv.focusedAppDelegate.surface)
404 id: moveAppShowWorkspaceSwitcherShortcutUp
405 shortcut: Qt.AltModifier|Qt.ControlModifier|Qt.ShiftModifier|Qt.Key_Up
406 active: !workspaceSwitcher.active && root.workspaceEnabled && priv.focusedAppDelegate !== null
409 workspaceSwitcher.showUpMoveApp(priv.focusedAppDelegate.surface)
413 id: moveAppShowWorkspaceSwitcherShortcutDown
414 shortcut: Qt.AltModifier|Qt.ControlModifier|Qt.ShiftModifier|Qt.Key_Down
415 active: !workspaceSwitcher.active && root.workspaceEnabled && priv.focusedAppDelegate !== null
418 workspaceSwitcher.showDownMoveApp(priv.focusedAppDelegate.surface)
424 objectName: "DesktopStagePrivate"
426 function startApp(appId) {
427 if (root.applicationManager.findApplication(appId)) {
428 return root.applicationManager.requestFocusApplication(appId);
430 return root.applicationManager.startApplication(appId) !== null;
434 property var focusedAppDelegate: null
435 property var foregroundMaximizedAppDelegate: null // for stuff like drop shadow and focusing maximized app by clicking panel
437 property bool goneToSpread: false
438 property int closingIndex: -1
439 property int animationDuration: LomiriAnimation.FastDuration
441 function updateForegroundMaximizedApp() {
443 for (var i = 0; i < appRepeater.count && !found; i++) {
444 var item = appRepeater.itemAt(i);
445 if (item && item.visuallyMaximized) {
446 foregroundMaximizedAppDelegate = item;
451 foregroundMaximizedAppDelegate = null;
455 function minimizeAllWindows() {
456 for (var i = appRepeater.count - 1; i >= 0; i--) {
457 var appDelegate = appRepeater.itemAt(i);
458 if (appDelegate && !appDelegate.minimized) {
459 appDelegate.requestMinimize();
464 readonly property bool sideStageEnabled: root.mode === "stagedWithSideStage" &&
465 (root.shellOrientation == Qt.LandscapeOrientation ||
466 root.shellOrientation == Qt.InvertedLandscapeOrientation)
467 onSideStageEnabledChanged: {
468 for (var i = 0; i < appRepeater.count; i++) {
469 appRepeater.itemAt(i).refreshStage();
471 priv.updateMainAndSideStageIndexes();
474 property var mainStageDelegate: null
475 property var sideStageDelegate: null
476 property int mainStageItemId: 0
477 property int sideStageItemId: 0
478 property string mainStageAppId: ""
479 property string sideStageAppId: ""
481 onSideStageDelegateChanged: {
482 if (!sideStageDelegate) {
487 function toggleSideStage() {
488 if (sideStage.shown) {
492 updateMainAndSideStageIndexes()
496 function updateMainAndSideStageIndexes() {
497 if (root.mode != "stagedWithSideStage") {
498 priv.sideStageDelegate = null;
499 priv.sideStageItemId = 0;
500 priv.sideStageAppId = "";
501 priv.mainStageDelegate = appRepeater.itemAt(0);
502 priv.mainStageItemId = topLevelSurfaceList.idAt(0);
503 priv.mainStageAppId = topLevelSurfaceList.applicationAt(0) ? topLevelSurfaceList.applicationAt(0).appId : ""
507 var choseMainStage = false;
508 var choseSideStage = false;
510 if (!root.topLevelSurfaceList)
513 for (var i = 0; i < appRepeater.count && (!choseMainStage || !choseSideStage); ++i) {
514 var appDelegate = appRepeater.itemAt(i);
516 // This might happen during startup phase... If the delegate appears and claims focus
517 // things are updated and appRepeater.itemAt(x) still returns null while appRepeater.count >= x
518 // Lets just skip it, on startup it will be generated at a later point too...
521 if (sideStage.shown && appDelegate.stage == ApplicationInfoInterface.SideStage
522 && !choseSideStage) {
523 priv.sideStageDelegate = appDelegate
524 priv.sideStageItemId = root.topLevelSurfaceList.idAt(i);
525 priv.sideStageAppId = root.topLevelSurfaceList.applicationAt(i).appId;
526 choseSideStage = true;
527 } else if (!choseMainStage && appDelegate.stage == ApplicationInfoInterface.MainStage) {
528 priv.mainStageDelegate = appDelegate;
529 priv.mainStageItemId = root.topLevelSurfaceList.idAt(i);
530 priv.mainStageAppId = root.topLevelSurfaceList.applicationAt(i).appId;
531 choseMainStage = true;
534 if (!choseMainStage && priv.mainStageDelegate) {
535 priv.mainStageDelegate = null;
536 priv.mainStageItemId = 0;
537 priv.mainStageAppId = "";
539 if (!choseSideStage && priv.sideStageDelegate) {
540 priv.sideStageDelegate = null;
541 priv.sideStageItemId = 0;
542 priv.sideStageAppId = "";
546 property int nextInStack: {
547 var mainStageIndex = priv.mainStageDelegate ? priv.mainStageDelegate.itemIndex : -1;
548 var sideStageIndex = priv.sideStageDelegate ? priv.sideStageDelegate.itemIndex : -1;
549 if (sideStageIndex == -1) {
550 return topLevelSurfaceList.count > 1 ? 1 : -1;
552 if (mainStageIndex == 0 || sideStageIndex == 0) {
553 if (mainStageIndex == 1 || sideStageIndex == 1) {
554 return topLevelSurfaceList.count > 2 ? 2 : -1;
561 readonly property real virtualKeyboardHeight: root.inputMethodRect.height
563 readonly property real windowDecorationHeight: units.gu(3)
566 Component.onCompleted: priv.updateMainAndSideStageIndexes()
570 function onCloseClicked() { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.close(); } }
571 function onMinimizeClicked() { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.requestMinimize(); } }
572 function onRestoreClicked() { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.requestRestore(); } }
577 restoreMode: Binding.RestoreBinding
578 property: "decorationsVisible"
579 value: mode == "windowed" && priv.focusedAppDelegate !== null && priv.focusedAppDelegate.maximized && !root.spreadShown
584 restoreMode: Binding.RestoreBinding
587 if (priv.focusedAppDelegate !== null) {
588 if (priv.focusedAppDelegate.maximized)
589 return priv.focusedAppDelegate.title
591 return priv.focusedAppDelegate.appName
595 when: priv.focusedAppDelegate
600 restoreMode: Binding.RestoreBinding
601 property: "focusedPersistentSurfaceId"
603 if (priv.focusedAppDelegate !== null) {
604 if (priv.focusedAppDelegate.surface) {
605 return priv.focusedAppDelegate.surface.persistentId;
610 when: priv.focusedAppDelegate
615 restoreMode: Binding.RestoreBinding
616 property: "dropShadow"
617 value: priv.focusedAppDelegate && !priv.focusedAppDelegate.maximized && priv.foregroundMaximizedAppDelegate !== null && mode == "windowed"
622 restoreMode: Binding.RestoreBinding
623 property: "closeButtonShown"
624 value: priv.focusedAppDelegate && priv.focusedAppDelegate.maximized
627 Component.onDestruction: {
628 panelState.title = "";
629 panelState.decorationsVisible = false;
630 panelState.dropShadow = false;
634 model: root.applicationManager
636 id: applicationDelegate
637 // TODO: figure out some lifecycle policy, like suspending minimized apps
638 // or something if running windowed.
639 // TODO: If the device has a dozen suspended apps because it was running
640 // in staged mode, when it switches to Windowed mode it will suddenly
641 // resume all those apps at once. We might want to avoid that.
642 property var requestedState: ApplicationInfoInterface.RequestedRunning
643 property bool temporaryAwaken: ProcessControl.awakenProcesses.indexOf(model.application.appId) >= 0
645 property var stateBinding: Binding {
646 target: model.application
647 property: "requestedState"
648 value: applicationDelegate.requestedState
649 restoreMode: Binding.RestoreBinding
652 property var lifecycleBinding: Binding {
653 target: model.application
654 property: "exemptFromLifecycle"
655 restoreMode: Binding.RestoreBinding
656 value: model.application
657 ? (!model.application.isTouchApp ||
658 isExemptFromLifecycle(model.application.appId) ||
659 applicationDelegate.temporaryAwaken)
664 property var focusRequestedConnection: Connections {
665 target: model.application
667 function onFocusRequested() {
668 // Application emits focusRequested when it has no surface (i.e. their processes died).
669 // Find the topmost window for this application and activate it, after which the app
670 // will be requested to be running.
672 for (var i = 0; i < appRepeater.count; i++) {
673 var appDelegate = appRepeater.itemAt(i);
674 if (appDelegate.application.appId === model.application.appId) {
675 appDelegate.activate();
680 console.warn("Application requested te be focused but no window for it. What should we do?");
688 name: "spread"; when: priv.goneToSpread
689 PropertyChanges { target: floatingFlickable; enabled: true }
690 PropertyChanges { target: root; focus: true }
691 PropertyChanges { target: spreadItem; focus: true }
692 PropertyChanges { target: hoverMouseArea; enabled: true }
693 PropertyChanges { target: rightEdgeDragArea; enabled: false }
694 PropertyChanges { target: cancelSpreadMouseArea; enabled: true }
695 PropertyChanges { target: noAppsRunningHint; visible: (root.topLevelSurfaceList.count < 1) }
696 PropertyChanges { target: blurLayer; visible: true; blurRadius: 32; brightness: .50; opacity: 1 }
697 PropertyChanges { target: wallpaper; visible: false }
698 PropertyChanges { target: screensAndWorkspaces.showTimer; running: true }
701 name: "stagedRightEdge"; when: root.spreadEnabled && (rightEdgeDragArea.dragging || rightEdgePushProgress > 0) && root.mode == "staged"
709 PropertyChanges { target: noAppsRunningHint; visible: (root.topLevelSurfaceList.count < 1) }
712 name: "sideStagedRightEdge"; when: root.spreadEnabled && (rightEdgeDragArea.dragging || rightEdgePushProgress > 0) && root.mode == "stagedWithSideStage"
713 extend: "stagedRightEdge"
716 opacity: priv.sideStageDelegate && priv.sideStageDelegate.x === sideStage.x ? 1 : 0
721 name: "windowedRightEdge"; when: root.spreadEnabled && (rightEdgeDragArea.dragging || rightEdgePushProgress > 0) && root.mode == "windowed"
727 opacity: MathUtils.linearAnimation(spreadItem.rightEdgeBreakPoint, 1, 0, 1, Math.max(rightEdgeDragArea.dragging ? rightEdgeDragArea.progress : 0, rightEdgePushProgress))
731 name: "staged"; when: root.mode === "staged"
732 PropertyChanges { target: root; focus: true }
733 PropertyChanges { target: appContainer; focus: true }
736 name: "stagedWithSideStage"; when: root.mode === "stagedWithSideStage"
737 PropertyChanges { target: triGestureArea; enabled: priv.sideStageEnabled }
738 PropertyChanges { target: sideStage; visible: true }
739 PropertyChanges { target: root; focus: true }
740 PropertyChanges { target: appContainer; focus: true }
743 name: "windowed"; when: root.mode === "windowed"
744 PropertyChanges { target: root; focus: true }
745 PropertyChanges { target: appContainer; focus: true }
750 from: "stagedRightEdge,sideStagedRightEdge,windowedRightEdge"; to: "spread"
751 PropertyAction { target: spreadItem; property: "highlightedIndex"; value: -1 }
752 PropertyAction { target: screensAndWorkspaces; property: "activeWorkspace"; value: WMScreen.currentWorkspace }
753 PropertyAnimation { target: blurLayer; properties: "brightness,blurRadius"; duration: priv.animationDuration }
757 PropertyAction { target: screensAndWorkspaces; property: "activeWorkspace"; value: WMScreen.currentWorkspace }
758 PropertyAction { target: spreadItem; property: "highlightedIndex"; value: appRepeater.count > 1 ? 1 : 0 }
759 PropertyAction { target: floatingFlickable; property: "contentX"; value: 0 }
763 SequentialAnimation {
766 var item = appRepeater.itemAt(Math.max(0, spreadItem.highlightedIndex));
768 if (item.stage == ApplicationInfoInterface.SideStage && !sideStage.shown) {
771 item.playFocusAnimation();
775 PropertyAction { target: spreadItem; property: "highlightedIndex"; value: -1 }
776 PropertyAction { target: floatingFlickable; property: "contentX"; value: 0 }
780 to: "stagedRightEdge,sideStagedRightEdge"
781 PropertyAction { target: floatingFlickable; property: "contentX"; value: 0 }
784 to: "stagedWithSideStage"
785 ScriptAction { script: priv.updateMainAndSideStageIndexes(); }
791 id: cancelSpreadMouseArea
794 onClicked: priv.goneToSpread = false
799 objectName: "appContainer"
805 objectName: "stageBackground"
807 source: root.background
808 // Make sure it's the lowest item. Due to the left edge drag we sometimes need
809 // to put the dash at -1 and we don't want it behind the Wallpaper
820 ScreensAndWorkspaces {
821 id: screensAndWorkspaces
822 anchors { left: parent.left; top: parent.top; right: parent.right; leftMargin: root.launcherLeftMargin }
823 height: Math.max(units.gu(30), parent.height * .3)
824 background: root.background
826 enabled: workspaceEnabled
828 availableDesktopArea: root.availableDesktopArea
829 onCloseSpread: priv.goneToSpread = false;
830 // Clicking a workspace should put it front and center
831 onActiveWorkspaceChanged: activeWorkspace.activate()
832 opacity: visible ? 1.0 : 0.0
833 Behavior on opacity {
834 NumberAnimation { duration: priv.animationDuration }
837 property bool showAllowed : false
838 property var showTimer: Timer {
841 interval: priv.animationDuration
843 if (!priv.goneToSpread)
845 screensAndWorkspaces.showAllowed = root.workspaceEnabled;
850 onGoneToSpreadChanged: if (!priv.goneToSpread) screensAndWorkspaces.showAllowed = false
856 objectName: "spreadItem"
859 bottom: parent.bottom;
861 top: workspaceEnabled ? screensAndWorkspaces.bottom : parent.top;
863 leftMargin: root.availableDesktopArea.x
864 model: root.topLevelSurfaceList
865 spreadFlickable: floatingFlickable
866 z: root.topLevelSurfaceList.count
869 priv.goneToSpread = false;
873 appRepeater.itemAt(highlightedIndex).close();
877 id: floatingFlickable
878 objectName: "spreadFlickable"
881 contentWidth: spreadItem.spreadTotalWidth
883 function snap(toIndex) {
884 var delegate = appRepeater.itemAt(toIndex)
885 var targetContentX = floatingFlickable.contentWidth / spreadItem.totalItemCount * toIndex;
886 if (targetContentX - floatingFlickable.contentX > spreadItem.rightStackXPos - (spreadItem.spreadItemWidth / 2)) {
887 var offset = (spreadItem.rightStackXPos - (spreadItem.spreadItemWidth / 2)) - (targetContentX - floatingFlickable.contentX)
888 snapAnimation.to = floatingFlickable.contentX - offset;
889 snapAnimation.start();
890 } else if (targetContentX - floatingFlickable.contentX < spreadItem.leftStackXPos + units.gu(1)) {
891 var offset = (spreadItem.leftStackXPos + units.gu(1)) - (targetContentX - floatingFlickable.contentX);
892 snapAnimation.to = floatingFlickable.contentX - offset;
893 snapAnimation.start();
896 LomiriNumberAnimation {id: snapAnimation; target: floatingFlickable; property: "contentX"}
901 objectName: "hoverMouseArea"
903 propagateComposedEvents: true
907 property bool wasTouchPress: false
909 property int scrollAreaWidth: width / 3
910 property bool progressiveScrollingEnabled: false
913 mouse.accepted = false
915 if (hoverMouseArea.pressed || wasTouchPress) {
919 // Find the hovered item and mark it active
920 for (var i = appRepeater.count - 1; i >= 0; i--) {
921 var appDelegate = appRepeater.itemAt(i);
922 var mapped = mapToItem(appDelegate, hoverMouseArea.mouseX, hoverMouseArea.mouseY)
923 var itemUnder = appDelegate.childAt(mapped.x, mapped.y);
924 if (itemUnder && (itemUnder.objectName === "dragArea" || itemUnder.objectName === "windowInfoItem" || itemUnder.objectName == "closeMouseArea")) {
925 spreadItem.highlightedIndex = i;
930 if (floatingFlickable.contentWidth > floatingFlickable.width) {
931 var margins = floatingFlickable.width * 0.05;
933 if (!progressiveScrollingEnabled && mouseX < floatingFlickable.width - scrollAreaWidth) {
934 progressiveScrollingEnabled = true
937 // do we need to scroll?
938 if (mouseX < scrollAreaWidth + margins) {
939 var progress = Math.min(1, (scrollAreaWidth + margins - mouseX) / (scrollAreaWidth - margins));
940 var contentX = (1 - progress) * (floatingFlickable.contentWidth - floatingFlickable.width)
941 floatingFlickable.contentX = Math.max(0, Math.min(floatingFlickable.contentX, contentX))
943 if (mouseX > floatingFlickable.width - scrollAreaWidth && progressiveScrollingEnabled) {
944 var progress = Math.min(1, (mouseX - (floatingFlickable.width - scrollAreaWidth)) / (scrollAreaWidth - margins))
945 var contentX = progress * (floatingFlickable.contentWidth - floatingFlickable.width)
946 floatingFlickable.contentX = Math.min(floatingFlickable.contentWidth - floatingFlickable.width, Math.max(floatingFlickable.contentX, contentX))
952 mouse.accepted = false;
953 wasTouchPress = mouse.source === Qt.MouseEventSynthesizedByQt;
956 onExited: wasTouchPress = false;
961 id: noAppsRunningHint
963 anchors.horizontalCenter: parent.horizontalCenter
964 anchors.verticalCenter: parent.verticalCenter
966 horizontalAlignment: Qt.AlignHCenter
967 verticalAlignment: Qt.AlignVCenter
968 anchors.leftMargin: root.launcherLeftMargin
969 wrapMode: Label.WordWrap
971 text: i18n.tr("No running apps")
976 target: root.topLevelSurfaceList
977 function onListChanged() { priv.updateMainAndSideStageIndexes() }
982 objectName: "MainStageDropArea"
986 bottom: parent.bottom
988 width: appContainer.width - sideStage.width
989 enabled: priv.sideStageEnabled
992 drop.source.appDelegate.saveStage(ApplicationInfoInterface.MainStage);
993 drop.source.appDelegate.activate();
1000 objectName: "sideStage"
1002 height: appContainer.height
1003 x: appContainer.width - width
1005 showHint: !priv.sideStageDelegate
1006 Behavior on opacity { LomiriNumberAnimation {} }
1008 if (!priv.mainStageItemId) return 0;
1010 if (priv.sideStageItemId && priv.nextInStack > 0) {
1012 // Due the order in which bindings are evaluated, this might be triggered while shuffling
1013 // the list and index doesn't yet match with itemIndex (even though itemIndex: index)
1014 // Let's walk the list and compare itemIndex to make sure we have the correct one.
1015 var nextDelegateInStack = -1;
1016 for (var i = 0; i < appRepeater.count; i++) {
1017 if (appRepeater.itemAt(i).itemIndex == priv.nextInStack) {
1018 nextDelegateInStack = appRepeater.itemAt(i);
1023 if (nextDelegateInStack.stage === ApplicationInfoInterface.MainStage) {
1024 // if the next app in stack is a main stage app, put the sidestage on top of it.
1034 if (!shown && priv.mainStageDelegate && !root.spreadShown) {
1035 priv.mainStageDelegate.activate();
1040 id: sideStageDropArea
1041 objectName: "SideStageDropArea"
1042 anchors.fill: parent
1044 property bool dropAllowed: true
1047 dropAllowed = drag.keys != "Disabled";
1053 if (drop.keys == "MainStage") {
1054 drop.source.appDelegate.saveStage(ApplicationInfoInterface.SideStage);
1055 drop.source.appDelegate.activate();
1060 if (!sideStageDropArea.drag.source) {
1070 property real previewScale: .5
1071 height: (screensAndWorkspaces.height - units.gu(8)) / 2
1073 width: implicitWidth * height / implicitHeight
1076 opacity: surface != null ? 1 : 0
1077 Behavior on opacity { LomiriNumberAnimation {} }
1078 visible: opacity > 0
1079 enabled: workspaceSwitcher
1081 Drag.active: surface != null
1082 Drag.keys: ["application"]
1089 model: topLevelSurfaceList
1090 objectName: "appRepeater"
1092 function indexOf(delegateItem) {
1093 for (var i = 0; i < count; i++) {
1094 if (itemAt(i) === delegateItem) {
1101 delegate: FocusScope {
1103 objectName: "appDelegate_" + model.window.id
1104 property int itemIndex: index // We need this from outside the repeater
1105 // z might be overriden in some cases by effects, but we need z ordering
1106 // to calculate occlusion detection
1107 property int normalZ: topLevelSurfaceList.count - index
1109 if (visuallyMaximized) {
1110 priv.updateForegroundMaximizedApp();
1115 opacity: fakeDragItem.surface == model.window.surface && fakeDragItem.Drag.active ? 0 : 1
1116 Behavior on opacity { LomiriNumberAnimation {} }
1118 // Set these as propertyes as they wont update otherwise
1119 property real screenOffsetX: Screen.virtualX
1120 property real screenOffsetY: Screen.virtualY
1122 // Normally we want x/y where the surface thinks it is. Width/height of our delegate will
1123 // match what the actual surface size is.
1124 // Don't write to those, they will be set by states
1126 // Here we will also need to remove the screen offset from miral's results
1127 // as lomiri x,y will be relative to the current screen only
1128 // FIXME: when proper multiscreen lands
1129 x: model.window.position.x - clientAreaItem.x - screenOffsetX
1130 y: model.window.position.y - clientAreaItem.y - screenOffsetY
1131 width: decoratedWindow.implicitWidth
1132 height: decoratedWindow.implicitHeight
1134 // requestedX/Y/width/height is what we ask the actual surface to be.
1135 // Do not write to those, they will be set by states
1136 property real requestedX: windowedX
1137 property real requestedY: windowedY
1138 property real requestedWidth: windowedWidth
1139 property real requestedHeight: windowedHeight
1141 // For both windowed and staged need to tell miral what screen we are on,
1142 // so we need to add the screen offset to the position we tell miral
1143 // FIXME: when proper multiscreen lands
1145 target: model.window; property: "requestedPosition"
1146 // miral doesn't know about our window decorations. So we have to deduct them
1147 value: Qt.point(appDelegate.requestedX + appDelegate.clientAreaItem.x + screenOffsetX,
1148 appDelegate.requestedY + appDelegate.clientAreaItem.y + screenOffsetY)
1149 when: root.mode == "windowed"
1150 restoreMode: Binding.RestoreBinding
1153 target: model.window; property: "requestedPosition"
1154 value: Qt.point(screenOffsetX, screenOffsetY)
1155 when: root.mode != "windowed"
1156 restoreMode: Binding.RestoreBinding
1159 // In those are for windowed mode. Those values basically store the window's properties
1160 // when having a floating window. If you want to move/resize a window in normal mode, this is what you want to write to.
1161 property real windowedX
1162 property real windowedY
1163 property real windowedWidth
1164 property real windowedHeight
1166 // unlike windowedX/Y, this is the last known grab position before being pushed against edges/corners
1167 // when restoring, the window should return to these, not to the place where it was dropped near the edge
1168 property real restoredX
1169 property real restoredY
1171 // Keeps track of the window geometry while in normal or restored state
1172 // Useful when returning from some maxmized state or when saving the geometry while maximized
1173 // FIXME: find a better solution
1174 property real normalX: 0
1175 property real normalY: 0
1176 property real normalWidth: 0
1177 property real normalHeight: 0
1178 function updateNormalGeometry() {
1179 if (appDelegate.state == "normal" || appDelegate.state == "restored") {
1180 normalX = appDelegate.requestedX;
1181 normalY = appDelegate.requestedY;
1182 normalWidth = appDelegate.width;
1183 normalHeight = appDelegate.height;
1186 function updateRestoredGeometry() {
1187 if (appDelegate.state == "normal" || appDelegate.state == "restored") {
1188 // save the x/y to restore to
1189 restoredX = appDelegate.x;
1190 restoredY = appDelegate.y;
1196 function onXChanged() { appDelegate.updateNormalGeometry(); }
1197 function onYChanged() { appDelegate.updateNormalGeometry(); }
1198 function onWidthChanged() { appDelegate.updateNormalGeometry(); }
1199 function onHeightChanged() { appDelegate.updateNormalGeometry(); }
1202 // True when the Stage is focusing this app and playing its own animation.
1203 // Stays true until the app is unfocused.
1204 // If it is, we don't want to play the slide in/out transition from StageMaths.
1205 // Setting it imperatively is not great, but any declarative solution hits
1206 // race conditions, causing two animations to play for one focus event.
1207 property bool inhibitSlideAnimation: false
1212 value: appDelegate.requestedY -
1213 Math.min(appDelegate.requestedY - root.availableDesktopArea.y,
1214 Math.max(0, priv.virtualKeyboardHeight - (appContainer.height - (appDelegate.requestedY + appDelegate.height))))
1215 when: root.oskEnabled && appDelegate.focus && (appDelegate.state == "normal" || appDelegate.state == "restored")
1216 && root.inputMethodRect.height > 0
1217 restoreMode: Binding.RestoreBinding
1220 Behavior on x { id: xBehavior; enabled: priv.closingIndex >= 0; LomiriNumberAnimation { onRunningChanged: if (!running) priv.closingIndex = -1} }
1224 function onShellOrientationAngleChanged() {
1225 // at this point decoratedWindow.surfaceOrientationAngle is the old shellOrientationAngle
1226 if (appDelegate.application && appDelegate.application.rotatesWindowContents) {
1227 if (root.state == "windowed") {
1228 var angleDiff = decoratedWindow.surfaceOrientationAngle - shellOrientationAngle;
1229 angleDiff = (360 + angleDiff) % 360;
1230 if (angleDiff === 90 || angleDiff === 270) {
1231 var aux = decoratedWindow.requestedHeight;
1232 decoratedWindow.requestedHeight = decoratedWindow.requestedWidth + decoratedWindow.actualDecorationHeight;
1233 decoratedWindow.requestedWidth = aux - decoratedWindow.actualDecorationHeight;
1236 decoratedWindow.surfaceOrientationAngle = shellOrientationAngle;
1238 decoratedWindow.surfaceOrientationAngle = 0;
1243 readonly property alias application: decoratedWindow.application
1244 readonly property alias minimumWidth: decoratedWindow.minimumWidth
1245 readonly property alias minimumHeight: decoratedWindow.minimumHeight
1246 readonly property alias maximumWidth: decoratedWindow.maximumWidth
1247 readonly property alias maximumHeight: decoratedWindow.maximumHeight
1248 readonly property alias widthIncrement: decoratedWindow.widthIncrement
1249 readonly property alias heightIncrement: decoratedWindow.heightIncrement
1251 readonly property bool maximized: windowState === Mir.MaximizedState
1252 readonly property bool maximizedLeft: windowState === Mir.MaximizedLeftState
1253 readonly property bool maximizedRight: windowState === Mir.MaximizedRightState
1254 readonly property bool maximizedHorizontally: windowState === Mir.HorizMaximizedState
1255 readonly property bool maximizedVertically: windowState === Mir.VertMaximizedState
1256 readonly property bool maximizedTopLeft: windowState === Mir.MaximizedTopLeftState
1257 readonly property bool maximizedTopRight: windowState === Mir.MaximizedTopRightState
1258 readonly property bool maximizedBottomLeft: windowState === Mir.MaximizedBottomLeftState
1259 readonly property bool maximizedBottomRight: windowState === Mir.MaximizedBottomRightState
1260 readonly property bool anyMaximized: maximized || maximizedLeft || maximizedRight || maximizedHorizontally || maximizedVertically ||
1261 maximizedTopLeft || maximizedTopRight || maximizedBottomLeft || maximizedBottomRight
1263 readonly property bool minimized: windowState === Mir.MinimizedState
1264 readonly property bool fullscreen: windowState === Mir.FullscreenState
1266 readonly property bool canBeMaximized: canBeMaximizedHorizontally && canBeMaximizedVertically
1267 readonly property bool canBeMaximizedLeftRight: (maximumWidth == 0 || maximumWidth >= appContainer.width/2) &&
1268 (maximumHeight == 0 || maximumHeight >= appContainer.height)
1269 readonly property bool canBeCornerMaximized: (maximumWidth == 0 || maximumWidth >= appContainer.width/2) &&
1270 (maximumHeight == 0 || maximumHeight >= appContainer.height/2)
1271 readonly property bool canBeMaximizedHorizontally: maximumWidth == 0 || maximumWidth >= appContainer.width
1272 readonly property bool canBeMaximizedVertically: maximumHeight == 0 || maximumHeight >= appContainer.height
1273 readonly property alias orientationChangesEnabled: decoratedWindow.orientationChangesEnabled
1275 property int windowState: model.window.state
1276 property int prevWindowState: Mir.RestoredState
1278 property bool animationsEnabled: true
1279 property alias title: decoratedWindow.title
1280 readonly property string appName: model.application ? model.application.name : ""
1281 property bool visuallyMaximized: false
1282 property bool visuallyMinimized: false
1283 readonly property alias windowedTransitionRunning: windowedTransition.running
1285 property int stage: ApplicationInfoInterface.MainStage
1286 function saveStage(newStage) {
1287 appDelegate.stage = newStage;
1288 WindowStateStorage.saveStage(appId, newStage);
1289 priv.updateMainAndSideStageIndexes()
1292 readonly property var surface: model.window.surface
1293 readonly property var window: model.window
1295 readonly property alias focusedSurface: decoratedWindow.focusedSurface
1296 readonly property bool dragging: touchControls.overlayShown ? touchControls.dragging : decoratedWindow.dragging
1298 readonly property string appId: model.application.appId
1299 readonly property alias clientAreaItem: decoratedWindow.clientAreaItem
1301 // It is Lomiri policy to close any window but the last one during OOM teardown
1304 target: model.window.surface
1306 if ((!surface.live && application && application.surfaceCount > 1) || !application)
1307 topLevelSurfaceList.removeAt(appRepeater.indexOf(appDelegate));
1313 function activate() {
1314 if (model.window.focused) {
1315 updateQmlFocusFromMirSurfaceFocus();
1318 // Activate the window since it has a surface (with a running app) backing it
1319 model.window.activate();
1321 // Otherwise, cause a respawn of the app, and trigger it's refocusing as the last window
1322 topLevelSurfaceList.raiseId(model.window.id);
1326 function requestMaximize() { model.window.requestState(Mir.MaximizedState); }
1327 function requestMaximizeVertically() { model.window.requestState(Mir.VertMaximizedState); }
1328 function requestMaximizeHorizontally() { model.window.requestState(Mir.HorizMaximizedState); }
1329 function requestMaximizeLeft() { model.window.requestState(Mir.MaximizedLeftState); }
1330 function requestMaximizeRight() { model.window.requestState(Mir.MaximizedRightState); }
1331 function requestMaximizeTopLeft() { model.window.requestState(Mir.MaximizedTopLeftState); }
1332 function requestMaximizeTopRight() { model.window.requestState(Mir.MaximizedTopRightState); }
1333 function requestMaximizeBottomLeft() { model.window.requestState(Mir.MaximizedBottomLeftState); }
1334 function requestMaximizeBottomRight() { model.window.requestState(Mir.MaximizedBottomRightState); }
1335 function requestMinimize() { model.window.requestState(Mir.MinimizedState); }
1336 function requestRestore() { model.window.requestState(Mir.RestoredState); }
1338 function claimFocus() {
1339 if (root.state == "spread") {
1340 spreadItem.highlightedIndex = index
1341 // force pendingActivation so that when switching to staged mode, topLevelSurfaceList focus won't got to previous app ( case when apps are launched from outside )
1342 topLevelSurfaceList.pendingActivation();
1343 priv.goneToSpread = false;
1345 if (root.mode == "stagedWithSideStage") {
1346 if (appDelegate.stage == ApplicationInfoInterface.SideStage && !sideStage.shown) {
1349 priv.updateMainAndSideStageIndexes();
1351 appDelegate.focus = true;
1353 // Don't set focusedAppDelegate (and signal mainAppChanged) unnecessarily
1354 // which can happen after getting interactive again.
1355 if (priv.focusedAppDelegate !== appDelegate)
1356 priv.focusedAppDelegate = appDelegate;
1359 function updateQmlFocusFromMirSurfaceFocus() {
1360 if (model.window.focused) {
1362 decoratedWindow.focus = true;
1367 id: windowStateSaver
1369 screenWidth: appContainer.width
1370 screenHeight: appContainer.height
1371 leftMargin: root.availableDesktopArea.x
1372 minimumY: root.availableDesktopArea.y
1376 target: model.window
1377 property int lastWindowState: Mir.RestoredState
1379 function onFocusedChanged() {
1380 updateQmlFocusFromMirSurfaceFocus();
1381 if (!model.window.focused) {
1382 inhibitSlideAnimation = false;
1385 function onFocusRequested() {
1386 appDelegate.activate();
1388 function onStateChanged(value) {
1389 if (value == Mir.FullscreenState || value == Mir.MinimizedState) {
1390 if (lastWindowState == Mir.MinimizedState) {
1391 appDelegate.prevWindowState = Mir.RestoredState;
1393 appDelegate.prevWindowState = lastWindowState;
1395 } else if (value == Mir.RestoredState) {
1396 if ((lastWindowState == Mir.FullscreenState || lastWindowState == Mir.MinimizedState) &&
1397 appDelegate.prevWindowState != Mir.RestoredState) {
1398 model.window.requestState(appDelegate.prevWindowState);
1403 lastWindowState = value;
1407 readonly property bool windowReady: clientAreaItem.surfaceInitialized
1408 onWindowReadyChanged: {
1410 var loadedMirState = windowStateSaver.loadedState;
1411 var state = loadedMirState;
1413 if (window.state == Mir.FullscreenState) {
1414 // If the app is fullscreen at startup, we should not use saved state
1415 // Example of why: if you open game that only requests fullscreen at
1416 // Statup, this will automaticly be set to "restored state" since
1417 // thats the default value of stateStorage, this will result in the app
1418 // having the "restored state" as it will not make a fullscreen
1419 // call after the app has started.
1420 console.log("Initial window state is fullscreen, not using saved state.");
1421 state = window.state;
1422 } else if (loadedMirState == Mir.FullscreenState) {
1423 // If saved state is fullscreen, we should use app initial state
1424 // Example of why: if you open browser with youtube video at fullscreen
1425 // and close this app, it will be fullscreen next time you open the app.
1426 console.log("Saved window state is fullscreen, using initial window state");
1427 state = window.state;
1430 // need to apply the shell chrome policy on top the saved window state
1432 if (root.mode == "windowed") {
1433 policy = windowedFullscreenPolicy;
1435 policy = stagedFullscreenPolicy
1437 window.requestState(policy.applyPolicy(state, surface.shellChrome));
1441 Component.onCompleted: {
1442 if (application && application.rotatesWindowContents) {
1443 decoratedWindow.surfaceOrientationAngle = shellOrientationAngle;
1445 decoratedWindow.surfaceOrientationAngle = 0;
1448 // First, cascade the newly created window, relative to the currently/old focused window.
1449 windowedX = priv.focusedAppDelegate ? priv.focusedAppDelegate.windowedX + units.gu(3) : (normalZ - 1) * units.gu(3)
1450 windowedY = priv.focusedAppDelegate ? priv.focusedAppDelegate.windowedY + units.gu(3) : normalZ * units.gu(3)
1451 // Now load any saved state. This needs to happen *after* the cascading!
1452 windowStateSaver.load(!model.window.constrained);
1453 if (!model.window.constrained) {
1454 // By this point windowStateSaver has loaded the state, and constrained it on screen. Set this to true
1455 model.window.constrained = true;
1458 if (!root.spreadShown) {
1459 updateQmlFocusFromMirSurfaceFocus();
1463 _constructing = false;
1465 Component.onDestruction: {
1466 windowStateSaver.save();
1469 // This stage is about to be destroyed. Don't mess up with the model at this point
1473 if (visuallyMaximized) {
1474 priv.updateForegroundMaximizedApp();
1478 onVisuallyMaximizedChanged: priv.updateForegroundMaximizedApp()
1480 property bool _constructing: true;
1482 if (!_constructing) {
1483 priv.updateMainAndSideStageIndexes();
1489 && !greeter.fullyShown
1490 && (priv.foregroundMaximizedAppDelegate === null || priv.foregroundMaximizedAppDelegate.normalZ <= z)
1492 || appDelegate.fullscreen
1493 || focusAnimation.running || rightEdgeFocusAnimation.running || hidingAnimation.running
1496 model.window.close();
1499 function playFocusAnimation() {
1500 if (state == "stagedRightEdge") {
1501 // TODO: Can we drop this if and find something that always works?
1502 if (root.mode == "staged") {
1503 rightEdgeFocusAnimation.targetX = 0
1504 rightEdgeFocusAnimation.start()
1505 } else if (root.mode == "stagedWithSideStage") {
1506 rightEdgeFocusAnimation.targetX = appDelegate.stage == ApplicationInfoInterface.SideStage ? sideStage.x : 0
1507 rightEdgeFocusAnimation.start()
1510 focusAnimation.start()
1513 function playHidingAnimation() {
1514 if (state != "windowedRightEdge") {
1515 hidingAnimation.start()
1519 function refreshStage() {
1520 var newStage = ApplicationInfoInterface.MainStage;
1521 if (priv.sideStageEnabled) { // we're in lanscape rotation.
1522 if (application && application.supportedOrientations & (Qt.PortraitOrientation|Qt.InvertedPortraitOrientation)) {
1523 var defaultStage = ApplicationInfoInterface.SideStage; // if application supports portrait, it defaults to sidestage.
1524 if (application.supportedOrientations & (Qt.LandscapeOrientation|Qt.InvertedLandscapeOrientation)) {
1525 // if it supports lanscape, it defaults to mainstage.
1526 defaultStage = ApplicationInfoInterface.MainStage;
1528 newStage = WindowStateStorage.getStage(application.appId, defaultStage);
1533 if (focus && stage == ApplicationInfoInterface.SideStage && !sideStage.shown) {
1538 LomiriNumberAnimation {
1544 duration: LomiriAnimation.SnapDuration
1546 topLevelSurfaceList.pendingActivation();
1547 topLevelSurfaceList.raiseId(model.window.id);
1550 appDelegate.activate();
1554 id: rightEdgeFocusAnimation
1555 property int targetX: 0
1556 LomiriNumberAnimation { target: appDelegate; properties: "x"; to: rightEdgeFocusAnimation.targetX; duration: priv.animationDuration }
1557 LomiriNumberAnimation { target: decoratedWindow; properties: "angle"; to: 0; duration: priv.animationDuration }
1558 LomiriNumberAnimation { target: decoratedWindow; properties: "itemScale"; to: 1; duration: priv.animationDuration }
1560 topLevelSurfaceList.pendingActivation();
1561 inhibitSlideAnimation = true;
1564 appDelegate.activate();
1569 LomiriNumberAnimation { target: appDelegate; property: "opacity"; to: 0; duration: priv.animationDuration }
1570 onStopped: appDelegate.opacity = 1
1577 flickable: floatingFlickable
1581 sceneWidth: root.width
1582 stage: appDelegate.stage
1583 thisDelegate: appDelegate
1584 mainStageDelegate: priv.mainStageDelegate
1585 sideStageDelegate: priv.sideStageDelegate
1586 sideStageWidth: sideStage.panelWidth
1587 sideStageHandleWidth: sideStage.handleWidth
1588 sideStageX: sideStage.x
1589 itemIndex: appDelegate.itemIndex
1590 nextInStack: priv.nextInStack
1591 animationDuration: priv.animationDuration
1594 StagedRightEdgeMaths {
1595 id: stagedRightEdgeMaths
1596 sceneWidth: root.availableDesktopArea.width
1597 sceneHeight: appContainer.height
1598 isMainStageApp: priv.mainStageDelegate == appDelegate
1599 isSideStageApp: priv.sideStageDelegate == appDelegate
1600 sideStageWidth: sideStage.width
1601 sideStageOpen: sideStage.shown
1603 nextInStack: priv.nextInStack
1605 targetHeight: spreadItem.stackHeight
1606 targetX: spreadMaths.targetX
1607 startY: appDelegate.fullscreen ? 0 : root.availableDesktopArea.y
1608 targetY: spreadMaths.targetY
1609 targetAngle: spreadMaths.targetAngle
1610 targetScale: spreadMaths.targetScale
1611 shuffledZ: stageMaths.itemZ
1612 breakPoint: spreadItem.rightEdgeBreakPoint
1615 WindowedRightEdgeMaths {
1616 id: windowedRightEdgeMaths
1618 startWidth: appDelegate.requestedWidth
1619 startHeight: appDelegate.requestedHeight
1620 targetHeight: spreadItem.stackHeight
1621 targetX: spreadMaths.targetX
1622 targetY: spreadMaths.targetY
1623 normalZ: appDelegate.normalZ
1624 targetAngle: spreadMaths.targetAngle
1625 targetScale: spreadMaths.targetScale
1626 breakPoint: spreadItem.rightEdgeBreakPoint
1631 name: "spread"; when: root.state == "spread"
1632 StateChangeScript { script: { decoratedWindow.cancelDrag(); } }
1634 target: decoratedWindow;
1635 showDecoration: false;
1636 angle: spreadMaths.targetAngle
1637 itemScale: spreadMaths.targetScale
1638 scaleToPreviewSize: spreadItem.stackHeight
1639 scaleToPreviewProgress: 1
1640 hasDecoration: root.mode === "windowed"
1641 shadowOpacity: spreadMaths.shadowOpacity
1642 showHighlight: spreadItem.highlightedIndex === index
1643 darkening: spreadItem.highlightedIndex >= 0
1644 anchors.topMargin: dragArea.distance
1648 x: spreadMaths.targetX
1649 y: spreadMaths.targetY
1651 height: spreadItem.spreadItemHeight
1652 visible: spreadMaths.itemVisible
1654 PropertyChanges { target: dragArea; enabled: true }
1655 PropertyChanges { target: windowInfoItem; opacity: spreadMaths.tileInfoOpacity; visible: spreadMaths.itemVisible }
1656 PropertyChanges { target: touchControls; enabled: false }
1659 name: "stagedRightEdge"
1660 when: (root.mode == "staged" || root.mode == "stagedWithSideStage") && (root.state == "sideStagedRightEdge" || root.state == "stagedRightEdge" || rightEdgeFocusAnimation.running || hidingAnimation.running)
1662 target: stagedRightEdgeMaths
1663 progress: Math.max(rightEdgePushProgress, rightEdgeDragArea.draggedProgress)
1667 x: stagedRightEdgeMaths.animatedX
1668 y: stagedRightEdgeMaths.animatedY
1669 z: stagedRightEdgeMaths.animatedZ
1670 height: stagedRightEdgeMaths.animatedHeight
1671 visible: appDelegate.x < root.width
1674 target: decoratedWindow
1675 hasDecoration: false
1676 angle: stagedRightEdgeMaths.animatedAngle
1677 itemScale: stagedRightEdgeMaths.animatedScale
1678 scaleToPreviewSize: spreadItem.stackHeight
1679 scaleToPreviewProgress: stagedRightEdgeMaths.scaleToPreviewProgress
1682 // make sure it's visible but transparent so it fades in when we transition to spread
1683 PropertyChanges { target: windowInfoItem; opacity: 0; visible: true }
1686 name: "windowedRightEdge"
1687 when: root.mode == "windowed" && (root.state == "windowedRightEdge" || rightEdgeFocusAnimation.running || hidingAnimation.running || rightEdgePushProgress > 0)
1689 target: windowedRightEdgeMaths
1690 swipeProgress: rightEdgeDragArea.dragging ? rightEdgeDragArea.progress : 0
1691 pushProgress: rightEdgePushProgress
1695 x: windowedRightEdgeMaths.animatedX
1696 y: windowedRightEdgeMaths.animatedY
1697 z: windowedRightEdgeMaths.animatedZ
1698 height: stagedRightEdgeMaths.animatedHeight
1701 target: decoratedWindow
1702 showDecoration: windowedRightEdgeMaths.decorationHeight
1703 angle: windowedRightEdgeMaths.animatedAngle
1704 itemScale: windowedRightEdgeMaths.animatedScale
1705 scaleToPreviewSize: spreadItem.stackHeight
1706 scaleToPreviewProgress: windowedRightEdgeMaths.scaleToPreviewProgress
1710 target: opacityEffect;
1711 opacityValue: windowedRightEdgeMaths.opacityMask
1712 sourceItem: windowedRightEdgeMaths.opacityMask < 1 ? decoratedWindow : null
1716 name: "staged"; when: root.state == "staged"
1720 y: root.availableDesktopArea.y
1721 visuallyMaximized: true
1722 visible: appDelegate.x < root.width
1726 requestedWidth: appContainer.width
1727 requestedHeight: root.availableDesktopArea.height
1728 restoreEntryValues: false
1731 target: decoratedWindow
1732 hasDecoration: false
1740 animateX: !focusAnimation.running && !rightEdgeFocusAnimation.running && itemIndex !== spreadItem.highlightedIndex && !inhibitSlideAnimation
1743 target: appDelegate.window
1744 allowClientResize: false
1748 name: "stagedWithSideStage"; when: root.state == "stagedWithSideStage"
1756 y: root.availableDesktopArea.y
1758 visuallyMaximized: true
1759 visible: appDelegate.x < root.width
1763 requestedWidth: stageMaths.itemWidth
1764 requestedHeight: root.availableDesktopArea.height
1765 restoreEntryValues: false
1768 target: decoratedWindow
1769 hasDecoration: false
1776 target: appDelegate.window
1777 allowClientResize: false
1781 name: "maximized"; when: appDelegate.maximized && !appDelegate.minimized
1783 target: appDelegate;
1784 requestedX: root.availableDesktopArea.x;
1786 visuallyMinimized: false;
1787 visuallyMaximized: true
1791 requestedWidth: root.availableDesktopArea.width;
1792 requestedHeight: appContainer.height;
1793 restoreEntryValues: false
1795 PropertyChanges { target: touchControls; enabled: true }
1796 PropertyChanges { target: decoratedWindow; windowControlButtonsVisible: false }
1799 name: "fullscreen"; when: appDelegate.fullscreen && !appDelegate.minimized
1801 target: appDelegate;
1807 requestedWidth: appContainer.width
1808 requestedHeight: appContainer.height
1809 restoreEntryValues: false
1811 PropertyChanges { target: decoratedWindow; hasDecoration: false }
1813 // TODO: merge normal and restored together, there's no point in normal being a distinct state
1818 visuallyMinimized: false
1820 PropertyChanges { target: touchControls; enabled: true }
1821 PropertyChanges { target: resizeArea; enabled: true }
1822 PropertyChanges { target: decoratedWindow; shadowOpacity: .3; windowControlButtonsVisible: true}
1825 requestedWidth: windowedWidth
1826 requestedHeight: windowedHeight
1827 restoreEntryValues: false
1832 when: appDelegate.windowState == Mir.RestoredState
1835 restoreEntryValues: false
1836 target: appDelegate;
1837 windowedX: restoredX;
1838 windowedY: restoredY;
1842 name: "maximizedLeft"; when: appDelegate.maximizedLeft && !appDelegate.minimized
1846 windowedX: root.availableDesktopArea.x
1847 windowedY: root.availableDesktopArea.y
1848 windowedWidth: root.availableDesktopArea.width / 2
1849 windowedHeight: root.availableDesktopArea.height
1853 name: "maximizedRight"; when: appDelegate.maximizedRight && !appDelegate.minimized
1854 extend: "maximizedLeft"
1856 target: appDelegate;
1857 windowedX: root.availableDesktopArea.x + (root.availableDesktopArea.width / 2)
1861 name: "maximizedTopLeft"; when: appDelegate.maximizedTopLeft && !appDelegate.minimized
1865 windowedX: root.availableDesktopArea.x
1866 windowedY: root.availableDesktopArea.y
1867 windowedWidth: root.availableDesktopArea.width / 2
1868 windowedHeight: root.availableDesktopArea.height / 2
1872 name: "maximizedTopRight"; when: appDelegate.maximizedTopRight && !appDelegate.minimized
1873 extend: "maximizedTopLeft"
1876 windowedX: root.availableDesktopArea.x + (root.availableDesktopArea.width / 2)
1880 name: "maximizedBottomLeft"; when: appDelegate.maximizedBottomLeft && !appDelegate.minimized
1884 windowedX: root.availableDesktopArea.x
1885 windowedY: root.availableDesktopArea.y + (root.availableDesktopArea.height / 2)
1886 windowedWidth: root.availableDesktopArea.width / 2
1887 windowedHeight: root.availableDesktopArea.height / 2
1891 name: "maximizedBottomRight"; when: appDelegate.maximizedBottomRight && !appDelegate.minimized
1892 extend: "maximizedBottomLeft"
1895 windowedX: root.availableDesktopArea.x + (root.availableDesktopArea.width / 2)
1899 name: "maximizedHorizontally"; when: appDelegate.maximizedHorizontally && !appDelegate.minimized
1903 windowedX: root.availableDesktopArea.x; windowedY: windowedY
1904 windowedWidth: root.availableDesktopArea.width; windowedHeight: windowedHeight
1908 name: "maximizedVertically"; when: appDelegate.maximizedVertically && !appDelegate.minimized
1912 windowedX: windowedX; windowedY: root.availableDesktopArea.y
1913 windowedWidth: windowedWidth; windowedHeight: root.availableDesktopArea.height
1917 name: "minimized"; when: appDelegate.minimized
1920 scale: units.gu(5) / appDelegate.width
1922 visuallyMinimized: true
1923 visuallyMaximized: false
1924 x: -appDelegate.width / 2
1932 // These two animate applications into position from Staged to Desktop and back
1934 from: "staged,stagedWithSideStage"
1935 to: "normal,restored,maximized,maximizedHorizontally,maximizedVertically,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedBottomLeft,maximizedTopRight,maximizedBottomRight"
1936 enabled: appDelegate.animationsEnabled
1937 PropertyAction { target: appDelegate; properties: "visuallyMinimized,visuallyMaximized" }
1938 LomiriNumberAnimation { target: appDelegate; properties: "x,y,requestedX,requestedY,opacity,requestedWidth,requestedHeight,scale"; duration: priv.animationDuration }
1941 from: "normal,restored,maximized,maximizedHorizontally,maximizedVertically,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedBottomLeft,maximizedTopRight,maximizedBottomRight"
1942 to: "staged,stagedWithSideStage"
1943 LomiriNumberAnimation { target: appDelegate; properties: "x,y,requestedX,requestedY,requestedWidth,requestedHeight"; duration: priv.animationDuration}
1947 from: "normal,restored,maximized,maximizedHorizontally,maximizedVertically,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedBottomLeft,maximizedTopRight,maximizedBottomRight,staged,stagedWithSideStage,windowedRightEdge,stagedRightEdge";
1949 // DecoratedWindow wants the scaleToPreviewSize set before enabling scaleToPreview
1950 PropertyAction { target: appDelegate; properties: "z,visible" }
1951 PropertyAction { target: decoratedWindow; property: "scaleToPreviewSize" }
1952 LomiriNumberAnimation { target: appDelegate; properties: "x,y,height"; duration: priv.animationDuration }
1953 LomiriNumberAnimation { target: decoratedWindow; properties: "width,height,itemScale,angle,scaleToPreviewProgress"; duration: priv.animationDuration }
1954 LomiriNumberAnimation { target: windowInfoItem; properties: "opacity"; duration: priv.animationDuration }
1957 from: "normal,staged"; to: "stagedWithSideStage"
1958 LomiriNumberAnimation { target: appDelegate; properties: "x,y,requestedWidth,requestedHeight"; duration: priv.animationDuration }
1961 to: "windowedRightEdge"
1964 windowedRightEdgeMaths.startX = appDelegate.requestedX
1965 windowedRightEdgeMaths.startY = appDelegate.requestedY
1968 var thisRect = { x: appDelegate.windowedX, y: appDelegate.windowedY, width: appDelegate.requestedWidth, height: appDelegate.requestedHeight }
1969 var otherDelegate = appRepeater.itemAt(0);
1970 var otherRect = { x: otherDelegate.windowedX, y: otherDelegate.windowedY, width: otherDelegate.requestedWidth, height: otherDelegate.requestedHeight }
1971 var intersectionRect = MathUtils.intersectionRect(thisRect, otherRect)
1972 var mappedInterSectionRect = appDelegate.mapFromItem(root, intersectionRect.x, intersectionRect.y)
1973 opacityEffect.maskX = mappedInterSectionRect.x
1974 opacityEffect.maskY = mappedInterSectionRect.y
1975 opacityEffect.maskWidth = intersectionRect.width
1976 opacityEffect.maskHeight = intersectionRect.height
1982 from: "stagedRightEdge"; to: "staged"
1983 enabled: rightEdgeDragArea.cancelled // only transition back to state if the gesture was cancelled, in the other cases we play the focusAnimations.
1984 SequentialAnimation {
1986 LomiriNumberAnimation { target: appDelegate; properties: "x,y,height,width,scale"; duration: priv.animationDuration }
1987 LomiriNumberAnimation { target: decoratedWindow; properties: "width,height,itemScale,angle,scaleToPreviewProgress"; duration: priv.animationDuration }
1989 // We need to release scaleToPreviewSize at last
1990 PropertyAction { target: decoratedWindow; property: "scaleToPreviewSize" }
1991 PropertyAction { target: appDelegate; property: "visible" }
1995 from: ",normal,restored,maximized,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedTopRight,maximizedBottomLeft,maximizedBottomRight,maximizedHorizontally,maximizedVertically,fullscreen"
1997 SequentialAnimation {
1998 ScriptAction { script: { fakeRectangle.stop(); } }
1999 PropertyAction { target: appDelegate; property: "visuallyMaximized" }
2000 PropertyAction { target: appDelegate; property: "visuallyMinimized" }
2001 LomiriNumberAnimation { target: appDelegate; properties: "x,y,scale,opacity"; duration: priv.animationDuration }
2002 PropertyAction { target: appDelegate; property: "visuallyMinimized" }
2007 to: ",normal,restored,maximized,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedTopRight,maximizedBottomLeft,maximizedBottomRight,maximizedHorizontally,maximizedVertically,fullscreen"
2008 SequentialAnimation {
2009 PropertyAction { target: appDelegate; property: "visuallyMinimized,z" }
2011 LomiriNumberAnimation { target: appDelegate; properties: "x"; from: -appDelegate.width / 2; duration: priv.animationDuration }
2012 LomiriNumberAnimation { target: appDelegate; properties: "y,opacity"; duration: priv.animationDuration }
2013 LomiriNumberAnimation { target: appDelegate; properties: "scale"; from: 0; duration: priv.animationDuration }
2015 PropertyAction { target: appDelegate; property: "visuallyMaximized" }
2019 id: windowedTransition
2020 from: ",normal,restored,maximized,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedTopRight,maximizedBottomLeft,maximizedBottomRight,maximizedHorizontally,maximizedVertically,fullscreen,minimized"
2021 to: ",normal,restored,maximized,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedTopRight,maximizedBottomLeft,maximizedBottomRight,maximizedHorizontally,maximizedVertically,fullscreen"
2022 enabled: appDelegate.animationsEnabled
2023 SequentialAnimation {
2024 ScriptAction { script: {
2025 if (appDelegate.visuallyMaximized) visuallyMaximized = false; // maximized before -> going to restored
2028 PropertyAction { target: appDelegate; property: "visuallyMinimized" }
2029 LomiriNumberAnimation { target: appDelegate; properties: "requestedX,requestedY,windowedX,windowedY,opacity,scale,requestedWidth,requestedHeight,windowedWidth,windowedHeight";
2030 duration: priv.animationDuration }
2031 ScriptAction { script: {
2032 fakeRectangle.stop();
2033 appDelegate.visuallyMaximized = appDelegate.maximized; // reflect the target state
2042 property: "decorationsAlwaysVisible"
2043 value: appDelegate && appDelegate.maximized && touchControls.overlayShown
2044 restoreMode: Binding.RestoreBinding
2049 objectName: "windowResizeArea"
2051 anchors.fill: appDelegate
2053 // workaround so that it chooses the correct resize borders when you drag from a corner ResizeGrip
2054 anchors.margins: touchControls.overlayShown ? borderThickness/2 : -borderThickness
2057 boundsItem: root.availableDesktopArea
2058 minWidth: units.gu(10)
2059 minHeight: units.gu(10)
2060 borderThickness: units.gu(2)
2063 readyToAssesBounds: !appDelegate._constructing
2066 appDelegate.activate();
2072 objectName: "decoratedWindow"
2073 anchors.left: appDelegate.left
2074 anchors.top: appDelegate.top
2075 application: model.application
2076 surface: model.window.surface
2077 active: model.window.focused
2079 interactive: root.interactive
2081 decorationHeight: priv.windowDecorationHeight
2082 maximizeButtonShown: appDelegate.canBeMaximized
2083 overlayShown: touchControls.overlayShown
2084 width: implicitWidth
2085 height: implicitHeight
2086 highlightSize: windowInfoItem.iconMargin
2087 boundsItem: root.availableDesktopArea
2088 panelState: root.panelState
2089 altDragEnabled: root.mode == "windowed"
2091 requestedWidth: appDelegate.requestedWidth
2092 requestedHeight: appDelegate.requestedHeight
2094 onCloseClicked: { appDelegate.close(); }
2095 onMaximizeClicked: {
2096 if (appDelegate.canBeMaximized) {
2097 appDelegate.anyMaximized ? appDelegate.requestRestore() : appDelegate.requestMaximize();
2100 onMaximizeHorizontallyClicked: {
2101 if (appDelegate.canBeMaximizedHorizontally) {
2102 appDelegate.maximizedHorizontally ? appDelegate.requestRestore() : appDelegate.requestMaximizeHorizontally()
2105 onMaximizeVerticallyClicked: {
2106 if (appDelegate.canBeMaximizedVertically) {
2107 appDelegate.maximizedVertically ? appDelegate.requestRestore() : appDelegate.requestMaximizeVertically()
2110 onMinimizeClicked: { appDelegate.requestMinimize(); }
2111 onDecorationPressed: { appDelegate.activate(); }
2112 onDecorationReleased: fakeRectangle.visible ? fakeRectangle.commit() : appDelegate.updateRestoredGeometry()
2114 onDragResizePressed: {
2115 appDelegate.activate();
2116 resizeArea.pressedChangedEx(true, mouse);
2118 onDragResizeReleased: resizeArea.pressedChangedEx(false, mouse);
2119 onDragResizePositionChanged: resizeArea.positionChangedEx(mouse);
2121 property real angle: 0
2122 Behavior on angle { enabled: priv.closingIndex >= 0; LomiriNumberAnimation {} }
2123 property real itemScale: 1
2124 Behavior on itemScale { enabled: priv.closingIndex >= 0; LomiriNumberAnimation {} }
2129 origin.y: decoratedWindow.implicitHeight / 2
2130 xScale: decoratedWindow.itemScale
2131 yScale: decoratedWindow.itemScale
2134 origin { x: 0; y: (decoratedWindow.height / 2) }
2135 axis { x: 0; y: 1; z: 0 }
2136 angle: decoratedWindow.angle
2143 anchors.fill: decoratedWindow
2146 WindowControlsOverlay {
2148 anchors.fill: appDelegate
2150 resizeArea: resizeArea
2153 boundsItem: root.availableDesktopArea
2155 onFakeMaximizeAnimationRequested: if (!appDelegate.maximized) fakeRectangle.maximize(amount, true)
2156 onFakeMaximizeLeftAnimationRequested: if (!appDelegate.maximizedLeft) fakeRectangle.maximizeLeft(amount, true)
2157 onFakeMaximizeRightAnimationRequested: if (!appDelegate.maximizedRight) fakeRectangle.maximizeRight(amount, true)
2158 onFakeMaximizeTopLeftAnimationRequested: if (!appDelegate.maximizedTopLeft) fakeRectangle.maximizeTopLeft(amount, true);
2159 onFakeMaximizeTopRightAnimationRequested: if (!appDelegate.maximizedTopRight) fakeRectangle.maximizeTopRight(amount, true);
2160 onFakeMaximizeBottomLeftAnimationRequested: if (!appDelegate.maximizedBottomLeft) fakeRectangle.maximizeBottomLeft(amount, true);
2161 onFakeMaximizeBottomRightAnimationRequested: if (!appDelegate.maximizedBottomRight) fakeRectangle.maximizeBottomRight(amount, true);
2162 onStopFakeAnimation: fakeRectangle.stop();
2163 onDragReleased: fakeRectangle.visible ? fakeRectangle.commit() : appDelegate.updateRestoredGeometry()
2166 WindowedFullscreenPolicy {
2167 id: windowedFullscreenPolicy
2169 StagedFullscreenPolicy {
2170 id: stagedFullscreenPolicy
2171 active: root.mode == "staged" || root.mode == "stagedWithSideStage"
2172 surface: model.window.surface
2175 SpreadDelegateInputArea {
2177 objectName: "dragArea"
2178 anchors.fill: decoratedWindow
2182 dragDelegate: fakeDragItem
2185 spreadItem.highlightedIndex = index;
2186 if (distance == 0) {
2187 priv.goneToSpread = false;
2191 priv.closingIndex = index
2192 appDelegate.close();
2198 objectName: "windowInfoItem"
2199 anchors { left: parent.left; top: decoratedWindow.bottom; topMargin: units.gu(1) }
2200 title: model.application.name
2201 iconSource: model.application.icon
2202 height: spreadItem.appInfoHeight
2205 visible: opacity > 0
2207 var nextApp = appRepeater.itemAt(index + 1);
2209 return Math.max(iconHeight, nextApp.x - appDelegate.x - units.gu(1))
2211 return appDelegate.width;
2215 spreadItem.highlightedIndex = index;
2216 priv.goneToSpread = false;
2222 objectName: "closeMouseArea"
2223 anchors { left: parent.left; top: parent.top; leftMargin: -height / 2; topMargin: -height / 2 + spreadMaths.closeIconOffset }
2224 readonly property var mousePos: hoverMouseArea.mapToItem(appDelegate, hoverMouseArea.mouseX, hoverMouseArea.mouseY)
2225 readonly property bool shown: dragArea.distance == 0
2226 && index == spreadItem.highlightedIndex
2227 && mousePos.y < (decoratedWindow.height / 3)
2228 && mousePos.y > -units.gu(4)
2229 && mousePos.x > -units.gu(4)
2230 && mousePos.x < (decoratedWindow.width * 2 / 3)
2231 opacity: shown ? 1 : 0
2232 visible: opacity > 0
2233 Behavior on opacity { LomiriNumberAnimation { duration: LomiriAnimation.SnapDuration } }
2238 priv.closingIndex = index;
2239 appDelegate.close();
2243 source: "graphics/window-close.svg"
2244 anchors.fill: closeMouseArea
2245 anchors.margins: units.gu(2)
2246 sourceSize.width: width
2247 sourceSize.height: height
2252 // Group all child windows in this item so that we can fade them out together when going to the spread
2253 // (and fade them in back again when returning from it)
2254 readonly property bool stageOnProperState: root.state === "windowed"
2255 || root.state === "staged"
2256 || root.state === "stagedWithSideStage"
2258 // TODO: Is it worth the extra cost of layering to avoid the opacity artifacts of intersecting children?
2259 // Btw, will involve more than uncommenting the line below as children won't necessarily fit this item's
2260 // geometry. This is just a reference.
2261 //layer.enabled: opacity !== 0.0 && opacity !== 1.0
2263 opacity: stageOnProperState ? 1.0 : 0.0
2264 visible: opacity !== 0.0 // make it transparent to input as well
2265 Behavior on opacity { LomiriNumberAnimation {} }
2268 id: childWindowRepeater
2269 model: appDelegate.surface ? appDelegate.surface.childSurfaceList : null
2271 delegate: ChildWindowTree {
2272 surface: model.surface
2274 // Account for the displacement caused by window decoration in the top-level surface
2275 // Ie, the top-level surface is not positioned at (0,0) of this ChildWindow's parent (appDelegate)
2276 displacementX: appDelegate.clientAreaItem.x
2277 displacementY: appDelegate.clientAreaItem.y
2279 boundsItem: root.availableDesktopArea
2280 decorationHeight: priv.windowDecorationHeight
2282 z: childWindowRepeater.count - model.index
2286 // some child surface in this tree got focus.
2287 // Ensure we also have it at the top-level hierarchy
2288 appDelegate.claimFocus();
2298 FakeMaximizeDelegate {
2300 target: priv.focusedAppDelegate
2301 leftMargin: root.availableDesktopArea.x
2302 appContainerWidth: appContainer.width
2303 appContainerHeight: appContainer.height
2304 panelState: root.panelState
2308 id: workspaceSwitcher
2309 enabled: workspaceEnabled
2310 anchors.centerIn: parent
2311 height: units.gu(20)
2312 width: root.width - units.gu(8)
2313 background: root.background
2314 availableDesktopArea: root.availableDesktopArea
2315 onWorkspaceSelected: screensAndWorkspaces.activeWorkspace = selectedWorkspace;
2318 appContainer.focus = true;
2324 id: shortRightEdgeSwipeAnimation
2327 duration: priv.animationDuration
2331 id: rightEdgeDragArea
2332 objectName: "rightEdgeDragArea"
2333 direction: Direction.Leftwards
2334 anchors { top: parent.top; right: parent.right; bottom: parent.bottom }
2335 width: root.dragAreaWidth
2336 enabled: root.spreadEnabled
2338 property var gesturePoints: []
2339 property bool cancelled: false
2341 property real progress: -touchPosition.x / root.width
2342 onProgressChanged: {
2344 draggedProgress = progress;
2348 property real draggedProgress: 0
2350 onTouchPositionChanged: {
2351 gesturePoints.push(touchPosition.x);
2352 if (gesturePoints.length > 10) {
2353 gesturePoints.splice(0, gesturePoints.length - 10)
2357 onDraggingChanged: {
2359 // A potential edge-drag gesture has started. Start recording it
2362 draggedProgress = 0;
2364 // Ok. The user released. Did he drag far enough to go to full spread?
2365 if (gesturePoints[gesturePoints.length - 1] < -spreadItem.rightEdgeBreakPoint * spreadItem.width ) {
2367 // He dragged far enough, but if the last movement was a flick to the right again, he wants to cancel the spread again.
2368 var oneWayFlickToRight = true;
2369 var smallestX = gesturePoints[0]-1;
2370 for (var i = 0; i < gesturePoints.length; i++) {
2371 if (gesturePoints[i] <= smallestX) {
2372 oneWayFlickToRight = false;
2375 smallestX = gesturePoints[i];
2378 if (!oneWayFlickToRight) {
2379 // Ok, the user made it, let's go to spread!
2380 priv.goneToSpread = true;
2385 // Ok, the user didn't drag far enough to cross the breakPoint
2386 // Find out if it was a one-way movement to the left, in which case we just switch directly to next app.
2387 var oneWayFlick = true;
2388 var smallestX = rightEdgeDragArea.width;
2389 for (var i = 0; i < gesturePoints.length; i++) {
2390 if (gesturePoints[i] >= smallestX) {
2391 oneWayFlick = false;
2394 smallestX = gesturePoints[i];
2397 if (appRepeater.count > 1 &&
2398 (oneWayFlick && rightEdgeDragArea.distance > units.gu(2) || rightEdgeDragArea.distance > spreadItem.rightEdgeBreakPoint * spreadItem.width)) {
2399 var nextStage = appRepeater.itemAt(priv.nextInStack).stage
2400 for (var i = 0; i < appRepeater.count; i++) {
2401 if (i != priv.nextInStack && appRepeater.itemAt(i).stage == nextStage) {
2402 appRepeater.itemAt(i).playHidingAnimation()
2406 appRepeater.itemAt(priv.nextInStack).playFocusAnimation()
2407 if (appRepeater.itemAt(priv.nextInStack).stage == ApplicationInfoInterface.SideStage && !sideStage.shown) {
2420 GestureAreaSizeHint {
2421 anchors.fill: parent
2425 TabletSideStageTouchGesture {
2427 objectName: "triGestureArea"
2428 anchors.fill: parent
2430 property Item appDelegate
2432 dragComponent: dragComponent
2433 dragComponentProperties: { "appDelegate": appDelegate }
2436 function matchDelegate(obj) { return String(obj.objectName).indexOf("appDelegate") >= 0; }
2438 var delegateAtCenter = Functions.itemAt(appContainer, x, y, matchDelegate);
2439 if (!delegateAtCenter) return;
2441 appDelegate = delegateAtCenter;
2445 priv.toggleSideStage()
2449 // If we're dragging to the sidestage.
2450 if (!sideStage.shown) {
2456 // Hide side stage if the app drag was cancelled
2457 if (!priv.sideStageDelegate) {
2465 property Item appDelegate
2467 surface: appDelegate ? appDelegate.surface : null
2469 consumesInput: false
2472 requestedWidth: appDelegate ? appDelegate.requestedWidth : 0
2473 requestedHeight: appDelegate ? appDelegate.requestedHeight : 0
2476 height: units.gu(40)
2478 Drag.hotSpot.x: width/2
2479 Drag.hotSpot.y: height/2
2480 // only accept opposite stage.
2482 if (!surface) return "Disabled";
2484 if (appDelegate.stage === ApplicationInfo.MainStage) {
2485 if (appDelegate.application.supportedOrientations
2486 & (Qt.PortraitOrientation|Qt.InvertedPortraitOrientation)) {