Merge lp:~mzanetti/unity8/cancel-alt-instead-of-delay into lp:unity8

Proposed by Michael Zanetti
Status: Merged
Approved by: Lukáš Tinkl
Approved revision: 2442
Merged at revision: 2479
Proposed branch: lp:~mzanetti/unity8/cancel-alt-instead-of-delay
Merge into: lp:unity8
Diff against target: 120 lines (+15/-44)
2 files modified
qml/Components/PhysicalKeysMapper.qml (+2/-22)
tests/qmltests/Components/tst_PhysicalKeysMapper.qml (+13/-22)
To merge this branch: bzr merge lp:~mzanetti/unity8/cancel-alt-instead-of-delay
Reviewer Review Type Date Requested Status
Unity8 CI Bot continuous-integration Needs Fixing
Lukáš Tinkl (community) Approve
Review via email: mp+296818@code.launchpad.net

Commit message

send a Alt-release event on alt+tab instead of delaying it completely and invoking it later

Description of the change

 * Are there any related MPs required for this MP to build/function as expected? Please list.

nope

 * Did you perform an exploratory manual test run of your code change and any related functionality?

yip yip

 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?

nope

 * If you changed the UI, has there been a design review?

nope

To post a comment you must log in.
Revision history for this message
Lukáš Tinkl (lukas-kde) wrote :

Yup, AltGr works \o/

* Did you perform an exploratory manual test run of the code change and any related functionality?

Yes

* Did CI run pass? If not, please explain why.

Not yet, will wait for it to top approve

review: Approve
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

FAILED: Continuous integration, rev:2442
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/1444/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/1921
    UNSTABLE: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=vivid+overlay,testname=qmluitests.sh/983
    UNSTABLE: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=qmluitests.sh/983
    UNSTABLE: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=yakkety,testname=qmluitests.sh/983
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/1947
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/1883
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/1883
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/1883
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1874
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1874/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1874
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1874/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/1874
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/1874/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1874
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1874/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1874
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1874/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/1874
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/1874/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/1874
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/1874/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/1874
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/1874/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/1874
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/1874/artifact/output/*zip*/output.zip

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

