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();
1462 // Make apps maximized on phones & tablets
1463 if (root.mode == "staged" || root.mode == "stagedWithSideStage")
1464 appDelegate.maximize()
1467 _constructing = false;
1469 Component.onDestruction: {
1470 windowStateSaver.save();
1473 // This stage is about to be destroyed. Don't mess up with the model at this point
1477 if (visuallyMaximized) {
1478 priv.updateForegroundMaximizedApp();
1482 onVisuallyMaximizedChanged: priv.updateForegroundMaximizedApp()
1484 property bool _constructing: true;
1486 if (!_constructing) {
1487 priv.updateMainAndSideStageIndexes();
1493 && !greeter.fullyShown
1494 && (priv.foregroundMaximizedAppDelegate === null || priv.foregroundMaximizedAppDelegate.normalZ <= z)
1496 || appDelegate.fullscreen
1497 || focusAnimation.running || rightEdgeFocusAnimation.running || hidingAnimation.running
1500 model.window.close();
1503 function playFocusAnimation() {
1504 if (state == "stagedRightEdge") {
1505 // TODO: Can we drop this if and find something that always works?
1506 if (root.mode == "staged") {
1507 rightEdgeFocusAnimation.targetX = 0
1508 rightEdgeFocusAnimation.start()
1509 } else if (root.mode == "stagedWithSideStage") {
1510 rightEdgeFocusAnimation.targetX = appDelegate.stage == ApplicationInfoInterface.SideStage ? sideStage.x : 0
1511 rightEdgeFocusAnimation.start()
1514 focusAnimation.start()
1517 function playHidingAnimation() {
1518 if (state != "windowedRightEdge") {
1519 hidingAnimation.start()
1523 function refreshStage() {
1524 var newStage = ApplicationInfoInterface.MainStage;
1525 if (priv.sideStageEnabled) { // we're in lanscape rotation.
1526 if (application && application.supportedOrientations & (Qt.PortraitOrientation|Qt.InvertedPortraitOrientation)) {
1527 var defaultStage = ApplicationInfoInterface.SideStage; // if application supports portrait, it defaults to sidestage.
1528 if (application.supportedOrientations & (Qt.LandscapeOrientation|Qt.InvertedLandscapeOrientation)) {
1529 // if it supports lanscape, it defaults to mainstage.
1530 defaultStage = ApplicationInfoInterface.MainStage;
1532 newStage = WindowStateStorage.getStage(application.appId, defaultStage);
1537 if (focus && stage == ApplicationInfoInterface.SideStage && !sideStage.shown) {
1542 LomiriNumberAnimation {
1548 duration: LomiriAnimation.SnapDuration
1550 topLevelSurfaceList.pendingActivation();
1551 topLevelSurfaceList.raiseId(model.window.id);
1554 appDelegate.activate();
1558 id: rightEdgeFocusAnimation
1559 property int targetX: 0
1560 LomiriNumberAnimation { target: appDelegate; properties: "x"; to: rightEdgeFocusAnimation.targetX; duration: priv.animationDuration }
1561 LomiriNumberAnimation { target: decoratedWindow; properties: "angle"; to: 0; duration: priv.animationDuration }
1562 LomiriNumberAnimation { target: decoratedWindow; properties: "itemScale"; to: 1; duration: priv.animationDuration }
1564 topLevelSurfaceList.pendingActivation();
1565 inhibitSlideAnimation = true;
1568 appDelegate.activate();
1573 LomiriNumberAnimation { target: appDelegate; property: "opacity"; to: 0; duration: priv.animationDuration }
1574 onStopped: appDelegate.opacity = 1
1581 flickable: floatingFlickable
1585 sceneWidth: root.width
1586 stage: appDelegate.stage
1587 thisDelegate: appDelegate
1588 mainStageDelegate: priv.mainStageDelegate
1589 sideStageDelegate: priv.sideStageDelegate
1590 sideStageWidth: sideStage.panelWidth
1591 sideStageHandleWidth: sideStage.handleWidth
1592 sideStageX: sideStage.x
1593 itemIndex: appDelegate.itemIndex
1594 nextInStack: priv.nextInStack
1595 animationDuration: priv.animationDuration
1598 StagedRightEdgeMaths {
1599 id: stagedRightEdgeMaths
1600 sceneWidth: root.availableDesktopArea.width
1601 sceneHeight: appContainer.height
1602 isMainStageApp: priv.mainStageDelegate == appDelegate
1603 isSideStageApp: priv.sideStageDelegate == appDelegate
1604 sideStageWidth: sideStage.width
1605 sideStageOpen: sideStage.shown
1607 nextInStack: priv.nextInStack
1609 targetHeight: spreadItem.stackHeight
1610 targetX: spreadMaths.targetX
1611 startY: appDelegate.fullscreen ? 0 : root.availableDesktopArea.y
1612 targetY: spreadMaths.targetY
1613 targetAngle: spreadMaths.targetAngle
1614 targetScale: spreadMaths.targetScale
1615 shuffledZ: stageMaths.itemZ
1616 breakPoint: spreadItem.rightEdgeBreakPoint
1619 WindowedRightEdgeMaths {
1620 id: windowedRightEdgeMaths
1622 startWidth: appDelegate.requestedWidth
1623 startHeight: appDelegate.requestedHeight
1624 targetHeight: spreadItem.stackHeight
1625 targetX: spreadMaths.targetX
1626 targetY: spreadMaths.targetY
1627 normalZ: appDelegate.normalZ
1628 targetAngle: spreadMaths.targetAngle
1629 targetScale: spreadMaths.targetScale
1630 breakPoint: spreadItem.rightEdgeBreakPoint
1635 name: "spread"; when: root.state == "spread"
1636 StateChangeScript { script: { decoratedWindow.cancelDrag(); } }
1638 target: decoratedWindow;
1639 showDecoration: false;
1640 angle: spreadMaths.targetAngle
1641 itemScale: spreadMaths.targetScale
1642 scaleToPreviewSize: spreadItem.stackHeight
1643 scaleToPreviewProgress: 1
1644 hasDecoration: root.mode === "windowed"
1645 shadowOpacity: spreadMaths.shadowOpacity
1646 showHighlight: spreadItem.highlightedIndex === index
1647 darkening: spreadItem.highlightedIndex >= 0
1648 anchors.topMargin: dragArea.distance
1652 x: spreadMaths.targetX
1653 y: spreadMaths.targetY
1655 height: spreadItem.spreadItemHeight
1656 visible: spreadMaths.itemVisible
1658 PropertyChanges { target: dragArea; enabled: true }
1659 PropertyChanges { target: windowInfoItem; opacity: spreadMaths.tileInfoOpacity; visible: spreadMaths.itemVisible }
1660 PropertyChanges { target: touchControls; enabled: false }
1663 name: "stagedRightEdge"
1664 when: (root.mode == "staged" || root.mode == "stagedWithSideStage") && (root.state == "sideStagedRightEdge" || root.state == "stagedRightEdge" || rightEdgeFocusAnimation.running || hidingAnimation.running)
1666 target: stagedRightEdgeMaths
1667 progress: Math.max(rightEdgePushProgress, rightEdgeDragArea.draggedProgress)
1671 x: stagedRightEdgeMaths.animatedX
1672 y: stagedRightEdgeMaths.animatedY
1673 z: stagedRightEdgeMaths.animatedZ
1674 height: stagedRightEdgeMaths.animatedHeight
1675 visible: appDelegate.x < root.width
1678 target: decoratedWindow
1679 hasDecoration: false
1680 angle: stagedRightEdgeMaths.animatedAngle
1681 itemScale: stagedRightEdgeMaths.animatedScale
1682 scaleToPreviewSize: spreadItem.stackHeight
1683 scaleToPreviewProgress: stagedRightEdgeMaths.scaleToPreviewProgress
1686 // make sure it's visible but transparent so it fades in when we transition to spread
1687 PropertyChanges { target: windowInfoItem; opacity: 0; visible: true }
1690 name: "windowedRightEdge"
1691 when: root.mode == "windowed" && (root.state == "windowedRightEdge" || rightEdgeFocusAnimation.running || hidingAnimation.running || rightEdgePushProgress > 0)
1693 target: windowedRightEdgeMaths
1694 swipeProgress: rightEdgeDragArea.dragging ? rightEdgeDragArea.progress : 0
1695 pushProgress: rightEdgePushProgress
1699 x: windowedRightEdgeMaths.animatedX
1700 y: windowedRightEdgeMaths.animatedY
1701 z: windowedRightEdgeMaths.animatedZ
1702 height: stagedRightEdgeMaths.animatedHeight
1705 target: decoratedWindow
1706 showDecoration: windowedRightEdgeMaths.decorationHeight
1707 angle: windowedRightEdgeMaths.animatedAngle
1708 itemScale: windowedRightEdgeMaths.animatedScale
1709 scaleToPreviewSize: spreadItem.stackHeight
1710 scaleToPreviewProgress: windowedRightEdgeMaths.scaleToPreviewProgress
1714 target: opacityEffect;
1715 opacityValue: windowedRightEdgeMaths.opacityMask
1716 sourceItem: windowedRightEdgeMaths.opacityMask < 1 ? decoratedWindow : null
1720 name: "staged"; when: root.state == "staged"
1724 y: root.availableDesktopArea.y
1725 visuallyMaximized: true
1726 visible: appDelegate.x < root.width
1730 requestedWidth: appContainer.width
1731 requestedHeight: root.availableDesktopArea.height
1732 restoreEntryValues: false
1735 target: decoratedWindow
1736 hasDecoration: false
1744 animateX: !focusAnimation.running && !rightEdgeFocusAnimation.running && itemIndex !== spreadItem.highlightedIndex && !inhibitSlideAnimation
1747 target: appDelegate.window
1748 allowClientResize: false
1752 name: "stagedWithSideStage"; when: root.state == "stagedWithSideStage"
1760 y: root.availableDesktopArea.y
1762 visuallyMaximized: true
1763 visible: appDelegate.x < root.width
1767 requestedWidth: stageMaths.itemWidth
1768 requestedHeight: root.availableDesktopArea.height
1769 restoreEntryValues: false
1772 target: decoratedWindow
1773 hasDecoration: false
1780 target: appDelegate.window
1781 allowClientResize: false
1785 name: "maximized"; when: appDelegate.maximized && !appDelegate.minimized
1787 target: appDelegate;
1788 requestedX: root.availableDesktopArea.x;
1790 visuallyMinimized: false;
1791 visuallyMaximized: true
1795 requestedWidth: root.availableDesktopArea.width;
1796 requestedHeight: appContainer.height;
1797 restoreEntryValues: false
1799 PropertyChanges { target: touchControls; enabled: true }
1800 PropertyChanges { target: decoratedWindow; windowControlButtonsVisible: false }
1803 name: "fullscreen"; when: appDelegate.fullscreen && !appDelegate.minimized
1805 target: appDelegate;
1811 requestedWidth: appContainer.width
1812 requestedHeight: appContainer.height
1813 restoreEntryValues: false
1815 PropertyChanges { target: decoratedWindow; hasDecoration: false }
1817 // TODO: merge normal and restored together, there's no point in normal being a distinct state
1822 visuallyMinimized: false
1824 PropertyChanges { target: touchControls; enabled: true }
1825 PropertyChanges { target: resizeArea; enabled: true }
1826 PropertyChanges { target: decoratedWindow; shadowOpacity: .3; windowControlButtonsVisible: true}
1829 requestedWidth: windowedWidth
1830 requestedHeight: windowedHeight
1831 restoreEntryValues: false
1836 when: appDelegate.windowState == Mir.RestoredState
1839 restoreEntryValues: false
1840 target: appDelegate;
1841 windowedX: restoredX;
1842 windowedY: restoredY;
1846 name: "maximizedLeft"; when: appDelegate.maximizedLeft && !appDelegate.minimized
1850 windowedX: root.availableDesktopArea.x
1851 windowedY: root.availableDesktopArea.y
1852 windowedWidth: root.availableDesktopArea.width / 2
1853 windowedHeight: root.availableDesktopArea.height
1857 name: "maximizedRight"; when: appDelegate.maximizedRight && !appDelegate.minimized
1858 extend: "maximizedLeft"
1860 target: appDelegate;
1861 windowedX: root.availableDesktopArea.x + (root.availableDesktopArea.width / 2)
1865 name: "maximizedTopLeft"; when: appDelegate.maximizedTopLeft && !appDelegate.minimized
1869 windowedX: root.availableDesktopArea.x
1870 windowedY: root.availableDesktopArea.y
1871 windowedWidth: root.availableDesktopArea.width / 2
1872 windowedHeight: root.availableDesktopArea.height / 2
1876 name: "maximizedTopRight"; when: appDelegate.maximizedTopRight && !appDelegate.minimized
1877 extend: "maximizedTopLeft"
1880 windowedX: root.availableDesktopArea.x + (root.availableDesktopArea.width / 2)
1884 name: "maximizedBottomLeft"; when: appDelegate.maximizedBottomLeft && !appDelegate.minimized
1888 windowedX: root.availableDesktopArea.x
1889 windowedY: root.availableDesktopArea.y + (root.availableDesktopArea.height / 2)
1890 windowedWidth: root.availableDesktopArea.width / 2
1891 windowedHeight: root.availableDesktopArea.height / 2
1895 name: "maximizedBottomRight"; when: appDelegate.maximizedBottomRight && !appDelegate.minimized
1896 extend: "maximizedBottomLeft"
1899 windowedX: root.availableDesktopArea.x + (root.availableDesktopArea.width / 2)
1903 name: "maximizedHorizontally"; when: appDelegate.maximizedHorizontally && !appDelegate.minimized
1907 windowedX: root.availableDesktopArea.x; windowedY: windowedY
1908 windowedWidth: root.availableDesktopArea.width; windowedHeight: windowedHeight
1912 name: "maximizedVertically"; when: appDelegate.maximizedVertically && !appDelegate.minimized
1916 windowedX: windowedX; windowedY: root.availableDesktopArea.y
1917 windowedWidth: windowedWidth; windowedHeight: root.availableDesktopArea.height
1921 name: "minimized"; when: appDelegate.minimized
1924 scale: units.gu(5) / appDelegate.width
1926 visuallyMinimized: true
1927 visuallyMaximized: false
1928 x: -appDelegate.width / 2
1936 // These two animate applications into position from Staged to Desktop and back
1938 from: "staged,stagedWithSideStage"
1939 to: "normal,restored,maximized,maximizedHorizontally,maximizedVertically,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedBottomLeft,maximizedTopRight,maximizedBottomRight"
1940 enabled: appDelegate.animationsEnabled
1941 PropertyAction { target: appDelegate; properties: "visuallyMinimized,visuallyMaximized" }
1942 LomiriNumberAnimation { target: appDelegate; properties: "x,y,requestedX,requestedY,opacity,requestedWidth,requestedHeight,scale"; duration: priv.animationDuration }
1945 from: "normal,restored,maximized,maximizedHorizontally,maximizedVertically,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedBottomLeft,maximizedTopRight,maximizedBottomRight"
1946 to: "staged,stagedWithSideStage"
1947 LomiriNumberAnimation { target: appDelegate; properties: "x,y,requestedX,requestedY,requestedWidth,requestedHeight"; duration: priv.animationDuration}
1951 from: "normal,restored,maximized,maximizedHorizontally,maximizedVertically,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedBottomLeft,maximizedTopRight,maximizedBottomRight,staged,stagedWithSideStage,windowedRightEdge,stagedRightEdge";
1953 // DecoratedWindow wants the scaleToPreviewSize set before enabling scaleToPreview
1954 PropertyAction { target: appDelegate; properties: "z,visible" }
1955 PropertyAction { target: decoratedWindow; property: "scaleToPreviewSize" }
1956 LomiriNumberAnimation { target: appDelegate; properties: "x,y,height"; duration: priv.animationDuration }
1957 LomiriNumberAnimation { target: decoratedWindow; properties: "width,height,itemScale,angle,scaleToPreviewProgress"; duration: priv.animationDuration }
1958 LomiriNumberAnimation { target: windowInfoItem; properties: "opacity"; duration: priv.animationDuration }
1961 from: "normal,staged"; to: "stagedWithSideStage"
1962 LomiriNumberAnimation { target: appDelegate; properties: "x,y,requestedWidth,requestedHeight"; duration: priv.animationDuration }
1965 to: "windowedRightEdge"
1968 windowedRightEdgeMaths.startX = appDelegate.requestedX
1969 windowedRightEdgeMaths.startY = appDelegate.requestedY
1972 var thisRect = { x: appDelegate.windowedX, y: appDelegate.windowedY, width: appDelegate.requestedWidth, height: appDelegate.requestedHeight }
1973 var otherDelegate = appRepeater.itemAt(0);
1974 var otherRect = { x: otherDelegate.windowedX, y: otherDelegate.windowedY, width: otherDelegate.requestedWidth, height: otherDelegate.requestedHeight }
1975 var intersectionRect = MathUtils.intersectionRect(thisRect, otherRect)
1976 var mappedInterSectionRect = appDelegate.mapFromItem(root, intersectionRect.x, intersectionRect.y)
1977 opacityEffect.maskX = mappedInterSectionRect.x
1978 opacityEffect.maskY = mappedInterSectionRect.y
1979 opacityEffect.maskWidth = intersectionRect.width
1980 opacityEffect.maskHeight = intersectionRect.height
1986 from: "stagedRightEdge"; to: "staged"
1987 enabled: rightEdgeDragArea.cancelled // only transition back to state if the gesture was cancelled, in the other cases we play the focusAnimations.
1988 SequentialAnimation {
1990 LomiriNumberAnimation { target: appDelegate; properties: "x,y,height,width,scale"; duration: priv.animationDuration }
1991 LomiriNumberAnimation { target: decoratedWindow; properties: "width,height,itemScale,angle,scaleToPreviewProgress"; duration: priv.animationDuration }
1993 // We need to release scaleToPreviewSize at last
1994 PropertyAction { target: decoratedWindow; property: "scaleToPreviewSize" }
1995 PropertyAction { target: appDelegate; property: "visible" }
1999 from: ",normal,restored,maximized,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedTopRight,maximizedBottomLeft,maximizedBottomRight,maximizedHorizontally,maximizedVertically,fullscreen"
2001 SequentialAnimation {
2002 ScriptAction { script: { fakeRectangle.stop(); } }
2003 PropertyAction { target: appDelegate; property: "visuallyMaximized" }
2004 PropertyAction { target: appDelegate; property: "visuallyMinimized" }
2005 LomiriNumberAnimation { target: appDelegate; properties: "x,y,scale,opacity"; duration: priv.animationDuration }
2006 PropertyAction { target: appDelegate; property: "visuallyMinimized" }
2011 to: ",normal,restored,maximized,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedTopRight,maximizedBottomLeft,maximizedBottomRight,maximizedHorizontally,maximizedVertically,fullscreen"
2012 SequentialAnimation {
2013 PropertyAction { target: appDelegate; property: "visuallyMinimized,z" }
2015 LomiriNumberAnimation { target: appDelegate; properties: "x"; from: -appDelegate.width / 2; duration: priv.animationDuration }
2016 LomiriNumberAnimation { target: appDelegate; properties: "y,opacity"; duration: priv.animationDuration }
2017 LomiriNumberAnimation { target: appDelegate; properties: "scale"; from: 0; duration: priv.animationDuration }
2019 PropertyAction { target: appDelegate; property: "visuallyMaximized" }
2023 id: windowedTransition
2024 from: ",normal,restored,maximized,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedTopRight,maximizedBottomLeft,maximizedBottomRight,maximizedHorizontally,maximizedVertically,fullscreen,minimized"
2025 to: ",normal,restored,maximized,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedTopRight,maximizedBottomLeft,maximizedBottomRight,maximizedHorizontally,maximizedVertically,fullscreen"
2026 enabled: appDelegate.animationsEnabled
2027 SequentialAnimation {
2028 ScriptAction { script: {
2029 if (appDelegate.visuallyMaximized) visuallyMaximized = false; // maximized before -> going to restored
2032 PropertyAction { target: appDelegate; property: "visuallyMinimized" }
2033 LomiriNumberAnimation { target: appDelegate; properties: "requestedX,requestedY,windowedX,windowedY,opacity,scale,requestedWidth,requestedHeight,windowedWidth,windowedHeight";
2034 duration: priv.animationDuration }
2035 ScriptAction { script: {
2036 fakeRectangle.stop();
2037 appDelegate.visuallyMaximized = appDelegate.maximized; // reflect the target state
2046 property: "decorationsAlwaysVisible"
2047 value: appDelegate && appDelegate.maximized && touchControls.overlayShown
2048 restoreMode: Binding.RestoreBinding
2053 objectName: "windowResizeArea"
2055 anchors.fill: appDelegate
2057 // workaround so that it chooses the correct resize borders when you drag from a corner ResizeGrip
2058 anchors.margins: touchControls.overlayShown ? borderThickness/2 : -borderThickness
2061 boundsItem: root.availableDesktopArea
2062 minWidth: units.gu(10)
2063 minHeight: units.gu(10)
2064 borderThickness: units.gu(2)
2067 readyToAssesBounds: !appDelegate._constructing
2070 appDelegate.activate();
2076 objectName: "decoratedWindow"
2077 anchors.left: appDelegate.left
2078 anchors.top: appDelegate.top
2079 application: model.application
2080 surface: model.window.surface
2081 active: model.window.focused
2083 interactive: root.interactive
2085 decorationHeight: priv.windowDecorationHeight
2086 maximizeButtonShown: appDelegate.canBeMaximized
2087 overlayShown: touchControls.overlayShown
2088 width: implicitWidth
2089 height: implicitHeight
2090 highlightSize: windowInfoItem.iconMargin
2091 boundsItem: root.availableDesktopArea
2092 panelState: root.panelState
2093 altDragEnabled: root.mode == "windowed"
2095 requestedWidth: appDelegate.requestedWidth
2096 requestedHeight: appDelegate.requestedHeight
2098 onCloseClicked: { appDelegate.close(); }
2099 onMaximizeClicked: {
2100 if (appDelegate.canBeMaximized) {
2101 appDelegate.anyMaximized ? appDelegate.requestRestore() : appDelegate.requestMaximize();
2104 onMaximizeHorizontallyClicked: {
2105 if (appDelegate.canBeMaximizedHorizontally) {
2106 appDelegate.maximizedHorizontally ? appDelegate.requestRestore() : appDelegate.requestMaximizeHorizontally()
2109 onMaximizeVerticallyClicked: {
2110 if (appDelegate.canBeMaximizedVertically) {
2111 appDelegate.maximizedVertically ? appDelegate.requestRestore() : appDelegate.requestMaximizeVertically()
2114 onMinimizeClicked: { appDelegate.requestMinimize(); }
2115 onDecorationPressed: { appDelegate.activate(); }
2116 onDecorationReleased: fakeRectangle.visible ? fakeRectangle.commit() : appDelegate.updateRestoredGeometry()
2118 onDragResizePressed: {
2119 appDelegate.activate();
2120 resizeArea.pressedChangedEx(true, mouse);
2122 onDragResizeReleased: resizeArea.pressedChangedEx(false, mouse);
2123 onDragResizePositionChanged: resizeArea.positionChangedEx(mouse);
2125 property real angle: 0
2126 Behavior on angle { enabled: priv.closingIndex >= 0; LomiriNumberAnimation {} }
2127 property real itemScale: 1
2128 Behavior on itemScale { enabled: priv.closingIndex >= 0; LomiriNumberAnimation {} }
2133 origin.y: decoratedWindow.implicitHeight / 2
2134 xScale: decoratedWindow.itemScale
2135 yScale: decoratedWindow.itemScale
2138 origin { x: 0; y: (decoratedWindow.height / 2) }
2139 axis { x: 0; y: 1; z: 0 }
2140 angle: decoratedWindow.angle
2147 anchors.fill: decoratedWindow
2150 WindowControlsOverlay {
2152 anchors.fill: appDelegate
2154 resizeArea: resizeArea
2157 boundsItem: root.availableDesktopArea
2159 onFakeMaximizeAnimationRequested: if (!appDelegate.maximized) fakeRectangle.maximize(amount, true)
2160 onFakeMaximizeLeftAnimationRequested: if (!appDelegate.maximizedLeft) fakeRectangle.maximizeLeft(amount, true)
2161 onFakeMaximizeRightAnimationRequested: if (!appDelegate.maximizedRight) fakeRectangle.maximizeRight(amount, true)
2162 onFakeMaximizeTopLeftAnimationRequested: if (!appDelegate.maximizedTopLeft) fakeRectangle.maximizeTopLeft(amount, true);
2163 onFakeMaximizeTopRightAnimationRequested: if (!appDelegate.maximizedTopRight) fakeRectangle.maximizeTopRight(amount, true);
2164 onFakeMaximizeBottomLeftAnimationRequested: if (!appDelegate.maximizedBottomLeft) fakeRectangle.maximizeBottomLeft(amount, true);
2165 onFakeMaximizeBottomRightAnimationRequested: if (!appDelegate.maximizedBottomRight) fakeRectangle.maximizeBottomRight(amount, true);
2166 onStopFakeAnimation: fakeRectangle.stop();
2167 onDragReleased: fakeRectangle.visible ? fakeRectangle.commit() : appDelegate.updateRestoredGeometry()
2170 WindowedFullscreenPolicy {
2171 id: windowedFullscreenPolicy
2173 StagedFullscreenPolicy {
2174 id: stagedFullscreenPolicy
2175 active: root.mode == "staged" || root.mode == "stagedWithSideStage"
2176 surface: model.window.surface
2179 SpreadDelegateInputArea {
2181 objectName: "dragArea"
2182 anchors.fill: decoratedWindow
2186 dragDelegate: fakeDragItem
2189 spreadItem.highlightedIndex = index;
2190 if (distance == 0) {
2191 priv.goneToSpread = false;
2195 priv.closingIndex = index
2196 appDelegate.close();
2202 objectName: "windowInfoItem"
2203 anchors { left: parent.left; top: decoratedWindow.bottom; topMargin: units.gu(1) }
2204 title: model.application.name
2205 iconSource: model.application.icon
2206 height: spreadItem.appInfoHeight
2209 visible: opacity > 0
2211 var nextApp = appRepeater.itemAt(index + 1);
2213 return Math.max(iconHeight, nextApp.x - appDelegate.x - units.gu(1))
2215 return appDelegate.width;
2219 spreadItem.highlightedIndex = index;
2220 priv.goneToSpread = false;
2226 objectName: "closeMouseArea"
2227 anchors { left: parent.left; top: parent.top; leftMargin: -height / 2; topMargin: -height / 2 + spreadMaths.closeIconOffset }
2228 readonly property var mousePos: hoverMouseArea.mapToItem(appDelegate, hoverMouseArea.mouseX, hoverMouseArea.mouseY)
2229 readonly property bool shown: dragArea.distance == 0
2230 && index == spreadItem.highlightedIndex
2231 && mousePos.y < (decoratedWindow.height / 3)
2232 && mousePos.y > -units.gu(4)
2233 && mousePos.x > -units.gu(4)
2234 && mousePos.x < (decoratedWindow.width * 2 / 3)
2235 opacity: shown ? 1 : 0
2236 visible: opacity > 0
2237 Behavior on opacity { LomiriNumberAnimation { duration: LomiriAnimation.SnapDuration } }
2242 priv.closingIndex = index;
2243 appDelegate.close();
2247 source: "graphics/window-close.svg"
2248 anchors.fill: closeMouseArea
2249 anchors.margins: units.gu(2)
2250 sourceSize.width: width
2251 sourceSize.height: height
2256 // Group all child windows in this item so that we can fade them out together when going to the spread
2257 // (and fade them in back again when returning from it)
2258 readonly property bool stageOnProperState: root.state === "windowed"
2259 || root.state === "staged"
2260 || root.state === "stagedWithSideStage"
2262 // TODO: Is it worth the extra cost of layering to avoid the opacity artifacts of intersecting children?
2263 // Btw, will involve more than uncommenting the line below as children won't necessarily fit this item's
2264 // geometry. This is just a reference.
2265 //layer.enabled: opacity !== 0.0 && opacity !== 1.0
2267 opacity: stageOnProperState ? 1.0 : 0.0
2268 visible: opacity !== 0.0 // make it transparent to input as well
2269 Behavior on opacity { LomiriNumberAnimation {} }
2272 id: childWindowRepeater
2273 model: appDelegate.surface ? appDelegate.surface.childSurfaceList : null
2275 delegate: ChildWindowTree {
2276 surface: model.surface
2278 // Account for the displacement caused by window decoration in the top-level surface
2279 // Ie, the top-level surface is not positioned at (0,0) of this ChildWindow's parent (appDelegate)
2280 displacementX: appDelegate.clientAreaItem.x
2281 displacementY: appDelegate.clientAreaItem.y
2283 boundsItem: root.availableDesktopArea
2284 decorationHeight: priv.windowDecorationHeight
2286 z: childWindowRepeater.count - model.index
2290 // some child surface in this tree got focus.
2291 // Ensure we also have it at the top-level hierarchy
2292 appDelegate.claimFocus();
2302 FakeMaximizeDelegate {
2304 target: priv.focusedAppDelegate
2305 leftMargin: root.availableDesktopArea.x
2306 appContainerWidth: appContainer.width
2307 appContainerHeight: appContainer.height
2308 panelState: root.panelState
2312 id: workspaceSwitcher
2313 enabled: workspaceEnabled
2314 anchors.centerIn: parent
2315 height: units.gu(20)
2316 width: root.width - units.gu(8)
2317 background: root.background
2318 availableDesktopArea: root.availableDesktopArea
2319 onWorkspaceSelected: screensAndWorkspaces.activeWorkspace = selectedWorkspace;
2322 appContainer.focus = true;
2328 id: shortRightEdgeSwipeAnimation
2331 duration: priv.animationDuration
2335 id: rightEdgeDragArea
2336 objectName: "rightEdgeDragArea"
2337 direction: Direction.Leftwards
2338 anchors { top: parent.top; right: parent.right; bottom: parent.bottom }
2339 width: root.dragAreaWidth
2340 enabled: root.spreadEnabled
2342 property var gesturePoints: []
2343 property bool cancelled: false
2345 property real progress: -touchPosition.x / root.width
2346 onProgressChanged: {
2348 draggedProgress = progress;
2352 property real draggedProgress: 0
2354 onTouchPositionChanged: {
2355 gesturePoints.push(touchPosition.x);
2356 if (gesturePoints.length > 10) {
2357 gesturePoints.splice(0, gesturePoints.length - 10)
2361 onDraggingChanged: {
2363 // A potential edge-drag gesture has started. Start recording it
2366 draggedProgress = 0;
2368 // Ok. The user released. Did he drag far enough to go to full spread?
2369 if (gesturePoints[gesturePoints.length - 1] < -spreadItem.rightEdgeBreakPoint * spreadItem.width ) {
2371 // He dragged far enough, but if the last movement was a flick to the right again, he wants to cancel the spread again.
2372 var oneWayFlickToRight = true;
2373 var smallestX = gesturePoints[0]-1;
2374 for (var i = 0; i < gesturePoints.length; i++) {
2375 if (gesturePoints[i] <= smallestX) {
2376 oneWayFlickToRight = false;
2379 smallestX = gesturePoints[i];
2382 if (!oneWayFlickToRight) {
2383 // Ok, the user made it, let's go to spread!
2384 priv.goneToSpread = true;
2389 // Ok, the user didn't drag far enough to cross the breakPoint
2390 // Find out if it was a one-way movement to the left, in which case we just switch directly to next app.
2391 var oneWayFlick = true;
2392 var smallestX = rightEdgeDragArea.width;
2393 for (var i = 0; i < gesturePoints.length; i++) {
2394 if (gesturePoints[i] >= smallestX) {
2395 oneWayFlick = false;
2398 smallestX = gesturePoints[i];
2401 if (appRepeater.count > 1 &&
2402 (oneWayFlick && rightEdgeDragArea.distance > units.gu(2) || rightEdgeDragArea.distance > spreadItem.rightEdgeBreakPoint * spreadItem.width)) {
2403 var nextStage = appRepeater.itemAt(priv.nextInStack).stage
2404 for (var i = 0; i < appRepeater.count; i++) {
2405 if (i != priv.nextInStack && appRepeater.itemAt(i).stage == nextStage) {
2406 appRepeater.itemAt(i).playHidingAnimation()
2410 appRepeater.itemAt(priv.nextInStack).playFocusAnimation()
2411 if (appRepeater.itemAt(priv.nextInStack).stage == ApplicationInfoInterface.SideStage && !sideStage.shown) {
2424 GestureAreaSizeHint {
2425 anchors.fill: parent
2429 TabletSideStageTouchGesture {
2431 objectName: "triGestureArea"
2432 anchors.fill: parent
2434 property Item appDelegate
2436 dragComponent: dragComponent
2437 dragComponentProperties: { "appDelegate": appDelegate }
2440 function matchDelegate(obj) { return String(obj.objectName).indexOf("appDelegate") >= 0; }
2442 var delegateAtCenter = Functions.itemAt(appContainer, x, y, matchDelegate);
2443 if (!delegateAtCenter) return;
2445 appDelegate = delegateAtCenter;
2449 priv.toggleSideStage()
2453 // If we're dragging to the sidestage.
2454 if (!sideStage.shown) {
2460 // Hide side stage if the app drag was cancelled
2461 if (!priv.sideStageDelegate) {
2469 property Item appDelegate
2471 surface: appDelegate ? appDelegate.surface : null
2473 consumesInput: false
2476 requestedWidth: appDelegate ? appDelegate.requestedWidth : 0
2477 requestedHeight: appDelegate ? appDelegate.requestedHeight : 0
2480 height: units.gu(40)
2482 Drag.hotSpot.x: width/2
2483 Drag.hotSpot.y: height/2
2484 // only accept opposite stage.
2486 if (!surface) return "Disabled";
2488 if (appDelegate.stage === ApplicationInfo.MainStage) {
2489 if (appDelegate.application.supportedOrientations
2490 & (Qt.PortraitOrientation|Qt.InvertedPortraitOrientation)) {