on xenial help sign in
simplify minimize/restore/restoreFrom maximized
1faa856Lukáš Tinkl
qml/Stage/Stage.qml+8−33
@@ -879,13 +879,7 @@ FocusScope {
879 } else if (model.window.state === Mir.MaximizedBottomRightState) {
879 } else if (model.window.state === Mir.MaximizedBottomRightState) {
880 appDelegate.maximizeBottomRight();
880 appDelegate.maximizeBottomRight();
881 } else if (model.window.state === Mir.RestoredState) {
881 } else if (model.window.state === Mir.RestoredState) {
882− if (decoratedWindow.dragging) {
883− appDelegate.restore(false, WindowStateStorage.WindowStateNormal);
882+ appDelegate.restore();
884− } else if (appDelegate.anyMaximized) {
885− appDelegate.restoreFromMaximized()
886− } else {
887− appDelegate.restore();
888− }
889 }
883 }
890 }
884 }
891 }
885 }
@@ -918,7 +912,6 @@ FocusScope {
918 if (visuallyMaximized) {
912 if (visuallyMaximized) {
919 priv.updateForegroundMaximizedApp();
913 priv.updateForegroundMaximizedApp();
920 }
914 }
921−
922 }
915 }
923
916
924 onVisuallyMaximizedChanged: priv.updateForegroundMaximizedApp()
917 onVisuallyMaximizedChanged: priv.updateForegroundMaximizedApp()
@@ -982,10 +975,6 @@ FocusScope {
982 animationsEnabled = (animated === undefined) || animated;
975 animationsEnabled = (animated === undefined) || animated;
983 windowState |= WindowStateStorage.WindowStateMinimized; // add the minimized bit
976 windowState |= WindowStateStorage.WindowStateMinimized; // add the minimized bit
984 }
977 }
985− function restoreFromMaximized(animated) {
986− animationsEnabled = (animated === undefined) || animated;
987− windowState = WindowStateStorage.WindowStateRestored;
988− }
989 function restore(animated,state) {
978 function restore(animated,state) {
990 animationsEnabled = (animated === undefined) || animated;
979 animationsEnabled = (animated === undefined) || animated;
991 windowState = state || WindowStateStorage.WindowStateRestored;
980 windowState = state || WindowStateStorage.WindowStateRestored;
@@ -1304,15 +1293,9 @@ FocusScope {
1304 windowedY: restoredY;
1293 windowedY: restoredY;
1305 }
1294 }
1306 },
1295 },
1307− State {
1308− name: "semiMaximized"
1309− PropertyChanges { target: touchControls; enabled: true }
1310− PropertyChanges { target: resizeArea; enabled: true }
1311− PropertyChanges { target: decoratedWindow; shadowOpacity: .3 }
1312− },
1313 State {
1296 State {
1314 name: "maximizedLeft"; when: appDelegate.maximizedLeft && !appDelegate.minimized
1297 name: "maximizedLeft"; when: appDelegate.maximizedLeft && !appDelegate.minimized
1315− extend: "semiMaximized"
1298+ extend: "restored"
1316 PropertyChanges {
1299 PropertyChanges {
1317 target: appDelegate
1300 target: appDelegate
1318 windowedX: root.leftMargin
1301 windowedX: root.leftMargin
@@ -1331,7 +1314,7 @@ FocusScope {
1331 },
1314 },
1332 State {
1315 State {
1333 name: "maximizedTopLeft"; when: appDelegate.maximizedTopLeft && !appDelegate.minimized
1316 name: "maximizedTopLeft"; when: appDelegate.maximizedTopLeft && !appDelegate.minimized
1334− extend: "semiMaximized"
1317+ extend: "restored"
1335 PropertyChanges {
1318 PropertyChanges {
1336 target: appDelegate
1319 target: appDelegate
1337 windowedX: root.leftMargin
1320 windowedX: root.leftMargin
@@ -1350,7 +1333,7 @@ FocusScope {
1350 },
1333 },
1351 State {
1334 State {
1352 name: "maximizedBottomLeft"; when: appDelegate.maximizedBottomLeft && !appDelegate.minimized
1335 name: "maximizedBottomLeft"; when: appDelegate.maximizedBottomLeft && !appDelegate.minimized
1353− extend: "semiMaximized"
1336+ extend: "restored"
1354 PropertyChanges {
1337 PropertyChanges {
1355 target: appDelegate
1338 target: appDelegate
1356 windowedX: root.leftMargin
1339 windowedX: root.leftMargin
@@ -1369,13 +1352,13 @@ FocusScope {
1369 },
1352 },
1370 State {
1353 State {
1371 name: "maximizedHorizontally"; when: appDelegate.maximizedHorizontally && !appDelegate.minimized
1354 name: "maximizedHorizontally"; when: appDelegate.maximizedHorizontally && !appDelegate.minimized
1372− extend: "semiMaximized"
1355+ extend: "restored"
1373 PropertyChanges { target: appDelegate; requestedX: root.leftMargin; requestedY: windowedY;
1356 PropertyChanges { target: appDelegate; requestedX: root.leftMargin; requestedY: windowedY;
1374 requestedWidth: appContainer.width - root.leftMargin; requestedHeight: appDelegate.windowedHeight }
1357 requestedWidth: appContainer.width - root.leftMargin; requestedHeight: appDelegate.windowedHeight }
1375 },
1358 },
1376 State {
1359 State {
1377 name: "maximizedVertically"; when: appDelegate.maximizedVertically && !appDelegate.minimized
1360 name: "maximizedVertically"; when: appDelegate.maximizedVertically && !appDelegate.minimized
1378− extend: "semiMaximized"
1361+ extend: "restored"
1379 PropertyChanges { target: appDelegate; requestedX: windowedX; requestedY: PanelState.panelHeight;
1362 PropertyChanges { target: appDelegate; requestedX: windowedX; requestedY: PanelState.panelHeight;
1380 requestedWidth: appDelegate.windowedWidth; requestedHeight: appContainer.height - PanelState.panelHeight }
1363 requestedWidth: appDelegate.windowedWidth; requestedHeight: appContainer.height - PanelState.panelHeight }
1381 },
1364 },
@@ -1403,14 +1386,6 @@ FocusScope {
1403 to: "staged,stagedWithSideStage"
1386 to: "staged,stagedWithSideStage"
1404 UbuntuNumberAnimation { target: appDelegate; properties: "x,y,requestedX,requestedY,requestedWidth,requestedHeight"; duration: priv.animationDuration}
1387 UbuntuNumberAnimation { target: appDelegate; properties: "x,y,requestedX,requestedY,requestedWidth,requestedHeight"; duration: priv.animationDuration}
1405 },
1388 },
1406− Transition {
1407− from: "maximized,maximizedHorizontally,maximizedVertically,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedBottomLeft,maximizedTopRight,maximizedBottomRight,minimized";
1408− to: "normal,restored"
1409− enabled: appDelegate.animationsEnabled
1410− PropertyAction { target: appDelegate; properties: "visuallyMinimized,visuallyMaximized" }
1411− UbuntuNumberAnimation { target: appDelegate; properties: "requestedX,requestedY,windowedX,windowedY,requestedWidth,requestedHeight,windowedWidth,windowedHeight,scale";
1412− duration: priv.animationDuration }
1413− },
1414 Transition {
1389 Transition {
1415 to: "minimized"
1390 to: "minimized"
1416 enabled: appDelegate.animationsEnabled
1391 enabled: appDelegate.animationsEnabled
@@ -1470,8 +1445,8 @@ FocusScope {
1470 },
1445 },
1471 Transition {
1446 Transition {
1472 id: windowedTransition
1447 id: windowedTransition
1473− from: "normal,restored,maximized,maximizedLeft,maximizedRight,maximizedTop,maximizedBottom,maximizedTopLeft,maximizedTopRight,maximizedBottomLeft,maximizedBottomRight,maximizedHorizontally,maximizedVertically,fullscreen"
1448+ from: ",normal,restored,maximized,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedTopRight,maximizedBottomLeft,maximizedBottomRight,maximizedHorizontally,maximizedVertically,fullscreen,minimized"
1474− to: "normal,restored,maximized,maximizedLeft,maximizedRight,maximizedTop,maximizedBottom,maximizedTopLeft,maximizedTopRight,maximizedBottomLeft,maximizedBottomRight,maximizedHorizontally,maximizedVertically,fullscreen"
1449+ to: ",normal,restored,maximized,maximizedLeft,maximizedRight,maximizedTopLeft,maximizedTopRight,maximizedBottomLeft,maximizedBottomRight,maximizedHorizontally,maximizedVertically,fullscreen"
1475 enabled: appDelegate.animationsEnabled
1450 enabled: appDelegate.animationsEnabled
1476 SequentialAnimation {
1451 SequentialAnimation {
1477 PropertyAction { target: appDelegate; property: "visuallyMinimized" }
1452 PropertyAction { target: appDelegate; property: "visuallyMinimized" }
tests/mocks/Unity/Application/MirSurface.h+4
@@ -141,6 +141,9 @@ public:
141
141
142 void setState(Mir::State state);
142 void setState(Mir::State state);
143
143
144+ Mir::State previousState() const { return m_previousState; }
145+ void setPreviousState(Mir::State state) { m_previousState = state; }
146+
144public Q_SLOTS:
147public Q_SLOTS:
145 ////
148 ////
146 // unity.shell.application.MirSurface
149 // unity.shell.application.MirSurface
@@ -174,6 +177,7 @@ private:
174 const QString m_name;
177 const QString m_name;
175 const Mir::Type m_type;
178 const Mir::Type m_type;
176 Mir::State m_state;
179 Mir::State m_state;
180+ Mir::State m_previousState{Mir::UnknownState};
177 Mir::OrientationAngle m_orientationAngle;
181 Mir::OrientationAngle m_orientationAngle;
178
182
179 QUrl m_screenshotUrl;
183 QUrl m_screenshotUrl;
tests/mocks/Unity/Application/SurfaceManager.cpp+7−4
@@ -164,9 +164,7 @@ void SurfaceManager::doRaise(unityapi::MirSurfaceInterface *apiSurface)
164 Q_ASSERT(index != -1);
164 Q_ASSERT(index != -1);
165 m_surfaces.move(index, 0);
165 m_surfaces.move(index, 0);
166
166
167− QVector<MirSurfaceInterface*> surfaces;
168− surfaces.append(surface);
169− Q_EMIT surfacesRaised(surfaces);
167+ Q_EMIT surfacesRaised({surface});
170}
168}
171
169
172void SurfaceManager::activate(unityapi::MirSurfaceInterface *apiSurface)
170void SurfaceManager::activate(unityapi::MirSurfaceInterface *apiSurface)
@@ -187,7 +185,11 @@ void SurfaceManager::activate(unityapi::MirSurfaceInterface *apiSurface)
187 }
185 }
188 if (surface) {
186 if (surface) {
189 if (surface->state() == Mir::HiddenState || surface->state() == Mir::MinimizedState) {
187 if (surface->state() == Mir::HiddenState || surface->state() == Mir::MinimizedState) {
188+ if (surface->previousState() != Mir::UnknownState) {
189+ surface->setState(surface->previousState());
190+ } else {
190− surface->setState(Mir::RestoredState);
191+ surface->setState(Mir::RestoredState);
192+ }
191 }
193 }
192 surface->setFocused(true);
194 surface->setFocused(true);
193 doRaise(surface);
195 doRaise(surface);
@@ -206,6 +208,7 @@ void SurfaceManager::onStateRequested(MirSurface *surface, Mir::State state)
206 Q_EMIT modificationsStarted();
208 Q_EMIT modificationsStarted();
207 m_underModification = true;
209 m_underModification = true;
208
210
211+ surface->setPreviousState(surface->state());
209 surface->setState(state);
212 surface->setState(state);
210
213
211 if ((state == Mir::MinimizedState || state == Mir::HiddenState) && surface->focused()) {
214 if ((state == Mir::MinimizedState || state == Mir::HiddenState) && surface->focused()) {