improve menu max-height

* Take scale factor into account.
* Put it in '_onMenuOpenStateChanged' so the max-height will be updated if the monitor size change.

See PanelMenu.Button.
This commit is contained in:
abakkk 2020-09-25 12:50:10 +02:00
parent 129c8f584c
commit 79f27d1b25
1 changed files with 7 additions and 1 deletions

View File

@ -143,6 +143,7 @@ var DrawingMenu = new Lang.Class({
_init: function(area, monitor, drawingTools) {
this.area = area;
this.monitor = monitor;
this.drawingTools = drawingTools;
let side = Clutter.get_default_text_direction() == Clutter.TextDirection.RTL ? St.Side.RIGHT : St.Side.LEFT;
@ -151,8 +152,8 @@ var DrawingMenu = new Lang.Class({
this.menuManager.addMenu(this.menu);
Main.layoutManager.uiGroup.add_actor(this.menu.actor);
this.menu.actor.add_style_class_name('background-menu draw-on-your-screen-menu');
this.menu.actor.set_style('max-height:' + monitor.height + 'px;');
this.menu.actor.hide();
this.hasSeparators = monitor.height >= 750;
@ -190,6 +191,11 @@ var DrawingMenu = new Lang.Class({
this.area.updateActionMode();
this.area.grab_key_focus();
}
let workArea = Main.layoutManager.getWorkAreaForMonitor(this.monitor.index);
let scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor;
let maxHeight = Math.round(workArea.height / scaleFactor);
this.menu.actor.set_style(`max-height:${maxHeight}px;`);
},
popup: function() {