~josharenson/unity8/fix-greeter-password-focus

« back to all changes in this revision

Viewing changes to qml/Shell.qml

  • Committer: Josh Arenson
  • Date: 2016-03-25 19:54:02 UTC
  • mfrom: (1979.1.9 session-chooser-gui)
  • Revision ID: joshua.arenson@canonical.com-20160325195402-867v3w2zvmjj0kq3
merge prereq

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
import Ubuntu.Telephony 0.1 as Telephony
25
25
import Unity.Connectivity 0.1
26
26
import Unity.Launcher 0.1
27
 
import GlobalShortcut 1.0 // has to be before Utils, because of WindowKeysFilter
 
27
import GlobalShortcut 1.0 // has to be before Utils, because of WindowInputFilter
28
28
import GSettings 1.0
29
29
import Utils 0.1
30
30
import Powerd 0.1
102
102
    // internal props from here onwards
103
103
    readonly property var mainApp:
104
104
            applicationsDisplayLoader.item ? applicationsDisplayLoader.item.mainApp : null
 
105
    readonly property var mainAppWindow:
 
106
            applicationsDisplayLoader.item ? applicationsDisplayLoader.item.mainAppWindow : null
105
107
 
106
108
    // Disable everything while greeter is waiting, so that the user can't swipe
107
109
    // the greeter or launcher until we know whether the session is locked.
120
122
        if (ApplicationManager.findApplication(appId)) {
121
123
            ApplicationManager.requestFocusApplication(appId);
122
124
        } else {
123
 
            var execFlags = shell.usageScenario === "phone" ? ApplicationManager.ForceMainStage
124
 
                                                            : ApplicationManager.NoFlag;
125
 
            ApplicationManager.startApplication(appId, execFlags);
 
125
            ApplicationManager.startApplication(appId);
126
126
        }
127
127
    }
128
128
 
168
168
    }
169
169
 
170
170
    GlobalShortcut {
171
 
        // dummy shortcut to force creation of GlobalShortcutRegistry before WindowKeyFilter
 
171
        // dummy shortcut to force creation of GlobalShortcutRegistry before WindowInputFilter
172
172
    }
173
173
 
