on xenial help sign in
Hide the cursor for fullscreen apps after 3 seconds of inactivity
081add8Lukáš Tinkl
qml/Shell.qml+10
@@ -697,8 +697,16 @@ StyledItem {
697 }
697 }
698 }
698 }
699
699
700+ Timer {
701+ id: cursorHidingTimer
702+ interval: 3000
703+ running: panel.focusedSurfaceIsFullscreen && cursor.opacity > 0
704+ onTriggered: cursor.opacity = 0;
705+ }
706+
700 Cursor {
707 Cursor {
701 id: cursor
708 id: cursor
709+ objectName: "cursor"
702 visible: shell.hasMouse
710 visible: shell.hasMouse
703 z: itemGrabber.z + 1
711 z: itemGrabber.z + 1
704 topBoundaryOffset: panel.panelHeight
712 topBoundaryOffset: panel.panelHeight
@@ -772,6 +780,8 @@ StyledItem {
772 mouseNeverMoved = false;
780 mouseNeverMoved = false;
773 cursor.opacity = 1;
781 cursor.opacity = 1;
774 }
782 }
783+
784+ Behavior on opacity { UbuntuNumberAnimation {} }
775 }
785 }
776
786
777 // non-visual object
787 // non-visual object
tests/mocks/Cursor/Cursor.qml+2
@@ -29,4 +29,6 @@ Item {
29 signal pushedBottomRightCorner(real amount, int buttons)
29 signal pushedBottomRightCorner(real amount, int buttons)
30 signal pushStopped()
30 signal pushStopped()
31 signal mouseMoved()
31 signal mouseMoved()
32+
33+ onMouseMoved: opacity = 1;
32}
34}
tests/qmltests/tst_Shell.qml+28
@@ -2733,5 +2733,33 @@ Rectangle {
2733 tryCompare(dashAppDelegate, "y", initialY);
2733 tryCompare(dashAppDelegate, "y", initialY);
2734 SurfaceManager.inputMethodSurface.state = oldOSKState;
2734 SurfaceManager.inputMethodSurface.state = oldOSKState;
2735 }
2735 }
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+ }
2736 }
2764 }
2737}
2765}