mirror of
https://github.com/morgan9e/dash-to-panel
synced 2026-04-14 00:04:17 +09:00
Update saved monitors on display configuration change
This commit is contained in:
@@ -62,15 +62,7 @@ var dtpPanelManager = Utils.defineClass({
|
||||
this.overview = new Overview.dtpOverview();
|
||||
this.panelsElementPositions = {};
|
||||
|
||||
//Mutter meta_monitor_manager_get_primary_monitor (global.display.get_primary_monitor()) doesn't return the same
|
||||
//monitor as GDK gdk_screen_get_primary_monitor (imports.gi.Gdk.Screen.get_default().get_primary_monitor()).
|
||||
//Since the Mutter function is what's used in gnome-shell and we can't access it from the settings dialog, store
|
||||
//the monitors information in a setting so we can use the same monitor indexes as the ones in gnome-shell
|
||||
let primaryIndex = Main.layoutManager.primaryIndex;
|
||||
let monitors = [primaryIndex];
|
||||
|
||||
Main.layoutManager.monitors.filter(m => m.index != primaryIndex).forEach(m => monitors.push(m.index));
|
||||
Me.settings.set_value('available-monitors', new GLib.Variant('ai', monitors));
|
||||
this._saveMonitors();
|
||||
|
||||
Main.overview.viewSelector.appDisplay._views.forEach(v => {
|
||||
Utils.wrapActor(v.view);
|
||||
@@ -81,7 +73,7 @@ var dtpPanelManager = Utils.defineClass({
|
||||
enable: function(reset) {
|
||||
let dtpPrimaryIndex = Me.settings.get_int('primary-monitor');
|
||||
|
||||
this.dtpPrimaryMonitor = Main.layoutManager.monitors[dtpPrimaryIndex];
|
||||
this.dtpPrimaryMonitor = Main.layoutManager.monitors[dtpPrimaryIndex] || Main.layoutManager.primaryMonitor;
|
||||
this.proximityManager = new Proximity.ProximityManager();
|
||||
|
||||
Utils.wrapActor(Main.panel);
|
||||
@@ -261,6 +253,7 @@ var dtpPanelManager = Utils.defineClass({
|
||||
'monitors-changed',
|
||||
() => {
|
||||
if (Main.layoutManager.primaryMonitor) {
|
||||
this._saveMonitors();
|
||||
this._reset();
|
||||
}
|
||||
}
|
||||
@@ -385,6 +378,18 @@ var dtpPanelManager = Utils.defineClass({
|
||||
}
|
||||
},
|
||||
|
||||
_saveMonitors: function() {
|
||||
//Mutter meta_monitor_manager_get_primary_monitor (global.display.get_primary_monitor()) doesn't return the same
|
||||
//monitor as GDK gdk_screen_get_primary_monitor (imports.gi.Gdk.Screen.get_default().get_primary_monitor()).
|
||||
//Since the Mutter function is what's used in gnome-shell and we can't access it from the settings dialog, store
|
||||
//the monitors information in a setting so we can use the same monitor indexes as the ones in gnome-shell
|
||||
let primaryIndex = Main.layoutManager.primaryIndex;
|
||||
let monitors = [primaryIndex];
|
||||
|
||||
Main.layoutManager.monitors.filter(m => m.index != primaryIndex).forEach(m => monitors.push(m.index));
|
||||
Me.settings.set_value('available-monitors', new GLib.Variant('ai', monitors));
|
||||
},
|
||||
|
||||
checkIfFocusedMonitor: function(monitor) {
|
||||
return Main.overview.viewSelector._workspacesDisplay._primaryIndex == monitor.index;
|
||||
},
|
||||
|
||||
12
prefs.js
12
prefs.js
@@ -696,8 +696,14 @@ const Settings = new Lang.Class({
|
||||
this._builder.get_object('taskbar_position_monitor_combo').append_text(label);
|
||||
}
|
||||
|
||||
this._builder.get_object('multimon_primary_combo').set_active(this.monitors.indexOf(this._settings.get_int('primary-monitor')));
|
||||
this._builder.get_object('taskbar_position_monitor_combo').set_active(this.monitors.indexOf(this._settings.get_int('primary-monitor')));
|
||||
let dtpPrimaryMonitorIndex = this.monitors.indexOf(this._settings.get_int('primary-monitor'));
|
||||
|
||||
if (dtpPrimaryMonitorIndex < 0) {
|
||||
dtpPrimaryMonitorIndex = 0;
|
||||
}
|
||||
|
||||
this._builder.get_object('multimon_primary_combo').set_active(dtpPrimaryMonitorIndex);
|
||||
this._builder.get_object('taskbar_position_monitor_combo').set_active(dtpPrimaryMonitorIndex);
|
||||
|
||||
this._builder.get_object('multimon_primary_combo').connect('changed', Lang.bind (this, function(widget) {
|
||||
this._settings.set_int('primary-monitor', this.monitors[widget.get_active()]);
|
||||
@@ -716,7 +722,7 @@ const Settings = new Lang.Class({
|
||||
Gio.SettingsBindFlags.DEFAULT);
|
||||
|
||||
if (this.monitors.length === 1) {
|
||||
this._builder.get_object('multimon_multi_switch').set_active(false);
|
||||
this._builder.get_object('multimon_multi_switch').set_sensitive(false);
|
||||
}
|
||||
|
||||
//dynamic opacity
|
||||
|
||||
Reference in New Issue
Block a user