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 bool lightMode: false
53 property rect inputMethodRect
54 property real rightEdgePushProgress: 0
55 property Item availableDesktopArea
56 property PanelState panelState
58 // Whether outside forces say that the Stage may have focus
59 property bool allowInteractivity
61 readonly property bool interactive: (state === "staged" || state === "stagedWithSideStage" || state === "windowed") && allowInteractivity
64 property string mode: "staged"
66 readonly property var temporarySelectedWorkspace: state == "spread" ? screensAndWorkspaces.activeWorkspace : null
67 property bool workspaceEnabled: (mode == "windowed" && settings.enableWorkspace) || settings.forceEnableWorkspace
69 // Used by the tutorial code
70 readonly property real rightEdgeDragProgress: rightEdgeDragArea.dragging ? rightEdgeDragArea.progress : 0 // How far left the stage has been dragged
72 // used by the snap windows (edge maximize) feature
73 readonly property alias previewRectangle: fakeRectangle
75 readonly property bool spreadShown: state == "spread"
76 readonly property var mainApp: priv.focusedAppDelegate ? priv.focusedAppDelegate.application : null
78 // application windows never rotate independently
79 property int mainAppWindowOrientationAngle: shellOrientationAngle
81 property bool orientationChangesEnabled: !priv.focusedAppDelegate || priv.focusedAppDelegate.orientationChangesEnabled
83 property int supportedOrientations: {
87 return mainApp.supportedOrientations;
88 case "stagedWithSideStage":
89 var orientations = mainApp.supportedOrientations;
90 orientations |= Qt.LandscapeOrientation | Qt.InvertedLandscapeOrientation;
91 if (priv.sideStageItemId) {
92 // If we have a sidestage app, support Portrait orientation
93 // so that it will switch the sidestage app to mainstage on rotate to portrait
94 orientations |= Qt.PortraitOrientation|Qt.InvertedPortraitOrientation;
100 return Qt.PortraitOrientation |
101 Qt.LandscapeOrientation |
102 Qt.InvertedPortraitOrientation |
103 Qt.InvertedLandscapeOrientation;
108 schema.id: "com.lomiri.Shell"
111 property int launcherLeftMargin : 0
114 target: topLevelSurfaceList
115 restoreMode: Binding.RestoreBinding
116 property: "rootFocus"
120 onInteractiveChanged: {
121 // Stage must have focus before activating windows, including null
127 onAltTabPressedChanged: {
130 if (root.spreadEnabled) {
131 altTabDelayTimer.start();
134 // Alt Tab has been released, did we already go to spread?
135 if (priv.goneToSpread) {
136 priv.goneToSpread = false;
138 // No we didn't, do a quick alt-tab
139 if (appRepeater.count > 1) {
140 appRepeater.itemAt(1).activate();
141 } else if (appRepeater.count > 0) {
142 appRepeater.itemAt(0).activate(); // quick alt-tab to the only (minimized) window should still activate it
153 if (root.altTabPressed) {
154 priv.goneToSpread = true;
159 // For MirAL window management
161 normal: Qt.rect(0, root.mode === "windowed" ? priv.windowDecorationHeight : 0, 0, 0)
165 property Item itemConfiningMouseCursor: !spreadShown && priv.focusedAppDelegate && priv.focusedAppDelegate.window && priv.focusedAppDelegate.window.confinesMousePointer ?
166 priv.focusedAppDelegate.clientAreaItem : null;
168 signal itemSnapshotRequested(Item item)
170 // functions to be called from outside
171 function updateFocusedAppOrientation() { /* TODO */ }
172 function updateFocusedAppOrientationAnimated() { /* TODO */}
174 function closeSpread() {
175 spreadItem.highlightedIndex = -1;
176 priv.goneToSpread = false;
179 onSpreadEnabledChanged: {
180 if (!spreadEnabled && spreadShown) {
185 onRightEdgePushProgressChanged: {
186 if (spreadEnabled && rightEdgePushProgress >= 1) {
187 priv.goneToSpread = true
192 id: lifecycleExceptions
193 schema.id: "com.canonical.qtmir"
196 function isExemptFromLifecycle(appId) {
197 var shortAppId = appId.split('_')[0];
198 for (var i = 0; i < lifecycleExceptions.lifecycleExemptAppids.length; i++) {
199 if (shortAppId === lifecycleExceptions.lifecycleExemptAppids[i]) {
207 id: closeFocusedShortcut
208 shortcut: Qt.AltModifier|Qt.Key_F4
210 if (priv.focusedAppDelegate) {
211 priv.focusedAppDelegate.close();
217 id: showSpreadShortcut
218 shortcut: Qt.MetaModifier|Qt.Key_W
219 active: root.spreadEnabled
220 onTriggered: priv.goneToSpread = true
224 id: toggleSideStageShortcut
225 shortcut: Qt.MetaModifier|Qt.Key_S
226 active: priv.sideStageEnabled
228 priv.toggleSideStage()
233 id: minimizeAllShortcut
234 shortcut: Qt.MetaModifier|Qt.ControlModifier|Qt.Key_D
235 onTriggered: priv.minimizeAllWindows()
236 active: root.state == "windowed"
240 id: maximizeWindowShortcut
241 shortcut: Qt.MetaModifier|Qt.ControlModifier|Qt.Key_Up
242 onTriggered: priv.focusedAppDelegate.requestMaximize()
243 active: root.state == "windowed" && priv.focusedAppDelegate && priv.focusedAppDelegate.canBeMaximized
247 id: maximizeWindowLeftShortcut
248 shortcut: Qt.MetaModifier|Qt.ControlModifier|Qt.Key_Left
251 case "stagedWithSideStage":
252 if (priv.focusedAppDelegate.stage == ApplicationInfoInterface.SideStage) {
253 priv.focusedAppDelegate.saveStage(ApplicationInfoInterface.MainStage);
254 priv.focusedAppDelegate.focus = true;
258 priv.focusedAppDelegate.requestMaximizeLeft()
262 active: (root.state == "windowed" && priv.focusedAppDelegate && priv.focusedAppDelegate.canBeMaximizedLeftRight)
263 || (root.state == "stagedWithSideStage" && priv.focusedAppDelegate.stage == ApplicationInfoInterface.SideStage)
267 id: maximizeWindowRightShortcut
268 shortcut: Qt.MetaModifier|Qt.ControlModifier|Qt.Key_Right
271 case "stagedWithSideStage":
272 if (priv.focusedAppDelegate.stage == ApplicationInfoInterface.MainStage) {
273 priv.focusedAppDelegate.saveStage(ApplicationInfoInterface.SideStage);
274 priv.focusedAppDelegate.focus = true;
276 priv.updateMainAndSideStageIndexes()
280 priv.focusedAppDelegate.requestMaximizeRight()
284 active: (root.state == "windowed" && priv.focusedAppDelegate && priv.focusedAppDelegate.canBeMaximizedLeftRight)
285 || (root.state == "stagedWithSideStage" && priv.focusedAppDelegate.stage == ApplicationInfoInterface.MainStage)
289 id: minimizeRestoreShortcut
290 shortcut: Qt.MetaModifier|Qt.ControlModifier|Qt.Key_Down
292 if (priv.focusedAppDelegate.anyMaximized) {
293 priv.focusedAppDelegate.requestRestore();
295 priv.focusedAppDelegate.requestMinimize();
298 active: root.state == "windowed" && priv.focusedAppDelegate
302 shortcut: Qt.AltModifier|Qt.Key_Print
303 onTriggered: root.itemSnapshotRequested(priv.focusedAppDelegate)
304 active: priv.focusedAppDelegate !== null
308 shortcut: Qt.ControlModifier|Qt.AltModifier|Qt.Key_T
310 // try in this order: snap pkg, new deb name, old deb name
311 var candidates = ["lomiri-terminal-app_lomiri-terminal-app", "lomiri-terminal-app", "com.lomiri.terminal_terminal"];
312 for (var i = 0; i < candidates.length; i++) {
313 if (priv.startApp(candidates[i]))
320 id: showWorkspaceSwitcherShortcutLeft
321 shortcut: Qt.AltModifier|Qt.ControlModifier|Qt.Key_Left
322 active: !workspaceSwitcher.active && root.workspaceEnabled
325 workspaceSwitcher.showLeft()
329 id: showWorkspaceSwitcherShortcutRight
330 shortcut: Qt.AltModifier|Qt.ControlModifier|Qt.Key_Right
331 active: !workspaceSwitcher.active && root.workspaceEnabled
334 workspaceSwitcher.showRight()
338 id: showWorkspaceSwitcherShortcutUp
339 shortcut: Qt.AltModifier|Qt.ControlModifier|Qt.Key_Up
340 active: !workspaceSwitcher.active && root.workspaceEnabled
343 workspaceSwitcher.showUp()
347 id: showWorkspaceSwitcherShortcutDown
348 shortcut: Qt.AltModifier|Qt.ControlModifier|Qt.Key_Down
349 active: !workspaceSwitcher.active && root.workspaceEnabled
352 workspaceSwitcher.showDown()
357 id: moveAppShowWorkspaceSwitcherShortcutLeft
358 shortcut: Qt.AltModifier|Qt.ControlModifier|Qt.ShiftModifier|Qt.Key_Left
359 active: !workspaceSwitcher.active && root.workspaceEnabled && root.focusedAppDelegate
362 workspaceSwitcher.showLeftMoveApp(root.focusedAppDelegate.surface)
366 id: moveAppShowWorkspaceSwitcherShortcutRight
367 shortcut: Qt.AltModifier|Qt.ControlModifier|Qt.ShiftModifier|Qt.Key_Right
368 active: !workspaceSwitcher.active && root.workspaceEnabled && root.focusedAppDelegate
371 workspaceSwitcher.showRightMoveApp(root.focusedAppDelegate.surface)
375 id: moveAppShowWorkspaceSwitcherShortcutUp
376 shortcut: Qt.AltModifier|Qt.ControlModifier|Qt.ShiftModifier|Qt.Key_Up
377 active: !workspaceSwitcher.active && root.workspaceEnabled && root.focusedAppDelegate
380 workspaceSwitcher.showUpMoveApp(root.focusedAppDelegate.surface)
384 id: moveAppShowWorkspaceSwitcherShortcutDown
385 shortcut: Qt.AltModifier|Qt.ControlModifier|Qt.ShiftModifier|Qt.Key_Down
386 active: !workspaceSwitcher.active && root.workspaceEnabled && root.focusedAppDelegate
389 workspaceSwitcher.showDownMoveApp(root.focusedAppDelegate.surface)
395 objectName: "DesktopStagePrivate"
397 function startApp(appId) {
398 if (root.applicationManager.findApplication(appId)) {
399 return root.applicationManager.requestFocusApplication(appId);
401 return root.applicationManager.startApplication(appId) !== null;
405 property var focusedAppDelegate: null
406 property var foregroundMaximizedAppDelegate: null // for stuff like drop shadow and focusing maximized app by clicking panel
408 property bool goneToSpread: false
409 property int closingIndex: -1
410 property int animationDuration: LomiriAnimation.FastDuration
412 function updateForegroundMaximizedApp() {
414 for (var i = 0; i < appRepeater.count && !found; i++) {
415 var item = appRepeater.itemAt(i);
416 if (item && item.visuallyMaximized) {
417 foregroundMaximizedAppDelegate = item;
422 foregroundMaximizedAppDelegate = null;
426 function minimizeAllWindows() {
427 for (var i = appRepeater.count - 1; i >= 0; i--) {
428 var appDelegate = appRepeater.itemAt(i);
429 if (appDelegate && !appDelegate.minimized) {
430 appDelegate.requestMinimize();
435 readonly property bool sideStageEnabled: root.mode === "stagedWithSideStage" &&
436 (root.shellOrientation == Qt.LandscapeOrientation ||
437 root.shellOrientation == Qt.InvertedLandscapeOrientation)
438 onSideStageEnabledChanged: {
439 for (var i = 0; i < appRepeater.count; i++) {
440 appRepeater.itemAt(i).refreshStage();
442 priv.updateMainAndSideStageIndexes();
445 property var mainStageDelegate: null
446 property var sideStageDelegate: null
447 property int mainStageItemId: 0
448 property int sideStageItemId: 0
449 property string mainStageAppId: ""
450 property string sideStageAppId: ""
452 onSideStageDelegateChanged: {
453 if (!sideStageDelegate) {
458 function toggleSideStage() {
459 if (sideStage.shown) {
463 updateMainAndSideStageIndexes()
467 function updateMainAndSideStageIndexes() {
468 if (root.mode != "stagedWithSideStage") {
469 priv.sideStageDelegate = null;
470 priv.sideStageItemId = 0;
471 priv.sideStageAppId = "";
472 priv.mainStageDelegate = appRepeater.itemAt(0);
473 priv.mainStageItemId = topLevelSurfaceList.idAt(0);
474 priv.mainStageAppId = topLevelSurfaceList.applicationAt(0) ? topLevelSurfaceList.applicationAt(0).appId : ""
478 var choseMainStage = false;
479 var choseSideStage = false;
481 if (!root.topLevelSurfaceList)
484 for (var i = 0; i < appRepeater.count && (!choseMainStage || !choseSideStage); ++i) {
485 var appDelegate = appRepeater.itemAt(i);
487 // This might happen during startup phase... If the delegate appears and claims focus
488 // things are updated and appRepeater.itemAt(x) still returns null while appRepeater.count >= x
489 // Lets just skip it, on startup it will be generated at a later point too...
492 if (sideStage.shown && appDelegate.stage == ApplicationInfoInterface.SideStage
493 && !choseSideStage) {
494 priv.sideStageDelegate = appDelegate
495 priv.sideStageItemId = root.topLevelSurfaceList.idAt(i);
496 priv.sideStageAppId = root.topLevelSurfaceList.applicationAt(i).appId;
497 choseSideStage = true;
498 } else if (!choseMainStage && appDelegate.stage == ApplicationInfoInterface.MainStage) {
499 priv.mainStageDelegate = appDelegate;
500 priv.mainStageItemId = root.topLevelSurfaceList.idAt(i);
501 priv.mainStageAppId = root.topLevelSurfaceList.applicationAt(i).appId;
502 choseMainStage = true;
505 if (!choseMainStage && priv.mainStageDelegate) {
506 priv.mainStageDelegate = null;
507 priv.mainStageItemId = 0;
508 priv.mainStageAppId = "";
510 if (!choseSideStage && priv.sideStageDelegate) {
511 priv.sideStageDelegate = null;
512 priv.sideStageItemId = 0;
513 priv.sideStageAppId = "";
517 property int nextInStack: {
518 var mainStageIndex = priv.mainStageDelegate ? priv.mainStageDelegate.itemIndex : -1;
519 var sideStageIndex = priv.sideStageDelegate ? priv.sideStageDelegate.itemIndex : -1;
520 if (sideStageIndex == -1) {
521 return topLevelSurfaceList.count > 1 ? 1 : -1;
523 if (mainStageIndex == 0 || sideStageIndex == 0) {
524 if (mainStageIndex == 1 || sideStageIndex == 1) {
525 return topLevelSurfaceList.count > 2 ? 2 : -1;
532 readonly property real virtualKeyboardHeight: root.inputMethodRect.height
534 readonly property real windowDecorationHeight: units.gu(3)
537 Component.onCompleted: priv.updateMainAndSideStageIndexes()
541 function onCloseClicked() { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.close(); } }
542 function onMinimizeClicked() { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.requestMinimize(); } }
543 function onRestoreClicked() { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.requestRestore(); } }
548 restoreMode: Binding.RestoreBinding
549 property: "decorationsVisible"
550 value: mode == "windowed" && priv.focusedAppDelegate !== null && priv.focusedAppDelegate.maximized && !root.spreadShown
555 restoreMode: Binding.RestoreBinding
558 if (priv.focusedAppDelegate !== null) {
559 if (priv.focusedAppDelegate.maximized)
560 return priv.focusedAppDelegate.title
562 return priv.focusedAppDelegate.appName
566 when: priv.focusedAppDelegate
571 restoreMode: Binding.RestoreBinding
572 property: "focusedPersistentSurfaceId"
574 if (priv.focusedAppDelegate !== null) {
575 if (priv.focusedAppDelegate.surface) {
576 return priv.focusedAppDelegate.surface.persistentId;
581 when: priv.focusedAppDelegate
586 restoreMode: Binding.RestoreBinding
587 property: "dropShadow"
588 value: priv.focusedAppDelegate && !priv.focusedAppDelegate.maximized && priv.foregroundMaximizedAppDelegate !== null && mode == "windowed"
593 restoreMode: Binding.RestoreBinding
594 property: "closeButtonShown"
595 value: priv.focusedAppDelegate && priv.focusedAppDelegate.maximized
598 Component.onDestruction: {
599 panelState.title = "";
600 panelState.decorationsVisible = false;
601 panelState.dropShadow = false;
605 model: root.applicationManager
607 id: applicationDelegate
608 // TODO: figure out some lifecycle policy, like suspending minimized apps
609 // or something if running windowed.
610 // TODO: If the device has a dozen suspended apps because it was running
611 // in staged mode, when it switches to Windowed mode it will suddenly
612 // resume all those apps at once. We might want to avoid that.
613 property var requestedState: ApplicationInfoInterface.RequestedRunning
614 property bool temporaryAwaken: ProcessControl.awakenProcesses.indexOf(model.application.appId) >= 0
616 property var stateBinding: Binding {
617 target: model.application
618 property: "requestedState"
619 value: applicationDelegate.requestedState
620 restoreMode: Binding.RestoreBinding
623 property var lifecycleBinding: Binding {
624 target: model.application
625 property: "exemptFromLifecycle"
626 restoreMode: Binding.RestoreBinding
627 value: model.application
628 ? (!model.application.isTouchApp ||
629 isExemptFromLifecycle(model.application.appId) ||
630 applicationDelegate.temporaryAwaken)
635 property var focusRequestedConnection: Connections {
636 target: model.application
638 function onFocusRequested() {
639 // Application emits focusRequested when it has no surface (i.e. their processes died).
640 // Find the topmost window for this application and activate it, after which the app
641 // will be requested to be running.
643 for (var i = 0; i < appRepeater.count; i++) {
644 var appDelegate = appRepeater.itemAt(i);
645 if (appDelegate.application.appId === model.application.appId) {
646 appDelegate.activate();
651 console.warn("Application requested te be focused but no window for it. What should we do?");
659 name: "spread"; when: priv.goneToSpread
660 PropertyChanges { target: floatingFlickable; enabled: true }
661 PropertyChanges { target: root; focus: true }
662 PropertyChanges { target: spreadItem; focus: true }
663 PropertyChanges { target: hoverMouseArea; enabled: true }
664 PropertyChanges { target: rightEdgeDragArea; enabled: false }
665 PropertyChanges { target: cancelSpreadMouseArea; enabled: true }
666 PropertyChanges { target: noAppsRunningHint; visible: (root.topLevelSurfaceList.count < 1) }
667 PropertyChanges { target: blurLayer; visible: true; blurRadius: 32; brightness: .65; opacity: 1 }
668 PropertyChanges { target: wallpaper; visible: false }
669 PropertyChanges { target: screensAndWorkspaces.showTimer; running: true }
672 name: "stagedRightEdge"; when: root.spreadEnabled && (rightEdgeDragArea.dragging || rightEdgePushProgress > 0) && root.mode == "staged"
680 PropertyChanges { target: noAppsRunningHint; visible: (root.topLevelSurfaceList.count < 1) }
683 name: "sideStagedRightEdge"; when: root.spreadEnabled && (rightEdgeDragArea.dragging || rightEdgePushProgress > 0) && root.mode == "stagedWithSideStage"
684 extend: "stagedRightEdge"
687 opacity: priv.sideStageDelegate && priv.sideStageDelegate.x === sideStage.x ? 1 : 0
692 name: "windowedRightEdge"; when: root.spreadEnabled && (rightEdgeDragArea.dragging || rightEdgePushProgress > 0) && root.mode == "windowed"
698 opacity: MathUtils.linearAnimation(spreadItem.rightEdgeBreakPoint, 1, 0, 1, Math.max(rightEdgeDragArea.dragging ? rightEdgeDragArea.progress : 0, rightEdgePushProgress))
702 name: "staged"; when: root.mode === "staged"
703 PropertyChanges { target: root; focus: true }
704 PropertyChanges { target: appContainer; focus: true }
707 name: "stagedWithSideStage"; when: root.mode === "stagedWithSideStage"
708 PropertyChanges { target: triGestureArea; enabled: priv.sideStageEnabled }
709 PropertyChanges { target: sideStage; visible: true }
710 PropertyChanges { target: root; focus: true }
711 PropertyChanges { target: appContainer; focus: true }
714 name: "windowed"; when: root.mode === "windowed"
715 PropertyChanges { target: root; focus: true }
716 PropertyChanges { target: appContainer; focus: true }
721 from: "stagedRightEdge,sideStagedRightEdge,windowedRightEdge"; to: "spread"
722 PropertyAction { target: spreadItem; property: "highlightedIndex"; value: -1 }
723 PropertyAction { target: screensAndWorkspaces; property: "activeWorkspace"; value: WMScreen.currentWorkspace }
724 PropertyAnimation { target: blurLayer; properties: "brightness,blurRadius"; duration: priv.animationDuration }
728 PropertyAction { target: screensAndWorkspaces; property: "activeWorkspace"; value: WMScreen.currentWorkspace }
729 PropertyAction { target: spreadItem; property: "highlightedIndex"; value: appRepeater.count > 1 ? 1 : 0 }
730 PropertyAction { target: floatingFlickable; property: "contentX"; value: 0 }
734 SequentialAnimation {
737 var item = appRepeater.itemAt(Math.max(0, spreadItem.highlightedIndex));
739 if (item.stage == ApplicationInfoInterface.SideStage && !sideStage.shown) {
742 item.playFocusAnimation();
746 PropertyAction { target: spreadItem; property: "highlightedIndex"; value: -1 }
747 PropertyAction { target: floatingFlickable; property: "contentX"; value: 0 }
751 to: "stagedRightEdge,sideStagedRightEdge"
752 PropertyAction { target: floatingFlickable; property: "contentX"; value: 0 }
755 to: "stagedWithSideStage"
756 ScriptAction { script: priv.updateMainAndSideStageIndexes(); }
762 id: cancelSpreadMouseArea
765 onClicked: priv.goneToSpread = false
770 objectName: "appContainer"
776 objectName: "stageBackground"
778 source: root.background
779 // Make sure it's the lowest item. Due to the left edge drag we sometimes need
780 // to put the dash at -1 and we don't want it behind the Wallpaper
791 ScreensAndWorkspaces {
792 id: screensAndWorkspaces
793 anchors { left: parent.left; top: parent.top; right: parent.right; leftMargin: root.launcherLeftMargin }
794 height: Math.max(units.gu(30), parent.height * .3)
795 background: root.background
797 enabled: workspaceEnabled
799 availableDesktopArea: root.availableDesktopArea
800 onCloseSpread: priv.goneToSpread = false;
801 // Clicking a workspace should put it front and center
802 onActiveWorkspaceChanged: activeWorkspace.activate()
803 opacity: visible ? 1.0 : 0.0
804 Behavior on opacity {
805 NumberAnimation { duration: priv.animationDuration }
808 property bool showAllowed : false
809 property var showTimer: Timer {
812 interval: priv.animationDuration
814 if (!priv.goneToSpread)
816 screensAndWorkspaces.showAllowed = root.workspaceEnabled;
821 onGoneToSpreadChanged: if (!priv.goneToSpread) screensAndWorkspaces.showAllowed = false
827 objectName: "spreadItem"
830 bottom: parent.bottom;
832 top: workspaceEnabled ? screensAndWorkspaces.bottom : parent.top;
834 leftMargin: root.availableDesktopArea.x
835 model: root.topLevelSurfaceList
836 spreadFlickable: floatingFlickable
837 z: root.topLevelSurfaceList.count
840 priv.goneToSpread = false;
844 appRepeater.itemAt(highlightedIndex).close();
848 id: floatingFlickable
849 objectName: "spreadFlickable"
852 contentWidth: spreadItem.spreadTotalWidth
854 function snap(toIndex) {
855 var delegate = appRepeater.itemAt(toIndex)
856 var targetContentX = floatingFlickable.contentWidth / spreadItem.totalItemCount * toIndex;
857 if (targetContentX - floatingFlickable.contentX > spreadItem.rightStackXPos - (spreadItem.spreadItemWidth / 2)) {
858 var offset = (spreadItem.rightStackXPos - (spreadItem.spreadItemWidth / 2)) - (targetContentX - floatingFlickable.contentX)
859 snapAnimation.to = floatingFlickable.contentX - offset;
860 snapAnimation.start();
861 } else if (targetContentX - floatingFlickable.contentX < spreadItem.leftStackXPos + units.gu(1)) {
862 var offset = (spreadItem.leftStackXPos + units.gu(1)) - (targetContentX - floatingFlickable.contentX);
863 snapAnimation.to = floatingFlickable.contentX - offset;
864 snapAnimation.start();
867 LomiriNumberAnimation {id: snapAnimation; target: floatingFlickable; property: "contentX"}
872 objectName: "hoverMouseArea"
874 propagateComposedEvents: true
878 property bool wasTouchPress: false
880 property int scrollAreaWidth: width / 3
881 property bool progressiveScrollingEnabled: false
884 mouse.accepted = false
886 if (hoverMouseArea.pressed || wasTouchPress) {
890 // Find the hovered item and mark it active
891 for (var i = appRepeater.count - 1; i >= 0; i--) {
892 var appDelegate = appRepeater.itemAt(i);
893 var mapped = mapToItem(appDelegate, hoverMouseArea.mouseX, hoverMouseArea.mouseY)
894 var itemUnder = appDelegate.childAt(mapped.x, mapped.y);
895 if (itemUnder && (itemUnder.objectName === "dragArea" || itemUnder.objectName === "windowInfoItem" || itemUnder.objectName == "closeMouseArea")) {
896 spreadItem.highlightedIndex = i;
901 if (floatingFlickable.contentWidth > floatingFlickable.width) {
902 var margins = floatingFlickable.width * 0.05;
904 if (!progressiveScrollingEnabled && mouseX < floatingFlickable.width - scrollAreaWidth) {
905 progressiveScrollingEnabled = true
908 // do we need to scroll?
909 if (mouseX < scrollAreaWidth + margins) {
910 var progress = Math.min(1, (scrollAreaWidth + margins - mouseX) / (scrollAreaWidth - margins));
911 var contentX = (1 - progress) * (floatingFlickable.contentWidth - floatingFlickable.width)
912 floatingFlickable.contentX = Math.max(0, Math.min(floatingFlickable.contentX, contentX))
914 if (mouseX > floatingFlickable.width - scrollAreaWidth && progressiveScrollingEnabled) {
915 var progress = Math.min(1, (mouseX - (floatingFlickable.width - scrollAreaWidth)) / (scrollAreaWidth - margins))
916 var contentX = progress * (floatingFlickable.contentWidth - floatingFlickable.width)
917 floatingFlickable.contentX = Math.min(floatingFlickable.contentWidth - floatingFlickable.width, Math.max(floatingFlickable.contentX, contentX))
923 mouse.accepted = false;
924 wasTouchPress = mouse.source === Qt.MouseEventSynthesizedByQt;
927 onExited: wasTouchPress = false;
932 id: noAppsRunningHint
934 anchors.horizontalCenter: parent.horizontalCenter
935 anchors.verticalCenter: parent.verticalCenter
937 horizontalAlignment: Qt.AlignHCenter
938 verticalAlignment: Qt.AlignVCenter
939 anchors.leftMargin: root.launcherLeftMargin
940 wrapMode: Label.WordWrap
942 text: i18n.tr("No running apps")
947 target: root.topLevelSurfaceList
948 function onListChanged() { priv.updateMainAndSideStageIndexes() }
953 objectName: "MainStageDropArea"
957 bottom: parent.bottom
959 width: appContainer.width - sideStage.width
960 enabled: priv.sideStageEnabled
963 drop.source.appDelegate.saveStage(ApplicationInfoInterface.MainStage);
964 drop.source.appDelegate.activate();
971 objectName: "sideStage"
973 height: appContainer.height
974 x: appContainer.width - width
976 showHint: !priv.sideStageDelegate
977 Behavior on opacity { LomiriNumberAnimation {} }
979 if (!priv.mainStageItemId) return 0;
981 if (priv.sideStageItemId && priv.nextInStack > 0) {
983 // Due the order in which bindings are evaluated, this might be triggered while shuffling
984 // the list and index doesn't yet match with itemIndex (even though itemIndex: index)
985 // Let's walk the list and compare itemIndex to make sure we have the correct one.
986 var nextDelegateInStack = -1;
987 for (var i = 0; i < appRepeater.count; i++) {
988 if (appRepeater.itemAt(i).itemIndex == priv.nextInStack) {
989 nextDelegateInStack = appRepeater.itemAt(i);
994 if (nextDelegateInStack.stage === ApplicationInfoInterface.MainStage) {
995 // if the next app in stack is a main stage app, put the sidestage on top of it.
1005 if (!shown && priv.mainStageDelegate && !root.spreadShown) {
1006 priv.mainStageDelegate.activate();
1011 id: sideStageDropArea
1012 objectName: "SideStageDropArea"
1013 anchors.fill: parent
1015 property bool dropAllowed: true
1018 dropAllowed = drag.keys != "Disabled";
1024 if (drop.keys == "MainStage") {
1025 drop.source.appDelegate.saveStage(ApplicationInfoInterface.SideStage);
1026 drop.source.appDelegate.activate();
1031 if (!sideStageDropArea.drag.source) {
1041 property real previewScale: .5
1042 height: (screensAndWorkspaces.height - units.gu(8)) / 2
1044 width: implicitWidth * height / implicitHeight
1047 opacity: surface != null ? 1 : 0
1048 Behavior on opacity { LomiriNumberAnimation {} }
1049 visible: opacity > 0
1050 enabled: workspaceSwitcher
1052 Drag.active: surface != null
1053 Drag.keys: ["application"]
1060 model: topLevelSurfaceList
1061 objectName: "appRepeater"
1063 function indexOf(delegateItem) {
1064 for (var i = 0; i < count; i++) {
1065 if (itemAt(i) === delegateItem) {
1072 delegate: FocusScope {
1074 objectName: "appDelegate_" + model.window.id
1075 property int itemIndex: index // We need this from outside the repeater
1076 // z might be overriden in some cases by effects, but we need z ordering
1077 // to calculate occlusion detection
1078 property int normalZ: topLevelSurfaceList.count - index
1080 if (visuallyMaximized) {
1081 priv.updateForegroundMaximizedApp();
1086 opacity: fakeDragItem.surface == model.window.surface && fakeDragItem.Drag.active ? 0 : 1
1087 Behavior on opacity { LomiriNumberAnimation {} }
1089 // Set these as propertyes as they wont update otherwise
1090 property real screenOffsetX: Screen.virtualX
1091 property real screenOffsetY: Screen.virtualY
1093 // Normally we want x/y where the surface thinks it is. Width/height of our delegate will
1094 // match what the actual surface size is.
1095 // Don't write to those, they will be set by states
1097 // Here we will also need to remove the screen offset from miral's results
1098 // as lomiri x,y will be relative to the current screen only
1099 // FIXME: when proper multiscreen lands
1100 x: model.window.position.x - clientAreaItem.x - screenOffsetX
1101 y: model.window.position.y - clientAreaItem.y - screenOffsetY
1102 width: decoratedWindow.implicitWidth
1103 height: decoratedWindow.implicitHeight
1105 // requestedX/Y/width/height is what we ask the actual surface to be.
1106 // Do not write to those, they will be set by states
1107 property real requestedX: windowedX
1108 property real requestedY: windowedY
1109 property real requestedWidth: windowedWidth
1110 property real requestedHeight: windowedHeight
1112 // For both windowed and staged need to tell miral what screen we are on,
1113 // so we need to add the screen offset to the position we tell miral
1114 // FIXME: when proper multiscreen lands
1116 target: model.window; property: "requestedPosition"
1117 // miral doesn't know about our window decorations. So we have to deduct them
1118 value: Qt.point(appDelegate.requestedX + appDelegate.clientAreaItem.x + screenOffsetX,
1119 appDelegate.requestedY + appDelegate.clientAreaItem.y + screenOffsetY)
1120 when: root.mode == "windowed"
1121 restoreMode: Binding.RestoreBinding
1124 target: model.window; property: "requestedPosition"
1125 value: Qt.point(screenOffsetX, screenOffsetY)
1126 when: root.mode != "windowed"
1127 restoreMode: Binding.RestoreBinding
1130 // In those are for windowed mode. Those values basically store the window's properties
1131 // when having a floating window. If you want to move/resize a window in normal mode, this is what you want to write to.
1132 property real windowedX
1133 property real windowedY
1134 property real windowedWidth
1135 property real windowedHeight
1137 // unlike windowedX/Y, this is the last known grab position before being pushed against edges/corners
1138 // when restoring, the window should return to these, not to the place where it was dropped near the edge
1139 property real restoredX
1140 property real restoredY
1142 // Keeps track of the window geometry while in normal or restored state
1143 // Useful when returning from some maxmized state or when saving the geometry while maximized
1144 // FIXME: find a better solution
1145 property real normalX: 0
1146 property real normalY: 0
1147 property real normalWidth: 0
1148 property real normalHeight: 0
1149 function updateNormalGeometry() {
1150 if (appDelegate.state == "normal" || appDelegate.state == "restored") {
1151 normalX = appDelegate.requestedX;
1152 normalY = appDelegate.requestedY;
1153 normalWidth = appDelegate.width;
1154 normalHeight = appDelegate.height;
1157 function updateRestoredGeometry() {
1158 if (appDelegate.state == "normal" || appDelegate.state == "restored") {
1159 // save the x/y to restore to
1160 restoredX = appDelegate.x;
1161 restoredY = appDelegate.y;
1167 function onXChanged() { appDelegate.updateNormalGeometry(); }
1168 function onYChanged() { appDelegate.updateNormalGeometry(); }
1169 function onWidthChanged() { appDelegate.updateNormalGeometry(); }
1170 function onHeightChanged() { appDelegate.updateNormalGeometry(); }
1173 // True when the Stage is focusing this app and playing its own animation.
1174 // Stays true until the app is unfocused.
1175 // If it is, we don't want to play the slide in/out transition from StageMaths.
1176 // Setting it imperatively is not great, but any declarative solution hits
1177 // race conditions, causing two animations to play for one focus event.
1178 property bool inhibitSlideAnimation: false
1183 value: appDelegate.requestedY -
1184 Math.min(appDelegate.requestedY - root.availableDesktopArea.y,
1185 Math.max(0, priv.virtualKeyboardHeight - (appContainer.height - (appDelegate.requestedY + appDelegate.height))))
1186 when: root.oskEnabled && appDelegate.focus && (appDelegate.state == "normal" || appDelegate.state == "restored")
1187 && root.inputMethodRect.height > 0
1188 restoreMode: Binding.RestoreBinding
1191 Behavior on x { id: xBehavior; enabled: priv.closingIndex >= 0; LomiriNumberAnimation { onRunningChanged: if (!running) priv.closingIndex = -1} }
1195 function onShellOrientationAngleChanged() {
1196 // at this point decoratedWindow.surfaceOrientationAngle is the old shellOrientationAngle
1197 if (appDelegate.application && appDelegate.application.rotatesWindowContents) {
1198 if (root.state == "windowed") {
1199 var angleDiff = decoratedWindow.surfaceOrientationAngle - shellOrientationAngle;
1200 angleDiff = (360 + angleDiff) % 360;
1201 if (angleDiff === 90 || angleDiff === 270) {
1202 var aux = decoratedWindow.requestedHeight;
1203 decoratedWindow.requestedHeight = decoratedWindow.requestedWidth + decoratedWindow.actualDecorationHeight;
1204 decoratedWindow.requestedWidth = aux - decoratedWindow.actualDecorationHeight;
1207 decoratedWindow.surfaceOrientationAngle = shellOrientationAngle;
1209 decoratedWindow.surfaceOrientationAngle = 0;
1214 readonly property alias application: decoratedWindow.application
1215 readonly property alias minimumWidth: decoratedWindow.minimumWidth
1216 readonly property alias minimumHeight: decoratedWindow.minimumHeight
1217 readonly property alias maximumWidth: decoratedWindow.maximumWidth
1218 readonly property alias maximumHeight: decoratedWindow.maximumHeight
1219 readonly property alias widthIncrement: decoratedWindow.widthIncrement
1220 readonly property alias heightIncrement: decoratedWindow.heightIncrement
1222 readonly property bool maximized: windowState === WindowStateStorage.WindowStateMaximized
1223 readonly property bool maximizedLeft: windowState === WindowStateStorage.WindowStateMaximizedLeft
1224 readonly property bool maximizedRight: windowState === WindowStateStorage.WindowStateMaximizedRight
1225 readonly property bool maximizedHorizontally: windowState === WindowStateStorage.WindowStateMaximizedHorizontally
1226 readonly property bool maximizedVertically: windowState === WindowStateStorage.WindowStateMaximizedVertically
1227 readonly property bool maximizedTopLeft: windowState === WindowStateStorage.WindowStateMaximizedTopLeft
1228 readonly property bool maximizedTopRight: windowState === WindowStateStorage.WindowStateMaximizedTopRight
1229 readonly property bool maximizedBottomLeft: windowState === WindowStateStorage.WindowStateMaximizedBottomLeft
1230 readonly property bool maximizedBottomRight: windowState === WindowStateStorage.WindowStateMaximizedBottomRight
1231 readonly property bool anyMaximized: maximized || maximizedLeft || maximizedRight || maximizedHorizontally || maximizedVertically ||
1232 maximizedTopLeft || maximizedTopRight || maximizedBottomLeft || maximizedBottomRight
1234 readonly property bool minimized: windowState & WindowStateStorage.WindowStateMinimized
1235 readonly property bool fullscreen: windowState === WindowStateStorage.WindowStateFullscreen
1237 readonly property bool canBeMaximized: canBeMaximizedHorizontally && canBeMaximizedVertically
1238 readonly property bool canBeMaximizedLeftRight: (maximumWidth == 0 || maximumWidth >= appContainer.width/2) &&
1239 (maximumHeight == 0 || maximumHeight >= appContainer.height)
1240 readonly property bool canBeCornerMaximized: (maximumWidth == 0 || maximumWidth >= appContainer.width/2) &&
1241 (maximumHeight == 0 || maximumHeight >= appContainer.height/2)
1242 readonly property bool canBeMaximizedHorizontally: maximumWidth == 0 || maximumWidth >= appContainer.width
1243 readonly property bool canBeMaximizedVertically: maximumHeight == 0 || maximumHeight >= appContainer.height
1244 readonly property alias orientationChangesEnabled: decoratedWindow.orientationChangesEnabled
1246 // TODO drop our own windowType once Mir/Miral/Qtmir gets in sync with ours
1247 property int windowState: WindowStateStorage.WindowStateNormal
1248 property int prevWindowState: WindowStateStorage.WindowStateRestored
1250 property bool animationsEnabled: true
1251 property alias title: decoratedWindow.title
1252 readonly property string appName: model.application ? model.application.name : ""
1253 property bool visuallyMaximized: false
1254 property bool visuallyMinimized: false
1255 readonly property alias windowedTransitionRunning: windowedTransition.running
1257 property int stage: ApplicationInfoInterface.MainStage
1258 function saveStage(newStage) {
1259 appDelegate.stage = newStage;
1260 WindowStateStorage.saveStage(appId, newStage);
1261 priv.updateMainAndSideStageIndexes()
1264 readonly property var surface: model.window.surface
1265 readonly property var window: model.window
1267 readonly property alias focusedSurface: decoratedWindow.focusedSurface
1268 readonly property bool dragging: touchControls.overlayShown ? touchControls.dragging : decoratedWindow.dragging
1270 readonly property string appId: model.application.appId
1271 readonly property alias clientAreaItem: decoratedWindow.clientAreaItem
1273 // It is Lomiri policy to close any window but the last one during OOM teardown
1276 target: model.window.surface
1278 if ((!surface.live && application && application.surfaceCount > 1) || !application)
1279 topLevelSurfaceList.removeAt(appRepeater.indexOf(appDelegate));
1285 function activate() {
1286 if (model.window.focused) {
1287 updateQmlFocusFromMirSurfaceFocus();
1290 // Activate the window since it has a surface (with a running app) backing it
1291 model.window.activate();
1293 // Otherwise, cause a respawn of the app, and trigger it's refocusing as the last window
1294 topLevelSurfaceList.raiseId(model.window.id);
1298 function requestMaximize() { model.window.requestState(Mir.MaximizedState); }
1299 function requestMaximizeVertically() { model.window.requestState(Mir.VertMaximizedState); }
1300 function requestMaximizeHorizontally() { model.window.requestState(Mir.HorizMaximizedState); }
1301 function requestMaximizeLeft() { model.window.requestState(Mir.MaximizedLeftState); }
1302 function requestMaximizeRight() { model.window.requestState(Mir.MaximizedRightState); }
1303 function requestMaximizeTopLeft() { model.window.requestState(Mir.MaximizedTopLeftState); }
1304 function requestMaximizeTopRight() { model.window.requestState(Mir.MaximizedTopRightState); }
1305 function requestMaximizeBottomLeft() { model.window.requestState(Mir.MaximizedBottomLeftState); }
1306 function requestMaximizeBottomRight() { model.window.requestState(Mir.MaximizedBottomRightState); }
1307 function requestMinimize() { model.window.requestState(Mir.MinimizedState); }
1308 function requestRestore() { model.window.requestState(Mir.RestoredState); }
1310 function claimFocus() {
1311 if (root.state == "spread") {
1312 spreadItem.highlightedIndex = index
1313 // force pendingActivation so that when switching to staged mode, topLevelSurfaceList focus won't got to previous app ( case when apps are launched from outside )
1314 topLevelSurfaceList.pendingActivation();
1315 priv.goneToSpread = false;
1317 if (root.mode == "stagedWithSideStage") {
1318 if (appDelegate.stage == ApplicationInfoInterface.SideStage && !sideStage.shown) {
1321 priv.updateMainAndSideStageIndexes();
1323 appDelegate.focus = true;
1325 // Don't set focusedAppDelegate (and signal mainAppChanged) unnecessarily
1326 // which can happen after getting interactive again.
1327 if (priv.focusedAppDelegate !== appDelegate)
1328 priv.focusedAppDelegate = appDelegate;
1331 function updateQmlFocusFromMirSurfaceFocus() {
1332 if (model.window.focused) {
1334 decoratedWindow.focus = true;
1339 id: windowStateSaver
1341 screenWidth: appContainer.width
1342 screenHeight: appContainer.height
1343 leftMargin: root.availableDesktopArea.x
1344 minimumY: root.availableDesktopArea.y
1348 target: model.window
1349 function onFocusedChanged() {
1350 updateQmlFocusFromMirSurfaceFocus();
1351 if (!model.window.focused) {
1352 inhibitSlideAnimation = false;
1355 function onFocusRequested() {
1356 appDelegate.activate();
1358 function onStateChanged(value) {
1359 if (value == Mir.MinimizedState) {
1360 appDelegate.minimize();
1361 } else if (value == Mir.MaximizedState) {
1362 appDelegate.maximize();
1363 } else if (value == Mir.VertMaximizedState) {
1364 appDelegate.maximizeVertically();
1365 } else if (value == Mir.HorizMaximizedState) {
1366 appDelegate.maximizeHorizontally();
1367 } else if (value == Mir.MaximizedLeftState) {
1368 appDelegate.maximizeLeft();
1369 } else if (value == Mir.MaximizedRightState) {
1370 appDelegate.maximizeRight();
1371 } else if (value == Mir.MaximizedTopLeftState) {
1372 appDelegate.maximizeTopLeft();
1373 } else if (value == Mir.MaximizedTopRightState) {
1374 appDelegate.maximizeTopRight();
1375 } else if (value == Mir.MaximizedBottomLeftState) {
1376 appDelegate.maximizeBottomLeft();
1377 } else if (value == Mir.MaximizedBottomRightState) {
1378 appDelegate.maximizeBottomRight();
1379 } else if (value == Mir.RestoredState) {
1380 if (appDelegate.fullscreen && appDelegate.prevWindowState != WindowStateStorage.WindowStateRestored
1381 && appDelegate.prevWindowState != WindowStateStorage.WindowStateNormal) {
1382 model.window.requestState(WindowStateStorage.toMirState(appDelegate.prevWindowState));
1384 appDelegate.restore();
1386 } else if (value == Mir.FullscreenState) {
1387 appDelegate.prevWindowState = appDelegate.windowState;
1388 appDelegate.windowState = WindowStateStorage.WindowStateFullscreen;
1393 readonly property bool windowReady: clientAreaItem.surfaceInitialized
1394 onWindowReadyChanged: {
1396 var loadedMirState = WindowStateStorage.toMirState(windowStateSaver.loadedState);
1397 var state = loadedMirState;
1399 if (window.state == Mir.FullscreenState) {
1400 // If the app is fullscreen at startup, we should not use saved state
1401 // Example of why: if you open game that only requests fullscreen at
1402 // Statup, this will automaticly be set to "restored state" since
1403 // thats the default value of stateStorage, this will result in the app
1404 // having the "restored state" as it will not make a fullscreen
1405 // call after the app has started.
1406 console.log("Initial window state is fullscreen, not using saved state.");
1407 state = window.state;
1408 } else if (loadedMirState == Mir.FullscreenState) {
1409 // If saved state is fullscreen, we should use app initial state
1410 // Example of why: if you open browser with youtube video at fullscreen
1411 // and close this app, it will be fullscreen next time you open the app.
1412 console.log("Saved window state is fullscreen, using initial window state");
1413 state = window.state;
1416 // need to apply the shell chrome policy on top the saved window state
1418 if (root.mode == "windowed") {
1419 policy = windowedFullscreenPolicy;
1421 policy = stagedFullscreenPolicy
1423 window.requestState(policy.applyPolicy(state, surface.shellChrome));
1427 Component.onCompleted: {
1428 if (application && application.rotatesWindowContents) {
1429 decoratedWindow.surfaceOrientationAngle = shellOrientationAngle;
1431 decoratedWindow.surfaceOrientationAngle = 0;
1434 // First, cascade the newly created window, relative to the currently/old focused window.
1435 windowedX = priv.focusedAppDelegate ? priv.focusedAppDelegate.windowedX + units.gu(3) : (normalZ - 1) * units.gu(3)
1436 windowedY = priv.focusedAppDelegate ? priv.focusedAppDelegate.windowedY + units.gu(3) : normalZ * units.gu(3)
1437 // Now load any saved state. This needs to happen *after* the cascading!
1438 windowStateSaver.load();
1440 updateQmlFocusFromMirSurfaceFocus();
1442 // Make apps maximized on phones & tablets
1443 if (root.mode == "staged" || root.mode == "stagedWithSideStage")
1444 appDelegate.maximize()
1447 _constructing = false;
1449 Component.onDestruction: {
1450 windowStateSaver.save();
1453 // This stage is about to be destroyed. Don't mess up with the model at this point
1457 if (visuallyMaximized) {
1458 priv.updateForegroundMaximizedApp();
1462 onVisuallyMaximizedChanged: priv.updateForegroundMaximizedApp()
1464 property bool _constructing: true;
1466 if (!_constructing) {
1467 priv.updateMainAndSideStageIndexes();
1473 && !greeter.fullyShown
1474 && (priv.foregroundMaximizedAppDelegate === null || priv.foregroundMaximizedAppDelegate.normalZ <= z)
1476 || appDelegate.fullscreen
1477 || focusAnimation.running || rightEdgeFocusAnimation.running || hidingAnimation.running
1480 model.window.close();
1483 function maximize(animated) {
1484 animationsEnabled = (animated === undefined) || animated;
1485 windowState = WindowStateStorage.WindowStateMaximized;
1487 function maximizeLeft(animated) {
1488 animationsEnabled = (animated === undefined) || animated;
1489 windowState = WindowStateStorage.WindowStateMaximizedLeft;
1491 function maximizeRight(animated) {
1492 animationsEnabled = (animated === undefined) || animated;
1493 windowState = WindowStateStorage.WindowStateMaximizedRight;
1495 function maximizeHorizontally(animated) {
1496 animationsEnabled = (animated === undefined) || animated;
1497 windowState = WindowStateStorage.WindowStateMaximizedHorizontally;
1499 function maximizeVertically(animated) {
1500 animationsEnabled = (animated === undefined) || animated;
1501 windowState = WindowStateStorage.WindowStateMaximizedVertically;
1503 function maximizeTopLeft(animated) {
1504 animationsEnabled = (animated === undefined) || animated;
1505 windowState = WindowStateStorage.WindowStateMaximizedTopLeft;
1507 function maximizeTopRight(animated) {
1508 animationsEnabled = (animated === undefined) || animated;
1509 windowState = WindowStateStorage.WindowStateMaximizedTopRight;
1511 function maximizeBottomLeft(animated) {
1512 animationsEnabled = (animated === undefined) || animated;
1513 windowState = WindowStateStorage.WindowStateMaximizedBottomLeft;
1515 function maximizeBottomRight(animated) {
1516 animationsEnabled = (animated === undefined) || animated;
1517 windowState = WindowStateStorage.WindowStateMaximizedBottomRight;
1519 function minimize(animated) {
1520 animationsEnabled = (animated === undefined) || animated;
1521 windowState |= WindowStateStorage.WindowStateMinimized; // add the minimized bit
1523 function restore(animated,state) {
1524 animationsEnabled = (animated === undefined) || animated;
1525 windowState = state || WindowStateStorage.WindowStateRestored;
1526 windowState &= ~WindowStateStorage.WindowStateMinimized; // clear the minimized bit
1527 prevWindowState = windowState;
1530 function playFocusAnimation() {
1531 if (state == "stagedRightEdge") {
1532 // TODO: Can we drop this if and find something that always works?
1533 if (root.mode == "staged") {
1534 rightEdgeFocusAnimation.targetX = 0
1535 rightEdgeFocusAnimation.start()
1536 } else if (root.mode == "stagedWithSideStage") {
1537 rightEdgeFocusAnimation.targetX = appDelegate.stage == ApplicationInfoInterface.SideStage ? sideStage.x : 0
1538 rightEdgeFocusAnimation.start()
1541 focusAnimation.start()
1544 function playHidingAnimation() {
1545 if (state != "windowedRightEdge") {
1546 hidingAnimation.start()
1550 function refreshStage() {
1551 var newStage = ApplicationInfoInterface.MainStage;
1552 if (priv.sideStageEnabled) { // we're in lanscape rotation.
1553 if (application && application.supportedOrientations & (Qt.PortraitOrientation|Qt.InvertedPortraitOrientation)) {
1554 var defaultStage = ApplicationInfoInterface.SideStage; // if application supports portrait, it defaults to sidestage.
1555 if (application.supportedOrientations & (Qt.LandscapeOrientation|Qt.InvertedLandscapeOrientation)) {
1556 // if it supports lanscape, it defaults to mainstage.
1557 defaultStage = ApplicationInfoInterface.MainStage;
1559 newStage = WindowStateStorage.getStage(application.appId, defaultStage);
1564 if (focus && stage == ApplicationInfoInterface.SideStage && !sideStage.shown) {
1569 LomiriNumberAnimation {
1575 duration: LomiriAnimation.SnapDuration
1577 topLevelSurfaceList.pendingActivation();
1578 topLevelSurfaceList.raiseId(model.window.id);
1581 appDelegate.activate();
1585 id: rightEdgeFocusAnimation
1586 property int targetX: 0
1587 LomiriNumberAnimation { target: appDelegate; properties: "x"; to: rightEdgeFocusAnimation.targetX; duration: priv.animationDuration }
1588 LomiriNumberAnimation { target: decoratedWindow; properties: "angle"; to: 0; duration: priv.animationDuration }
1589 LomiriNumberAnimation { target: decoratedWindow; properties: "itemScale"; to: 1; duration: priv.animationDuration }
1591 topLevelSurfaceList.pendingActivation();
1592 inhibitSlideAnimation = true;
1595 appDelegate.activate();
1600 LomiriNumberAnimation { target: appDelegate; property: "opacity"; to: 0; duration: priv.animationDuration }
1601 onStopped: appDelegate.opacity = 1
1608 flickable: floatingFlickable
1612 sceneWidth: root.width
1613 stage: appDelegate.stage
1614 thisDelegate: appDelegate
1615 mainStageDelegate: priv.mainStageDelegate
1616 sideStageDelegate: priv.sideStageDelegate
1617 sideStageWidth: sideStage.panelWidth
1618 sideStageHandleWidth: sideStage.handleWidth
1619 sideStageX: sideStage.x
1620 itemIndex: appDelegate.itemIndex
1621 nextInStack: priv.nextInStack
1622 animationDuration: priv.animationDuration
1625 StagedRightEdgeMaths {
1626 id: stagedRightEdgeMaths
1627 sceneWidth: root.availableDesktopArea.width
1628 sceneHeight: appContainer.height
1629 isMainStageApp: priv.mainStageDelegate == appDelegate
1630 isSideStageApp: priv.sideStageDelegate == appDelegate
1631 sideStageWidth: sideStage.width
1632 sideStageOpen: sideStage.shown
1634 nextInStack: priv.nextInStack
1636 targetHeight: spreadItem.stackHeight
1637 targetX: spreadMaths.targetX
1638 startY: appDelegate.fullscreen ? 0 : root.availableDesktopArea.y
1639 targetY: spreadMaths.targetY
1640 targetAngle: spreadMaths.targetAngle
1641 targetScale: spreadMaths.targetScale
1642 shuffledZ: stageMaths.itemZ
1643 breakPoint: spreadItem.rightEdgeBreakPoint
1646 WindowedRightEdgeMaths {
1647 id: windowedRightEdgeMaths
1649 startWidth: appDelegate.requestedWidth
1650 startHeight: appDelegate.requestedHeight
1651 targetHeight: spreadItem.stackHeight
1652 targetX: spreadMaths.targetX
1653 targetY: spreadMaths.targetY
1654 normalZ: appDelegate.normalZ
1655 targetAngle: spreadMaths.targetAngle
1656 targetScale: spreadMaths.targetScale
1657 breakPoint: spreadItem.rightEdgeBreakPoint
1662 name: "spread"; when: root.state == "spread"
1663 StateChangeScript { script: { decoratedWindow.cancelDrag(); } }
1665 target: decoratedWindow;
1666 showDecoration: false;
1667 angle: spreadMaths.targetAngle
1668 itemScale: spreadMaths.targetScale
1669 scaleToPreviewSize: spreadItem.stackHeight
1670 scaleToPreviewProgress: 1
1671 hasDecoration: root.mode === "windowed"
1672 shadowOpacity: spreadMaths.shadowOpacity
1673 showHighlight: spreadItem.highlightedIndex === index
1674 darkening: spreadItem.highlightedIndex >= 0
1675 anchors.topMargin: dragArea.distance
1679 x: spreadMaths.targetX
1680 y: spreadMaths.targetY
1682 height: spreadItem.spreadItemHeight
1683 visible: spreadMaths.itemVisible
1685 PropertyChanges { target: dragArea; enabled: true }
1686 PropertyChanges { target: windowInfoItem; opacity: spreadMaths.tileInfoOpacity; visible: spreadMaths.itemVisible }
1687 PropertyChanges { target: touchControls; enabled: false }
1690 name: "stagedRightEdge"
1691 when: (root.mode == "staged" || root.mode == "stagedWithSideStage") && (root.state == "sideStagedRightEdge" || root.state == "stagedRightEdge" || rightEdgeFocusAnimation.running || hidingAnimation.running)
1693 target: stagedRightEdgeMaths
1694 progress: Math.max(rightEdgePushProgress, rightEdgeDragArea.draggedProgress)
1698 x: stagedRightEdgeMaths.animatedX
1699 y: stagedRightEdgeMaths.animatedY
1700 z: stagedRightEdgeMaths.animatedZ
1701 height: stagedRightEdgeMaths.animatedHeight
1702 visible: appDelegate.x < root.width
1705 target: decoratedWindow
1706 hasDecoration: false
1707 angle: stagedRightEdgeMaths.animatedAngle
1708 itemScale: stagedRightEdgeMaths.animatedScale
1709 scaleToPreviewSize: spreadItem.stackHeight
1710 scaleToPreviewProgress: stagedRightEdgeMaths.scaleToPreviewProgress
1713 // make sure it's visible but transparent so it fades in when we transition to spread
1714 PropertyChanges { target: windowInfoItem; opacity: 0; visible: true }
1717 name: "windowedRightEdge"
1718 when: root.mode == "windowed" && (root.state == "windowedRightEdge" || rightEdgeFocusAnimation.running || hidingAnimation.running || rightEdgePushProgress > 0)
1720 target: windowedRightEdgeMaths
1721 swipeProgress: rightEdgeDragArea.dragging ? rightEdgeDragArea.progress : 0
1722 pushProgress: rightEdgePushProgress
1726 x: windowedRightEdgeMaths.animatedX
1727 y: windowedRightEdgeMaths.animatedY
1728 z: windowedRightEdgeMaths.animatedZ
1729 height: stagedRightEdgeMaths.animatedHeight
1732 target: decoratedWindow
1733 showDecoration: windowedRightEdgeMaths.decorationHeight
1734 angle: windowedRightEdgeMaths.animatedAngle
1735 itemScale: windowedRightEdgeMaths.animatedScale
1736 scaleToPreviewSize: spreadItem.stackHeight
1737 scaleToPreviewProgress: windowedRightEdgeMaths.scaleToPreviewProgress
1741 target: opacityEffect;
1742 opacityValue: windowedRightEdgeMaths.opacityMask
1743 sourceItem: windowedRightEdgeMaths.opacityMask < 1 ? decoratedWindow : null
1747 name: "staged"; when: root.state == "staged"
1751 y: root.availableDesktopArea.y
1752 visuallyMaximized: true
1753 visible: appDelegate.x < root.width
1757 requestedWidth: appContainer.width
1758 requestedHeight: root.availableDesktopArea.height
1759 restoreEntryValues: false
1762 target: decoratedWindow
1763 hasDecoration: false
1771 animateX: !focusAnimation.running && !rightEdgeFocusAnimation.running && itemIndex !== spreadItem.highlightedIndex && !inhibitSlideAnimation
1774 target: appDelegate.window
1775 allowClientResize: false
1779 name: "stagedWithSideStage"; when: root.state == "stagedWithSideStage"
1787 y: root.availableDesktopArea.y
1789 visuallyMaximized: true
1790 visible: appDelegate.x < root.width
1794 requestedWidth: stageMaths.itemWidth
1795 requestedHeight: root.availableDesktopArea.height
1796 restoreEntryValues: false
1799 target: decoratedWindow
1800 hasDecoration: false
1807 target: appDelegate.window
1808 allowClientResize: false
1812 name: "maximized"; when: appDelegate.maximized && !appDelegate.minimized
1814 target: appDelegate;
1815 requestedX: root.availableDesktopArea.x;
1817 visuallyMinimized: false;
1818 visuallyMaximized: true
1822 requestedWidth: root.availableDesktopArea.width;
1823 requestedHeight: appContainer.height;
1824 restoreEntryValues: false
1826 PropertyChanges { target: touchControls; enabled: true }
1827 PropertyChanges { target: decoratedWindow; windowControlButtonsVisible: false }
1830 name: "fullscreen"; when: appDelegate.fullscreen && !appDelegate.minimized
1832 target: appDelegate;
1838 requestedWidth: appContainer.width
1839 requestedHeight: appContainer.height
1840 restoreEntryValues: false
1842 PropertyChanges { target: decoratedWindow; hasDecoration: false }
1846 when: appDelegate.windowState == WindowStateStorage.WindowStateNormal
1849 visuallyMinimized: false
1851 PropertyChanges { target: touchControls; enabled: true }
1852 PropertyChanges { target: resizeArea; enabled: true }
1853 PropertyChanges { target: decoratedWindow; shadowOpacity: .3; windowControlButtonsVisible: true}
1856 requestedWidth: windowedWidth
1857 requestedHeight: windowedHeight
1858 restoreEntryValues: false
1863 when: appDelegate.windowState == WindowStateStorage.WindowStateRestored
1866 restoreEntryValues: false
1867 target: appDelegate;
1868 windowedX: restoredX;
1869 windowedY: restoredY;
1873 name: "maximizedLeft"; when: appDelegate.maximizedLeft && !appDelegate.minimized
1877 windowedX: root.availableDesktopArea.x
1878 windowedY: root.availableDesktopArea.y
1879 windowedWidth: root.availableDesktopArea.width / 2
1880 windowedHeight: root.availableDesktopArea.height
1884 name: "maximizedRight"; when: appDelegate.maximizedRight && !appDelegate.minimized
1885 extend: "maximizedLeft"
1887 target: appDelegate;
1888 windowedX: root.availableDesktopArea.x + (root.availableDesktopArea.width / 2)
1892 name: "maximizedTopLeft"; when: appDelegate.maximizedTopLeft && !appDelegate.minimized
1896 windowedX: root.availableDesktopArea.x
1897 windowedY: root.availableDesktopArea.y
1898 windowedWidth: root.availableDesktopArea.width / 2
1899 windowedHeight: root.availableDesktopArea.height / 2
1903 name: "maximizedTopRight"; when: appDelegate.maximizedTopRight && !appDelegate.minimized
1904 extend: "maximizedTopLeft"
1907 windowedX: root.availableDesktopArea.x + (root.availableDesktopArea.width / 2)
1911 name: "maximizedBottomLeft"; when: appDelegate.maximizedBottomLeft && !appDelegate.minimized
1915 windowedX: root.availableDesktopArea.x
1916 windowedY: root.availableDesktopArea.y + (root.availableDesktopArea.height / 2)
1917 windowedWidth: root.availableDesktopArea.width / 2
1918 windowedHeight: root.availableDesktopArea.height / 2
1922 name: "maximizedBottomRight"; when: appDelegate.maximizedBottomRight && !appDelegate.minimized
1923 extend: "maximizedBottomLeft"
1926 windowedX: root.availableDesktopArea.x + (root.availableDesktopArea.width / 2)
1930 name: "maximizedHorizontally"; when: appDelegate.maximizedHorizontally && !appDelegate.minimized
1934 windowedX: root.availableDesktopArea.x; windowedY: windowedY
1935 windowedWidth: root.availableDesktopArea.width; windowedHeight: windowedHeight
1939 name: "maximizedVertically"; when: appDelegate.maximizedVertically && !appDelegate.minimized
1943 windowedX: windowedX; windowedY: root.availableDesktopArea.y
1944 windowedWidth: windowedWidth; windowedHeight: root.availableDesktopArea.height
1948 name: "minimized"; when: appDelegate.minimized
1951 scale: units.gu(5) / appDelegate.width
1953 visuallyMinimized: true
1954 visuallyMaximized: false
1955 x: -appDelegate.width / 2
1963 // These two animate applications into position from Staged to Desktop and back
1965 from: "staged,stagedWithSideStage"
1966 to: "normal,restored,maximized,maximizedHorizontally,maximizedVertically,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedBottomLeft,maximizedTopRight,maximizedBottomRight"
1967 enabled: appDelegate.animationsEnabled
1968 PropertyAction { target: appDelegate; properties: "visuallyMinimized,visuallyMaximized" }
1969 LomiriNumberAnimation { target: appDelegate; properties: "x,y,requestedX,requestedY,opacity,requestedWidth,requestedHeight,scale"; duration: priv.animationDuration }
1972 from: "normal,restored,maximized,maximizedHorizontally,maximizedVertically,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedBottomLeft,maximizedTopRight,maximizedBottomRight"
1973 to: "staged,stagedWithSideStage"
1974 LomiriNumberAnimation { target: appDelegate; properties: "x,y,requestedX,requestedY,requestedWidth,requestedHeight"; duration: priv.animationDuration}
1978 from: "normal,restored,maximized,maximizedHorizontally,maximizedVertically,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedBottomLeft,maximizedTopRight,maximizedBottomRight,staged,stagedWithSideStage,windowedRightEdge,stagedRightEdge";
1980 // DecoratedWindow wants the scaleToPreviewSize set before enabling scaleToPreview
1981 PropertyAction { target: appDelegate; properties: "z,visible" }
1982 PropertyAction { target: decoratedWindow; property: "scaleToPreviewSize" }
1983 LomiriNumberAnimation { target: appDelegate; properties: "x,y,height"; duration: priv.animationDuration }
1984 LomiriNumberAnimation { target: decoratedWindow; properties: "width,height,itemScale,angle,scaleToPreviewProgress"; duration: priv.animationDuration }
1985 LomiriNumberAnimation { target: windowInfoItem; properties: "opacity"; duration: priv.animationDuration }
1988 from: "normal,staged"; to: "stagedWithSideStage"
1989 LomiriNumberAnimation { target: appDelegate; properties: "x,y,requestedWidth,requestedHeight"; duration: priv.animationDuration }
1992 to: "windowedRightEdge"
1995 windowedRightEdgeMaths.startX = appDelegate.requestedX
1996 windowedRightEdgeMaths.startY = appDelegate.requestedY
1999 var thisRect = { x: appDelegate.windowedX, y: appDelegate.windowedY, width: appDelegate.requestedWidth, height: appDelegate.requestedHeight }
2000 var otherDelegate = appRepeater.itemAt(0);
2001 var otherRect = { x: otherDelegate.windowedX, y: otherDelegate.windowedY, width: otherDelegate.requestedWidth, height: otherDelegate.requestedHeight }
2002 var intersectionRect = MathUtils.intersectionRect(thisRect, otherRect)
2003 var mappedInterSectionRect = appDelegate.mapFromItem(root, intersectionRect.x, intersectionRect.y)
2004 opacityEffect.maskX = mappedInterSectionRect.x
2005 opacityEffect.maskY = mappedInterSectionRect.y
2006 opacityEffect.maskWidth = intersectionRect.width
2007 opacityEffect.maskHeight = intersectionRect.height
2013 from: "stagedRightEdge"; to: "staged"
2014 enabled: rightEdgeDragArea.cancelled // only transition back to state if the gesture was cancelled, in the other cases we play the focusAnimations.
2015 SequentialAnimation {
2017 LomiriNumberAnimation { target: appDelegate; properties: "x,y,height,width,scale"; duration: priv.animationDuration }
2018 LomiriNumberAnimation { target: decoratedWindow; properties: "width,height,itemScale,angle,scaleToPreviewProgress"; duration: priv.animationDuration }
2020 // We need to release scaleToPreviewSize at last
2021 PropertyAction { target: decoratedWindow; property: "scaleToPreviewSize" }
2022 PropertyAction { target: appDelegate; property: "visible" }
2026 from: ",normal,restored,maximized,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedTopRight,maximizedBottomLeft,maximizedBottomRight,maximizedHorizontally,maximizedVertically,fullscreen"
2028 SequentialAnimation {
2029 ScriptAction { script: { fakeRectangle.stop(); } }
2030 PropertyAction { target: appDelegate; property: "visuallyMaximized" }
2031 PropertyAction { target: appDelegate; property: "visuallyMinimized" }
2032 LomiriNumberAnimation { target: appDelegate; properties: "x,y,scale,opacity"; duration: priv.animationDuration }
2033 PropertyAction { target: appDelegate; property: "visuallyMinimized" }
2038 to: ",normal,restored,maximized,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedTopRight,maximizedBottomLeft,maximizedBottomRight,maximizedHorizontally,maximizedVertically,fullscreen"
2039 SequentialAnimation {
2040 PropertyAction { target: appDelegate; property: "visuallyMinimized,z" }
2042 LomiriNumberAnimation { target: appDelegate; properties: "x"; from: -appDelegate.width / 2; duration: priv.animationDuration }
2043 LomiriNumberAnimation { target: appDelegate; properties: "y,opacity"; duration: priv.animationDuration }
2044 LomiriNumberAnimation { target: appDelegate; properties: "scale"; from: 0; duration: priv.animationDuration }
2046 PropertyAction { target: appDelegate; property: "visuallyMaximized" }
2050 id: windowedTransition
2051 from: ",normal,restored,maximized,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedTopRight,maximizedBottomLeft,maximizedBottomRight,maximizedHorizontally,maximizedVertically,fullscreen,minimized"
2052 to: ",normal,restored,maximized,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedTopRight,maximizedBottomLeft,maximizedBottomRight,maximizedHorizontally,maximizedVertically,fullscreen"
2053 enabled: appDelegate.animationsEnabled
2054 SequentialAnimation {
2055 ScriptAction { script: {
2056 if (appDelegate.visuallyMaximized) visuallyMaximized = false; // maximized before -> going to restored
2059 PropertyAction { target: appDelegate; property: "visuallyMinimized" }
2060 LomiriNumberAnimation { target: appDelegate; properties: "requestedX,requestedY,windowedX,windowedY,opacity,scale,requestedWidth,requestedHeight,windowedWidth,windowedHeight";
2061 duration: priv.animationDuration }
2062 ScriptAction { script: {
2063 fakeRectangle.stop();
2064 appDelegate.visuallyMaximized = appDelegate.maximized; // reflect the target state
2073 property: "decorationsAlwaysVisible"
2074 value: appDelegate && appDelegate.maximized && touchControls.overlayShown
2075 restoreMode: Binding.RestoreBinding
2080 objectName: "windowResizeArea"
2082 anchors.fill: appDelegate
2084 // workaround so that it chooses the correct resize borders when you drag from a corner ResizeGrip
2085 anchors.margins: touchControls.overlayShown ? borderThickness/2 : -borderThickness
2088 boundsItem: root.availableDesktopArea
2089 minWidth: units.gu(10)
2090 minHeight: units.gu(10)
2091 borderThickness: units.gu(2)
2094 readyToAssesBounds: !appDelegate._constructing
2097 appDelegate.activate();
2103 objectName: "decoratedWindow"
2104 anchors.left: appDelegate.left
2105 anchors.top: appDelegate.top
2107 application: model.application
2108 surface: model.window.surface
2109 active: model.window.focused
2111 interactive: root.interactive
2113 decorationHeight: priv.windowDecorationHeight
2114 maximizeButtonShown: appDelegate.canBeMaximized
2115 overlayShown: touchControls.overlayShown
2116 width: implicitWidth
2117 height: implicitHeight
2118 highlightSize: windowInfoItem.iconMargin / 2
2119 boundsItem: root.availableDesktopArea
2120 panelState: root.panelState
2121 altDragEnabled: root.mode == "windowed"
2122 lightMode: root.lightMode
2123 clipSurface: root.mode === "windowed"
2125 requestedWidth: appDelegate.requestedWidth
2126 requestedHeight: appDelegate.requestedHeight
2128 onCloseClicked: { appDelegate.close(); }
2129 onMaximizeClicked: {
2130 if (appDelegate.canBeMaximized) {
2131 appDelegate.anyMaximized ? appDelegate.requestRestore() : appDelegate.requestMaximize();
2134 onMaximizeHorizontallyClicked: {
2135 if (appDelegate.canBeMaximizedHorizontally) {
2136 appDelegate.maximizedHorizontally ? appDelegate.requestRestore() : appDelegate.requestMaximizeHorizontally()
2139 onMaximizeVerticallyClicked: {
2140 if (appDelegate.canBeMaximizedVertically) {
2141 appDelegate.maximizedVertically ? appDelegate.requestRestore() : appDelegate.requestMaximizeVertically()
2144 onMinimizeClicked: { appDelegate.requestMinimize(); }
2145 onDecorationPressed: { appDelegate.activate(); }
2146 onDecorationReleased: fakeRectangle.visible ? fakeRectangle.commit() : appDelegate.updateRestoredGeometry()
2148 property real angle: 0
2149 Behavior on angle { enabled: priv.closingIndex >= 0; LomiriNumberAnimation {} }
2150 property real itemScale: 1
2151 Behavior on itemScale { enabled: priv.closingIndex >= 0; LomiriNumberAnimation {} }
2156 origin.y: decoratedWindow.implicitHeight / 2
2157 xScale: decoratedWindow.itemScale
2158 yScale: decoratedWindow.itemScale
2161 origin { x: 0; y: (decoratedWindow.height / 2) }
2162 axis { x: 0; y: 1; z: 0 }
2163 angle: decoratedWindow.angle
2170 anchors.fill: decoratedWindow
2173 WindowControlsOverlay {
2175 anchors.fill: appDelegate
2177 resizeArea: resizeArea
2180 boundsItem: root.availableDesktopArea
2182 onFakeMaximizeAnimationRequested: if (!appDelegate.maximized) fakeRectangle.maximize(amount, true)
2183 onFakeMaximizeLeftAnimationRequested: if (!appDelegate.maximizedLeft) fakeRectangle.maximizeLeft(amount, true)
2184 onFakeMaximizeRightAnimationRequested: if (!appDelegate.maximizedRight) fakeRectangle.maximizeRight(amount, true)
2185 onFakeMaximizeTopLeftAnimationRequested: if (!appDelegate.maximizedTopLeft) fakeRectangle.maximizeTopLeft(amount, true);
2186 onFakeMaximizeTopRightAnimationRequested: if (!appDelegate.maximizedTopRight) fakeRectangle.maximizeTopRight(amount, true);
2187 onFakeMaximizeBottomLeftAnimationRequested: if (!appDelegate.maximizedBottomLeft) fakeRectangle.maximizeBottomLeft(amount, true);
2188 onFakeMaximizeBottomRightAnimationRequested: if (!appDelegate.maximizedBottomRight) fakeRectangle.maximizeBottomRight(amount, true);
2189 onStopFakeAnimation: fakeRectangle.stop();
2190 onDragReleased: fakeRectangle.visible ? fakeRectangle.commit() : appDelegate.updateRestoredGeometry()
2193 WindowedFullscreenPolicy {
2194 id: windowedFullscreenPolicy
2196 StagedFullscreenPolicy {
2197 id: stagedFullscreenPolicy
2198 active: root.mode == "staged" || root.mode == "stagedWithSideStage"
2199 surface: model.window.surface
2202 SpreadDelegateInputArea {
2204 objectName: "dragArea"
2205 anchors.fill: decoratedWindow
2209 dragDelegate: fakeDragItem
2212 spreadItem.highlightedIndex = index;
2213 if (distance == 0) {
2214 priv.goneToSpread = false;
2218 priv.closingIndex = index
2219 appDelegate.close();
2225 objectName: "windowInfoItem"
2226 anchors { left: parent.left; top: decoratedWindow.bottom; topMargin: units.gu(1) }
2227 title: model.application.name
2228 iconSource: model.application.icon
2229 height: spreadItem.appInfoHeight
2232 visible: opacity > 0
2234 var nextApp = appRepeater.itemAt(index + 1);
2236 return Math.max(iconHeight, nextApp.x - appDelegate.x - units.gu(1))
2238 return appDelegate.width;
2242 spreadItem.highlightedIndex = index;
2243 priv.goneToSpread = false;
2249 objectName: "closeMouseArea"
2250 anchors { left: parent.left; top: parent.top; leftMargin: -height / 2; topMargin: -height / 2 + spreadMaths.closeIconOffset }
2251 readonly property var mousePos: hoverMouseArea.mapToItem(appDelegate, hoverMouseArea.mouseX, hoverMouseArea.mouseY)
2252 readonly property bool shown: dragArea.distance == 0
2253 && index == spreadItem.highlightedIndex
2254 && mousePos.y < (decoratedWindow.height / 3)
2255 && mousePos.y > -units.gu(4)
2256 && mousePos.x > -units.gu(4)
2257 && mousePos.x < (decoratedWindow.width * 2 / 3)
2258 opacity: shown ? 1 : 0
2259 visible: opacity > 0
2260 Behavior on opacity { LomiriNumberAnimation { duration: LomiriAnimation.SnapDuration } }
2265 priv.closingIndex = index;
2266 appDelegate.close();
2270 source: "graphics/window-close.svg"
2271 anchors.fill: closeMouseArea
2272 anchors.margins: units.gu(2)
2273 sourceSize.width: width
2274 sourceSize.height: height
2279 // Group all child windows in this item so that we can fade them out together when going to the spread
2280 // (and fade them in back again when returning from it)
2281 readonly property bool stageOnProperState: root.state === "windowed"
2282 || root.state === "staged"
2283 || root.state === "stagedWithSideStage"
2285 // TODO: Is it worth the extra cost of layering to avoid the opacity artifacts of intersecting children?
2286 // Btw, will involve more than uncommenting the line below as children won't necessarily fit this item's
2287 // geometry. This is just a reference.
2288 //layer.enabled: opacity !== 0.0 && opacity !== 1.0
2290 opacity: stageOnProperState ? 1.0 : 0.0
2291 visible: opacity !== 0.0 // make it transparent to input as well
2292 Behavior on opacity { LomiriNumberAnimation {} }
2295 id: childWindowRepeater
2296 model: appDelegate.surface ? appDelegate.surface.childSurfaceList : null
2298 delegate: ChildWindowTree {
2299 surface: model.surface
2301 // Account for the displacement caused by window decoration in the top-level surface
2302 // Ie, the top-level surface is not positioned at (0,0) of this ChildWindow's parent (appDelegate)
2303 displacementX: appDelegate.clientAreaItem.x
2304 displacementY: appDelegate.clientAreaItem.y
2306 boundsItem: root.availableDesktopArea
2307 decorationHeight: priv.windowDecorationHeight
2309 z: childWindowRepeater.count - model.index
2313 // some child surface in this tree got focus.
2314 // Ensure we also have it at the top-level hierarchy
2315 appDelegate.claimFocus();
2325 FakeMaximizeDelegate {
2327 target: priv.focusedAppDelegate
2328 leftMargin: root.availableDesktopArea.x
2329 appContainerWidth: appContainer.width
2330 appContainerHeight: appContainer.height
2331 panelState: root.panelState
2335 id: workspaceSwitcher
2336 enabled: workspaceEnabled
2337 anchors.centerIn: parent
2338 height: units.gu(20)
2339 width: root.width - units.gu(8)
2340 background: root.background
2341 availableDesktopArea: root.availableDesktopArea
2344 appContainer.focus = true;
2350 id: shortRightEdgeSwipeAnimation
2353 duration: priv.animationDuration
2357 id: rightEdgeDragArea
2358 objectName: "rightEdgeDragArea"
2359 direction: Direction.Leftwards
2360 anchors { top: parent.top; right: parent.right; bottom: parent.bottom }
2361 width: root.dragAreaWidth
2362 enabled: root.spreadEnabled
2364 property var gesturePoints: []
2365 property bool cancelled: false
2367 property real progress: -touchPosition.x / root.width
2368 onProgressChanged: {
2370 draggedProgress = progress;
2374 property real draggedProgress: 0
2376 onTouchPositionChanged: {
2377 gesturePoints.push(touchPosition.x);
2378 if (gesturePoints.length > 10) {
2379 gesturePoints.splice(0, gesturePoints.length - 10)
2383 onDraggingChanged: {
2385 // A potential edge-drag gesture has started. Start recording it
2388 draggedProgress = 0;
2390 // Ok. The user released. Did he drag far enough to go to full spread?
2391 if (gesturePoints[gesturePoints.length - 1] < -spreadItem.rightEdgeBreakPoint * spreadItem.width ) {
2393 // He dragged far enough, but if the last movement was a flick to the right again, he wants to cancel the spread again.
2394 var oneWayFlickToRight = true;
2395 var smallestX = gesturePoints[0]-1;
2396 for (var i = 0; i < gesturePoints.length; i++) {
2397 if (gesturePoints[i] <= smallestX) {
2398 oneWayFlickToRight = false;
2401 smallestX = gesturePoints[i];
2404 if (!oneWayFlickToRight) {
2405 // Ok, the user made it, let's go to spread!
2406 priv.goneToSpread = true;
2411 // Ok, the user didn't drag far enough to cross the breakPoint
2412 // Find out if it was a one-way movement to the left, in which case we just switch directly to next app.
2413 var oneWayFlick = true;
2414 var smallestX = rightEdgeDragArea.width;
2415 for (var i = 0; i < gesturePoints.length; i++) {
2416 if (gesturePoints[i] >= smallestX) {
2417 oneWayFlick = false;
2420 smallestX = gesturePoints[i];
2423 if (appRepeater.count > 1 &&
2424 (oneWayFlick && rightEdgeDragArea.distance > units.gu(2) || rightEdgeDragArea.distance > spreadItem.rightEdgeBreakPoint * spreadItem.width)) {
2425 var nextStage = appRepeater.itemAt(priv.nextInStack).stage
2426 for (var i = 0; i < appRepeater.count; i++) {
2427 if (i != priv.nextInStack && appRepeater.itemAt(i).stage == nextStage) {
2428 appRepeater.itemAt(i).playHidingAnimation()
2432 appRepeater.itemAt(priv.nextInStack).playFocusAnimation()
2433 if (appRepeater.itemAt(priv.nextInStack).stage == ApplicationInfoInterface.SideStage && !sideStage.shown) {
2446 GestureAreaSizeHint {
2447 anchors.fill: parent
2451 TabletSideStageTouchGesture {
2453 objectName: "triGestureArea"
2454 anchors.fill: parent
2456 property Item appDelegate
2458 dragComponent: dragComponent
2459 dragComponentProperties: { "appDelegate": appDelegate }
2462 function matchDelegate(obj) { return String(obj.objectName).indexOf("appDelegate") >= 0; }
2464 var delegateAtCenter = Functions.itemAt(appContainer, x, y, matchDelegate);
2465 if (!delegateAtCenter) return;
2467 appDelegate = delegateAtCenter;
2471 priv.toggleSideStage()
2475 // If we're dragging to the sidestage.
2476 if (!sideStage.shown) {
2482 // Hide side stage if the app drag was cancelled
2483 if (!priv.sideStageDelegate) {
2491 property Item appDelegate
2493 surface: appDelegate ? appDelegate.surface : null
2495 consumesInput: false
2498 requestedWidth: appDelegate ? appDelegate.requestedWidth : 0
2499 requestedHeight: appDelegate ? appDelegate.requestedHeight : 0
2502 height: units.gu(40)
2504 Drag.hotSpot.x: width/2
2505 Drag.hotSpot.y: height/2
2506 // only accept opposite stage.
2508 if (!surface) return "Disabled";
2510 if (appDelegate.stage === ApplicationInfo.MainStage) {
2511 if (appDelegate.application.supportedOrientations
2512 & (Qt.PortraitOrientation|Qt.InvertedPortraitOrientation)) {