on xenial help sign in
Small updates for DesktopState and its tests
commit09057337af77293c9df2c63c9437f85d1f3678ab authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateTue 5 Apr 2016, 17:14 (11 years ago) parent79466a9
2 files changed+28−10
qml/Stages/DesktopStage.qml+10−4 tests/qmltests/Stages/tst_DesktopStage.qml+18−6
qml/Stages/DesktopStage.qml+10−4
@@ -140,8 +140,6 @@ AbstractStage {
140140 appDelegate.minimize();
141141 }
142142 }
143−
144− root.applicationManager.unfocusCurrentApplication(); // no app should have focus at this point
145143 }
146144
147145 function focusNext() {
@@ -308,8 +306,15 @@ AbstractStage {
308306 }
309307
310308 onFocusChanged: {
311− if (focus && !appRepeater.startingUp) {
309+ if (appRepeater.startingUp)
310+ return;
311+
312+ if (focus) {
312313 priv.focusedAppDelegate = appDelegate;
314+ } else if (!focus && priv.focusedAppDelegate === appDelegate) {
315+ priv.focusedAppDelegate = null;
316+ // FIXME: No idea why the Binding{} doens't update when focusedAppDelegate turns null
317+ MirFocusController.focusedSurface = null;
313318 }
314319 }
315320 Component.onCompleted: {
@@ -412,7 +417,7 @@ AbstractStage {
412417
413418 states: [
414419 State {
415− name: "fullscreen"; when: decoratedWindow.fullscreen
420+ name: "fullscreen"; when: decoratedWindow.fullscreen && !appDelegate.minimized
416421 PropertyChanges {
417422 target: appDelegate;
418423 x: 0;
@@ -505,6 +510,7 @@ AbstractStage {
505510 ScriptAction {
506511 script: {
507512 if (appDelegate.minimized) {
513+ appDelegate.focus = false;
508514 priv.focusNext();
509515 }
510516 }
tests/qmltests/Stages/tst_DesktopStage.qml+18−6
@@ -381,7 +381,10 @@ Item {
381381 var dialerDelegate = startApplication("dialer-app");
382382 startApplication("camera-app");
383383
384− ApplicationManager.focusApplication("dialer-app");
384+ tryCompareFunction(function(){ return dialerDelegate.surface !== null; }, true);
385+ dialerDelegate.surface.requestFocus();
386+ tryCompare(dialerDelegate, "focus", true);
387+
385388 keyClick(Qt.Key_Up, Qt.MetaModifier|Qt.ControlModifier); // Ctrl+Super+Up shortcut to maximize
386389 tryCompare(dialerDelegate, "maximized", true);
387390 tryCompare(dialerDelegate, "minimized", false);
@@ -391,7 +394,10 @@ Item {
391394 var dialerDelegate = startApplication("dialer-app");
392395 startApplication("camera-app");
393396
394− ApplicationManager.focusApplication("dialer-app");
397+ tryCompareFunction(function(){ return dialerDelegate.surface !== null; }, true);
398+ dialerDelegate.surface.requestFocus();
399+ tryCompare(dialerDelegate, "focus", true);
400+
395401 keyClick(Qt.Key_Left, Qt.MetaModifier|Qt.ControlModifier); // Ctrl+Super+Left shortcut to maximizeLeft
396402 tryCompare(dialerDelegate, "maximized", false);
397403 tryCompare(dialerDelegate, "minimized", false);
@@ -403,7 +409,10 @@ Item {
403409 var dialerDelegate = startApplication("dialer-app");
404410 startApplication("camera-app");
405411
406− ApplicationManager.focusApplication("dialer-app");
412+ tryCompareFunction(function(){ return dialerDelegate.surface !== null; }, true);
413+ dialerDelegate.surface.requestFocus();
414+ tryCompare(dialerDelegate, "focus", true);
415+
407416 keyClick(Qt.Key_Right, Qt.MetaModifier|Qt.ControlModifier); // Ctrl+Super+Right shortcut to maximizeRight
408417 tryCompare(dialerDelegate, "maximized", false);
409418 tryCompare(dialerDelegate, "minimized", false);
@@ -415,7 +424,10 @@ Item {
415424 var dialerDelegate = startApplication("dialer-app");
416425 startApplication("camera-app");
417426
418− ApplicationManager.focusApplication("dialer-app");
427+ tryCompareFunction(function(){ return dialerDelegate.surface !== null; }, true);
428+ dialerDelegate.surface.requestFocus();
429+ tryCompare(dialerDelegate, "focus", true);
430+
419431 keyClick(Qt.Key_Down, Qt.MetaModifier|Qt.ControlModifier); // Ctrl+Super+Down shortcut to minimize
420432 tryCompare(dialerDelegate, "maximized", false);
421433 tryCompare(dialerDelegate, "minimized", true);
@@ -566,13 +578,13 @@ Item {
566578 tryCompare(facebookAppDelegate, "visible", true);
567579
568580 // Bring dash to front. make sure dash and the maximized facebook are visible, the restored one behind is hidden
569− ApplicationManager.focusApplication("unity8-dash");
581+ dashAppDelegate.focus = true;
570582 tryCompare(dashAppDelegate, "visible", true);
571583 tryCompare(dialerAppDelegate, "visible", false);
572584 tryCompare(facebookAppDelegate, "visible", true);
573585
574586 // Now focus the dialer app. all 3 should be visible again
575− ApplicationManager.focusApplication("dialer-app");
587+ dialerAppDelegate.focus = true;
576588 tryCompare(dashAppDelegate, "visible", true);
577589 tryCompare(dialerAppDelegate, "visible", true);
578590 tryCompare(facebookAppDelegate, "visible", true);