osdWindow: Show on all monitors
We had one osdWindow that we displayed either on the primary monitor or on whatever monitor index got passed over dbus. Change that to show the osd on all monitors when no explicit monitor is requested. A monitor should be requested in cases like display brightness where it makes sense to only show the osd on the affected monitor. https://bugzilla.gnome.org/show_bug.cgi?id=722684
This commit is contained in:
parent
4a6b89d44c
commit
5c3f9f6999
@ -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();
|
||||
|
@ -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();
|
||||
}
|
||||
});
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user