on xenial help sign in
Hide the cursor for fullscreen apps after 3 seconds of inactivity

Approved by: Albert Astals Cid

commit081add87098ad7bf0a5ff3337790c2c661fd8219 authorLukáš Tinkl <lukas.tinkl@canonical.com> dateMon 24 Oct 2016, 11:34 (10 years ago) parent89ff34e747bcf1
3 files changed+40
qml/Shell.qml+10 tests/mocks/Cursor/Cursor.qml+2 tests/qmltests/tst_Shell.qml+28
qml/Shell.qml+10
@@ -697,8 +697,16 @@ StyledItem {
697697 }
698698 }
699699
700+ Timer {
701+ id: cursorHidingTimer
702+ interval: 3000
703+ running: panel.focusedSurfaceIsFullscreen && cursor.opacity > 0
704+ onTriggered: cursor.opacity = 0;
705+ }
706+
700707 Cursor {
701708 id: cursor
709+ objectName: "cursor"
702710 visible: shell.hasMouse
703711 z: itemGrabber.z + 1
704712 topBoundaryOffset: panel.panelHeight
@@ -772,6 +780,8 @@ StyledItem {
772780 mouseNeverMoved = false;
773781 cursor.opacity = 1;
774782 }
783+
784+ Behavior on opacity { UbuntuNumberAnimation {} }
775785 }
776786
777787 // non-visual object
tests/mocks/Cursor/Cursor.qml+2
@@ -29,4 +29,6 @@ Item {
2929 signal pushedBottomRightCorner(real amount, int buttons)
3030 signal pushStopped()
3131 signal mouseMoved()
32+
33+ onMouseMoved: opacity = 1;
3234}
tests/qmltests/tst_Shell.qml+28
@@ -2733,5 +2733,33 @@ Rectangle {
27332733 tryCompare(dashAppDelegate, "y", initialY);
27342734 SurfaceManager.inputMethodSurface.state = oldOSKState;
27352735 }
2736+
2737+ function test_cursorHidingWithFullscreenApp() {
2738+ loadShell("desktop");
2739+ shell.usageScenario = "desktop";
2740+ waitForRendering(shell);
2741+ swipeAwayGreeter();
2742+
2743+ // load some fullscreen app
2744+ var cameraSurfaceId = topLevelSurfaceList.nextId;
2745+ var cameraApp = ApplicationManager.startApplication("camera-app");
2746+ waitUntilAppWindowIsFullyLoaded(cameraSurfaceId);
2747+
2748+ var cursor = findChild(shell, "cursor");
2749+ verify(cursor);
2750+ tryCompare(cursor, "opacity", 1);
2751+
2752+ // let the timer kick in and verify the cursor got hidden
2753+ wait(3000);
2754+ tryCompare(cursor, "opacity", 0);
2755+
2756+ // simulate moving the mouse, check the cursor is visible again
2757+ cursor.mouseMoved();
2758+ tryCompare(cursor, "opacity", 1);
2759+
2760+ // let the timer kick in again and verify the cursor got hidden
2761+ wait(3000);
2762+ tryCompare(cursor, "opacity", 0);
2763+ }
27362764 }
27372765}