Merge lp:~mzanetti/unity8/fix-focus-on-app-launch into lp:unity8

Proposed by Michael Zanetti
Status: Needs review
Proposed branch: lp:~mzanetti/unity8/fix-focus-on-app-launch
Merge into: lp:unity8
Diff against target: 56 lines (+16/-1)
3 files modified
qml/Launcher/Launcher.qml (+1/-1)
qml/Shell.qml (+1/-0)
tests/qmltests/tst_Shell.qml (+14/-0)
To merge this branch: bzr merge lp:~mzanetti/unity8/fix-focus-on-app-launch
Reviewer Review Type Date Requested Status
Unity8 CI Bot continuous-integration Needs Fixing
Unity Team Pending
Review via email: mp+321868@code.launchpad.net

Commit message

properly put focus back on stage after launching something from the drawer

Description of the change

 * Are there any related MPs required for this MP to build/function as expected? Please list.
no
 * Did you perform an exploratory manual test run of your code change and any related functionality?
yes
 * If you changed the UI, has there been a design review?
n/a

To post a comment you must log in.
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

FAILED: Continuous integration, rev:2914
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/3666/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/4867
    UNSTABLE: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=qmluitests.sh/2982
    UNSTABLE: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=zesty,testname=qmluitests.sh/2982
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/4895
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/4706
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/4706/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/4706
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/4706/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/4706
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/4706/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/4706
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/4706/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/4706
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/4706/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/4706
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/4706/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/3666/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

"""
root.focus = false;
"""

This looks redundant. I think code should be caring about whom to give focus to, not in explicitly unfocusing the item that's losing it as this is the side-effect of focusing someone else anyway. Is that really needed?

--------------------------------

"""
stage.focus = true;
"""

In some other focus-related branch you have the Stage focusing itself on its own accord. Would be good to consolidate that responsibility in Shell if feasible to avoid clashes. Ideally I think Shell logic should be the one deciding which Shell immediate child will get focus at any given time.

Revision history for this message
Michael Zanetti (mzanetti) wrote :

> """
> root.focus = false;
> """
>
> This looks redundant. I think code should be caring about whom to give focus
> to, not in explicitly unfocusing the item that's losing it as this is the
> side-effect of focusing someone else anyway. Is that really needed?
>
> --------------------------------
>
> """
> stage.focus = true;
> """
>
> In some other focus-related branch you have the Stage focusing itself on its
> own accord. Would be good to consolidate that responsibility in Shell if
> feasible to avoid clashes. Ideally I think Shell logic should be the one
> deciding which Shell immediate child will get focus at any given time.

yeah, you're certainly having a point there... the current situation isn't nice... however, it's not that simple... sometimes some things need to be focused by a GlobalShortcut which is buried somewhere inside components, other times something deep down in a component trigger a focus change into another component... I'd love to rework this somehow and am thinking how to best solve it, but that's gonna be a bigger thing...

Revision history for this message
Michael Zanetti (mzanetti) wrote :

> """
> root.focus = false;
> """
>
> This looks redundant. I think code should be caring about whom to give focus
> to, not in explicitly unfocusing the item that's losing it as this is the
> side-effect of focusing someone else anyway. Is that really needed?

yes... I just moved it a bit from where it was before... currently the launcher works in a way that when it is closed it unfocuses itself and in shell we have:

Launcher { onFocusChanged: if (!focus) stage.focus = true }

so that's kinda ok for here... I do certainly agree that in general this needs to be consolidated in a way eventually.

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

On 04/04/2017 13:37, Michael Zanetti wrote:
>> """
>> root.focus = false;
>> """
>>
>> This looks redundant. I think code should be caring about whom to give focus
>> to, not in explicitly unfocusing the item that's losing it as this is the
>> side-effect of focusing someone else anyway. Is that really needed?
> yes... I just moved it a bit from where it was before... currently the launcher works in a way that when it is closed it unfocuses itself and in shell we have:
>
> Launcher { onFocusChanged: if (!focus) stage.focus = true }
>
> so that's kinda ok for here... I do certainly agree that in general this needs to be consolidated in a way eventually.

