Skip to content

Commit

Permalink
Right-click menu: support multi monitors.
Browse files Browse the repository at this point in the history
  • Loading branch information
franglais125 committed Jun 13, 2017
1 parent f01d8a1 commit f6fc688
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions dash.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ function extendDashItemContainer(dashItemContainer, settings) {
const MyDashActor = new Lang.Class({
Name: 'DashToDock.MyDashActor',

_init: function(settings) {
_init: function(settings, monitorIndex) {
// a prefix is required to avoid conflicting with the parent class variable
this._dtdSettings = settings;
this._monitorIndex = monitorIndex;
this._rtl = (Clutter.get_default_text_direction() == Clutter.TextDirection.RTL);

this._position = Utils.getPosition(settings);
Expand Down Expand Up @@ -185,22 +186,18 @@ const MyDashActor = new Lang.Class({

let button = event.get_button();
if (button == 3) {
let monitor = this._dtdSettings.get_int('preferred-monitor');
if ((monitor <= 0) || (monitor > Main.layoutManager.monitors.length -1))
monitor = Main.layoutManager.primaryIndex;

[x, y] = event.get_coords();
let coords, offset, size;

if (this._isHorizontal) {
coords = x;
offset = (Main.layoutManager.getWorkAreaForMonitor(monitor).width - this.actor.width)/2;
offset = (Main.layoutManager.getWorkAreaForMonitor(this._monitorIndex).width - this.actor.width)/2;
size = this.actor.width;
}
else {
coords = y;
offset = (Main.layoutManager.getWorkAreaForMonitor(monitor).height - this.actor.height)/2
+ Main.layoutManager.getWorkAreaForMonitor(monitor).y; // This is the offset due to the top bar
offset = (Main.layoutManager.getWorkAreaForMonitor(this._monitorIndex).height - this.actor.height)/2
+ Main.layoutManager.getWorkAreaForMonitor(this._monitorIndex).y; // This is the offset due to the top bar
size = this.actor.height;
}

Expand Down Expand Up @@ -252,7 +249,7 @@ const MyDash = new Lang.Class({
this._ensureAppIconVisibilityTimeoutId = 0;
this._labelShowing = false;

this._containerObject = new MyDashActor(settings);
this._containerObject = new MyDashActor(settings, this._monitorIndex);
this._container = this._containerObject.actor;
this._scrollView = new St.ScrollView({
name: 'dashtodockDashScrollview',
Expand Down

0 comments on commit f6fc688

Please sign in to comment.