on xenial help sign in
merge removeForceActiveFocus branch
b334b79Michael Zanetti
plugins/Utils/activefocuslogger.h−1
@@ -35,4 +35,3 @@ private:
35};
35};
36
36
37#endif // UNITY_ACTIVEFOCUSLOGGER_H
37#endif // UNITY_ACTIVEFOCUSLOGGER_H
38−
qml/Stages/DesktopSpread.qml+8−1
@@ -12,8 +12,15 @@ FocusScope {
12
12
13 readonly property alias highlightedIndex: spreadRepeater.highlightedIndex
13 readonly property alias highlightedIndex: spreadRepeater.highlightedIndex
14
14
15+ onFocusChanged: {
16+ // When the spread comes active, we want to keep focus to the input handler below
17+ // Make sure nothing inside the ApplicationWindow grabs our focus!
18+ if (focus) {
19+ forceActiveFocus();
20+ }
21+ }
22+
15 Keys.onPressed: {
23 Keys.onPressed: {
16− print("key pressed", event.key)
17 switch (event.key) {
24 switch (event.key) {
18 case Qt.Key_Left:
25 case Qt.Key_Left:
19 case Qt.Key_Backtab:
26 case Qt.Key_Backtab:
qml/Stages/DesktopStage.qml+14−3
@@ -70,7 +70,7 @@ Rectangle {
70 var appIndex = priv.indexOf(appId);
70 var appIndex = priv.indexOf(appId);
71 var appDelegate = appRepeater.itemAt(appIndex);
71 var appDelegate = appRepeater.itemAt(appIndex);
72 appDelegate.minimized = false;
72 appDelegate.minimized = false;
73− ApplicationManager.focusApplication(appId);
73+ appDelegate.focus = true;
74 }
74 }
75 }
75 }
76
76
@@ -145,7 +145,18 @@ Rectangle {
145 property bool maximized: false
145 property bool maximized: false
146 property bool minimized: false
146 property bool minimized: false
147
147
148− focus: priv.focusedAppId === model.appId && spread.state !== "altTab"
148+ onFocusChanged: {
149+ if (focus && ApplicationManager.focusedApplicationId !== model.appId) {
150+ ApplicationManager.focusApplication(model.appId);
151+ }
152+ }
153+
154+ Component.onCompleted: {
155+ // Focus the top-most or AppMan-focused application on start up.
156+ if (ApplicationManager.focusedApplicationId === model.appId && !focus) {
157+ focus = true;
158+ }
159+ }
149
160
150 Binding {
161 Binding {
151 target: ApplicationManager.get(index)
162 target: ApplicationManager.get(index)
@@ -220,7 +231,7 @@ Rectangle {
220 resizeHandleWidth: units.gu(2)
231 resizeHandleWidth: units.gu(2)
221 windowId: model.appId // FIXME: Change this to point to windowId once we have such a thing
232 windowId: model.appId // FIXME: Change this to point to windowId once we have such a thing
222
233
223− onPressed: ApplicationManager.focusApplication(model.appId);
234+ onPressed: { appDelegate.focus = true; }
224 }
235 }
225
236
226 DecoratedWindow {
237 DecoratedWindow {
tests/mocks/Unity/Application/MirSurfaceItem.cpp+15
@@ -161,6 +161,21 @@ void MirSurfaceItem::touchEvent(QTouchEvent * event)
161 }
161 }
162}
162}
163
163
164+void MirSurfaceItem::mousePressEvent(QMouseEvent * event)
165+{
166+ event->accept();
167+}
168+
169+void MirSurfaceItem::mouseMoveEvent(QMouseEvent * event)
170+{
171+ event->accept();
172+}
173+
174+void MirSurfaceItem::mouseReleaseEvent(QMouseEvent * event)
175+{
176+ event->accept();
177+}
178+
164void MirSurfaceItem::setSurface(MirSurfaceInterface* surface)
179void MirSurfaceItem::setSurface(MirSurfaceInterface* surface)
165{
180{
166 qDebug().nospace() << "MirSurfaceItem::setSurface() this=" << (void*)(this)
181 qDebug().nospace() << "MirSurfaceItem::setSurface() this=" << (void*)(this)
tests/mocks/Unity/Application/MirSurfaceItem.h+3
@@ -79,6 +79,9 @@ Q_SIGNALS:
79
79
80protected:
80protected:
81 void touchEvent(QTouchEvent * event) override;
81 void touchEvent(QTouchEvent * event) override;
82+ void mousePressEvent(QMouseEvent * event) override;
83+ void mouseMoveEvent(QMouseEvent * event) override;
84+ void mouseReleaseEvent(QMouseEvent * event) override;
82 void itemChange(ItemChange change, const ItemChangeData & value) override;
85 void itemChange(ItemChange change, const ItemChangeData & value) override;
83
86
84private Q_SLOTS:
87private Q_SLOTS:
tests/qmltests/Stages/tst_DesktopStage.qml+8−4
@@ -161,8 +161,8 @@ Item {
161
161
162 function test_tappingOnWindowChangesFocusedApp_data() {
162 function test_tappingOnWindowChangesFocusedApp_data() {
163 return [
163 return [
164− {tag: "dash", apps: [ "unity8-dash", "dialer-app", "camera-app" ], focusfrom: 0, focusTo: 1 },
164+ {tag: "dash to dialer", apps: [ "unity8-dash", "dialer-app", "camera-app" ], focusfrom: 0, focusTo: 1 },
165− {tag: "dash", apps: [ "unity8-dash", "dialer-app", "camera-app" ], focusfrom: 1, focusTo: 0 },
165+ {tag: "dialer to dash", apps: [ "unity8-dash", "dialer-app", "camera-app" ], focusfrom: 1, focusTo: 0 },
166 ]
166 ]
167 }
167 }
168
168
@@ -171,16 +171,20 @@ Item {
171 for (i = 0; i < data.apps.length; i++) {
171 for (i = 0; i < data.apps.length; i++) {
172 startApplication(data.apps[i]);
172 startApplication(data.apps[i]);
173 }
173 }
174+ var fromAppId = data.apps[data.focusfrom];
175+ var toAppId = data.apps[data.focusTo]
174
176
175− var fromAppWindow = findChild(desktopStage, "appWindow_" + data.apps[data.focusfrom]);
177+ var fromAppWindow = findChild(desktopStage, "appWindow_" + fromAppId);
176 verify(fromAppWindow);
178 verify(fromAppWindow);
177 tap(fromAppWindow);
179 tap(fromAppWindow);
178 compare(fromAppWindow.application.session.surface.activeFocus, true);
180 compare(fromAppWindow.application.session.surface.activeFocus, true);
181+ compare(ApplicationManager.focusedApplicationId, fromAppId);
179
182
180− var toAppWindow = findChild(desktopStage, "appWindow_" + data.apps[data.focusTo]);
183+ var toAppWindow = findChild(desktopStage, "appWindow_" + toAppId);
181 verify(toAppWindow);
184 verify(toAppWindow);
182 tap(toAppWindow);
185 tap(toAppWindow);
183 compare(toAppWindow.application.session.surface.activeFocus, true);
186 compare(toAppWindow.application.session.surface.activeFocus, true);
187+ compare(ApplicationManager.focusedApplicationId, toAppId);
184 }
188 }
185
189
186 function test_tappingOnDecorationFocusesApplication_data() {
190 function test_tappingOnDecorationFocusesApplication_data() {