review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'qml/Components/PhysicalKeysMapper.qml'
2--- qml/Components/PhysicalKeysMapper.qml 2016-02-02 15:21:44 +0000
3+++ qml/Components/PhysicalKeysMapper.qml 2016-06-08 16:25:15 +0000
4@@ -66,11 +66,6 @@
5 property bool superTabPressed: false
6
7 property var powerButtonPressStart: 0
8-
9- // We need to eat ALT presses until we know what they're for (Alt+Tab or going to the app?)
10- // Once we know if an ALT keypress is for the app, we need to re-inject the pressed event for it
11- // but we must only do that once.
12- property bool altPressInjected: false
13 }
14
15 InputEventGenerator {
16@@ -78,12 +73,6 @@
17 }
18
19 function onKeyPressed(event, currentEventTimestamp) {
20- if (d.altPressed && !d.altTabPressed && event.key !== Qt.Key_Tab && event.key !== Qt.Key_Alt && !d.altPressInjected) {
21- // ALT is pressed and another key that is not Tab has been received. Re-inject the alt pressed event
22- d.altPressInjected = true;
23- inputEventGenerator.generateKeyEvent(Qt.Key_Alt, true, Qt.NoModifier, currentEventTimestamp - 1, 56);
24- }
25-
26 if (event.key == Qt.Key_PowerDown || event.key == Qt.Key_PowerOff) {
27 if (event.isAutoRepeat) {
28 if (d.powerButtonPressStart > 0
29@@ -119,12 +108,7 @@
30 d.volumeUpKeyPressed = true;
31 }
32 } else if (event.key == Qt.Key_Alt || (root.controlInsteadOfAlt && event.key == Qt.Key_Control)) {
33- if (!d.altPressed || event.isAutoRepeat) {
34- // Only eat it if it's the first time we receive alt pressed (or if it's the autorepeat of the first press)
35- d.altPressed = true;
36- event.accepted = true;
37- d.altPressInjected = false;
38- }
39+ d.altPressed = true;
40
41 // Adding MetaModifier here because that's what keyboards do. Pressing Super_L actually gives
42 // Super_L + MetaModifier. This helps to make sure we only invoke superPressed if no other
43@@ -135,6 +119,7 @@
44 d.superPressed = true;
45 } else if (event.key == Qt.Key_Tab) {
46 if (d.altPressed && !d.altTabPressed) {
47+ inputEventGenerator.generateKeyEvent(Qt.Key_Alt, false, Qt.NoModifier, currentEventTimestamp, 56);
48 d.altTabPressed = true;
49 event.accepted = true;
50 }
51@@ -161,11 +146,6 @@
52 if (d.altTabPressed) {
53 d.altTabPressed = false;
54 event.accepted = true;
55- } else if (d.altPressed && !d.altPressInjected) {
56- // Alt was released but nothing else. Let's inject a pressed event and also forward the release.
57- d.altPressInjected = true;
58- inputEventGenerator.generateKeyEvent(Qt.Key_Alt, true, Qt.AltModifer, currentEventTimestamp, 56);
59- d.altPressInjected = false;
60 }
61 d.altPressed = false;
62 } else if (event.key == Qt.Key_Tab) {
63
64=== modified file 'tests/qmltests/Components/tst_PhysicalKeysMapper.qml'
65--- tests/qmltests/Components/tst_PhysicalKeysMapper.qml 2016-03-29 03:47:39 +0000
66+++ tests/qmltests/Components/tst_PhysicalKeysMapper.qml 2016-06-08 16:25:15 +0000
67@@ -134,40 +134,31 @@
68 compare(screenshotSpy.count, 1);
69 }
70
71- function test_altIsDispatchedOnRelease() {
72- // Press alt, make sure it does *not* end up in inputCatcher (aka, the focused app)
73+ function test_altIsCancelledOnAltTab() {
74+ // Press alt, make sure it does end up in inputCatcher (aka, the focused app)
75+ inputCatcher.pressedKeys = [];
76 keyPress(Qt.Key_Alt, Qt.NoModifier)
77- compare(inputCatcher.pressedKeys.length, 0);
78- // Now release alt. It should cause the previous Alt press to be dispatched along with the release
79- keyRelease(Qt.Key_Alt, Qt.NoModifier);
80 compare(inputCatcher.pressedKeys.length, 1);
81 compare(inputCatcher.pressedKeys[0], Qt.Key_Alt);
82+ // Now also press tab. As this should trigger the spread, alt needs to be released for the app
83+ keyPress(Qt.Key_Tab, Qt.NoModifier)
84 compare(inputCatcher.releasedKeys.length, 1);
85 compare(inputCatcher.releasedKeys[0], Qt.Key_Alt);
86- }
87-
88- function test_altIsNotDispatchedOnAltTab() {
89- // Press alt, make sure it does *not* end up in inputCatcher (aka, the focused app)
90- inputCatcher.pressedKeys = [];
91- keyPress(Qt.Key_Alt, Qt.NoModifier)
92- compare(inputCatcher.pressedKeys.length, 0);
93- // Now also press tab. As this should trigger the spread, neither of them should end up in the app
94- keyPress(Qt.Key_Tab, Qt.NoModifier)
95- compare(inputCatcher.pressedKeys.length, 0);
96-
97- // Also the release events should not be dispatched to the app
98+
99+ // Now release the keys, none of that should get to the app any more
100 keyRelease(Qt.Key_Tab, Qt.NoModifier);
101 keyRelease(Qt.Key_Alt, Qt.NoModifier);
102- compare(inputCatcher.pressedKeys.length, 0);
103- compare(inputCatcher.releasedKeys.length, 0);
104+ compare(inputCatcher.pressedKeys.length, 1);
105+ compare(inputCatcher.releasedKeys.length, 1);
106 }
107
108 function test_altComboIsDispatched() {
109 inputCatcher.pressedKeys = [];
110- // Press alt, make sure it does *not* yet end up in inputCatcher (aka, the focused app)
111+ // Press alt, make sure it does end up in inputCatcher (aka, the focused app)
112 keyPress(Qt.Key_Alt, Qt.NoModifier)
113- compare(inputCatcher.pressedKeys.length, 0);
114- // Now press F in order to opening the File menu (Alt+F), now the app should get the full combo
115+ compare(inputCatcher.pressedKeys.length, 1);
116+ compare(inputCatcher.pressedKeys[0], Qt.Key_Alt);
117+ // Now press F in order to opening the File menu (Alt+F), make sure it is dispatched too
118 keyPress(Qt.Key_F, Qt.NoModifier)
119 compare(inputCatcher.pressedKeys.length, 2);
120 compare(inputCatcher.pressedKeys[0], Qt.Key_Alt);

Subscribers

People subscribed via source and target branches