on d39f93f help sign in
unity8/qml/Shell.qml
882 lines 31 kB history raw
1/*
2 * Copyright (C) 2013-2016 Canonical, Ltd.
3 *
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.
7 *
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.
12 *
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/>.
15 */
17import QtQuick 2.4
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
28import GSettings 1.0
29import ImageCache 0.1
30import Utils 0.1
31import Powerd 0.1
32import SessionBroadcast 0.1
33import "Greeter"
34import "Launcher"
35import "Panel"
36import "Components"
37import "Notifications"
38import "Stage"
39import "Tutorial"
40import "Wizard"
41import Unity.Notifications 1.0 as NotificationBackend
42import Unity.Session 0.1
43import Unity.DashCommunicator 0.1
44import Unity.Indicators 0.1 as Indicators
45import Cursor 1.1
46import WindowManager 1.0
49StyledItem {
50 id: shell
52 theme.name: "Ubuntu.Components.Themes.SuruDark"
54 // to be set from outside
55 property int orientationAngle: 0
56 property int orientation
57 property Orientations orientations
58 property real nativeWidth
59 property real nativeHeight
60 property alias panelAreaShowProgress: panel.panelAreaShowProgress
61 property string usageScenario: "phone" // supported values: "phone", "tablet" or "desktop"
62 property string mode: "full-greeter"
63 property alias oskEnabled: inputMethod.enabled
64 function updateFocusedAppOrientation() {
65 stage.updateFocusedAppOrientation();
66 }
67 function updateFocusedAppOrientationAnimated() {
68 stage.updateFocusedAppOrientationAnimated();
69 }
70 property bool hasMouse: false
71 property bool hasKeyboard: false
72 property bool hasTouchscreen: false
74 // to be read from outside
75 readonly property int mainAppWindowOrientationAngle: stage.mainAppWindowOrientationAngle
77 readonly property bool orientationChangesEnabled: panel.indicators.fullyClosed
78 && stage.orientationChangesEnabled
79 && (!greeter || !greeter.animating)
81 readonly property bool showingGreeter: greeter && greeter.shown
83 property bool startingUp: true
84 Timer { id: finishStartUpTimer; interval: 500; onTriggered: startingUp = false }
86 property int supportedOrientations: {
87 if (startingUp) {
88 // Ensure we don't rotate during start up
89 return Qt.PrimaryOrientation;
90 } else if (showingGreeter || notifications.topmostIsFullscreen) {
91 return Qt.PrimaryOrientation;
92 } else {
93 return shell.orientations.map(stage.supportedOrientations);
94 }
95 }
97 readonly property var mainApp: stage.mainApp
99 onMainAppChanged: {
100 if (mainApp) {
101 _onMainAppChanged(mainApp.appId);
102 }
103 }
104 Connections {
105 target: ApplicationManager
106 onFocusRequested: {
107 if (shell.mainApp && shell.mainApp.appId === appId) {
108 _onMainAppChanged(appId);
109 }
110 }
111 }
112 function _onMainAppChanged(appId) {
113 if (wizard.active && appId != "" && appId != "unity8-dash") {
114 // If this happens on first boot, we may be in the
115 // wizard while receiving a call. But a call is more
116 // important than the wizard so just bail out of it.
117 wizard.hide();
118 }
120 if (appId === "dialer-app" && callManager.hasCalls && greeter.locked) {
121 // If we are in the middle of a call, make dialer lockedApp and show it.
122 // This can happen if user backs out of dialer back to greeter, then
123 // launches dialer again.
124 greeter.lockedApp = appId;
125 }
126 greeter.notifyAppFocusRequested(appId);
128 panel.indicators.hide();
129 launcher.hide(launcher.ignoreHideIfMouseOverLauncher);
130 }
132 // For autopilot consumption
133 readonly property string focusedApplicationId: ApplicationManager.focusedApplicationId
135 // Note when greeter is waiting on PAM, so that we can disable edges until
136 // we know which user data to show and whether the session is locked.
137 readonly property bool waitingOnGreeter: greeter && greeter.waiting
139 property real edgeSize: units.gu(settings.edgeDragWidth)
141 WallpaperResolver {
142 id: wallpaperResolver
143 objectName: "wallpaperResolver"
145 readonly property url defaultBackground: "file://" + Constants.defaultWallpaper
146 readonly property bool hasCustomBackground: background != defaultBackground
148 // Use a cached version of the scaled-down wallpaper (as sometimes the
149 // image can be quite big compared to the device size, including for
150 // our default wallpaper). We use a name=wallpaper argument here to
151 // make sure we don't litter our cache with lots of scaled images. We
152 // only need to bother caching one at a time.
153 readonly property url cachedBackground: background.toString().indexOf("file:///") === 0 ? "image://unity8imagecache/" + background + "?name=wallpaper" : background
155 GSettings {
156 id: backgroundSettings
157 schema.id: "org.gnome.desktop.background"
158 }
160 candidates: [
161 AccountsService.backgroundFile,
162 backgroundSettings.pictureUri,
163 defaultBackground
164 ]
165 }
167 readonly property alias greeter: greeterLoader.item
169 function activateApplication(appId) {
170 // Either open the app in our own session, or -- if we're acting as a
171 // greeter -- ask the user's session to open it for us.
172 if (shell.mode === "greeter") {
173 activateURL("application:///" + appId + ".desktop");
174 } else {
175 startApp(appId);
176 }
177 }
179 function activateURL(url) {
180 SessionBroadcast.requestUrlStart(AccountsService.user, url);
181 greeter.notifyUserRequestedApp();
182 panel.indicators.hide();
183 }
185 function startApp(appId) {
186 if (ApplicationManager.findApplication(appId)) {
187 ApplicationManager.requestFocusApplication(appId);
188 } else {
189 ApplicationManager.startApplication(appId);
190 }
191 }
193 function startLockedApp(app) {
194 if (greeter.locked) {
195 greeter.lockedApp = app;
196 }
197 startApp(app); // locked apps are always in our same session
198 }
200 Binding {
201 target: LauncherModel
202 property: "applicationManager"
203 value: ApplicationManager
204 }
206 Component.onCompleted: {
207 finishStartUpTimer.start();
208 }
210 VolumeControl {
211 id: volumeControl
212 }
214 DashCommunicator {
215 id: dash
216 objectName: "dashCommunicator"
217 }
219 PhysicalKeysMapper {
220 id: physicalKeysMapper
221 objectName: "physicalKeysMapper"
223 onPowerKeyLongPressed: dialogs.showPowerDialog();
224 onVolumeDownTriggered: volumeControl.volumeDown();
225 onVolumeUpTriggered: volumeControl.volumeUp();
226 onScreenshotTriggered: itemGrabber.capture(shell);
227 }
229 GlobalShortcut {
230 // dummy shortcut to force creation of GlobalShortcutRegistry before WindowInputFilter
231 }
233 WindowInputFilter {
234 id: inputFilter
235 Keys.onPressed: physicalKeysMapper.onKeyPressed(event, lastInputTimestamp);
236 Keys.onReleased: physicalKeysMapper.onKeyReleased(event, lastInputTimestamp);
237 }
239 WindowInputMonitor {
240 objectName: "windowInputMonitor"
241 onHomeKeyActivated: {
242 // Ignore when greeter is active, to avoid pocket presses
243 if (!greeter.active) {
244 launcher.fadeOut();
245 ApplicationManager.requestFocusApplication("unity8-dash");
246 }
247 }
248 onTouchBegun: { cursor.opacity = 0; }
249 onTouchEnded: {
250 // move the (hidden) cursor to the last known touch position
251 var mappedCoords = mapFromItem(null, pos.x, pos.y);
252 cursor.x = mappedCoords.x;
253 cursor.y = mappedCoords.y;
254 cursor.mouseNeverMoved = false;
255 }
256 }
258 GSettings {
259 id: settings
260 schema.id: "com.canonical.Unity8"
261 }
263 Item {
264 id: stages
265 objectName: "stages"
266 width: parent.width
267 height: parent.height
269 SurfaceManager {
270 id: surfaceMan
271 objectName: "surfaceManager"
272 }
273 TopLevelWindowModel {
274 id: topLevelSurfaceList
275 objectName: "topLevelSurfaceList"
276 applicationManager: ApplicationManager // it's a singleton
277 surfaceManager: surfaceMan
278 }
280 Stage {
281 id: stage
282 objectName: "stage"
283 anchors.fill: parent
284 focus: true
286 dragAreaWidth: shell.edgeSize
287 background: wallpaperResolver.background
289 applicationManager: ApplicationManager
290 topLevelSurfaceList: topLevelSurfaceList
291 inputMethodRect: inputMethod.visibleRect
292 rightEdgePushProgress: rightEdgeBarrier.progress
294 property string usageScenario: shell.usageScenario === "phone" || greeter.hasLockedApp
295 ? "phone"
296 : shell.usageScenario
298 mode: usageScenario == "phone" ? "staged"
299 : usageScenario == "tablet" ? "stagedWithSideStage"
300 : "windowed"
302 shellOrientation: shell.orientation
303 shellOrientationAngle: shell.orientationAngle
304 orientations: shell.orientations
305 nativeWidth: shell.nativeWidth
306 nativeHeight: shell.nativeHeight
308 interactive: (!greeter || !greeter.shown)
309 && panel.indicators.fullyClosed
310 && !notifications.useModal
312 onInteractiveChanged: { if (interactive) { focus = true; } }
314 leftMargin: shell.usageScenario == "desktop" && !settings.autohideLauncher ? launcher.panelWidth: 0
315 suspended: greeter.shown
316 altTabPressed: physicalKeysMapper.altTabPressed
317 oskEnabled: shell.oskEnabled
318 spreadEnabled: tutorial.spreadEnabled && (!greeter || (!greeter.hasLockedApp && !greeter.shown))
320 onSpreadShownChanged: {
321 panel.indicators.hide();
322 panel.applicationMenus.hide();
323 }
324 }
326 TouchGestureArea {
327 anchors.fill: stage
329 minimumTouchPoints: 4
330 maximumTouchPoints: minimumTouchPoints
332 readonly property bool recognisedPress: status == TouchGestureArea.Recognized &&
333 touchPoints.length >= minimumTouchPoints &&
334 touchPoints.length <= maximumTouchPoints
335 property bool wasPressed: false
337 onRecognisedPressChanged: {
338 if (recognisedPress) {
339 wasPressed = true;
340 }
341 }
343 onStatusChanged: {
344 if (status !== TouchGestureArea.Recognized) {
345 if (status === TouchGestureArea.WaitingForTouch) {
346 if (wasPressed && !dragging) {
347 launcher.openDrawer(true);
348 }
349 }
350 wasPressed = false;
351 }
352 }
353 }
354 }
356 InputMethod {
357 id: inputMethod
358 objectName: "inputMethod"
359 surface: topLevelSurfaceList.inputMethodSurface
360 anchors {
361 fill: parent
362 topMargin: panel.panelHeight
363 leftMargin: launcher.lockedVisible ? launcher.panelWidth : 0
364 }
365 z: notifications.useModal || panel.indicators.shown || wizard.active || tutorial.running || launcher.drawerShown ? overlay.z + 1 : overlay.z - 1
366 }
368 Loader {
369 id: greeterLoader
370 objectName: "greeterLoader"
371 anchors.fill: parent
372 anchors.topMargin: panel.panelHeight
373 sourceComponent: shell.mode != "shell" ? integratedGreeter :
374 Qt.createComponent(Qt.resolvedUrl("Greeter/ShimGreeter.qml"));
375 onLoaded: {
376 item.objectName = "greeter"
377 }
378 property bool openDrawerAfterUnlock: false
379 Connections {
380 target: greeter
381 onActiveChanged: {
382 if (!greeter.active && greeterLoader.openDrawerAfterUnlock) {
383 launcher.openDrawer(false);
384 greeterLoader.openDrawerAfterUnlock = false;
385 }
386 }
387 }
388 }
390 Component {
391 id: integratedGreeter
392 Greeter {
394 enabled: panel.indicators.fullyClosed // hides OSK when panel is open
395 hides: [launcher, panel.indicators, panel.applicationMenus]
396 tabletMode: shell.usageScenario != "phone"
397 forcedUnlock: wizard.active || shell.mode === "full-shell"
398 background: wallpaperResolver.cachedBackground
399 hasCustomBackground: wallpaperResolver.hasCustomBackground
400 allowFingerprint: !dialogs.hasActiveDialog &&
401 !notifications.topmostIsFullscreen &&
402 !panel.indicators.shown
404 // avoid overlapping with Launcher's edge drag area
405 // FIXME: Fix TouchRegistry & friends and remove this workaround
406 // Issue involves launcher's DDA getting disabled on a long
407 // left-edge drag
408 dragHandleLeftMargin: launcher.available ? launcher.dragAreaWidth + 1 : 0
410 onSessionStarted: {
411 launcher.hide();
412 }
414 onTease: {
415 if (!tutorial.running) {
416 launcher.tease();
417 }
418 }
420 onEmergencyCall: startLockedApp("dialer-app")
421 }
422 }
424 Timer {
425 // See powerConnection for why this is useful
426 id: showGreeterDelayed
427 interval: 1
428 onTriggered: {
429 // Go through the dbus service, because it has checks for whether
430 // we are even allowed to lock or not.
431 DBusUnitySessionService.PromptLock();
432 }
433 }
435 Connections {
436 id: callConnection
437 target: callManager
439 onHasCallsChanged: {
440 if (greeter.locked && callManager.hasCalls && greeter.lockedApp !== "dialer-app") {
441 // We just received an incoming call while locked. The
442 // indicator will have already launched dialer-app for us, but
443 // there is a race between "hasCalls" changing and the dialer
444 // starting up. So in case we lose that race, we'll start/
445 // focus the dialer ourselves here too. Even if the indicator
446 // didn't launch the dialer for some reason (or maybe a call
447 // started via some other means), if an active call is
448 // happening, we want to be in the dialer.
449 startLockedApp("dialer-app")
450 }
451 }
452 }
454 Connections {
455 id: powerConnection
456 target: Powerd
458 onStatusChanged: {
459 if (Powerd.status === Powerd.Off && reason !== Powerd.Proximity &&
460 !callManager.hasCalls && !wizard.active) {
461 // We don't want to simply call greeter.showNow() here, because
462 // that will take too long. Qt will delay button event
463 // handling until the greeter is done loading and may think the
464 // user held down the power button the whole time, leading to a
465 // power dialog being shown. Instead, delay showing the
466 // greeter until we've finished handling the event. We could
467 // make the greeter load asynchronously instead, but that
468 // introduces a whole host of timing issues, especially with
469 // its animations. So this is simpler.
470 showGreeterDelayed.start();
471 }
472 }
473 }
475 function showHome() {
476 greeter.notifyUserRequestedApp();
478 if (shell.mode === "greeter") {
479 SessionBroadcast.requestHomeShown(AccountsService.user);
480 } else {
481 if (!greeter.active) {
482 launcher.openDrawer(false);
483 } else {
484 greeterLoader.openDrawerAfterUnlock = true;
485 }
486 }
487 }
489 Item {
490 id: overlay
491 z: 10
493 anchors.fill: parent
495 Panel {
496 id: panel
497 objectName: "panel"
498 anchors.fill: parent //because this draws indicator menus
500 mode: shell.usageScenario == "desktop" ? "windowed" : "staged"
501 minimizedPanelHeight: units.gu(3)
502 expandedPanelHeight: units.gu(7)
503 indicatorMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
504 applicationMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
506 indicators {
507 hides: [launcher]
508 available: tutorial.panelEnabled
509 && ((!greeter || !greeter.locked) || AccountsService.enableIndicatorsWhileLocked)
510 && (!greeter || !greeter.hasLockedApp)
511 && !shell.waitingOnGreeter
512 && settings.enableIndicatorMenu
514 model: Indicators.IndicatorsModel {
515 // tablet and phone both use the same profile
516 // FIXME: use just "phone" for greeter too, but first fix
517 // greeter app launching to either load the app inside the
518 // greeter or tell the session to load the app. This will
519 // involve taking the url-dispatcher dbus name and using
520 // SessionBroadcast to tell the session.
521 profile: shell.mode === "greeter" ? "desktop_greeter" : "phone"
522 Component.onCompleted: load();
523 }
524 }
526 applicationMenus {
527 hides: [launcher]
528 available: (!greeter || !greeter.shown)
529 && !shell.waitingOnGreeter
530 && !stage.spreadShown
531 }
533 readonly property bool focusedSurfaceIsFullscreen: topLevelSurfaceList.focusedWindow
534 ? topLevelSurfaceList.focusedWindow.state === Mir.FullscreenState
535 : false
536 fullscreenMode: (focusedSurfaceIsFullscreen && !LightDMService.greeter.active && launcher.progress == 0 && !stage.spreadShown)
537 || greeter.hasLockedApp
538 greeterShown: greeter && greeter.shown
539 hasKeyboard: shell.hasKeyboard
540 }
542 Launcher {
543 id: launcher
544 objectName: "launcher"
546 anchors.top: parent.top
547 anchors.topMargin: inverted ? 0 : panel.panelHeight
548 anchors.bottom: parent.bottom
549 width: parent.width
550 dragAreaWidth: shell.edgeSize
551 available: tutorial.launcherEnabled
552 && (!greeter.locked || AccountsService.enableLauncherWhileLocked)
553 && !greeter.hasLockedApp
554 && !shell.waitingOnGreeter
555 && settings.enableLauncher
556 inverted: shell.usageScenario !== "desktop"
557 superPressed: physicalKeysMapper.superPressed
558 superTabPressed: physicalKeysMapper.superTabPressed
559 panelWidth: units.gu(settings.launcherWidth)
560 lockedVisible: shell.usageScenario == "desktop" && !settings.autohideLauncher && !panel.fullscreenMode
561 blurSource: greeter.shown ? greeter : stages
562 topPanelHeight: panel.panelHeight
563 drawerEnabled: !greeter.active
565 onShowDashHome: showHome()
566 onLauncherApplicationSelected: {
567 greeter.notifyUserRequestedApp();
568 shell.activateApplication(appId);
569 }
570 onShownChanged: {
571 if (shown) {
572 panel.indicators.hide()
573 }
574 }
575 onFocusChanged: {
576 if (!focus) {
577 stage.focus = true;
578 }
579 }
581 GlobalShortcut {
582 shortcut: Qt.MetaModifier | Qt.Key_A
583 onTriggered: {
584 launcher.openDrawer(true);
585 }
586 }
587 GlobalShortcut {
588 shortcut: Qt.AltModifier | Qt.Key_F1
589 onTriggered: {
590 launcher.openForKeyboardNavigation();
591 }
592 }
593 GlobalShortcut {
594 shortcut: Qt.MetaModifier | Qt.Key_0
595 onTriggered: {
596 if (LauncherModel.get(9)) {
597 activateApplication(LauncherModel.get(9).appId);
598 }
599 }
600 }
601 Repeater {
602 model: 9
603 GlobalShortcut {
604 shortcut: Qt.MetaModifier | (Qt.Key_1 + index)
605 onTriggered: {
606 if (LauncherModel.get(index)) {
607 activateApplication(LauncherModel.get(index).appId);
608 }
609 }
610 }
611 }
612 }
614 KeyboardShortcutsOverlay {
615 objectName: "shortcutsOverlay"
616 enabled: launcher.shortcutHintsShown && width < parent.width - (launcher.lockedVisible ? launcher.panelWidth : 0) - padding
617 && height < parent.height - padding - panel.panelHeight
618 anchors.centerIn: parent
619 anchors.horizontalCenterOffset: launcher.lockedVisible ? launcher.panelWidth/2 : 0
620 anchors.verticalCenterOffset: panel.panelHeight/2
621 visible: opacity > 0
622 opacity: enabled ? 0.95 : 0
624 Behavior on opacity {
625 UbuntuNumberAnimation {}
626 }
627 }
629 Tutorial {
630 id: tutorial
631 objectName: "tutorial"
632 anchors.fill: parent
634 paused: callManager.hasCalls || !greeter || greeter.active || wizard.active
635 || !hasTouchscreen // TODO #1661557 something better for no touchscreen
636 delayed: dialogs.hasActiveDialog || notifications.hasNotification ||
637 inputMethod.visible ||
638 (launcher.shown && !launcher.lockedVisible) ||
639 panel.indicators.shown || stage.rightEdgeDragProgress > 0
640 usageScenario: shell.usageScenario
641 lastInputTimestamp: inputFilter.lastInputTimestamp
642 launcher: launcher
643 panel: panel
644 stage: stage
645 }
647 Wizard {
648 id: wizard
649 objectName: "wizard"
650 anchors.fill: parent
651 deferred: shell.mode === "greeter"
653 function unlockWhenDoneWithWizard() {
654 if (!active) {
655 Connectivity.unlockAllModems();
656 }
657 }
659 Component.onCompleted: unlockWhenDoneWithWizard()
660 onActiveChanged: unlockWhenDoneWithWizard()
661 }
663 MouseArea { // modal notifications prevent interacting with other contents
664 anchors.fill: parent
665 visible: notifications.useModal
666 enabled: visible
667 }
669 Notifications {
670 id: notifications
672 model: NotificationBackend.Model
673 margin: units.gu(1)
674 hasMouse: shell.hasMouse
675 background: wallpaperResolver.cachedBackground
677 y: topmostIsFullscreen ? 0 : panel.panelHeight
678 height: parent.height - (topmostIsFullscreen ? 0 : panel.panelHeight)
680 states: [
681 State {
682 name: "narrow"
683 when: overlay.width <= units.gu(60)
684 AnchorChanges {
685 target: notifications
686 anchors.left: parent.left
687 anchors.right: parent.right
688 }
689 },
690 State {
691 name: "wide"
692 when: overlay.width > units.gu(60)
693 AnchorChanges {
694 target: notifications
695 anchors.left: undefined
696 anchors.right: parent.right
697 }
698 PropertyChanges { target: notifications; width: units.gu(38) }
699 }
700 ]
701 }
703 EdgeBarrier {
704 id: rightEdgeBarrier
705 enabled: !greeter.shown
707 // NB: it does its own positioning according to the specified edge
708 edge: Qt.RightEdge
710 onPassed: {
711 panel.indicators.hide()
712 }
714 material: Component {
715 Item {
716 Rectangle {
717 width: parent.height
718 height: parent.width
719 rotation: 90
720 anchors.centerIn: parent
721 gradient: Gradient {
722 GradientStop { position: 0.0; color: Qt.rgba(0.16,0.16,0.16,0.5)}
723 GradientStop { position: 1.0; color: Qt.rgba(0.16,0.16,0.16,0)}
724 }
725 }
726 }
727 }
728 }
729 }
731 Dialogs {
732 id: dialogs
733 objectName: "dialogs"
734 anchors.fill: parent
735 visible: hasActiveDialog
736 z: overlay.z + 10
737 usageScenario: shell.usageScenario
738 hasKeyboard: shell.hasKeyboard
739 onPowerOffClicked: {
740 shutdownFadeOutRectangle.enabled = true;
741 shutdownFadeOutRectangle.visible = true;
742 shutdownFadeOut.start();
743 }
744 }
746 Connections {
747 target: SessionBroadcast
748 onShowHome: if (shell.mode !== "greeter") showHome()
749 }
751 URLDispatcher {
752 id: urlDispatcher
753 objectName: "urlDispatcher"
754 active: shell.mode === "greeter"
755 onUrlRequested: shell.activateURL(url)
756 }
758 ItemGrabber {
759 id: itemGrabber
760 anchors.fill: parent
761 z: dialogs.z + 10
762 GlobalShortcut { shortcut: Qt.Key_Print; onTriggered: itemGrabber.capture(shell) }
763 Connections {
764 target: stage
765 ignoreUnknownSignals: true
766 onItemSnapshotRequested: itemGrabber.capture(item)
767 }
768 }
770 Timer {
771 id: cursorHidingTimer
772 interval: 3000
773 running: panel.focusedSurfaceIsFullscreen && cursor.opacity > 0
774 onTriggered: cursor.opacity = 0;
775 }
777 Cursor {
778 id: cursor
779 objectName: "cursor"
780 visible: shell.hasMouse
781 z: itemGrabber.z + 1
782 topBoundaryOffset: panel.panelHeight
784 confiningItem: stage.itemConfiningMouseCursor
786 property bool mouseNeverMoved: true
787 Binding {
788 target: cursor; property: "x"; value: shell.width / 2
789 when: cursor.mouseNeverMoved && cursor.visible
790 }
791 Binding {
792 target: cursor; property: "y"; value: shell.height / 2
793 when: cursor.mouseNeverMoved && cursor.visible
794 }
796 height: units.gu(3)
798 readonly property var previewRectangle: stage.previewRectangle.target &&
799 stage.previewRectangle.target.dragging ?
800 stage.previewRectangle : null
802 onPushedLeftBoundary: {
803 if (buttons === Qt.NoButton) {
804 launcher.pushEdge(amount);
805 } else if (buttons === Qt.LeftButton && previewRectangle && previewRectangle.target.canBeMaximizedLeftRight) {
806 previewRectangle.maximizeLeft(amount);
807 }
808 }
810 onPushedRightBoundary: {
811 if (buttons === Qt.NoButton) {
812 rightEdgeBarrier.push(amount);
813 } else if (buttons === Qt.LeftButton && previewRectangle && previewRectangle.target.canBeMaximizedLeftRight) {
814 previewRectangle.maximizeRight(amount);
815 }
816 }
818 onPushedTopBoundary: {
819 if (buttons === Qt.LeftButton && previewRectangle && previewRectangle.target.canBeMaximized) {
820 previewRectangle.maximize(amount);
821 }
822 }
823 onPushedTopLeftCorner: {
824 if (buttons === Qt.LeftButton && previewRectangle && previewRectangle.target.canBeCornerMaximized) {
825 previewRectangle.maximizeTopLeft(amount);
826 }
827 }
828 onPushedTopRightCorner: {
829 if (buttons === Qt.LeftButton && previewRectangle && previewRectangle.target.canBeCornerMaximized) {
830 previewRectangle.maximizeTopRight(amount);
831 }
832 }
833 onPushedBottomLeftCorner: {
834 if (buttons === Qt.LeftButton && previewRectangle && previewRectangle.target.canBeCornerMaximized) {
835 previewRectangle.maximizeBottomLeft(amount);
836 }
837 }
838 onPushedBottomRightCorner: {
839 if (buttons === Qt.LeftButton && previewRectangle && previewRectangle.target.canBeCornerMaximized) {
840 previewRectangle.maximizeBottomRight(amount);
841 }
842 }
843 onPushStopped: {
844 if (previewRectangle) {
845 previewRectangle.stop();
846 }
847 }
849 onMouseMoved: {
850 mouseNeverMoved = false;
851 cursor.opacity = 1;
852 }
854 Behavior on opacity { UbuntuNumberAnimation {} }
855 }
857 // non-visual objects
858 KeymapSwitcher {
859 focusedSurface: topLevelSurfaceList.focusedWindow ? topLevelSurfaceList.focusedWindow.surface : null
860 }
861 BrightnessControl {}
863 Rectangle {
864 id: shutdownFadeOutRectangle
865 z: cursor.z + 1
866 enabled: false
867 visible: false
868 color: "black"
869 anchors.fill: parent
870 opacity: 0.0
871 NumberAnimation on opacity {
872 id: shutdownFadeOut
873 from: 0.0
874 to: 1.0
875 onStopped: {
876 if (shutdownFadeOutRectangle.enabled && shutdownFadeOutRectangle.visible) {
877 DBusUnitySessionService.shutdown();
878 }
879 }
880 }
881 }