Skip to content

Commit cec5ee5

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

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

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

Lines changed: 12 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"));
@@ -1507,6 +1508,7 @@ class CinnamonMenuApplet extends Applet.TextIconApplet {
15071508
}
15081509

15091510
on_orientation_changed (orientation) {
1511+
this.orientation = orientation;
15101512
this._updateIconAndLabel();
15111513
this._size_dirty = true;
15121514
}
@@ -1551,6 +1553,16 @@ class CinnamonMenuApplet extends Applet.TextIconApplet {
15511553
}
15521554
this._allAppsCategoryButton.actor.style_class = "appmenu-category-button-selected";
15531555

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

0 commit comments

Comments
 (0)