forked from Shinonome/dots-hyprland
fix(SysTrayItem): anchor popup menu to icon instead of fixed coordinates
- Improved anchor positioning to make the expanded menu follow the icon dynamically rather than using fixed absolute coordinates. - Replaced manual `rect` calculations with direct `item: root` binding. - Updated `gravity` and `edges` logic to properly support both vertical and horizontal bar orientations.
This commit is contained in:
@@ -29,6 +29,11 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setExtraWindowAndGrabFocus(window) {
|
function setExtraWindowAndGrabFocus(window) {
|
||||||
|
if (root.activeMenu && root.activeMenu !== window) {
|
||||||
|
if (typeof root.activeMenu.close === "function")
|
||||||
|
root.activeMenu.close();
|
||||||
|
root.activeMenu = null;
|
||||||
|
}
|
||||||
root.activeMenu = window;
|
root.activeMenu = window;
|
||||||
root.grabFocus();
|
root.grabFocus();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,11 @@ MouseArea {
|
|||||||
item.activate();
|
item.activate();
|
||||||
break;
|
break;
|
||||||
case Qt.RightButton:
|
case Qt.RightButton:
|
||||||
if (item.hasMenu) menu.open();
|
if (item.hasMenu)
|
||||||
|
if (menu.active && menu.item && typeof menu.item.close === "function")
|
||||||
|
menu.item.close();
|
||||||
|
else
|
||||||
|
menu.open();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
@@ -44,15 +48,16 @@ MouseArea {
|
|||||||
sourceComponent: SysTrayMenu {
|
sourceComponent: SysTrayMenu {
|
||||||
Component.onCompleted: this.open();
|
Component.onCompleted: this.open();
|
||||||
trayItemMenuHandle: root.item.menu
|
trayItemMenuHandle: root.item.menu
|
||||||
anchor {
|
anchor {
|
||||||
window: root.QsWindow.window
|
window: root.QsWindow.window
|
||||||
rect.x: root.x + (Config.options.bar.vertical ? 0 : QsWindow.window?.width)
|
item: root
|
||||||
rect.y: root.y + (Config.options.bar.vertical ? QsWindow.window?.height : 0)
|
gravity: Config.options.bar.vertical
|
||||||
rect.height: root.height
|
? (Config.options.bar.bottom ? Edges.Left : Edges.Right)
|
||||||
rect.width: root.width
|
: (Config.options.bar.bottom ? Edges.Top : Edges.Bottom)
|
||||||
edges: Config.options.bar.bottom ? (Edges.Top | Edges.Left) : (Edges.Bottom | Edges.Right)
|
edges: Config.options.bar.vertical
|
||||||
gravity: Config.options.bar.bottom ? (Edges.Top | Edges.Left) : (Edges.Bottom | Edges.Right)
|
? (Config.options.bar.bottom ? Edges.Left : Edges.Right)
|
||||||
}
|
: (Config.options.bar.bottom ? Edges.Top : Edges.Bottom)
|
||||||
|
}
|
||||||
onMenuOpened: (window) => root.menuOpened(window);
|
onMenuOpened: (window) => root.menuOpened(window);
|
||||||
onMenuClosed: {
|
onMenuClosed: {
|
||||||
root.menuClosed();
|
root.menuClosed();
|
||||||
|
|||||||
Reference in New Issue
Block a user