diff --git a/js/ui/main.js b/js/ui/main.js index bf2540102..22a561fc9 100644 --- a/js/ui/main.js +++ b/js/ui/main.js @@ -55,7 +55,7 @@ let screenShield = null; let notificationDaemon = null; let windowAttentionHandler = null; let ctrlAltTabManager = null; -let osdWindow = null; +let osdWindowManager = null; let sessionMode = null; let shellDBusService = null; let shellMountOpDBusService = null; @@ -155,7 +155,7 @@ function _initializeUI() { screencastService = new Screencast.ScreencastService(); xdndHandler = new XdndHandler.XdndHandler(); ctrlAltTabManager = new CtrlAltTab.CtrlAltTabManager(); - osdWindow = new OsdWindow.OsdWindow(); + osdWindowManager = new OsdWindow.OsdWindowManager(); overview = new Overview.Overview(); wm = new WindowManager.WindowManager(); magnifier = new Magnifier.Magnifier(); diff --git a/js/ui/osdWindow.js b/js/ui/osdWindow.js index 2513aa843..1916812bf 100644 --- a/js/ui/osdWindow.js +++ b/js/ui/osdWindow.js @@ -73,14 +73,17 @@ const LevelBar = new Lang.Class({ const OsdWindow = new Lang.Class({ Name: 'OsdWindow', - _init: function() { + _init: function(monitorIndex) { this._popupSize = 0; this.actor = new St.Widget({ x_expand: true, y_expand: true, x_align: Clutter.ActorAlign.CENTER, y_align: Clutter.ActorAlign.CENTER }); - this._currentMonitor = undefined; - this.setMonitor (-1); + + this._monitorIndex = monitorIndex; + let constraint = new Layout.MonitorConstraint({ index: monitorIndex }); + this.actor.add_constraint(constraint); + this._box = new St.BoxLayout({ style_class: 'osd-window', vertical: true }); this.actor.add_actor(this._box); @@ -109,7 +112,6 @@ const OsdWindow = new Lang.Class({ Main.layoutManager.connect('monitors-changed', Lang.bind(this, this._monitorsChanged)); this._monitorsChanged(); - Main.uiGroup.add_child(this.actor); }, @@ -189,12 +191,7 @@ const OsdWindow = new Lang.Class({ _monitorsChanged: function() { /* assume 110x110 on a 640x480 display and scale from there */ - let monitor; - - if (this._currentMonitor >= 0) - monitor = Main.layoutManager.monitors[this._currentMonitor]; - else - monitor = Main.layoutManager.primaryMonitor; + let monitor = Main.layoutManager.monitors[this._monitorIndex]; let scalew = monitor.width / 640.0; let scaleh = monitor.height / 480.0; @@ -223,23 +220,56 @@ const OsdWindow = new Lang.Class({ // but the theme takes measures in unscaled dimensions let scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor; this._box.style = 'min-height: %dpx;'.format(Math.max(minWidth, minHeight) / scaleFactor); - }, - - 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; + } +}); + +const OsdWindowManager = new Lang.Class({ + Name: 'OsdWindowManager', + + _init: function() { + this._osdWindows = []; + Main.layoutManager.connect('monitors-changed', + Lang.bind(this, this._monitorsChanged)); + this._monitorsChanged(); + }, + + _monitorsChanged: function() { + for (let i = 0; i < Main.layoutManager.monitors.length; i++) { + if (this._osdWindows[i] == undefined) + this._osdWindows[i] = new OsdWindow(i); + } + + for (let i = Main.layoutManager.monitors.length; i < this._osdWindows.length; i++) { + this._osdWindows[i].actor.destroy(); + this._osdWindows[i] = null; + } + + this._osdWindows.length = Main.layoutManager.monitors.length; + }, + + _showOsdWindow: function(monitorIndex, icon, label, level) { + this._osdWindows[monitorIndex].setIcon(icon); + this._osdWindows[monitorIndex].setLabel(label); + this._osdWindows[monitorIndex].setLevel(level); + this._osdWindows[monitorIndex].show(); + }, + + show: function(monitorIndex, icon, label, level) { + if (monitorIndex != -1) { + for (let i = 0; i < this._osdWindows.length; i++) { + if (i == monitorIndex) + this._showOsdWindow(i, icon, label, level); + else + this._osdWindows[i].cancel(); + } + } else { + for (let i = 0; i < this._osdWindows.length; i++) + this._showOsdWindow(i, icon, label, level); + } + }, + + hideAll: function() { + for (let i = 0; i < this._osdWindows.length; i++) + this._osdWindows[i].cancel(); } }); diff --git a/js/ui/shellDBus.js b/js/ui/shellDBus.js index 52e9fa8f6..a87ea4171 100644 --- a/js/ui/shellDBus.js +++ b/js/ui/shellDBus.js @@ -141,12 +141,7 @@ const GnomeShell = new Lang.Class({ 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']); - - Main.osdWindow.show(); + Main.osdWindowManager.show(monitorIndex, icon, params['label'], params['level']); }, FocusApp: function(id) { diff --git a/js/ui/switcherPopup.js b/js/ui/switcherPopup.js index bd7875f8d..f7b8897e8 100644 --- a/js/ui/switcherPopup.js +++ b/js/ui/switcherPopup.js @@ -161,7 +161,7 @@ const SwitcherPopup = new Lang.Class({ // disturbed by the popup briefly flashing. this._initialDelayTimeoutId = Mainloop.timeout_add(POPUP_DELAY_TIMEOUT, Lang.bind(this, function () { - Main.osdWindow.cancel(); + Main.osdWindowManager.hideAll(); this.actor.opacity = 255; this._initialDelayTimeoutId = 0; return GLib.SOURCE_REMOVE;