[gnome-shell/wip/fmuellner/notification-redux+sass: 9/61] layout: Add MonitorConstraint:work-area property
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/fmuellner/notification-redux+sass: 9/61] layout: Add MonitorConstraint:work-area property
- Date: Thu, 19 Feb 2015 14:09:23 +0000 (UTC)
commit 86eeed6f6610526fe664c46582b718ee21aea382
Author: Florian Müllner <fmuellner gnome org>
Date: Fri Feb 6 19:27:02 2015 +0100
layout: Add MonitorConstraint:work-area property
Occasionally it makes sense to constrain to a monitor's work-area
rather than the entire monitor, so implement that behavior and add
a property to turn it on.
js/ui/layout.js | 49 ++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 42 insertions(+), 7 deletions(-)
---
diff --git a/js/ui/layout.js b/js/ui/layout.js
index 204ab94..0ff8dfc 100644
--- a/js/ui/layout.js
+++ b/js/ui/layout.js
@@ -50,11 +50,16 @@ const MonitorConstraint = new Lang.Class({
'index': GObject.ParamSpec.int('index',
'Monitor index', 'Track specific monitor',
GObject.ParamFlags.READABLE | GObject.ParamFlags.WRITABLE,
- -1, 64, -1)},
+ -1, 64, -1),
+ 'work-area': GObject.ParamSpec.boolean('work-area',
+ 'Work-area', 'Track monitor\'s work-area',
+ GObject.ParamFlags.READABLE |
GObject.ParamFlags.WRITABLE,
+ false)},
_init: function(props) {
this._primary = false;
this._index = -1;
+ this._workArea = false;
this.parent(props);
},
@@ -84,6 +89,19 @@ const MonitorConstraint = new Lang.Class({
this.notify('index');
},
+ get work_area() {
+ return this._workArea;
+ },
+
+ set work_area(v) {
+ if (v == this._workArea)
+ return;
+ this._workArea = v;
+ if (this.actor)
+ this.actor.queue_relayout();
+ this.notify('work-area');
+ },
+
vfunc_set_actor: function(actor) {
if (actor) {
if (!this._monitorsChangedId) {
@@ -91,10 +109,21 @@ const MonitorConstraint = new Lang.Class({
this.actor.queue_relayout();
}));
}
+
+ if (!this._workareasChangedId) {
+ this._workareasChangedId = global.screen.connect('workareas-changed', Lang.bind(this,
function() {
+ if (this._workArea)
+ this.actor.queue_relayout();
+ }));
+ }
} else {
if (this._monitorsChangedId)
Main.layoutManager.disconnect(this._monitorsChangedId);
this._monitorsChangedId = 0;
+
+ if (this._workareasChangedId)
+ global.screen.disconnect(this._workareasChangedId);
+ this._workareasChangedId = 0;
}
this.parent(actor);
@@ -104,15 +133,21 @@ const MonitorConstraint = new Lang.Class({
if (!this._primary && this._index < 0)
return;
- let monitor;
- if (this._primary) {
- monitor = Main.layoutManager.primaryMonitor;
+ let index;
+ if (this._primary)
+ index = Main.layoutManager.primaryIndex;
+ else
+ index = Math.min(this._index, Main.layoutManager.monitors.length - 1);
+
+ let rect;
+ if (this._workArea) {
+ let ws = global.screen.get_workspace_by_index(0);
+ rect = ws.get_work_area_for_monitor(index);
} else {
- let index = Math.min(this._index, Main.layoutManager.monitors.length - 1);
- monitor = Main.layoutManager.monitors[index];
+ rect = Main.layoutManager.monitors[index];
}
- actorBox.init_rect(monitor.x, monitor.y, monitor.width, monitor.height);
+ actorBox.init_rect(rect.x, rect.y, rect.width, rect.height);
}
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]