2 * Copyright (C) 2013-2016 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18import QtQuick.Window 2.2
19import AccountsService 0.1
20import Unity.Application 0.1
21import Ubuntu.Components 1.3
22import Ubuntu.Components.Popups 1.3
23import Ubuntu.Gestures 0.1
24import Ubuntu.Telephony 0.1 as Telephony
25import Unity.Connectivity 0.1
26import Unity.Launcher 0.1
27import GlobalShortcut 1.0 // has to be before Utils, because of WindowInputFilter
32import SessionBroadcast 0.1
41import Unity.Notifications 1.0 as NotificationBackend
42import Unity.Session 0.1
43import Unity.Indicators 0.1 as Indicators
45import WindowManager 1.0
51 theme.name: "Ubuntu.Components.Themes.SuruDark"
53 // to be set from outside
54 property int orientationAngle: 0
55 property int orientation
56 property Orientations orientations
57 property real nativeWidth
58 property real nativeHeight
59 property alias panelAreaShowProgress: panel.panelAreaShowProgress
60 property string usageScenario: "phone" // supported values: "phone", "tablet" or "desktop"
61 property string mode: "full-greeter"
62 property alias oskEnabled: inputMethod.enabled
63 function updateFocusedAppOrientation() {
64 stage.updateFocusedAppOrientation();
66 function updateFocusedAppOrientationAnimated() {
67 stage.updateFocusedAppOrientationAnimated();
69 property bool hasMouse: false
70 property bool hasKeyboard: false
71 property bool hasTouchscreen: false
73 // to be read from outside
74 readonly property int mainAppWindowOrientationAngle: stage.mainAppWindowOrientationAngle
76 readonly property bool orientationChangesEnabled: panel.indicators.fullyClosed
77 && stage.orientationChangesEnabled
78 && (!greeter || !greeter.animating)
80 readonly property bool showingGreeter: greeter && greeter.shown
82 property bool startingUp: true
83 Timer { id: finishStartUpTimer; interval: 500; onTriggered: startingUp = false }
85 property int supportedOrientations: {
87 // Ensure we don't rotate during start up
88 return Qt.PrimaryOrientation;
89 } else if (showingGreeter || notifications.topmostIsFullscreen) {
90 return Qt.PrimaryOrientation;
92 return shell.orientations.map(stage.supportedOrientations);
96 readonly property var mainApp: stage.mainApp
99 _onMainAppChanged((mainApp ? mainApp.appId : ""));
102 target: ApplicationManager
104 if (shell.mainApp && shell.mainApp.appId === appId) {
105 _onMainAppChanged(appId);
110 // Calls attention back to the most important thing that's been focused
111 // (ex: phone calls go over Wizard, app focuses go over indicators, greeter
112 // goes over everything if it is locked)
113 // Must be called whenever app focus changes occur, even if the focus change
114 // is "nothing is focused". In that case, call with appId = ""
115 function _onMainAppChanged(appId) {
119 // If this happens on first boot, we may be in the
120 // wizard while receiving a call. A call is more
121 // important than the wizard so just bail out of it.
125 if (appId === "dialer-app" && callManager.hasCalls && greeter.locked) {
126 // If we are in the middle of a call, make dialer lockedApp. The
127 // Greeter will show it when it's notified of the focus.
128 // This can happen if user backs out of dialer back to greeter, then
129 // launches dialer again.
130 greeter.lockedApp = appId;
133 panel.indicators.hide();
134 launcher.hide(launcher.ignoreHideIfMouseOverLauncher);
135 } else if (topLevelSurfaceList.count === 0 && !greeter.active && !wizard.active) {
136 // Show the Launcher when there are no apps running
141 // *Always* make sure the greeter knows that the focused app changed
142 if (greeter) greeter.notifyAppFocusRequested(appId);
145 // For autopilot consumption
146 readonly property string focusedApplicationId: ApplicationManager.focusedApplicationId
148 // Note when greeter is waiting on PAM, so that we can disable edges until
149 // we know which user data to show and whether the session is locked.
150 readonly property bool waitingOnGreeter: greeter && greeter.waiting
152 property real edgeSize: units.gu(settings.edgeDragWidth)
155 id: wallpaperResolver
156 objectName: "wallpaperResolver"
158 readonly property url defaultBackground: "file://" + Constants.defaultWallpaper
159 readonly property bool hasCustomBackground: background != defaultBackground
161 // Use a cached version of the scaled-down wallpaper (as sometimes the
162 // image can be quite big compared to the device size, including for
163 // our default wallpaper). We use a name=wallpaper argument here to
164 // make sure we don't litter our cache with lots of scaled images. We
165 // only need to bother caching one at a time.
166 readonly property url cachedBackground: background.toString().indexOf("file:///") === 0 ? "image://unity8imagecache/" + background + "?name=wallpaper" : background
169 id: backgroundSettings
170 schema.id: "org.gnome.desktop.background"
174 AccountsService.backgroundFile,
175 backgroundSettings.pictureUri,
180 readonly property alias greeter: greeterLoader.item
182 function activateApplication(appId) {
183 topLevelSurfaceList.pendingActivation();
185 // Either open the app in our own session, or -- if we're acting as a
186 // greeter -- ask the user's session to open it for us.
187 if (shell.mode === "greeter") {
188 activateURL("application:///" + appId + ".desktop");
195 function activateURL(url) {
196 SessionBroadcast.requestUrlStart(AccountsService.user, url);
197 greeter.notifyUserRequestedApp();
198 panel.indicators.hide();
201 function startApp(appId) {
202 if (ApplicationManager.findApplication(appId)) {
203 ApplicationManager.requestFocusApplication(appId);
205 ApplicationManager.startApplication(appId);
209 function startLockedApp(app) {
210 if (greeter.locked) {
211 greeter.lockedApp = app;
213 startApp(app); // locked apps are always in our same session
217 target: LauncherModel
218 property: "applicationManager"
219 value: ApplicationManager
222 Component.onCompleted: {
223 finishStartUpTimer.start();
231 id: physicalKeysMapper
232 objectName: "physicalKeysMapper"
234 onPowerKeyLongPressed: dialogs.showPowerDialog();
235 onVolumeDownTriggered: volumeControl.volumeDown();
236 onVolumeUpTriggered: volumeControl.volumeUp();
237 onScreenshotTriggered: itemGrabber.capture(shell);
241 // dummy shortcut to force creation of GlobalShortcutRegistry before WindowInputFilter
246 Keys.onPressed: physicalKeysMapper.onKeyPressed(event, lastInputTimestamp);
247 Keys.onReleased: physicalKeysMapper.onKeyReleased(event, lastInputTimestamp);
251 objectName: "windowInputMonitor"
252 onHomeKeyActivated: {
253 // Ignore when greeter is active, to avoid pocket presses
254 if (!greeter.active) {
255 launcher.toggleDrawer(false);
258 onTouchBegun: { cursor.opacity = 0; }
260 // move the (hidden) cursor to the last known touch position
261 var mappedCoords = mapFromItem(null, pos.x, pos.y);
262 cursor.x = mappedCoords.x;
263 cursor.y = mappedCoords.y;
264 cursor.mouseNeverMoved = false;
268 AvailableDesktopArea {
269 id: availableDesktopAreaItem
271 anchors.topMargin: panel.fullscreenMode ? 0 : panel.minimizedPanelHeight
272 anchors.leftMargin: launcher.lockedVisible ? launcher.panelWidth : 0
277 schema.id: "com.canonical.Unity8"
284 height: parent.height
288 objectName: "surfaceManager"
290 TopLevelWindowModel {
291 id: topLevelSurfaceList
292 objectName: "topLevelSurfaceList"
293 applicationManager: ApplicationManager // it's a singleton
294 surfaceManager: surfaceMan
303 dragAreaWidth: shell.edgeSize
304 background: wallpaperResolver.background
306 applicationManager: ApplicationManager
307 topLevelSurfaceList: topLevelSurfaceList
308 inputMethodRect: inputMethod.visibleRect
309 rightEdgePushProgress: rightEdgeBarrier.progress
310 availableDesktopArea: availableDesktopAreaItem
312 property string usageScenario: shell.usageScenario === "phone" || greeter.hasLockedApp
314 : shell.usageScenario
316 mode: usageScenario == "phone" ? "staged"
317 : usageScenario == "tablet" ? "stagedWithSideStage"
320 shellOrientation: shell.orientation
321 shellOrientationAngle: shell.orientationAngle
322 orientations: shell.orientations
323 nativeWidth: shell.nativeWidth
324 nativeHeight: shell.nativeHeight
326 interactive: (!greeter || !greeter.shown)
327 && panel.indicators.fullyClosed
328 && !notifications.useModal
329 && !launcher.takesFocus
331 suspended: greeter.shown
332 altTabPressed: physicalKeysMapper.altTabPressed
333 oskEnabled: shell.oskEnabled
334 spreadEnabled: tutorial.spreadEnabled && (!greeter || (!greeter.hasLockedApp && !greeter.shown))
336 onSpreadShownChanged: {
337 panel.indicators.hide();
338 panel.applicationMenus.hide();
345 minimumTouchPoints: 4
346 maximumTouchPoints: minimumTouchPoints
348 readonly property bool recognisedPress: status == TouchGestureArea.Recognized &&
349 touchPoints.length >= minimumTouchPoints &&
350 touchPoints.length <= maximumTouchPoints
351 property bool wasPressed: false
353 onRecognisedPressChanged: {
354 if (recognisedPress) {
360 if (status !== TouchGestureArea.Recognized) {
361 if (status === TouchGestureArea.WaitingForTouch) {
362 if (wasPressed && !dragging) {
363 launcher.toggleDrawer(true);
374 objectName: "inputMethod"
375 surface: topLevelSurfaceList.inputMethodSurface
378 topMargin: panel.panelHeight
379 leftMargin: launcher.lockedVisible ? launcher.panelWidth : 0
381 z: notifications.useModal || panel.indicators.shown || wizard.active || tutorial.running || launcher.drawerShown ? overlay.z + 1 : overlay.z - 1
386 objectName: "greeterLoader"
388 anchors.topMargin: panel.panelHeight
389 sourceComponent: shell.mode != "shell" ? integratedGreeter :
390 Qt.createComponent(Qt.resolvedUrl("Greeter/ShimGreeter.qml"));
392 item.objectName = "greeter"
394 property bool toggleDrawerAfterUnlock: false
401 // Show drawer in case showHome() requests it
402 if (greeterLoader.toggleDrawerAfterUnlock) {
403 launcher.toggleDrawer(false);
404 greeterLoader.toggleDrawerAfterUnlock = false;
406 // Show the launcher when there are no running apps
407 else if (topLevelSurfaceList.count < 1) {
408 launcher.switchToNextState("visible")
415 id: integratedGreeter
418 enabled: panel.indicators.fullyClosed // hides OSK when panel is open
419 hides: [launcher, panel.indicators, panel.applicationMenus]
420 tabletMode: shell.usageScenario != "phone"
421 forcedUnlock: wizard.active || shell.mode === "full-shell"
422 background: wallpaperResolver.cachedBackground
423 hasCustomBackground: wallpaperResolver.hasCustomBackground
424 allowFingerprint: !dialogs.hasActiveDialog &&
425 !notifications.topmostIsFullscreen &&
426 !panel.indicators.shown
428 // avoid overlapping with Launcher's edge drag area
429 // FIXME: Fix TouchRegistry & friends and remove this workaround
430 // Issue involves launcher's DDA getting disabled on a long
432 dragHandleLeftMargin: launcher.available ? launcher.dragAreaWidth + 1 : 0
439 if (!tutorial.running) {
444 onEmergencyCall: startLockedApp("dialer-app")
449 // See powerConnection for why this is useful
450 id: showGreeterDelayed
453 // Go through the dbus service, because it has checks for whether
454 // we are even allowed to lock or not.
455 DBusUnitySessionService.PromptLock();
464 if (greeter.locked && callManager.hasCalls && greeter.lockedApp !== "dialer-app") {
465 // We just received an incoming call while locked. The
466 // indicator will have already launched dialer-app for us, but
467 // there is a race between "hasCalls" changing and the dialer
468 // starting up. So in case we lose that race, we'll start/
469 // focus the dialer ourselves here too. Even if the indicator
470 // didn't launch the dialer for some reason (or maybe a call
471 // started via some other means), if an active call is
472 // happening, we want to be in the dialer.
473 startLockedApp("dialer-app")
483 if (Powerd.status === Powerd.Off && reason !== Powerd.Proximity &&
484 !callManager.hasCalls && !wizard.active) {
485 // We don't want to simply call greeter.showNow() here, because
486 // that will take too long. Qt will delay button event
487 // handling until the greeter is done loading and may think the
488 // user held down the power button the whole time, leading to a
489 // power dialog being shown. Instead, delay showing the
490 // greeter until we've finished handling the event. We could
491 // make the greeter load asynchronously instead, but that
492 // introduces a whole host of timing issues, especially with
493 // its animations. So this is simpler.
494 showGreeterDelayed.start();
499 function showHome() {
500 greeter.notifyUserRequestedApp();
502 if (shell.mode === "greeter") {
503 SessionBroadcast.requestHomeShown(AccountsService.user);
505 if (!greeter.active) {
506 launcher.toggleDrawer(false);
508 greeterLoader.toggleDrawerAfterUnlock = true;
522 anchors.fill: parent //because this draws indicator menus
524 mode: shell.usageScenario == "desktop" ? "windowed" : "staged"
525 minimizedPanelHeight: units.gu(3)
526 expandedPanelHeight: units.gu(7)
527 indicatorMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
528 applicationMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
529 applicationMenuContentX: launcher.lockedVisible ? launcher.panelWidth : 0
533 available: tutorial.panelEnabled
534 && ((!greeter || !greeter.locked) || AccountsService.enableIndicatorsWhileLocked)
535 && (!greeter || !greeter.hasLockedApp)
536 && !shell.waitingOnGreeter
537 && settings.enableIndicatorMenu
539 model: Indicators.IndicatorsModel {
540 // tablet and phone both use the same profile
541 // FIXME: use just "phone" for greeter too, but first fix
542 // greeter app launching to either load the app inside the
543 // greeter or tell the session to load the app. This will
544 // involve taking the url-dispatcher dbus name and using
545 // SessionBroadcast to tell the session.
546 profile: shell.mode === "greeter" ? "desktop_greeter" : "phone"
547 Component.onCompleted: load();
553 available: (!greeter || !greeter.shown)
554 && !shell.waitingOnGreeter
555 && !stage.spreadShown
558 readonly property bool focusedSurfaceIsFullscreen: topLevelSurfaceList.focusedWindow
559 ? topLevelSurfaceList.focusedWindow.state == Mir.FullscreenState
561 fullscreenMode: (focusedSurfaceIsFullscreen && !LightDMService.greeter.active && launcher.progress == 0 && !stage.spreadShown)
562 || greeter.hasLockedApp
563 greeterShown: greeter && greeter.shown
564 hasKeyboard: shell.hasKeyboard
569 objectName: "launcher"
571 anchors.top: parent.top
572 anchors.topMargin: inverted ? 0 : panel.panelHeight
573 anchors.bottom: parent.bottom
575 dragAreaWidth: shell.edgeSize
576 available: tutorial.launcherEnabled
577 && (!greeter.locked || AccountsService.enableLauncherWhileLocked)
578 && !greeter.hasLockedApp
579 && !shell.waitingOnGreeter
580 inverted: shell.usageScenario !== "desktop"
581 superPressed: physicalKeysMapper.superPressed
582 superTabPressed: physicalKeysMapper.superTabPressed
583 panelWidth: units.gu(settings.launcherWidth)
584 lockedVisible: shell.usageScenario == "desktop" && !settings.autohideLauncher && !panel.fullscreenMode
585 topPanelHeight: panel.panelHeight
586 drawerEnabled: !greeter.active
587 privateMode: greeter.active
588 background: wallpaperResolver.cachedBackground
590 onShowDashHome: showHome()
591 onLauncherApplicationSelected: {
592 greeter.notifyUserRequestedApp();
593 shell.activateApplication(appId);
597 panel.indicators.hide();
598 panel.applicationMenus.hide();
601 onDrawerShownChanged: {
603 panel.indicators.hide();
604 panel.applicationMenus.hide();
614 shortcut: Qt.MetaModifier | Qt.Key_A
616 launcher.toggleDrawer(true);
620 shortcut: Qt.AltModifier | Qt.Key_F1
622 launcher.openForKeyboardNavigation();
626 shortcut: Qt.MetaModifier | Qt.Key_0
628 if (LauncherModel.get(9)) {
629 activateApplication(LauncherModel.get(9).appId);
636 shortcut: Qt.MetaModifier | (Qt.Key_1 + index)
638 if (LauncherModel.get(index)) {
639 activateApplication(LauncherModel.get(index).appId);
646 KeyboardShortcutsOverlay {
647 objectName: "shortcutsOverlay"
648 enabled: launcher.shortcutHintsShown && width < parent.width - (launcher.lockedVisible ? launcher.panelWidth : 0) - padding
649 && height < parent.height - padding - panel.panelHeight
650 anchors.centerIn: parent
651 anchors.horizontalCenterOffset: launcher.lockedVisible ? launcher.panelWidth/2 : 0
652 anchors.verticalCenterOffset: panel.panelHeight/2
654 opacity: enabled ? 0.95 : 0
656 Behavior on opacity {
657 UbuntuNumberAnimation {}
663 objectName: "tutorial"
666 paused: callManager.hasCalls || !greeter || greeter.active || wizard.active
667 || !hasTouchscreen // TODO #1661557 something better for no touchscreen
668 delayed: dialogs.hasActiveDialog || notifications.hasNotification ||
669 inputMethod.visible ||
670 (launcher.shown && !launcher.lockedVisible) ||
671 panel.indicators.shown || stage.rightEdgeDragProgress > 0
672 usageScenario: shell.usageScenario
673 lastInputTimestamp: inputFilter.lastInputTimestamp
683 deferred: shell.mode === "greeter"
685 function unlockWhenDoneWithWizard() {
687 Connectivity.unlockAllModems();
691 Component.onCompleted: unlockWhenDoneWithWizard()
692 onActiveChanged: unlockWhenDoneWithWizard()
695 MouseArea { // modal notifications prevent interacting with other contents
697 visible: notifications.useModal
704 model: NotificationBackend.Model
706 hasMouse: shell.hasMouse
707 background: wallpaperResolver.cachedBackground
709 y: topmostIsFullscreen ? 0 : panel.panelHeight
710 height: parent.height - (topmostIsFullscreen ? 0 : panel.panelHeight)
715 when: overlay.width <= units.gu(60)
717 target: notifications
718 anchors.left: parent.left
719 anchors.right: parent.right
724 when: overlay.width > units.gu(60)
726 target: notifications
727 anchors.left: undefined
728 anchors.right: parent.right
730 PropertyChanges { target: notifications; width: units.gu(38) }
737 enabled: !greeter.shown
739 // NB: it does its own positioning according to the specified edge
743 panel.indicators.hide()
746 material: Component {
752 anchors.centerIn: parent
754 GradientStop { position: 0.0; color: Qt.rgba(0.16,0.16,0.16,0.5)}
755 GradientStop { position: 1.0; color: Qt.rgba(0.16,0.16,0.16,0)}
765 objectName: "dialogs"
767 visible: hasActiveDialog
769 usageScenario: shell.usageScenario
770 hasKeyboard: shell.hasKeyboard
772 shutdownFadeOutRectangle.enabled = true;
773 shutdownFadeOutRectangle.visible = true;
774 shutdownFadeOut.start();
779 target: SessionBroadcast
780 onShowHome: if (shell.mode !== "greeter") showHome()
785 objectName: "urlDispatcher"
786 active: shell.mode === "greeter"
787 onUrlRequested: shell.activateURL(url)
794 GlobalShortcut { shortcut: Qt.Key_Print; onTriggered: itemGrabber.capture(shell) }
797 ignoreUnknownSignals: true
798 onItemSnapshotRequested: itemGrabber.capture(item)
803 id: cursorHidingTimer
805 running: panel.focusedSurfaceIsFullscreen && cursor.opacity > 0
806 onTriggered: cursor.opacity = 0;
812 visible: shell.hasMouse
814 topBoundaryOffset: panel.panelHeight
816 confiningItem: stage.itemConfiningMouseCursor
818 property bool mouseNeverMoved: true
820 target: cursor; property: "x"; value: shell.width / 2
821 when: cursor.mouseNeverMoved && cursor.visible
824 target: cursor; property: "y"; value: shell.height / 2
825 when: cursor.mouseNeverMoved && cursor.visible
830 readonly property var previewRectangle: stage.previewRectangle.target &&
831 stage.previewRectangle.target.dragging ?
832 stage.previewRectangle : null
834 onPushedLeftBoundary: {
835 if (buttons === Qt.NoButton) {
836 launcher.pushEdge(amount);
837 } else if (buttons === Qt.LeftButton && previewRectangle && previewRectangle.target.canBeMaximizedLeftRight) {
838 previewRectangle.maximizeLeft(amount);
842 onPushedRightBoundary: {
843 if (buttons === Qt.NoButton) {
844 rightEdgeBarrier.push(amount);
845 } else if (buttons === Qt.LeftButton && previewRectangle && previewRectangle.target.canBeMaximizedLeftRight) {
846 previewRectangle.maximizeRight(amount);
850 onPushedTopBoundary: {
851 if (buttons === Qt.LeftButton && previewRectangle && previewRectangle.target.canBeMaximized) {
852 previewRectangle.maximize(amount);
855 onPushedTopLeftCorner: {
856 if (buttons === Qt.LeftButton && previewRectangle && previewRectangle.target.canBeCornerMaximized) {
857 previewRectangle.maximizeTopLeft(amount);
860 onPushedTopRightCorner: {
861 if (buttons === Qt.LeftButton && previewRectangle && previewRectangle.target.canBeCornerMaximized) {
862 previewRectangle.maximizeTopRight(amount);
865 onPushedBottomLeftCorner: {
866 if (buttons === Qt.LeftButton && previewRectangle && previewRectangle.target.canBeCornerMaximized) {
867 previewRectangle.maximizeBottomLeft(amount);
870 onPushedBottomRightCorner: {
871 if (buttons === Qt.LeftButton && previewRectangle && previewRectangle.target.canBeCornerMaximized) {
872 previewRectangle.maximizeBottomRight(amount);
876 if (previewRectangle) {
877 previewRectangle.stop();
882 mouseNeverMoved = false;
886 Behavior on opacity { UbuntuNumberAnimation {} }
889 // non-visual objects
891 focusedSurface: topLevelSurfaceList.focusedWindow ? topLevelSurfaceList.focusedWindow.surface : null
896 id: shutdownFadeOutRectangle
903 NumberAnimation on opacity {
908 if (shutdownFadeOutRectangle.enabled && shutdownFadeOutRectangle.visible) {
909 DBusUnitySessionService.shutdown();
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list