on xenial help sign in
Small updates for DesktopState and its tests
0905733Daniel d'Andrada
qml/Stages/DesktopStage.qml+10−4
@@ -140,8 +140,6 @@ AbstractStage {
140 appDelegate.minimize();
140 appDelegate.minimize();
141 }
141 }
142 }
142 }
143−
144− root.applicationManager.unfocusCurrentApplication(); // no app should have focus at this point
145 }
143 }
146
144
147 function focusNext() {
145 function focusNext() {
@@ -308,8 +306,15 @@ AbstractStage {
308 }
306 }
309
307
310 onFocusChanged: {
308 onFocusChanged: {
311− if (focus && !appRepeater.startingUp) {
309+ if (appRepeater.startingUp)
310+ return;
311+
312+ if (focus) {
312 priv.focusedAppDelegate = appDelegate;
313 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;
313 }
318 }
314 }
319 }
315 Component.onCompleted: {
320 Component.onCompleted: {
@@ -412,7 +417,7 @@ AbstractStage {
412
417
413 states: [
418 states: [
414 State {
419 State {
415− name: "fullscreen"; when: decoratedWindow.fullscreen
420+ name: "fullscreen"; when: decoratedWindow.fullscreen && !appDelegate.minimized
416 PropertyChanges {
421 PropertyChanges {
417 target: appDelegate;
422 target: appDelegate;
418 x: 0;
423 x: 0;
@@ -505,6 +510,7 @@ AbstractStage {
505 ScriptAction {
510 ScriptAction {
506 script: {
511 script: {
507 if (appDelegate.minimized) {
512 if (appDelegate.minimized) {
513+ appDelegate.focus = false;
508 priv.focusNext();
514 priv.focusNext();
509 }
515 }
510 }
516 }
tests/qmltests/Stages/tst_DesktopStage.qml+18−6
@@ -381,7 +381,10 @@ Item {
381 var dialerDelegate = startApplication("dialer-app");
381 var dialerDelegate = startApplication("dialer-app");
382 startApplication("camera-app");
382 startApplication("camera-app");
383
383
384− ApplicationManager.focusApplication("dialer-app");
384+ tryCompareFunction(function(){ return dialerDelegate.surface !== null; }, true);
385+ dialerDelegate.surface.requestFocus();
386+ tryCompare(dialerDelegate, "focus", true);
387+
385 keyClick(Qt.Key_Up, Qt.MetaModifier|Qt.ControlModifier); // Ctrl+Super+Up shortcut to maximize
388 keyClick(Qt.Key_Up, Qt.MetaModifier|Qt.ControlModifier); // Ctrl+Super+Up shortcut to maximize
386 tryCompare(dialerDelegate, "maximized", true);
389 tryCompare(dialerDelegate, "maximized", true);
387 tryCompare(dialerDelegate, "minimized", false);
390 tryCompare(dialerDelegate, "minimized", false);
@@ -391,7 +394,10 @@ Item {
391 var dialerDelegate = startApplication("dialer-app");
394 var dialerDelegate = startApplication("dialer-app");
392 startApplication("camera-app");
395 startApplication("camera-app");
393
396
394− ApplicationManager.focusApplication("dialer-app");
397+ tryCompareFunction(function(){ return dialerDelegate.surface !== null; }, true);
398+ dialerDelegate.surface.requestFocus();
399+ tryCompare(dialerDelegate, "focus", true);
400+
395 keyClick(Qt.Key_Left, Qt.MetaModifier|Qt.ControlModifier); // Ctrl+Super+Left shortcut to maximizeLeft
401 keyClick(Qt.Key_Left, Qt.MetaModifier|Qt.ControlModifier); // Ctrl+Super+Left shortcut to maximizeLeft
396 tryCompare(dialerDelegate, "maximized", false);
402 tryCompare(dialerDelegate, "maximized", false);
397 tryCompare(dialerDelegate, "minimized", false);
403 tryCompare(dialerDelegate, "minimized", false);
@@ -403,7 +409,10 @@ Item {
403 var dialerDelegate = startApplication("dialer-app");
409 var dialerDelegate = startApplication("dialer-app");
404 startApplication("camera-app");
410 startApplication("camera-app");
405
411
406− ApplicationManager.focusApplication("dialer-app");
412+ tryCompareFunction(function(){ return dialerDelegate.surface !== null; }, true);
413+ dialerDelegate.surface.requestFocus();
414+ tryCompare(dialerDelegate, "focus", true);
415+
407 keyClick(Qt.Key_Right, Qt.MetaModifier|Qt.ControlModifier); // Ctrl+Super+Right shortcut to maximizeRight
416 keyClick(Qt.Key_Right, Qt.MetaModifier|Qt.ControlModifier); // Ctrl+Super+Right shortcut to maximizeRight
408 tryCompare(dialerDelegate, "maximized", false);
417 tryCompare(dialerDelegate, "maximized", false);
409 tryCompare(dialerDelegate, "minimized", false);
418 tryCompare(dialerDelegate, "minimized", false);
@@ -415,7 +424,10 @@ Item {
415 var dialerDelegate = startApplication("dialer-app");
424 var dialerDelegate = startApplication("dialer-app");
416 startApplication("camera-app");
425 startApplication("camera-app");
417
426
418− ApplicationManager.focusApplication("dialer-app");
427+ tryCompareFunction(function(){ return dialerDelegate.surface !== null; }, true);
428+ dialerDelegate.surface.requestFocus();
429+ tryCompare(dialerDelegate, "focus", true);
430+
419 keyClick(Qt.Key_Down, Qt.MetaModifier|Qt.ControlModifier); // Ctrl+Super+Down shortcut to minimize
431 keyClick(Qt.Key_Down, Qt.MetaModifier|Qt.ControlModifier); // Ctrl+Super+Down shortcut to minimize
420 tryCompare(dialerDelegate, "maximized", false);
432 tryCompare(dialerDelegate, "maximized", false);
421 tryCompare(dialerDelegate, "minimized", true);
433 tryCompare(dialerDelegate, "minimized", true);
@@ -566,13 +578,13 @@ Item {
566 tryCompare(facebookAppDelegate, "visible", true);
578 tryCompare(facebookAppDelegate, "visible", true);
567
579
568 // Bring dash to front. make sure dash and the maximized facebook are visible, the restored one behind is hidden
580 // 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;
570 tryCompare(dashAppDelegate, "visible", true);
582 tryCompare(dashAppDelegate, "visible", true);
571 tryCompare(dialerAppDelegate, "visible", false);
583 tryCompare(dialerAppDelegate, "visible", false);
572 tryCompare(facebookAppDelegate, "visible", true);
584 tryCompare(facebookAppDelegate, "visible", true);
573
585
574 // Now focus the dialer app. all 3 should be visible again
586 // Now focus the dialer app. all 3 should be visible again
575− ApplicationManager.focusApplication("dialer-app");
587+ dialerAppDelegate.focus = true;
576 tryCompare(dashAppDelegate, "visible", true);
588 tryCompare(dashAppDelegate, "visible", true);
577 tryCompare(dialerAppDelegate, "visible", true);
589 tryCompare(dialerAppDelegate, "visible", true);
578 tryCompare(facebookAppDelegate, "visible", true);
590 tryCompare(facebookAppDelegate, "visible", true);