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 "Components/PanelState"
42import Unity.Notifications 1.0 as NotificationBackend
43import Unity.Session 0.1
44import Unity.DashCommunicator 0.1
45import Unity.Indicators 0.1 as Indicators
47import WindowManager 1.0
53 theme.name: "Ubuntu.Components.Themes.SuruDark"
55 // to be set from outside
56 property int orientationAngle: 0
57 property int orientation
58 property Orientations orientations
59 property real nativeWidth
60 property real nativeHeight
61 property alias panelAreaShowProgress: panel.panelAreaShowProgress
62 property string usageScenario: "phone" // supported values: "phone", "tablet" or "desktop"
63 property string mode: "full-greeter"
64 property alias oskEnabled: inputMethod.enabled
65 function updateFocusedAppOrientation() {
66 stage.updateFocusedAppOrientation();
68 function updateFocusedAppOrientationAnimated() {
69 stage.updateFocusedAppOrientationAnimated();
71 property bool hasMouse: false
72 property bool hasKeyboard: false
73 property bool hasTouchscreen: false
75 // to be read from outside
76 readonly property int mainAppWindowOrientationAngle: stage.mainAppWindowOrientationAngle
78 readonly property bool orientationChangesEnabled: panel.indicators.fullyClosed
79 && stage.orientationChangesEnabled
80 && (!greeter || !greeter.animating)
82 readonly property bool showingGreeter: greeter && greeter.shown
84 property bool startingUp: true
85 Timer { id: finishStartUpTimer; interval: 500; onTriggered: startingUp = false }
87 property int supportedOrientations: {
89 // Ensure we don't rotate during start up
90 return Qt.PrimaryOrientation;
91 } else if (showingGreeter || notifications.topmostIsFullscreen) {
92 return Qt.PrimaryOrientation;
94 return shell.orientations.map(stage.supportedOrientations);
98 readonly property var mainApp: stage.mainApp
100 readonly property var topLevelSurfaceList: {
101 if (!WMScreen.currentWorkspace) return null;
102 return WMScreen.currentWorkspace.windowModel
107 _onMainAppChanged(mainApp.appId);
111 target: ApplicationManager
113 if (shell.mainApp && shell.mainApp.appId === appId) {
114 _onMainAppChanged(appId);
118 function _onMainAppChanged(appId) {
119 if (wizard.active && appId != "" && appId != "unity8-dash") {
120 // If this happens on first boot, we may be in the
121 // wizard while receiving a call. But a call is more
122 // important than the wizard so just bail out of it.
126 if (appId === "dialer-app" && callManager.hasCalls && greeter.locked) {
127 // If we are in the middle of a call, make dialer lockedApp and show it.
128 // This can happen if user backs out of dialer back to greeter, then
129 // launches dialer again.
130 greeter.lockedApp = appId;
132 greeter.notifyAppFocusRequested(appId);
134 panel.indicators.hide();
135 launcher.hide(launcher.ignoreHideIfMouseOverLauncher);
138 // For autopilot consumption
139 readonly property string focusedApplicationId: ApplicationManager.focusedApplicationId
141 // Note when greeter is waiting on PAM, so that we can disable edges until
142 // we know which user data to show and whether the session is locked.
143 readonly property bool waitingOnGreeter: greeter && greeter.waiting
145 property real edgeSize: units.gu(settings.edgeDragWidth)
148 id: wallpaperResolver
149 objectName: "wallpaperResolver"
151 readonly property url defaultBackground: "file://" + Constants.defaultWallpaper
152 readonly property bool hasCustomBackground: background != defaultBackground
154 // Use a cached version of the scaled-down wallpaper (as sometimes the
155 // image can be quite big compared to the device size, including for
156 // our default wallpaper). We use a name=wallpaper argument here to
157 // make sure we don't litter our cache with lots of scaled images. We
158 // only need to bother caching one at a time.
159 readonly property url cachedBackground: background.toString().indexOf("file:///") === 0 ? "image://unity8imagecache/" + background + "?name=wallpaper" : background
162 id: backgroundSettings
163 schema.id: "org.gnome.desktop.background"
167 AccountsService.backgroundFile,
168 backgroundSettings.pictureUri,
173 readonly property alias greeter: greeterLoader.item
175 function activateApplication(appId) {
176 // Either open the app in our own session, or -- if we're acting as a
177 // greeter -- ask the user's session to open it for us.
178 if (shell.mode === "greeter") {
179 activateURL("application:///" + appId + ".desktop");
185 function activateURL(url) {
186 SessionBroadcast.requestUrlStart(AccountsService.user, url);
187 greeter.notifyUserRequestedApp();
188 panel.indicators.hide();
191 function startApp(appId) {
192 if (ApplicationManager.findApplication(appId)) {
193 ApplicationManager.requestFocusApplication(appId);
195 print("calling startApplication. active workspace is", WorkspaceManager.activeWorkspace)
196 ApplicationManager.startApplication(appId);
200 function startLockedApp(app) {
201 if (greeter.locked) {
202 greeter.lockedApp = app;
204 startApp(app); // locked apps are always in our same session
208 target: LauncherModel
209 property: "applicationManager"
210 value: ApplicationManager
213 Component.onCompleted: {
214 finishStartUpTimer.start();
223 objectName: "dashCommunicator"
227 id: physicalKeysMapper
228 objectName: "physicalKeysMapper"
230 onPowerKeyLongPressed: dialogs.showPowerDialog();
231 onVolumeDownTriggered: volumeControl.volumeDown();
232 onVolumeUpTriggered: volumeControl.volumeUp();
233 onScreenshotTriggered: itemGrabber.capture(shell);
237 // dummy shortcut to force creation of GlobalShortcutRegistry before WindowInputFilter
242 Keys.onPressed: physicalKeysMapper.onKeyPressed(event, lastInputTimestamp);
243 Keys.onReleased: physicalKeysMapper.onKeyReleased(event, lastInputTimestamp);
247 objectName: "windowInputMonitor"
248 onHomeKeyActivated: {
249 // Ignore when greeter is active, to avoid pocket presses
250 if (!greeter.active) {
252 ApplicationManager.requestFocusApplication("unity8-dash");
255 onTouchBegun: { cursor.opacity = 0; }
257 // move the (hidden) cursor to the last known touch position
258 var mappedCoords = mapFromItem(null, pos.x, pos.y);
259 cursor.x = mappedCoords.x;
260 cursor.y = mappedCoords.y;
261 cursor.mouseNeverMoved = false;
267 schema.id: "com.canonical.Unity8"
272 objectName: "panelState"
279 height: parent.height
287 dragAreaWidth: shell.edgeSize
288 background: wallpaperResolver.background
290 applicationManager: ApplicationManager
291 topLevelSurfaceList: shell.topLevelSurfaceList
292 inputMethodRect: inputMethod.visibleRect
293 rightEdgePushProgress: rightEdgeBarrier.progress
295 property string usageScenario: shell.usageScenario === "phone" || greeter.hasLockedApp
297 : shell.usageScenario
299 mode: usageScenario == "phone" ? "staged"
300 : usageScenario == "tablet" ? "stagedWithSideStage"
303 shellOrientation: shell.orientation
304 shellOrientationAngle: shell.orientationAngle
305 orientations: shell.orientations
306 nativeWidth: shell.nativeWidth
307 nativeHeight: shell.nativeHeight
309 interactive: (!greeter || !greeter.shown)
310 && panel.indicators.fullyClosed
311 && !notifications.useModal
313 onInteractiveChanged: { if (interactive) { focus = true; } }
315 leftMargin: shell.usageScenario == "desktop" && !settings.autohideLauncher ? launcher.panelWidth: 0
316 suspended: greeter.shown
317 altTabPressed: physicalKeysMapper.altTabPressed
318 oskEnabled: shell.oskEnabled
319 spreadEnabled: tutorial.spreadEnabled && (!greeter || (!greeter.hasLockedApp && !greeter.shown))
320 panelState: panelState
322 onSpreadShownChanged: {
323 panel.indicators.hide();
324 panel.applicationMenus.hide();
331 minimumTouchPoints: 4
332 maximumTouchPoints: minimumTouchPoints
334 readonly property bool recognisedPress: status == TouchGestureArea.Recognized &&
335 touchPoints.length >= minimumTouchPoints &&
336 touchPoints.length <= maximumTouchPoints
337 property bool wasPressed: false
339 onRecognisedPressChanged: {
340 if (recognisedPress) {
346 if (status !== TouchGestureArea.Recognized) {
347 if (status === TouchGestureArea.WaitingForTouch) {
348 if (wasPressed && !dragging) {
349 launcher.openDrawer(true);
360 objectName: "inputMethod"
361 surface: shell.topLevelSurfaceList.inputMethodSurface
364 topMargin: panel.panelHeight
365 leftMargin: launcher.lockedVisible ? launcher.panelWidth : 0
367 z: notifications.useModal || panel.indicators.shown || wizard.active || tutorial.running || launcher.drawerShown ? overlay.z + 1 : overlay.z - 1
372 objectName: "greeterLoader"
374 anchors.topMargin: panel.panelHeight
376 if (shell.mode != "shell") {
377 if (screenWindow.primary) return integratedGreeter;
378 return secondaryGreeter;
380 return Qt.createComponent(Qt.resolvedUrl("Greeter/ShimGreeter.qml"));
383 item.objectName = "greeter"
385 property bool openDrawerAfterUnlock: false
389 if (!greeter.active && greeterLoader.openDrawerAfterUnlock) {
390 launcher.openDrawer(false);
391 greeterLoader.openDrawerAfterUnlock = false;
398 id: integratedGreeter
401 enabled: panel.indicators.fullyClosed // hides OSK when panel is open
402 hides: [launcher, panel.indicators, panel.applicationMenus]
403 tabletMode: shell.usageScenario != "phone"
404 forcedUnlock: wizard.active || shell.mode === "full-shell"
405 background: wallpaperResolver.cachedBackground
406 hasCustomBackground: wallpaperResolver.hasCustomBackground
407 allowFingerprint: !dialogs.hasActiveDialog &&
408 !notifications.topmostIsFullscreen &&
409 !panel.indicators.shown
411 // avoid overlapping with Launcher's edge drag area
412 // FIXME: Fix TouchRegistry & friends and remove this workaround
413 // Issue involves launcher's DDA getting disabled on a long
415 dragHandleLeftMargin: launcher.available ? launcher.dragAreaWidth + 1 : 0
422 if (!tutorial.running) {
427 onEmergencyCall: startLockedApp("dialer-app")
434 hides: [launcher, panel.indicators]
439 // See powerConnection for why this is useful
440 id: showGreeterDelayed
443 // Go through the dbus service, because it has checks for whether
444 // we are even allowed to lock or not.
445 DBusUnitySessionService.PromptLock();
454 if (greeter.locked && callManager.hasCalls && greeter.lockedApp !== "dialer-app") {
455 // We just received an incoming call while locked. The
456 // indicator will have already launched dialer-app for us, but
457 // there is a race between "hasCalls" changing and the dialer
458 // starting up. So in case we lose that race, we'll start/
459 // focus the dialer ourselves here too. Even if the indicator
460 // didn't launch the dialer for some reason (or maybe a call
461 // started via some other means), if an active call is
462 // happening, we want to be in the dialer.
463 startLockedApp("dialer-app")
473 if (Powerd.status === Powerd.Off && reason !== Powerd.Proximity &&
474 !callManager.hasCalls && !wizard.active) {
475 // We don't want to simply call greeter.showNow() here, because
476 // that will take too long. Qt will delay button event
477 // handling until the greeter is done loading and may think the
478 // user held down the power button the whole time, leading to a
479 // power dialog being shown. Instead, delay showing the
480 // greeter until we've finished handling the event. We could
481 // make the greeter load asynchronously instead, but that
482 // introduces a whole host of timing issues, especially with
483 // its animations. So this is simpler.
484 showGreeterDelayed.start();
489 function showHome() {
490 greeter.notifyUserRequestedApp();
492 if (shell.mode === "greeter") {
493 SessionBroadcast.requestHomeShown(AccountsService.user);
495 if (!greeter.active) {
496 launcher.openDrawer(false);
498 greeterLoader.openDrawerAfterUnlock = true;
512 anchors.fill: parent //because this draws indicator menus
514 mode: shell.usageScenario == "desktop" ? "windowed" : "staged"
515 minimizedPanelHeight: units.gu(3)
516 expandedPanelHeight: units.gu(7)
517 indicatorMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
518 applicationMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
519 applicationMenuContentX: launcher.lockedVisible ? launcher.panelWidth : 0
523 available: tutorial.panelEnabled
524 && ((!greeter || !greeter.locked) || AccountsService.enableIndicatorsWhileLocked)
525 && (!greeter || !greeter.hasLockedApp)
526 && !shell.waitingOnGreeter
527 && settings.enableIndicatorMenu
529 model: Indicators.IndicatorsModel {
530 // tablet and phone both use the same profile
531 // FIXME: use just "phone" for greeter too, but first fix
532 // greeter app launching to either load the app inside the
533 // greeter or tell the session to load the app. This will
534 // involve taking the url-dispatcher dbus name and using
535 // SessionBroadcast to tell the session.
536 profile: shell.mode === "greeter" ? "desktop_greeter" : "phone"
537 Component.onCompleted: load();
543 available: (!greeter || !greeter.shown)
544 && !shell.waitingOnGreeter
545 && !stage.spreadShown
548 readonly property bool focusedSurfaceIsFullscreen: shell.topLevelSurfaceList.focusedWindow
549 ? shell.topLevelSurfaceList.focusedWindow.state === Mir.FullscreenState
551 fullscreenMode: (focusedSurfaceIsFullscreen && !LightDMService.greeter.active && launcher.progress == 0 && !stage.spreadShown)
552 || greeter.hasLockedApp
553 greeterShown: greeter && greeter.shown
554 hasKeyboard: shell.hasKeyboard
555 panelState: panelState
560 objectName: "launcher"
562 anchors.top: parent.top
563 anchors.topMargin: inverted ? 0 : panel.panelHeight
564 anchors.bottom: parent.bottom
566 dragAreaWidth: shell.edgeSize
567 available: tutorial.launcherEnabled
568 && (!greeter.locked || AccountsService.enableLauncherWhileLocked)
569 && !greeter.hasLockedApp
570 && !shell.waitingOnGreeter
571 && settings.enableLauncher
572 inverted: shell.usageScenario !== "desktop"
573 superPressed: physicalKeysMapper.superPressed
574 superTabPressed: physicalKeysMapper.superTabPressed
575 panelWidth: units.gu(settings.launcherWidth)
576 lockedVisible: shell.usageScenario == "desktop" && !settings.autohideLauncher && !panel.fullscreenMode
577 blurSource: greeter.shown ? greeter : stages
578 topPanelHeight: panel.panelHeight
579 drawerEnabled: !greeter.active
580 privateMode: greeter.active
582 onShowDashHome: showHome()
583 onLauncherApplicationSelected: {
584 greeter.notifyUserRequestedApp();
585 shell.activateApplication(appId);
589 panel.indicators.hide();
590 panel.applicationMenus.hide();
593 onDrawerShownChanged: {
595 panel.indicators.hide();
596 panel.applicationMenus.hide();
606 shortcut: Qt.MetaModifier | Qt.Key_A
608 launcher.openDrawer(true);
612 shortcut: Qt.AltModifier | Qt.Key_F1
614 launcher.openForKeyboardNavigation();
618 shortcut: Qt.MetaModifier | Qt.Key_0
620 if (LauncherModel.get(9)) {
621 activateApplication(LauncherModel.get(9).appId);
628 shortcut: Qt.MetaModifier | (Qt.Key_1 + index)
630 if (LauncherModel.get(index)) {
631 activateApplication(LauncherModel.get(index).appId);
638 KeyboardShortcutsOverlay {
639 objectName: "shortcutsOverlay"
640 enabled: launcher.shortcutHintsShown && width < parent.width - (launcher.lockedVisible ? launcher.panelWidth : 0) - padding
641 && height < parent.height - padding - panel.panelHeight
642 anchors.centerIn: parent
643 anchors.horizontalCenterOffset: launcher.lockedVisible ? launcher.panelWidth/2 : 0
644 anchors.verticalCenterOffset: panel.panelHeight/2
646 opacity: enabled ? 0.95 : 0
648 Behavior on opacity {
649 UbuntuNumberAnimation {}
655 objectName: "tutorial"
658 paused: callManager.hasCalls || !greeter || greeter.active || wizard.active
659 || !hasTouchscreen // TODO #1661557 something better for no touchscreen
660 delayed: dialogs.hasActiveDialog || notifications.hasNotification ||
661 inputMethod.visible ||
662 (launcher.shown && !launcher.lockedVisible) ||
663 panel.indicators.shown || stage.rightEdgeDragProgress > 0
664 usageScenario: shell.usageScenario
665 lastInputTimestamp: inputFilter.lastInputTimestamp
675 deferred: shell.mode === "greeter"
677 function unlockWhenDoneWithWizard() {
679 Connectivity.unlockAllModems();
683 Component.onCompleted: unlockWhenDoneWithWizard()
684 onActiveChanged: unlockWhenDoneWithWizard()
687 MouseArea { // modal notifications prevent interacting with other contents
689 visible: notifications.useModal
696 model: NotificationBackend.Model
698 hasMouse: shell.hasMouse
699 background: wallpaperResolver.cachedBackground
701 y: topmostIsFullscreen ? 0 : panel.panelHeight
702 height: parent.height - (topmostIsFullscreen ? 0 : panel.panelHeight)
707 when: overlay.width <= units.gu(60)
709 target: notifications
710 anchors.left: parent.left
711 anchors.right: parent.right
716 when: overlay.width > units.gu(60)
718 target: notifications
719 anchors.left: undefined
720 anchors.right: parent.right
722 PropertyChanges { target: notifications; width: units.gu(38) }
729 enabled: !greeter.shown
731 // NB: it does its own positioning according to the specified edge
735 panel.indicators.hide()
738 material: Component {
744 anchors.centerIn: parent
746 GradientStop { position: 0.0; color: Qt.rgba(0.16,0.16,0.16,0.5)}
747 GradientStop { position: 1.0; color: Qt.rgba(0.16,0.16,0.16,0)}
757 objectName: "dialogs"
759 visible: hasActiveDialog
761 usageScenario: shell.usageScenario
762 hasKeyboard: shell.hasKeyboard
764 shutdownFadeOutRectangle.enabled = true;
765 shutdownFadeOutRectangle.visible = true;
766 shutdownFadeOut.start();
771 target: SessionBroadcast
772 onShowHome: if (shell.mode !== "greeter") showHome()
777 objectName: "urlDispatcher"
778 active: shell.mode === "greeter"
779 onUrlRequested: shell.activateURL(url)
786 GlobalShortcut { shortcut: Qt.Key_Print; onTriggered: itemGrabber.capture(shell) }
789 ignoreUnknownSignals: true
790 onItemSnapshotRequested: itemGrabber.capture(item)
795 id: cursorHidingTimer
797 running: panel.focusedSurfaceIsFullscreen && cursor.opacity > 0
798 onTriggered: cursor.opacity = 0;
806 topBoundaryOffset: panel.panelHeight
807 enabled: shell.hasMouse && screenWindow.active
810 property bool mouseNeverMoved: true
812 target: cursor; property: "x"; value: shell.width / 2
813 when: cursor.mouseNeverMoved && cursor.visible
816 target: cursor; property: "y"; value: shell.height / 2
817 when: cursor.mouseNeverMoved && cursor.visible
820 confiningItem: stage.itemConfiningMouseCursor
824 readonly property var previewRectangle: stage.previewRectangle.target &&
825 stage.previewRectangle.target.dragging ?
826 stage.previewRectangle : null
828 onPushedLeftBoundary: {
829 if (buttons === Qt.NoButton) {
830 launcher.pushEdge(amount);
831 } else if (buttons === Qt.LeftButton && previewRectangle && previewRectangle.target.canBeMaximizedLeftRight) {
832 previewRectangle.maximizeLeft(amount);
836 onPushedRightBoundary: {
837 if (buttons === Qt.NoButton) {
838 rightEdgeBarrier.push(amount);
839 } else if (buttons === Qt.LeftButton && previewRectangle && previewRectangle.target.canBeMaximizedLeftRight) {
840 previewRectangle.maximizeRight(amount);
844 onPushedTopBoundary: {
845 if (buttons === Qt.LeftButton && previewRectangle && previewRectangle.target.canBeMaximized) {
846 previewRectangle.maximize(amount);
849 onPushedTopLeftCorner: {
850 if (buttons === Qt.LeftButton && previewRectangle && previewRectangle.target.canBeCornerMaximized) {
851 previewRectangle.maximizeTopLeft(amount);
854 onPushedTopRightCorner: {
855 if (buttons === Qt.LeftButton && previewRectangle && previewRectangle.target.canBeCornerMaximized) {
856 previewRectangle.maximizeTopRight(amount);
859 onPushedBottomLeftCorner: {
860 if (buttons === Qt.LeftButton && previewRectangle && previewRectangle.target.canBeCornerMaximized) {
861 previewRectangle.maximizeBottomLeft(amount);
864 onPushedBottomRightCorner: {
865 if (buttons === Qt.LeftButton && previewRectangle && previewRectangle.target.canBeCornerMaximized) {
866 previewRectangle.maximizeBottomRight(amount);
870 if (previewRectangle) {
871 previewRectangle.stop();
876 mouseNeverMoved = false;
880 Behavior on opacity { UbuntuNumberAnimation {} }
883 // non-visual objects
885 focusedSurface: shell.topLevelSurfaceList.focusedWindow ? shell.topLevelSurfaceList.focusedWindow.surface : null
890 id: shutdownFadeOutRectangle
897 NumberAnimation on opacity {
902 if (shutdownFadeOutRectangle.enabled && shutdownFadeOutRectangle.visible) {
903 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