~mterry/+junk/u8

« back to all changes in this revision

Viewing changes to qml/Components/PhysicalKeysMapper.qml

Merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
66
66
        property bool superTabPressed: false
67
67
 
68
68
        property var powerButtonPressStart: 0
69
 
 
70
 
        // We need to eat ALT presses until we know what they're for (Alt+Tab or going to the app?)
71
 
        // Once we know if an ALT keypress is for the app, we need to re-inject the pressed event for it
72
 
        // but we must only do that once.
73
 
        property bool altPressInjected: false
74
69
    }
75
70
 
76
71
    InputEventGenerator {
78
73
    }
79
74
 
80
75
    function onKeyPressed(event, currentEventTimestamp) {
81
 
        if (d.altPressed && !d.altTabPressed && event.key !== Qt.Key_Tab && event.key !== Qt.Key_Alt && !d.altPressInjected) {
82
 
            // ALT is pressed and another key that is not Tab has been received. Re-inject the alt pressed event
83
 
            d.altPressInjected = true;
84
 
            inputEventGenerator.generateKeyEvent(Qt.Key_Alt, true, Qt.NoModifier, currentEventTimestamp - 1, 56);
85
 
        }
86
 
 
87
76
        if (event.key == Qt.Key_PowerDown || event.key == Qt.Key_PowerOff) {
88
77
            if (event.isAutoRepeat) {
89
78
                if (d.powerButtonPressStart > 0
119
108
                d.volumeUpKeyPressed = true;
120
109
            }
121
110
        } else if (event.key == Qt.Key_Alt || (root.controlInsteadOfAlt && event.key == Qt.Key_Control)) {
122
 
            if (!d.altPressed || event.isAutoRepeat) {
123
 
                // Only eat it if it's the first time we receive alt pressed (or if it's the autorepeat of the first press)
124
 
                d.altPressed = true;
125
 
                event.accepted = true;
126
 
                d.altPressInjected = false;
127
 
            }
 
111
            d.altPressed = true;
128
112
 
129
113
        // Adding MetaModifier here because that's what keyboards do. Pressing Super_L actually gives
130
114
        // Super_L + MetaModifier. This helps to make sure we only invoke superPressed if no other
135
119
            d.superPressed = true;
136
120
        } else if (event.key == Qt.Key_Tab) {
137
121
            if (d.altPressed && !d.altTabPressed) {
 
122
                inputEventGenerator.generateKeyEvent(Qt.Key_Alt, false, Qt.NoModifier, currentEventTimestamp, 56);
138
123
                d.altTabPressed = true;
139
124
                event.accepted = true;
140
125
            }
161
146
            if (d.altTabPressed) {
162
147
                d.altTabPressed = false;
163
148
                event.accepted = true;
164
 
            } else if (d.altPressed && !d.altPressInjected) {
165
 
                // Alt was released but nothing else. Let's inject a pressed event and also forward the release.
166
 
                d.altPressInjected = true;
167
 
                inputEventGenerator.generateKeyEvent(Qt.Key_Alt, true, Qt.AltModifer, currentEventTimestamp, 56);
168
 
                d.altPressInjected = false;
169
149
            }
170
150
            d.altPressed = false;
171
151
        } else if (event.key == Qt.Key_Tab) {