mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-29 07:52:50 -05:00
Revert "systemtray: fix UI thread freeze when opening menu on Hyprland"
This reverts commit 4cb652abd9.
This commit is contained in:
@@ -645,43 +645,11 @@ Item {
|
|||||||
property bool showMenu: false
|
property bool showMenu: false
|
||||||
property var menuHandle: null
|
property var menuHandle: null
|
||||||
|
|
||||||
property bool shouldLoadMenu: false
|
|
||||||
property var menuItems: []
|
|
||||||
|
|
||||||
ListModel { id: entryStack }
|
ListModel { id: entryStack }
|
||||||
function topEntry() {
|
function topEntry() {
|
||||||
return entryStack.count ? entryStack.get(entryStack.count - 1).handle : null
|
return entryStack.count ? entryStack.get(entryStack.count - 1).handle : null
|
||||||
}
|
}
|
||||||
|
|
||||||
onShouldLoadMenuChanged: {
|
|
||||||
if (shouldLoadMenu) {
|
|
||||||
loadMenuItemsSafely()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadMenuItemsSafely() {
|
|
||||||
menuLoadTimer.start()
|
|
||||||
}
|
|
||||||
|
|
||||||
Timer {
|
|
||||||
id: menuLoadTimer
|
|
||||||
interval: 50
|
|
||||||
repeat: false
|
|
||||||
onTriggered: {
|
|
||||||
try {
|
|
||||||
const currentOpener = entryStack.count ? subOpener : rootOpener
|
|
||||||
if (currentOpener && currentOpener.children && currentOpener.children.values) {
|
|
||||||
const values = currentOpener.children.values
|
|
||||||
if (values && values.length > 0) {
|
|
||||||
menuRoot.menuItems = [...values]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.warn("Failed to load menu items:", e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function showForTrayItem(item, anchor, screen, atBottom, vertical, axisObj) {
|
function showForTrayItem(item, anchor, screen, atBottom, vertical, axisObj) {
|
||||||
trayItem = item
|
trayItem = item
|
||||||
anchorItem = anchor
|
anchorItem = anchor
|
||||||
@@ -689,12 +657,7 @@ Item {
|
|||||||
isAtBottom = atBottom
|
isAtBottom = atBottom
|
||||||
isVertical = vertical
|
isVertical = vertical
|
||||||
axis = axisObj
|
axis = axisObj
|
||||||
|
menuHandle = item?.menu
|
||||||
if (item && item.menu) {
|
|
||||||
menuHandle = item.menu
|
|
||||||
}
|
|
||||||
|
|
||||||
menuItems = []
|
|
||||||
|
|
||||||
if (parentScreen) {
|
if (parentScreen) {
|
||||||
for (var i = 0; i < Quickshell.screens.length; i++) {
|
for (var i = 0; i < Quickshell.screens.length; i++) {
|
||||||
@@ -706,7 +669,6 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
shouldLoadMenu = true
|
|
||||||
showMenu = true
|
showMenu = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -728,17 +690,17 @@ Item {
|
|||||||
|
|
||||||
entryStack.append({ handle: entry });
|
entryStack.append({ handle: entry });
|
||||||
|
|
||||||
menuItems = []
|
const h = entry.menu || entry;
|
||||||
|
if (h && typeof h.updateLayout === "function") h.updateLayout();
|
||||||
|
|
||||||
shouldLoadMenu = true
|
submenuHydrator.menu = h;
|
||||||
|
submenuHydrator.open();
|
||||||
|
Qt.callLater(() => submenuHydrator.close());
|
||||||
}
|
}
|
||||||
|
|
||||||
function goBack() {
|
function goBack() {
|
||||||
if (!entryStack.count) return;
|
if (!entryStack.count) return;
|
||||||
entryStack.remove(entryStack.count - 1);
|
entryStack.remove(entryStack.count - 1);
|
||||||
|
|
||||||
menuItems = []
|
|
||||||
Qt.callLater(() => loadMenuItemsSafely())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
width: 0
|
width: 0
|
||||||
@@ -917,16 +879,14 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QsMenuAnchor {
|
||||||
|
id: submenuHydrator
|
||||||
|
anchor.window: menuWindow
|
||||||
|
}
|
||||||
|
|
||||||
QsMenuOpener {
|
QsMenuOpener {
|
||||||
id: rootOpener
|
id: rootOpener
|
||||||
menu: menuRoot.menuHandle
|
menu: menuRoot.menuHandle
|
||||||
|
|
||||||
onMenuChanged: {
|
|
||||||
if (menuRoot.shouldLoadMenu && !entryStack.count) {
|
|
||||||
menuRoot.menuItems = []
|
|
||||||
Qt.callLater(() => menuRoot.loadMenuItemsSafely())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QsMenuOpener {
|
QsMenuOpener {
|
||||||
@@ -935,13 +895,6 @@ Item {
|
|||||||
const e = menuRoot.topEntry();
|
const e = menuRoot.topEntry();
|
||||||
return e ? (e.menu || e) : null;
|
return e ? (e.menu || e) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
onMenuChanged: {
|
|
||||||
if (menuRoot.shouldLoadMenu && entryStack.count) {
|
|
||||||
menuRoot.menuItems = []
|
|
||||||
Qt.callLater(() => menuRoot.loadMenuItemsSafely())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1052,7 +1005,10 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
model: menuRoot.menuItems
|
model: entryStack.count
|
||||||
|
? (subOpener.children ? subOpener.children
|
||||||
|
: (menuRoot.topEntry()?.children || []))
|
||||||
|
: rootOpener.children
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
property var menuEntry: modelData
|
property var menuEntry: modelData
|
||||||
|
|||||||
Reference in New Issue
Block a user