Improve desktop 'unfocus' functionality

This commit is contained in:
Brad Davis 2016-06-30 15:18:14 -07:00
parent 86f8b57841
commit ce54f1b1d1

View file

@ -30,6 +30,7 @@ FocusScope {
if (!repositionLocked) {
d.handleSizeChanged();
}
}
onHeightChanged: d.handleSizeChanged();
@ -66,7 +67,6 @@ FocusScope {
if (desktop.repositionLocked) {
return;
}
var oldRecommendedRect = recommendedRect;
var newRecommendedRectJS = (typeof Controller === "undefined") ? Qt.rect(0,0,0,0) : Controller.getRecommendedOverlayRect();
var newRecommendedRect = Qt.rect(newRecommendedRectJS.x, newRecommendedRectJS.y,
@ -311,8 +311,8 @@ FocusScope {
onPinnedChanged: {
if (pinned) {
nullFocus.focus = true;
nullFocus.forceActiveFocus();
desktop.focus = true;
desktop.forceActiveFocus();
// recalculate our non-pinned children
hiddenChildren = d.findMatchingChildren(desktop, function(child){
@ -486,17 +486,31 @@ FocusScope {
}
function unfocusWindows() {
// First find the active focus item, and unfocus it, all the way
// up the parent chain to the window
var currentFocus = offscreenWindow.activeFocusItem;
var targetWindow = d.getDesktopWindow(currentFocus);
while (currentFocus) {
if (currentFocus === targetWindow) {
break;
}
currentFocus.focus = false;
currentFocus = currentFocus.parent;
}
// Unfocus all windows
var windows = d.getTopLevelWindows();
for (var i = 0; i < windows.length; ++i) {
windows[i].focus = false;
}
// For the desktop to have active focus
desktop.focus = true;
desktop.forceActiveFocus();
}
FocusHack { id: focusHack; }
FocusScope { id: nullFocus; }
Rectangle {
id: focusDebugger;
objectName: "focusDebugger"
@ -510,5 +524,5 @@ FocusScope {
enabled: DebugQML
onTriggered: focusDebugger.visible = !focusDebugger.visible
}
}