mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
Merge pull request #1835 from CLEMENTINATOR/display-cc-on-right-click-pos
control-center: open at right-click position on bar
This commit is contained in:
+7
-6
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user