on xenial help sign in
Fixes for activating minimized windows and restoring fullscreen ones (LP: #1656808, #1658937, #1658938)

Approved by: Michael Zanetti, Unity8 CI Bot

commit81465971c1f233955470a886bd0fff8dc3936713 authorLukáš Tinkl <lukas.tinkl@canonical.com> dateThu 16 Feb 2017, 13:43 (10 years ago) parent76d1e682559281
4 files changed+80−11
qml/Shell.qml+2−1 qml/Stage/Stage.qml+15−5 tests/mocks/Unity/Application/SurfaceManager.cpp+4−5 tests/qmltests/tst_Shell.qml+59
qml/Shell.qml+2−1
@@ -523,12 +523,13 @@ StyledItem {
523523 hides: [launcher]
524524 available: (!greeter || !greeter.shown)
525525 && !shell.waitingOnGreeter
526+ && !stage.spreadShown
526527 }
527528
528529 readonly property bool focusedSurfaceIsFullscreen: topLevelSurfaceList.focusedWindow
529530 ? topLevelSurfaceList.focusedWindow.state === Mir.FullscreenState
530531 : false
531− fullscreenMode: (focusedSurfaceIsFullscreen && !LightDMService.greeter.active && launcher.progress == 0)
532+ fullscreenMode: (focusedSurfaceIsFullscreen && !LightDMService.greeter.active && launcher.progress == 0 && !stage.spreadShown)
532533 || greeter.hasLockedApp
533534 greeterShown: greeter && greeter.shown
534535 }
qml/Stage/Stage.qml+15−5
@@ -101,6 +101,8 @@ FocusScope {
101101 // No we didn't, do a quick alt-tab
102102 if (appRepeater.count > 1) {
103103 appRepeater.itemAt(1).activate();
104+ } else if (appRepeater.count > 0) {
105+ appRepeater.itemAt(0).activate(); // quick alt-tab to the only (minimized) window should still activate it
104106 }
105107 }
106108 }
@@ -811,7 +813,7 @@ FocusScope {
811813 maximizedTopLeft || maximizedTopRight || maximizedBottomLeft || maximizedBottomRight
812814
813815 readonly property bool minimized: windowState & WindowStateStorage.WindowStateMinimized
814− readonly property bool fullscreen: window.state === Mir.FullscreenState
816+ readonly property bool fullscreen: windowState === WindowStateStorage.WindowStateFullscreen
815817
816818 readonly property bool canBeMaximized: canBeMaximizedHorizontally && canBeMaximizedVertically
817819 readonly property bool canBeMaximizedLeftRight: (maximumWidth == 0 || maximumWidth >= appContainer.width/2) &&
@@ -822,7 +824,10 @@ FocusScope {
822824 readonly property bool canBeMaximizedVertically: maximumHeight == 0 || maximumHeight >= appContainer.height
823825 readonly property alias orientationChangesEnabled: decoratedWindow.orientationChangesEnabled
824826
827+ // TODO drop our own windowType once Mir/Miral/Qtmir gets in sync with ours
825828 property int windowState: WindowStateStorage.WindowStateNormal
829+ property int prevWindowState: WindowStateStorage.WindowStateRestored
830+
826831 property bool animationsEnabled: true
827832 property alias title: decoratedWindow.title
828833 readonly property string appName: model.application ? model.application.name : ""
@@ -877,9 +882,6 @@ FocusScope {
877882 }
878883 priv.updateMainAndSideStageIndexes();
879884 }
880− if (root.mode == "windowed") {
881− appDelegate.restore(true /* animated */, appDelegate.windowState);
882− }
883885 appDelegate.focus = true;
884886 }
885887
@@ -929,7 +931,14 @@ FocusScope {
929931 } else if (model.window.state === Mir.MaximizedBottomRightState) {
930932 appDelegate.maximizeBottomRight();
931933 } else if (model.window.state === Mir.RestoredState) {
932− appDelegate.restore();
934+ if (appDelegate.fullscreen && appDelegate.prevWindowState != WindowStateStorage.WindowStateRestored) {
935+ model.window.requestState(WindowStateStorage.toMirState(appDelegate.prevWindowState));
936+ } else {
937+ appDelegate.restore();
938+ }
939+ } else if (model.window.state === Mir.FullscreenState) {
940+ appDelegate.prevWindowState = appDelegate.windowState;
941+ appDelegate.windowState = WindowStateStorage.WindowStateFullscreen;
933942 }
934943 }
935944 }
@@ -1031,6 +1040,7 @@ FocusScope {
10311040 animationsEnabled = (animated === undefined) || animated;
10321041 windowState = state || WindowStateStorage.WindowStateRestored;
10331042 windowState &= ~WindowStateStorage.WindowStateMinimized; // clear the minimized bit
1043+ prevWindowState = windowState;
10341044 }
10351045
10361046 function playFocusAnimation() {
tests/mocks/Unity/Application/SurfaceManager.cpp+4−5
@@ -211,8 +211,6 @@ void SurfaceManager::activate(unityapi::MirSurfaceInterface *apiSurface)
211211
212212void SurfaceManager::onStateRequested(MirSurface *surface, Mir::State state)
213213{
214− Q_ASSERT(!m_underModification);
215−
216214 DEBUG_MSG("("<<surface<<","<<state<<") started");
217215 Q_EMIT modificationsStarted();
218216 m_underModification = true;
@@ -266,9 +264,10 @@ void SurfaceManager::focusFirstAvailableSurface()
266264 if (m_focusedSurface) {
267265 m_focusedSurface->setFocused(false);
268266 }
269− if (chosenSurface) {
270− chosenSurface->setFocused(true);
271− }
267+
268+ chosenSurface->setFocused(true);
269+ doRaise(chosenSurface);
270+
272271 m_focusedSurface = chosenSurface;
273272}
274273
tests/qmltests/tst_Shell.qml+59
@@ -335,6 +335,8 @@ Rectangle {
335335 Row {
336336 CheckBox {
337337 id: fullscreeAppCheck
338+ activeFocusOnPress: false
339+ activeFocusOnTab: false
338340
339341 onTriggered: {
340342 if (!topLevelSurfaceList.focusedWindow) return;
@@ -2779,5 +2781,62 @@ Rectangle {
27792781 }
27802782 tryCompareFunction(function() { return drawer.visible; }, false);
27812783 }
2784+
2785+ function test_restoreFromFullscreen() {
2786+ loadShell("desktop");
2787+ shell.usageScenario = "desktop";
2788+ waitForRendering(shell);
2789+ swipeAwayGreeter();
2790+
2791+ var appSurfaceId = topLevelSurfaceList.nextId;
2792+ var app = ApplicationManager.startApplication("dialer-app")
2793+ waitUntilAppWindowIsFullyLoaded(appSurfaceId);
2794+
2795+ // start dialer
2796+ var appContainer = findChild(shell, "appContainer");
2797+ var appDelegate = findChild(appContainer, "appDelegate_" + appSurfaceId);
2798+ verify(appDelegate);
2799+ tryCompare(appDelegate, "state", "normal");
2800+
2801+ // now maximize to right
2802+ appDelegate.requestMaximizeRight();
2803+ tryCompare(appDelegate, "state", "maximizedRight");
2804+
2805+ // switch to fullscreen
2806+ app.surfaceList.get(0).requestState(Mir.FullscreenState);
2807+ tryCompare(appDelegate, "state", "fullscreen");
2808+
2809+ // restore, should go back to maximizedRight, not restored
2810+ appDelegate.requestRestore();
2811+ tryCompare(appDelegate, "state", "maximizedRight");
2812+ }
2813+
2814+ function test_altTabToMinimizedApp() {
2815+ loadShell("desktop");
2816+ shell.usageScenario = "desktop";
2817+ waitForRendering(shell);
2818+ swipeAwayGreeter();
2819+
2820+ var appSurfaceId = topLevelSurfaceList.nextId;
2821+ var app = ApplicationManager.startApplication("dialer-app")
2822+ waitUntilAppWindowIsFullyLoaded(appSurfaceId);
2823+
2824+ // start dialer
2825+ var appContainer = findChild(shell, "appContainer");
2826+ var appDelegate = findChild(appContainer, "appDelegate_" + appSurfaceId);
2827+ verify(appDelegate);
2828+ tryCompare(appDelegate, "state", "normal");
2829+
2830+ // minimize dialer
2831+ appDelegate.requestMinimize();
2832+ tryCompare(appDelegate, "state", "minimized");
2833+
2834+ // try to bring dialer back from minimized by doing alt-tab
2835+ keyClick(Qt.Key_Tab, Qt.AltModifier);
2836+ tryCompare(appDelegate, "visible", true);
2837+ tryCompare(appDelegate, "focus", true);
2838+ tryCompare(topLevelSurfaceList.focusedWindow, "surface", appDelegate.surface);
2839+ tryCompare(topLevelSurfaceList.applicationAt(0), "appId", "dialer-app");
2840+ }
27822841 }
27832842}