mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 04:57:58 +02:00
Improve desktop 'unfocus' functionality
This commit is contained in:
parent
86f8b57841
commit
ce54f1b1d1
1 changed files with 20 additions and 6 deletions
|
@ -30,6 +30,7 @@ FocusScope {
|
||||||
if (!repositionLocked) {
|
if (!repositionLocked) {
|
||||||
d.handleSizeChanged();
|
d.handleSizeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onHeightChanged: d.handleSizeChanged();
|
onHeightChanged: d.handleSizeChanged();
|
||||||
|
@ -66,7 +67,6 @@ FocusScope {
|
||||||
if (desktop.repositionLocked) {
|
if (desktop.repositionLocked) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var oldRecommendedRect = recommendedRect;
|
var oldRecommendedRect = recommendedRect;
|
||||||
var newRecommendedRectJS = (typeof Controller === "undefined") ? Qt.rect(0,0,0,0) : Controller.getRecommendedOverlayRect();
|
var newRecommendedRectJS = (typeof Controller === "undefined") ? Qt.rect(0,0,0,0) : Controller.getRecommendedOverlayRect();
|
||||||
var newRecommendedRect = Qt.rect(newRecommendedRectJS.x, newRecommendedRectJS.y,
|
var newRecommendedRect = Qt.rect(newRecommendedRectJS.x, newRecommendedRectJS.y,
|
||||||
|
@ -311,8 +311,8 @@ FocusScope {
|
||||||
|
|
||||||
onPinnedChanged: {
|
onPinnedChanged: {
|
||||||
if (pinned) {
|
if (pinned) {
|
||||||
nullFocus.focus = true;
|
desktop.focus = true;
|
||||||
nullFocus.forceActiveFocus();
|
desktop.forceActiveFocus();
|
||||||
|
|
||||||
// recalculate our non-pinned children
|
// recalculate our non-pinned children
|
||||||
hiddenChildren = d.findMatchingChildren(desktop, function(child){
|
hiddenChildren = d.findMatchingChildren(desktop, function(child){
|
||||||
|
@ -486,17 +486,31 @@ FocusScope {
|
||||||
}
|
}
|
||||||
|
|
||||||
function unfocusWindows() {
|
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();
|
var windows = d.getTopLevelWindows();
|
||||||
for (var i = 0; i < windows.length; ++i) {
|
for (var i = 0; i < windows.length; ++i) {
|
||||||
windows[i].focus = false;
|
windows[i].focus = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For the desktop to have active focus
|
||||||
desktop.focus = true;
|
desktop.focus = true;
|
||||||
|
desktop.forceActiveFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
FocusHack { id: focusHack; }
|
FocusHack { id: focusHack; }
|
||||||
|
|
||||||
FocusScope { id: nullFocus; }
|
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: focusDebugger;
|
id: focusDebugger;
|
||||||
objectName: "focusDebugger"
|
objectName: "focusDebugger"
|
||||||
|
@ -510,5 +524,5 @@ FocusScope {
|
||||||
enabled: DebugQML
|
enabled: DebugQML
|
||||||
onTriggered: focusDebugger.visible = !focusDebugger.visible
|
onTriggered: focusDebugger.visible = !focusDebugger.visible
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue