control-center: open at right-click position on bar

This commit is contained in:
Clement Bouvet
2026-02-14 22:17:25 +01:00
parent abfcbd3a54
commit cf29e898fc
2 changed files with 20 additions and 10 deletions
+7 -6
View File
@@ -292,12 +292,13 @@ Item {
}
// Click is on empty bar background - open control center
var controlCenterPanel = PanelService.getPanel("controlCenterPanel", screen);
if (Settings.data.controlCenter.position === "close_to_bar_button") {
// Will attempt to open the panel next to the bar button if any.
controlCenterPanel?.toggle(null, "ControlCenter");
} else {
controlCenterPanel?.toggle();
}
// Map click position to screen-relative coordinates
// We need to map from bar coordinates to screen coordinates
var screenRelativePos = mapToItem(null, mouse.x, mouse.y);
// Pass click position directly
controlCenterPanel?.toggle(null, screenRelativePos);
mouse.accepted = true;
}
}
+13 -4
View File
@@ -157,7 +157,17 @@ Item {
PanelService.closedImmediately = false;
if (!buttonItem && buttonName) {
buttonItem = BarService.lookupWidget(buttonName, screen.name);
// Check if buttonName is actually a point object (click coordinates)
if (typeof buttonName === "object" && buttonName.x !== undefined && buttonName.y !== undefined) {
root.buttonItem = null;
root.buttonPosition = buttonName;
root.buttonWidth = 0;
root.buttonHeight = 0;
root.useButtonPosition = true;
} else {
// buttonName is a widget name, look it up
buttonItem = BarService.lookupWidget(buttonName, screen.name);
}
}
// Validate buttonItem is a valid QML Item with mapToItem function
@@ -201,10 +211,9 @@ Item {
root.buttonItem = null;
root.useButtonPosition = false;
}
} else {
// No valid button provided: reset button position mode
} else if (!root.useButtonPosition) {
// No valid button provided and no click position: reset button position mode
root.buttonItem = null;
root.useButtonPosition = false;
}
// Set isPanelOpen to trigger content loading, but don't show yet