Skip to content

Commit 64cc125

Browse files
committed
Center menu on monitor if applet in center zone of horizontal panel
1 parent 6e00036 commit 64cc125

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

files/usr/share/cinnamon/applets/[email protected]/applet.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,6 +1243,7 @@ class CinnamonMenuApplet extends Applet.TextIconApplet {
12431243
constructor(orientation, panel_height, instance_id) {
12441244
super(orientation, panel_height, instance_id);
12451245

1246+
this.orientation = orientation;
12461247
this.setAllowedLayout(Applet.AllowedLayout.BOTH);
12471248

12481249
this.set_applet_tooltip(_("Menu"));
@@ -1551,6 +1552,14 @@ class CinnamonMenuApplet extends Applet.TextIconApplet {
15511552
}
15521553
this._allAppsCategoryButton.actor.style_class = "appmenu-category-button-selected";
15531554

1555+
// Center menu if applet in center zone of top or bottom panel.
1556+
const appletDefinition = Main.AppletManager.getAppletDefinition({applet_id: this.instance_id});
1557+
if ((this.orientation === St.Side.BOTTOM || this.orientation === St.Side.TOP) &&
1558+
appletDefinition.location_label === 'center') {
1559+
const monitor = Main.layoutManager.findMonitorForActor(this.menu.actor);
1560+
this.menu.shiftToPosition(Math.floor(monitor.width / 2) + monitor.x);
1561+
}
1562+
15541563
Mainloop.idle_add(() => {
15551564
if(this.lastSelectedCategory !== null) //if a category is already selected
15561565
return;

0 commit comments

Comments
 (0)