Maybe something like this would be a step in the right direction:

Launcher { onClosed: stage.focus = true }

Revision history for this message
Michael Zanetti (mzanetti) wrote :

On 04.04.2017 18:42, Daniel d'Andrada wrote:
> On 04/04/2017 13:37, Michael Zanetti wrote:
>>> """
>>> root.focus = false;
>>> """
>>>
>>> This looks redundant. I think code should be caring about whom to give focus
>>> to, not in explicitly unfocusing the item that's losing it as this is the
>>> side-effect of focusing someone else anyway. Is that really needed?
>> yes... I just moved it a bit from where it was before... currently the launcher works in a way that when it is closed it unfocuses itself and in shell we have:
>>
>> Launcher { onFocusChanged: if (!focus) stage.focus = true }
>>
>> so that's kinda ok for here... I do certainly agree that in general this needs to be consolidated in a way eventually.
>
> Maybe something like this would be a step in the right direction:
>
> Launcher { onClosed: stage.focus = true }
>
>

It doesn't necessarily only happen when closed... e.g. with alt+F1 you
focus it for keyboard navigation... when then you press esc the launcher
unfocuses itself and focus should go back to the stage even if the
launcher might not close because the setting says it should stay opened.

Unmerged revisions

2914. By Michael Zanetti

properly put focus back on stage after launching something from the drawer

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'qml/Launcher/Launcher.qml'
--- qml/Launcher/Launcher.qml 2017-03-21 10:54:59 +0000
+++ qml/Launcher/Launcher.qml 2017-04-04 14:29:06 +0000
@@ -128,6 +128,7 @@
128 } else {128 } else {
129 switchToNextState("")129 switchToNextState("")
130 }130 }
131 root.focus = false;
131 }132 }
132133
133 function fadeOut() {134 function fadeOut() {
@@ -229,7 +230,6 @@
229 root.hide();230 root.hide();
230 panel.highlightIndex = -2231 panel.highlightIndex = -2
231 event.accepted = true;232 event.accepted = true;
232 root.focus = false;
233 }233 }
234 }234 }
235235
236236
=== modified file 'qml/Shell.qml'
--- qml/Shell.qml 2017-03-24 14:04:50 +0000
+++ qml/Shell.qml 2017-04-04 14:29:06 +0000
@@ -174,6 +174,7 @@
174 } else {174 } else {
175 startApp(appId);175 startApp(appId);
176 }176 }
177 stage.focus = true;
177 }178 }
178179
179 function activateURL(url) {180 function activateURL(url) {
180181
=== modified file 'tests/qmltests/tst_Shell.qml'
--- tests/qmltests/tst_Shell.qml 2017-03-24 11:08:11 +0000
+++ tests/qmltests/tst_Shell.qml 2017-04-04 14:29:06 +0000
@@ -3170,6 +3170,20 @@
3170 tryCompare(menuBarLoader.item, "visible", true);3170 tryCompare(menuBarLoader.item, "visible", true);
3171 }3171 }
31723172
3173 function test_launchFromDrawerPutsFocusOnStage() {
3174 loadShell("desktop");
3175 shell.usageScenario = "desktop";
3176 waitForRendering(shell);
3177 swipeAwayGreeter();
3178
3179 keyClick(Qt.Key_A, Qt.MetaModifier);
3180 typeString("browser");
3181 keyClick(Qt.Key_Enter);
3182
3183 var appRepeater = findChild(shell, "appRepeater");
3184 tryCompare(appRepeater.itemAt(0), "activeFocus", true);
3185 }
3186
3173 function test_maximizedWindowAndMenuInPanel() {3187 function test_maximizedWindowAndMenuInPanel() {
3174 loadShell("desktop");3188 loadShell("desktop");
3175 shell.usageScenario = "desktop";3189 shell.usageScenario = "desktop";

Subscribers

People subscribed via source and target branches