174
 
    WindowKeysFilter {
175
 
        Keys.onPressed: physicalKeysMapper.onKeyPressed(event, currentEventTimestamp);
176
 
        Keys.onReleased: physicalKeysMapper.onKeyReleased(event, currentEventTimestamp);
 
174
    WindowInputFilter {
 
175
        id: inputFilter
 
176
        Keys.onPressed: physicalKeysMapper.onKeyPressed(event, lastInputTimestamp);
 
177
        Keys.onReleased: physicalKeysMapper.onKeyReleased(event, lastInputTimestamp);
177
178
    }
178
179
 
179
180
    WindowInputMonitor {
206
207
            onFocusedApplicationIdChanged: {
207
208
                var appId = ApplicationManager.focusedApplicationId;
208
209
 
209
 
                if (tutorial.running && appId != "" && appId != "unity8-dash") {
 
210
                if (wizard.active && appId != "" && appId != "unity8-dash") {
210
211
                    // If this happens on first boot, we may be in edge
211
212
                    // tutorial or wizard while receiving a call.  But a call
212
213
                    // is more important than wizard so just bail out of those.
247
248
            property string usageScenario: shell.usageScenario === "phone" || greeter.hasLockedApp
248
249
                                           ? "phone"
249
250
                                           : shell.usageScenario
250
 
            source: {
 
251
            readonly property string qmlComponent: {
251
252
                if(shell.mode === "greeter") {
252
253
                    return "Stages/ShimStage.qml"
253
254
                } else if (applicationsDisplayLoader.usageScenario === "phone") {
258
259
                    return "Stages/DesktopStage.qml";
259
260
                }
260
261
            }
 
262
            onQmlComponentChanged: {
 
263
                if (item) item.stageAboutToBeUnloaded();
 
264
                source = qmlComponent;
 
265
            }
261
266
 
262
 
            property bool interactive: tutorial.spreadEnabled
263
 
                    && (!greeter || !greeter.shown)
 
267
            property bool interactive: (!greeter || !greeter.shown)
264
268
                    && panel.indicators.fullyClosed
265
269
                    && launcher.progress == 0
266
270
                    && !notifications.useModal
355
359
            }
356
360
        }
357
361
 
358
 
        Tutorial {
359
 
            id: tutorial
360
 
            objectName: "tutorial"
361
 
            anchors.fill: parent
362
 
 
363
 
            // EdgeDragAreas don't work with mice.  So to avoid trapping the user,
364
 
            // we skip the tutorial on the Desktop to avoid using them.  The
365
 
            // Desktop doesn't use the same spread design anyway.  The tutorial is
366
 
            // all a bit of a placeholder on non-phone form factors right now.
367
 
            // When the design team gives us more guidance, we can do something
368
 
            // more clever here.
369
 
            active: usageScenario != "desktop" && AccountsService.demoEdges
370
 
 
371
 
            paused: LightDMService.greeter.active
372
 
            launcher: launcher
373
 
            panel: panel
374
 
            edgeSize: shell.edgeSize
375
 
 
376
 
            onFinished: {
377
 
                AccountsService.demoEdges = false;
378
 
                active = false; // for immediate response / if AS is having problems
379
 
            }
380
 
        }
381
 
    }
382
 
 
383
362
    InputMethod {
384
363
        id: inputMethod
385
364
        objectName: "inputMethod"
388
367
            topMargin: panel.panelHeight
389
368
            leftMargin: launcher.lockedVisible ? launcher.panelWidth : 0
390
369
        }
391
 
        z: notifications.useModal || panel.indicators.shown || wizard.active ? overlay.z + 1 : overlay.z - 1
 
370
        z: notifications.useModal || panel.indicators.shown || wizard.active || tutorial.running ? overlay.z + 1 : overlay.z - 1
392
371
    }
393
372
 
394
373
    Connections {
419
398
            hides: [launcher, panel.indicators]
420
399
            tabletMode: shell.usageScenario != "phone"
421
400
            launcherOffset: launcher.progress
422
 
            forcedUnlock: tutorial.running
 
401
            forcedUnlock: wizard.active
423
402
            background: wallpaperResolver.background
424
403
 
425
404
            // avoid overlapping with Launcher's edge drag area
476
455
 
477
456
        onStatusChanged: {
478
457
            if (Powerd.status === Powerd.Off && reason !== Powerd.Proximity &&
479
 
                    !callManager.hasCalls && !tutorial.running) {
 
458
                    !callManager.hasCalls && !wizard.active) {
480
459
                // We don't want to simply call greeter.showNow() here, because
481
460
                // that will take too long.  Qt will delay button event
482
461
                // handling until the greeter is done loading and may think the
492
471
    }
493
472
 
494
473
    function showHome() {
495
 
        if (tutorial.running) {
496
 
            return
497
 
        }
498
 
 
499
474
        greeter.notifyAboutToFocusApp("unity8-dash");
500
475
 
501
476
        var animate = !LightDMService.greeter.active && !stages.shown
529
504
                available: tutorial.panelEnabled
530
505
                        && ((!greeter || !greeter.locked) || AccountsService.enableIndicatorsWhileLocked)
531
506
                        && (!greeter || !greeter.hasLockedApp)
532
 
                contentEnabled: tutorial.panelContentEnabled
533
507
                width: parent.width > units.gu(60) ? units.gu(40) : parent.width
534
508
 
535
509
                minimizedPanelHeight: units.gu(3)
546
520
                greeterShown: greeter.shown
547
521
            }
548
522
 
549
 
            readonly property bool topmostApplicationIsFullscreen:
550
 
                ApplicationManager.focusedApplicationId &&
551
 
                    ApplicationManager.findApplication(ApplicationManager.focusedApplicationId).fullscreen
 
523
            readonly property bool topmostApplicationIsFullscreen: mainApp && mainApp.fullscreen
552
524
 
553
525
            fullscreenMode: (topmostApplicationIsFullscreen && !LightDMService.greeter.active && launcher.progress == 0)
554
526
                            || greeter.hasLockedApp
570
542
                    && (!greeter.locked || AccountsService.enableLauncherWhileLocked)
571
543
                    && !greeter.hasLockedApp
572
544
            inverted: shell.usageScenario !== "desktop"
573
 
            shadeBackground: !tutorial.running
574
545
            superPressed: physicalKeysMapper.superPressed
575
546
            superTabPressed: physicalKeysMapper.superTabPressed
576
547
            panelWidth: units.gu(settings.launcherWidth)
584
555
                }
585
556
            }
586
557
            onLauncherApplicationSelected: {
587
 
                if (!tutorial.running) {
588
 
                    greeter.notifyAboutToFocusApp(appId);
589
 
                    shell.activateApplication(appId)
590
 
                }
 
558
                greeter.notifyAboutToFocusApp(appId);
 
559
                shell.activateApplication(appId);
591
560
            }
592
561
            onShownChanged: {
593
562
                if (shown) {
627
596
            }
628
597
        }
629
598
 
 
599
        Tutorial {
 
600
            id: tutorial
 
601
            objectName: "tutorial"
 
602
            anchors.fill: parent
 
603
 
 
604
            paused: callManager.hasCalls || greeter.shown
 
605
            keyboardVisible: inputMethod.state === "shown"
 
606
            usageScenario: shell.usageScenario
 
607
            lastInputTimestamp: inputFilter.lastInputTimestamp
 
608
            launcher: launcher
 
609
            panel: panel
 
610
            stage: applicationsDisplayLoader.item
 
611
        }
 
612
 
630
613
        Wizard {
631
614
            id: wizard
632
615
            objectName: "wizard"
738
721
        onMouseMoved: { cursor.opacity = 1; }
739
722
    }
740
723
 
 
724
    // keymap switching
 
725
    GlobalShortcut {
 
726
        shortcut: Qt.MetaModifier|Qt.Key_Space
 
727
        onTriggered: keymapPriv.nextKeymap()
 
728
        active: keymapPriv.keymapCount > 1
 
729
    }
 
730
 
 
731
    GlobalShortcut {
 
732
        shortcut: Qt.MetaModifier|Qt.ShiftModifier|Qt.Key_Space
 
733
        onTriggered: keymapPriv.previousKeymap()
 
734
        active: keymapPriv.keymapCount > 1
 
735
    }
 
736
 
 
737
    QtObject {
 
738
        id: keymapPriv
 
739
 
 
740
        readonly property var keymaps: AccountsService.keymaps
 
741
        readonly property int keymapCount: keymaps.length
 
742
        property int currentKeymapIndex: 0  // the new one that we're setting
 
743
        onCurrentKeymapIndexChanged: switchToKeymap();
 
744
 
 
745
        function nextKeymap() {
 
746
            var nextIndex = 0;
 
747
 
 
748
            if (currentKeymapIndex !== -1 && currentKeymapIndex < keymapCount - 1) {
 
749
                nextIndex = currentKeymapIndex + 1;
 
750
            }
 
751
            currentKeymapIndex = nextIndex;
 
752
        }
 
753
 
 
754
        function previousKeymap() {
 
755
            var prevIndex = keymapCount - 1;
 
756
 
 
757
            if (currentKeymapIndex > 0) {
 
758
                prevIndex = currentKeymapIndex - 1;
 
759
            }
 
760
            currentKeymapIndex = prevIndex;
 
761
        }
 
762
 
 
763
        function switchToKeymap() {
 
764
            if (mainAppWindow) {
 
765
                mainAppWindow.switchToKeymap(keymaps[currentKeymapIndex]);
 
766
            }
 
767
        }
 
768
    }
 
769
 
 
770
    onMainAppWindowChanged: keymapPriv.switchToKeymap()
 
771
 
741
772
    Rectangle {
742
773
        id: shutdownFadeOutRectangle
743
774
        z: cursor.z + 1