on xenial help sign in
a cleaner version of the focus race workaround
1e29d26Lukáš Tinkl
qml/Stages/DesktopStage.qml−14
@@ -280,20 +280,6 @@ AbstractStage {
280 source: root.background
280 source: root.background
281 }
281 }
282
282
283− Timer { // fix a race condition between TopLevelSurfaceRepeater and app (usually dash) starting up; set a focusedAppDelegate
284− running: !appRepeater.startingUp
285− interval: 1
286− onTriggered: {
287− for (var i = 0; i < appRepeater.count; i++) {
288− var appDelegate = appRepeater.itemAt(i);
289− if (appDelegate && appDelegate.focus) {
290− priv.focusedAppDelegate = appDelegate;
291− break;
292− }
293− }
294− }
295− }
296−
297 TopLevelSurfaceRepeater {
283 TopLevelSurfaceRepeater {
298 id: appRepeater
284 id: appRepeater
299 model: topLevelSurfaceList
285 model: topLevelSurfaceList
qml/Stages/TabletStage.qml−14
@@ -699,20 +699,6 @@ AbstractStage {
699 }
699 }
700 }
700 }
701
701
702− Timer { // fix a race condition between TopLevelSurfaceRepeater and app (usually dash) starting up; set a focusedAppDelegate
703− running: !spreadRepeater.startingUp
704− interval: 1
705− onTriggered: {
706− for (var i = 0; i < spreadRepeater.count; i++) {
707− var appDelegate = spreadRepeater.itemAt(i);
708− if (appDelegate && appDelegate.focus) {
709− priv.focusedAppDelegate = appDelegate;
710− break;
711− }
712− }
713− }
714− }
715−
716 TopLevelSurfaceRepeater {
702 TopLevelSurfaceRepeater {
717 id: spreadRepeater
703 id: spreadRepeater
718 objectName: "spreadRepeater"
704 objectName: "spreadRepeater"
qml/Stages/TopLevelSurfaceRepeater.qml+7−1
@@ -27,7 +27,13 @@ Repeater {
27 if (!startingUp) {
27 if (!startingUp) {
28 // the top-most surface must be the focused one.
28 // the top-most surface must be the focused one.
29 var topmostDelegate = itemAt(0);
29 var topmostDelegate = itemAt(0);
30+ if (topmostDelegate.focus) {
31+ // Delegate got focused while we were still starting up. Not good.
32+ // Force signal handler to run again
33+ topmostDelegate.onFocusChanged(true);
34+ } else {
30− topmostDelegate.focus = true;
35+ topmostDelegate.focus = true;
36+ }
31 }
37 }
32 }
38 }
33
39
tests/mocks/Cursor/Cursor.qml+1
@@ -18,6 +18,7 @@ import QtQuick 2.4
18
18
19Item {
19Item {
20 property int topBoundaryOffset // effectively panel height
20 property int topBoundaryOffset // effectively panel height
21+ property Item confiningItem
21
22
22 signal pushedLeftBoundary(real amount, int buttons)
23 signal pushedLeftBoundary(real amount, int buttons)
23 signal pushedRightBoundary(real amount, int buttons)
24 signal pushedRightBoundary(real amount, int buttons)