@@ -49,20 +49,22 @@ FocusScope {
4949 readonly property real panelHeight: panel.panelHeight
5050
5151 property bool dashShown: dash.shown
52− property bool stageScreenshotsReady: {
53− if (sideStage.shown) {
54− if (mainStage.applications.count > 0) {
55− return mainStage.usingScreenshots && sideStage.usingScreenshots;
56− } else {
57− return sideStage.usingScreenshots;
58− }
52+
53+ function activateApplication(appId) {
54+ if (ApplicationManager.findApplication(appId)) {
55+ print("Shell.qml: activating app", appId);
56+ ApplicationManager.activateApplication(appId);
5957 } else {
60− return mainStage.usingScreenshots;
58+ print("starting app", appId);
59+
60+ // FIXME:
61+// var execFlags = sideStageEnabled ? ApplicationManager.NoFlag : ApplicationManager.ForceMainStage;
62+ var execFlags = ApplicationManager.ForceMainStage;
63+
64+ ApplicationManager.startApplication(appId, execFlags);
6165 }
6266 }
6367
64− property var applicationManager: ApplicationManagerWrapper {}
65−
6668 Binding {
6769 target: LauncherModel
6870 property: "applicationManager"
@@ -71,49 +73,6 @@ FocusScope {
7173
7274 Component.onCompleted: {
7375 Theme.name = "Ubuntu.Components.Themes.SuruGradient"
74−
75− applicationManager.sideStageEnabled = Qt.binding(function() { return sideStage.enabled })
76−
77− // FIXME: if application focused before shell starts, shell draws on top of it only.
78− // We should detect already running applications on shell start and bring them to the front.
79− applicationManager.unfocusCurrentApplication();
80− }
81−
82− readonly property bool applicationFocused: !!applicationManager.mainStageFocusedApplication
83− || !!applicationManager.sideStageFocusedApplication
84− // Used for autopilot testing.
85− readonly property string currentFocusedAppId: ApplicationManager.focusedApplicationId
86−
87− readonly property bool fullscreenMode: {
88− if (greeter.shown || lockscreen.shown) {
89− return false;
90− } else if (mainStage.usingScreenshots) { // Window Manager animating so want to re-evaluate fullscreen mode
91− return mainStage.switchingFromFullscreenToFullscreen;
92− } else if (applicationManager.mainStageFocusedApplication) {
93− return applicationManager.mainStageFocusedApplication.fullscreen;
94− } else {
95− return false;
96− }
97− }
98−
99− function activateApplication(appId, argument) {
100− if (applicationManager) {
101− // For newly started applications, as it takes them time to draw their first frame
102− // we add a delay before we hide the animation screenshots to compensate.
103− var addDelay = !applicationManager.getApplicationFromDesktopFile(appId);
104−
105− var application;
106− application = applicationManager.activateApplication(appId, argument);
107− if (application == null) {
108− return;
109− }
110− if (application.stage == ApplicationInfo.MainStage || !sideStage.enabled) {
111− mainStage.activateApplication(appId, addDelay);
112− } else {
113− sideStage.activateApplication(appId, addDelay);
114− }
115− stages.show();
116− }
11776 }
11877
11978 GSettings {
@@ -161,19 +120,18 @@ FocusScope {
161120 // Whether the underlay is fully covered by opaque UI elements.
162121 property bool fullyCovered: panel.indicators.fullyOpened && shell.width <= panel.indicatorsMenuWidth
163122
164− readonly property bool applicationRunning: ((mainStage.applications && mainStage.applications.count > 0)
165− || (sideStage.applications && sideStage.applications.count > 0))
123+ readonly property bool applicationRunning: ApplicationManager.focusedApplicationId.length > 0
166124
167125 // Whether the user should see the topmost application surface (if there's one at all).
168− readonly property bool applicationSurfaceShouldBeSeen: applicationRunning && !stages.fullyHidden
169− && !mainStage.usingScreenshots // but want sideStage animating over app surface
170−
171−
126+ readonly property bool applicationSurfaceShouldBeSeen: applicationRunning && !stages.painting
172127
173128 // NB! Application surfaces are stacked behing the shell one. So they can only be seen by the user
174129 // through the translucent parts of the shell surface.
175130 visible: !fullyCovered && !applicationSurfaceShouldBeSeen
176131
132+ onVisibleChanged: print("hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", visible, fullyCovered, applicationSurfaceShouldBeSeen,
133+ applicationRunning, stages.fullyHidden, stages.usingScreenshots)
134+
177135 CrossFadeImage {
178136 id: backgroundImage
179137 objectName: "backgroundImage"
@@ -197,12 +155,6 @@ FocusScope {
197155 hides: [stages, launcher, panel.indicators]
198156 shown: disappearingAnimationProgress !== 1.0
199157 enabled: disappearingAnimationProgress === 0.0 && edgeDemo.dashEnabled
200− // FIXME: unfocus all applications when going back to the dash
201− onEnabledChanged: {
202− if (enabled) {
203− shell.applicationManager.unfocusCurrentApplication()
204− }
205− }
206158
207159 anchors {
208160 fill: parent
@@ -233,8 +185,7 @@ FocusScope {
233185 x: launcher.progress
234186 Behavior on x {SmoothedAnimation{velocity: 600}}
235187
236− property real showProgress:
237− MathUtils.clamp(1 - (x + stages.x) / shell.width, 0, 1)
188+ property real showProgress: MathUtils.clamp(1 - (x + stages.x) / shell.width, 0, 1)
238189
239190 Showable {
240191 id: stages
@@ -244,6 +195,9 @@ FocusScope {
244195
245196 property bool fullyShown: shown && x == 0 && parent.x == 0
246197 property bool fullyHidden: !shown && x == width
198+
199+ property bool painting: applicationsDisplayLoader.item ? applicationsDisplayLoader.item.painting : false
200+
247201 available: !greeter.shown
248202 hides: [panel.indicators]
249203 shown: false
@@ -254,145 +208,50 @@ FocusScope {
254208 width: parent.width
255209 height: parent.height
256210
257− // close the stages when no focused application remains
258− Connections {
259− target: shell.applicationManager
260− onMainStageFocusedApplicationChanged: stages.closeIfNoApplications()
261− onSideStageFocusedApplicationChanged: stages.closeIfNoApplications()
262− ignoreUnknownSignals: true
211+ onShownChanged: {
212+ print("stages shown", shown)
213+ if (!shown) {
214+ ApplicationManager.unfocusCurrentApplication();
215+ }
263216 }
264217
265− function closeIfNoApplications() {
266− if (!shell.applicationManager.mainStageFocusedApplication
267− && !shell.applicationManager.sideStageFocusedApplication
268− && shell.applicationManager.mainStageApplications.count == 0
269− && shell.applicationManager.sideStageApplications.count == 0) {
270− stages.hide();
271− }
218+ onFullyShownChanged: {
219+ print("kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk", fullyShown)
272220 }
273221
274− // show the stages when an application gets the focus
275222 Connections {
276− target: shell.applicationManager
277− onMainStageFocusedApplicationChanged: {
278− if (shell.applicationManager.mainStageFocusedApplication) {
279− mainStage.show();
223+ target: ApplicationManager
224+ onFocusedApplicationIdChanged: {
225+ if (ApplicationManager.focusedApplicationId.length > 0) {
226+ print("should show stages")
280227 stages.show();
281228 }
282229 }
283− onSideStageFocusedApplicationChanged: {
284− if (shell.applicationManager.sideStageFocusedApplication) {
285− sideStage.show();
286− stages.show();
287− }
288− }
289− ignoreUnknownSignals: true
290− }
291230
292− Stage {
293− id: mainStage
294−
295− anchors.fill: parent
296− fullyShown: stages.fullyShown
297− fullyHidden: stages.fullyHidden
298− shouldUseScreenshots: !fullyShown
299− rightEdgeEnabled: !sideStage.enabled
300−
301− applicationManager: shell.applicationManager
302− rightEdgeDraggingAreaWidth: shell.edgeSize
303− normalApplicationY: shell.panelHeight
304−
305− shown: true
306− function show() {
231+ onApplicationAdded: {
307232 stages.show();
308233 }
309− function hide() {
310− }
311−
312− // FIXME: workaround the fact that focusing a main stage application
313− // raises its surface on top of all other surfaces including the ones
314− // that belong to side stage applications.
315− onFocusedApplicationChanged: {
316− if (focusedApplication && sideStage.focusedApplication && sideStage.fullyShown) {
317− shell.applicationManager.focusApplication(sideStage.focusedApplication);
318− }
319− }
320234 }
321235
322− SideStage {
323− id: sideStage
236+ Loader {
237+ id: applicationsDisplayLoader
238+ anchors.fill: parent
239+
240+// source: "Stages/StageWithSideStage.qml"
241+ source: "Stages/PhoneStage.qml"
324242
325− applicationManager: shell.applicationManager
326− rightEdgeDraggingAreaWidth: shell.edgeSize
327− normalApplicationY: shell.panelHeight
243+// Rectangle { anchors.fill: parent; color: "blue"; opacity: .5 }
328244
329− onShownChanged: {
330− if (!shown && mainStage.applications.count == 0) {
331− stages.hide();
332− }
245+ Binding {
246+ target: applicationsDisplayLoader.item
247+ property: "moving"
248+ value: !stages.fullyShown
333249 }
334− // FIXME: when hiding the side stage, refocus the main stage
335− // application so that it goes in front of the side stage
336− // application and hides it
337− onFullyShownChanged: {
338− if (!fullyShown && stages.fullyShown && sideStage.focusedApplication != null) {
339− shell.applicationManager.focusApplication(mainStage.focusedApplication);
340− }
250+ Binding {
251+ target: applicationsDisplayLoader.item
252+ property: "shown"
253+ value: stages.shown
341254 }
342−
343− enabled: shell.width >= units.gu(60)
344− visible: enabled
345− fullyShown: stages.fullyShown && shown
346− && sideStage[sideStageRevealer.boundProperty] == sideStageRevealer.openedValue
347− shouldUseScreenshots: !fullyShown || mainStage.usingScreenshots || sideStageRevealer.pressed
348−
349− available: !greeter.shown && !lockscreen.shown && enabled
350− hides: [launcher, panel.indicators]
351− shown: false
352− showAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.openedValue; easing.type: Easing.OutQuint }
353− hideAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.closedValue; easing.type: Easing.OutQuint }
354−
355− width: units.gu(40)
356− height: stages.height
357− handleExpanded: sideStageRevealer.pressed
358− }
359−
360− Revealer {
361− id: sideStageRevealer
362−
363− enabled: mainStage.applications.count > 0 && sideStage.applications.count > 0
364− && sideStage.available
365− direction: Qt.RightToLeft
366− openedValue: parent.width - sideStage.width
367− hintDisplacement: units.gu(3)
368− /* The size of the sidestage handle needs to be bigger than the
369− typical size used for edge detection otherwise it is really
370− hard to grab.
371− */
372− handleSize: sideStage.shown ? units.gu(4) : shell.edgeSize
373− closedValue: parent.width + sideStage.handleSizeCollapsed
374− target: sideStage
375− x: parent.width - width
376− width: sideStage.width + handleSize * 0.7
377− height: sideStage.height
378− orientation: Qt.Horizontal
379− }
380−
381− DragHandle {
382− id: stagesDragHandle
383−
384− anchors.top: parent.top
385− anchors.bottom: parent.bottom
386− anchors.right: parent.left
387−
388− width: shell.edgeSize
389− direction: Direction.Leftwards
390− enabled: greeter.showProgress == 0 && edgeDemo.dashEnabled
391− property bool haveApps: mainStage.applications.count > 0 || sideStage.applications.count > 0
392−
393− maxTotalDragDistance: haveApps ? parent.width : parent.width * 0.7
394− // Make autocompletion impossible when !haveApps
395− edgeDragEvaluator.minDragDistance: haveApps ? maxTotalDragDistance * 0.1 : Number.MAX_VALUE
396255 }
397256 }
398257 }
@@ -472,23 +331,6 @@ FocusScope {
472331 property var previousMainApp: null
473332 property var previousSideApp: null
474333
475− function removeApplicationFocus() {
476− greeter.previousMainApp = applicationManager.mainStageFocusedApplication;
477− greeter.previousSideApp = applicationManager.sideStageFocusedApplication;
478− applicationManager.unfocusCurrentApplication();
479− }
480−
481− function restoreApplicationFocus() {
482− if (greeter.previousMainApp) {
483− applicationManager.focusApplication(greeter.previousMainApp);
484− greeter.previousMainApp = null;
485− }
486− if (greeter.previousSideApp) {
487− applicationManager.focusApplication(greeter.previousSideApp);
488− greeter.previousSideApp = null;
489− }
490− }
491−
492334 onShownChanged: {
493335 if (shown) {
494336 lockscreen.reset();
@@ -499,9 +341,6 @@ FocusScope {
499341 greeter.selected(0);
500342 }
501343 greeter.forceActiveFocus();
502− removeApplicationFocus();
503− } else {
504− restoreApplicationFocus();
505344 }
506345 }
507346
@@ -518,34 +357,11 @@ FocusScope {
518357 launcher.tease();
519358 }
520359 }
521−
522− Connections {
523− target: applicationManager
524− ignoreUnknownSignals: true
525− // If any app is focused when greeter is open, it's due to a user action
526− // like a snap decision (say, an incoming call).
527− // TODO: these should be protected to only unlock for certain applications / certain usecases
528− // potentially only in connection with a notification.
529− onMainStageFocusedApplicationChanged: {
530− if (greeter.shown && applicationManager.mainStageFocusedApplication) {
531− greeter.previousMainApp = null // make way for new focused app
532− greeter.previousSideApp = null
533− greeter.hide()
534− }
535− }
536− onSideStageFocusedApplicationChanged: {
537− if (greeter.shown && applicationManager.sideStageFocusedApplication) {
538− greeter.previousMainApp = null // make way for new focused app
539− greeter.previousSideApp = null
540− greeter.hide()
541− }
542− }
543− }
544360 }
545361
546362 InputFilterArea {
547363 anchors.fill: parent
548− blockInput: !applicationFocused || greeter.shown || lockscreen.shown || launcher.shown
364+ blockInput: ApplicationManager.focusedApplicationId.length === 0 || greeter.shown || lockscreen.shown || launcher.shown
549365 || panel.indicators.shown || hud.shown
550366 }
551367
@@ -590,7 +406,9 @@ FocusScope {
590406 available: edgeDemo.panelEnabled
591407 contentEnabled: edgeDemo.panelContentEnabled
592408 }
593− fullscreenMode: shell.fullscreenMode
409+ property string focusedAppId: ApplicationManager.focusedApplicationId
410+ property var focusedApplication: ApplicationManager.findApplication(focusedAppId)
411+ fullscreenMode: focusedApplication && focusedApplication.fullscreen
594412 searchVisible: !greeter.shown && !lockscreen.shown && dash.shown
595413
596414 InputFilterArea {
@@ -616,9 +434,8 @@ FocusScope {
616434 hideAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: hudRevealer.closedValue; easing.type: Easing.Linear }
617435
618436 Connections {
619− target: shell.applicationManager
620− onMainStageFocusedApplicationChanged: hud.hide()
621− onSideStageFocusedApplicationChanged: hud.hide()
437+ target: ApplicationManager
438+ onFocusedApplicationIdChanged: hud.hide()
622439 }
623440 }
624441
@@ -643,7 +460,7 @@ FocusScope {
643460 theHud: hud
644461 anchors.fill: parent
645462 enabled: hud.available
646− applicationIsOnForeground: applicationFocused
463+ applicationIsOnForeground: ApplicationManager.focusedApplicationId
647464 }
648465
649466 InputFilterArea {
@@ -667,7 +484,12 @@ FocusScope {
667484 dragAreaWidth: shell.edgeSize
668485 available: (!greeter.shown || greeter.narrowMode) && edgeDemo.launcherEnabled
669486
670− onDashItemSelected: showHome()
487+ onDashItemSelected: {
488+ if (edgeDemo.running)
489+ return;
490+
491+ showHome()
492+ }
671493 onDash: {
672494 if (stages.shown) {
673495 stages.hide();
@@ -676,6 +498,9 @@ FocusScope {
676498 }
677499 onDashSwipeChanged: if (dashSwipe && stages.shown) dash.setCurrentScope("applications.scope", false, true)
678500 onLauncherApplicationSelected:{
501+ if (edgeDemo.running)
502+ return;
503+
679504 greeter.hide()
680505 shell.activateApplication(appId)
681506 }
@@ -761,14 +586,14 @@ FocusScope {
761586 anchors.bottom: parent.bottom
762587 anchors.left: parent.left
763588 anchors.right: parent.right
764− height: shell.applicationManager ? shell.applicationManager.keyboardHeight : 0
589+ height: ApplicationManager.keyboardVisible ? ApplicationManager.keyboardHeight : 0
765590
766− enabled: shell.applicationManager && shell.applicationManager.keyboardVisible
591+ enabled: ApplicationManager.keyboardVisible
767592 }
768593
769594 Label {
770595 anchors.centerIn: parent
771− visible: applicationManager.fake
596+ visible: ApplicationManager.fake ? ApplicationManager.fake : false
772597 text: "EARLY ALPHA\nNOT READY FOR USE"
773598 color: "lightgrey"
774599 opacity: 0.2