mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-23 13:35:06 +02:00
Desktop cleanup
This commit is contained in:
parent
8dc066fc00
commit
cea57a111b
2 changed files with 36 additions and 37 deletions
|
@ -13,6 +13,9 @@ FocusScope {
|
||||||
anchors.fill: parent;
|
anchors.fill: parent;
|
||||||
objectName: "desktop"
|
objectName: "desktop"
|
||||||
|
|
||||||
|
onHeightChanged: d.repositionAll();
|
||||||
|
onWidthChanged: d.repositionAll();
|
||||||
|
|
||||||
// Allows QML/JS to find the desktop through the parent chain
|
// Allows QML/JS to find the desktop through the parent chain
|
||||||
property bool desktopRoot: true
|
property bool desktopRoot: true
|
||||||
|
|
||||||
|
@ -50,10 +53,6 @@ FocusScope {
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isDesktop(item) {
|
|
||||||
return item.desktopRoot;
|
|
||||||
}
|
|
||||||
|
|
||||||
function isTopLevelWindow(item) {
|
function isTopLevelWindow(item) {
|
||||||
return item.topLevelWindow;
|
return item.topLevelWindow;
|
||||||
}
|
}
|
||||||
|
@ -147,6 +146,31 @@ FocusScope {
|
||||||
var windows = getTopLevelWindows(predicate);
|
var windows = getTopLevelWindows(predicate);
|
||||||
fixupZOrder(windows, zBasis, targetWindow);
|
fixupZOrder(windows, zBasis, targetWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
offscreenWindow.activeFocusItemChanged.connect(onWindowFocusChanged);
|
||||||
|
focusHack.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
function onWindowFocusChanged() {
|
||||||
|
console.log("Focus item is " + offscreenWindow.activeFocusItem);
|
||||||
|
// var focusedItem = offscreenWindow.activeFocusItem ;
|
||||||
|
// if (DebugQML && focusedItem) {
|
||||||
|
// var rect = desktop.mapFromItem(focusedItem, 0, 0, focusedItem.width, focusedItem.height);
|
||||||
|
// focusDebugger.x = rect.x;
|
||||||
|
// focusDebugger.y = rect.y;
|
||||||
|
// focusDebugger.width = rect.width
|
||||||
|
// focusDebugger.height = rect.height
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function repositionAll() {
|
||||||
|
var windows = d.getTopLevelWindows();
|
||||||
|
for (var i = 0; i < windows.length; ++i) {
|
||||||
|
reposition(windows[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function raise(item) {
|
function raise(item) {
|
||||||
|
@ -190,24 +214,16 @@ FocusScope {
|
||||||
var newPosition;
|
var newPosition;
|
||||||
if (targetWindow.x === -1 && targetWindow.y === -1) {
|
if (targetWindow.x === -1 && targetWindow.y === -1) {
|
||||||
// Set initial window position
|
// Set initial window position
|
||||||
newPosition = Utils.randomPosition(minPosition, maxPosition);
|
// newPosition = Utils.randomPosition(minPosition, maxPosition);
|
||||||
} else {
|
newPosition = Qt.vector2d(desktop.width / 2 - windowRect.width / 2,
|
||||||
newPosition = Utils.clampVector(Qt.vector2d(targetWindow.x, targetWindow.y), minPosition, maxPosition);
|
desktop.height / 2 - windowRect.height / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
newPosition = Utils.clampVector(Qt.vector2d(targetWindow.x, targetWindow.y), minPosition, maxPosition);
|
||||||
targetWindow.x = newPosition.x;
|
targetWindow.x = newPosition.x;
|
||||||
targetWindow.y = newPosition.y;
|
targetWindow.y = newPosition.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
function repositionAll() {
|
|
||||||
var windows = d.getTopLevelWindows();
|
|
||||||
for (var i = 0; i < windows.length; ++i) {
|
|
||||||
reposition(windows[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onHeightChanged: repositionAll();
|
|
||||||
onWidthChanged: repositionAll();
|
|
||||||
|
|
||||||
Component { id: messageDialogBuilder; MessageDialog { } }
|
Component { id: messageDialogBuilder; MessageDialog { } }
|
||||||
function messageBox(properties) {
|
function messageBox(properties) {
|
||||||
return messageDialogBuilder.createObject(desktop, properties);
|
return messageDialogBuilder.createObject(desktop, properties);
|
||||||
|
@ -252,39 +268,21 @@ FocusScope {
|
||||||
desktop.focus = true;
|
desktop.focus = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Debugging help for figuring out focus issues
|
|
||||||
property var offscreenWindow;
|
|
||||||
onOffscreenWindowChanged: {
|
|
||||||
offscreenWindow.activeFocusItemChanged.connect(onWindowFocusChanged);
|
|
||||||
focusHack.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
FocusHack { id: focusHack; }
|
FocusHack { id: focusHack; }
|
||||||
|
|
||||||
function onWindowFocusChanged() {
|
|
||||||
console.log("Focus item is " + offscreenWindow.activeFocusItem);
|
|
||||||
var focusedItem = offscreenWindow.activeFocusItem ;
|
|
||||||
if (DebugQML && focusedItem) {
|
|
||||||
var rect = desktop.mapFromItem(focusedItem, 0, 0, focusedItem.width, focusedItem.height);
|
|
||||||
focusDebugger.x = rect.x;
|
|
||||||
focusDebugger.y = rect.y;
|
|
||||||
focusDebugger.width = rect.width
|
|
||||||
focusDebugger.height = rect.height
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: focusDebugger;
|
id: focusDebugger;
|
||||||
z: 9999; visible: false; color: "red"
|
z: 9999; visible: false; color: "red"
|
||||||
ColorAnimation on color { from: "#7fffff00"; to: "#7f0000ff"; duration: 1000; loops: 9999 }
|
ColorAnimation on color { from: "#7fffff00"; to: "#7f0000ff"; duration: 1000; loops: 9999 }
|
||||||
}
|
}
|
||||||
|
|
||||||
Action {
|
Action {
|
||||||
text: "Toggle Focus Debugger"
|
text: "Toggle Focus Debugger"
|
||||||
shortcut: "Ctrl+Shift+F"
|
shortcut: "Ctrl+Shift+F"
|
||||||
enabled: DebugQML
|
enabled: DebugQML
|
||||||
onTriggered: focusDebugger.visible = !focusDebugger.visible
|
onTriggered: focusDebugger.visible = !focusDebugger.visible
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -338,6 +338,7 @@ void OffscreenQmlSurface::create(QOpenGLContext* shareContext) {
|
||||||
_updateTimer.start();
|
_updateTimer.start();
|
||||||
|
|
||||||
_qmlComponent = new QQmlComponent(_qmlEngine);
|
_qmlComponent = new QQmlComponent(_qmlEngine);
|
||||||
|
_qmlEngine->rootContext()->setContextProperty("offscreenWindow", QVariant::fromValue(getWindow()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffscreenQmlSurface::resize(const QSize& newSize_) {
|
void OffscreenQmlSurface::resize(const QSize& newSize_) {
|
||||||
|
|
Loading…
Reference in a new issue