From b66d6e043031a65dd2e84a35aa06ebc0020d1dea Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Tue, 4 Feb 2025 21:50:43 -0500 Subject: [PATCH] Use gnome-shell monitor order --- ...shell.extensions.dash-to-panel.gschema.xml | 13 +++++----- src/panelManager.js | 26 +++++-------------- src/prefs.js | 21 +++++++++++---- 3 files changed, 29 insertions(+), 31 deletions(-) diff --git a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml index a605be4..092fd85 100644 --- a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml +++ b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml @@ -610,20 +610,19 @@ When the applications are ungrouped, this defines if running applications stay separate from the favorite icons. - 0 + -1 Primary monitor index - Specifies the index of the primary monitor. + Specifies the index of the primary monitor. -1 if same as gnome-shell primary monitor. + + + 0 + Primary gnome-shell monitor index true Display panels on all monitors Specifies if a panel is shown on every monitors - - [] - Available monitors - Available gnome-shell (Mutter) monitors, internal use - false Provide monitor isolation diff --git a/src/panelManager.js b/src/panelManager.js index cce0e92..9587a37 100755 --- a/src/panelManager.js +++ b/src/panelManager.js @@ -491,30 +491,18 @@ export const PanelManager = class { //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 keyMonitors = 'available-monitors' let keyPrimary = 'primary-monitor' let primaryIndex = Main.layoutManager.primaryIndex - let newMonitors = [primaryIndex] - let savedMonitors = SETTINGS.get_value(keyMonitors).deep_unpack() let dtpPrimaryIndex = SETTINGS.get_int(keyPrimary) - let newDtpPrimaryIndex = primaryIndex - Main.layoutManager.monitors - .filter((m) => m.index != primaryIndex) - .forEach((m) => newMonitors.push(m.index)) + if ( + !Main.layoutManager.monitors[dtpPrimaryIndex] || + dtpPrimaryIndex == primaryIndex + ) + dtpPrimaryIndex = -1 - if (savedMonitors[0] != dtpPrimaryIndex) { - // dash to panel primary wasn't the gnome-shell primary (first index of available-monitors) - let savedIndex = savedMonitors.indexOf(dtpPrimaryIndex) - - // default to primary if it was set to a monitor that is no longer available - newDtpPrimaryIndex = newMonitors[savedIndex] - newDtpPrimaryIndex = - newDtpPrimaryIndex == null ? primaryIndex : newDtpPrimaryIndex - } - - SETTINGS.set_int(keyPrimary, newDtpPrimaryIndex) - SETTINGS.set_value(keyMonitors, new GLib.Variant('ai', newMonitors)) + SETTINGS.set_int(keyPrimary, dtpPrimaryIndex) + SETTINGS.set_int('gs-primary-monitor', primaryIndex) } checkIfFocusedMonitor(monitor) { diff --git a/src/prefs.js b/src/prefs.js index daead65..71671e0 100644 --- a/src/prefs.js +++ b/src/prefs.js @@ -1234,17 +1234,26 @@ const Preferences = class { }) //multi-monitor - this.monitors = this._settings.get_value('available-monitors').deep_unpack() + this.monitors = [] + for ( + let i = 0; + i < Gdk.Display.get_default().get_monitors().get_n_items(); + ++i + ) { + this.monitors.push(i) + } + + let primaryMonitorIndex = this._settings.get_int('gs-primary-monitor') let dtpPrimaryMonitorIndex = this.monitors.indexOf( this._settings.get_int('primary-monitor'), ) if (dtpPrimaryMonitorIndex < 0) { - dtpPrimaryMonitorIndex = 0 + dtpPrimaryMonitorIndex = primaryMonitorIndex } - this._currentMonitorIndex = this.monitors[dtpPrimaryMonitorIndex] + this._currentMonitorIndex = dtpPrimaryMonitorIndex this._settings.connect('changed::panel-positions', () => this._updateVerticalRelatedOptions(), @@ -1252,8 +1261,10 @@ const Preferences = class { this._updateVerticalRelatedOptions() for (let i = 0; i < this.monitors.length; ++i) { - //the gnome-shell primary index is the first one in the "available-monitors" setting - let label = !i ? _('Primary monitor') : _('Monitor ') + (i + 1) + let label = + i == primaryMonitorIndex + ? _('Primary monitor') + : _('Monitor ') + (i + 1) this._builder.get_object('multimon_primary_combo').append_text(label) this._builder