[gnome-shell] osdWindow: add setMonitor() to allow changing the monitor



commit 4b90953226c0980fd7b2fb233c51b5582ad583e6
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Nov 18 13:48:19 2013 +0100

    osdWindow: add setMonitor() to allow changing the monitor
    
    This is also exposed in the ShowOSD DBus method, the "monitor"
    parameter may contain an integer to indicate the monitor number.
    If the value is not provided or <0 is used, the monitor is shown
    on the primary monitor as usually.
    
    This way, the OSD can be used to notify upon events that solely
    apply to one monitor, like tablet mapping as discussed in
    https://bugzilla.gnome.org/show_bug.cgi?id=710373.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=712664

 js/ui/osdWindow.js |   29 +++++++++++++++++++++++++++--
 js/ui/shellDBus.js |    5 +++++
 2 files changed, 32 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/osdWindow.js b/js/ui/osdWindow.js
index bb7d888..24f78b4 100644
--- a/js/ui/osdWindow.js
+++ b/js/ui/osdWindow.js
@@ -77,7 +77,8 @@ const OsdWindow = new Lang.Class({
                                      y_expand: true,
                                      x_align: Clutter.ActorAlign.CENTER,
                                      y_align: Clutter.ActorAlign.CENTER });
-        this.actor.add_constraint(new Layout.MonitorConstraint({ primary: true }));
+        this._currentMonitor = undefined;
+        this.setMonitor (-1);
         this._box = new St.BoxLayout({ style_class: 'osd-window',
                                        vertical: true });
         this.actor.add_actor(this._box);
@@ -182,7 +183,13 @@ const OsdWindow = new Lang.Class({
 
     _monitorsChanged: function() {
         /* assume 110x110 on a 640x480 display and scale from there */
-        let monitor = Main.layoutManager.primaryMonitor;
+        let monitor;
+
+        if (this._currentMonitor >= 0)
+            monitor = Main.layoutManager.monitors[this._currentMonitor];
+        else
+            monitor = Main.layoutManager.primaryMonitor;
+
         let scalew = monitor.width / 640.0;
         let scaleh = monitor.height / 480.0;
         let scale = Math.min(scalew, scaleh);
@@ -206,5 +213,23 @@ const OsdWindow = new Lang.Class({
         let minHeight = this._popupSize - horizontalPadding - topBorder - bottomBorder;
 
         this._box.style = 'min-height: %dpx;'.format(Math.max(minWidth, minHeight));
+    },
+
+    setMonitor: function(index) {
+        let constraint;
+
+        if (index < 0)
+            index = -1;
+        if (this._currentMonitor == index)
+            return;
+
+        if (index < 0)
+            constraint = new Layout.MonitorConstraint({ primary: true });
+        else
+            constraint = new Layout.MonitorConstraint({ index: index });
+
+        this.actor.clear_constraints();
+        this.actor.add_constraint(constraint);
+        this._currentMonitor = index;
     }
 });
diff --git a/js/ui/shellDBus.js b/js/ui/shellDBus.js
index 79ff46c..4049095 100644
--- a/js/ui/shellDBus.js
+++ b/js/ui/shellDBus.js
@@ -133,11 +133,16 @@ const GnomeShell = new Lang.Class({
         for (let param in params)
             params[param] = params[param].deep_unpack();
 
+        let monitorIndex = -1;
+        if (params['monitor'])
+            monitorIndex = params['monitor'];
+
         let icon = null;
         if (params['icon'])
             icon = Gio.Icon.new_for_string(params['icon']);
 
         Main.osdWindow.setIcon(icon);
+        Main.osdWindow.setMonitor (monitorIndex);
         Main.osdWindow.setLabel(params['label']);
         Main.osdWindow.setLevel(params['level']);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]