mirror of
https://github.com/morgan9e/dash-to-panel
synced 2026-04-14 00:04:17 +09:00
Use gnome-shell monitor order
This commit is contained in:
@@ -610,20 +610,19 @@
|
||||
<description>When the applications are ungrouped, this defines if running applications stay separate from the favorite icons.</description>
|
||||
</key>
|
||||
<key type="i" name="primary-monitor">
|
||||
<default>0</default>
|
||||
<default>-1</default>
|
||||
<summary>Primary monitor index</summary>
|
||||
<description>Specifies the index of the primary monitor.</description>
|
||||
<description>Specifies the index of the primary monitor. -1 if same as gnome-shell primary monitor.</description>
|
||||
</key>
|
||||
<key type="i" name="gs-primary-monitor">
|
||||
<default>0</default>
|
||||
<summary>Primary gnome-shell monitor index</summary>
|
||||
</key>
|
||||
<key type="b" name="multi-monitors">
|
||||
<default>true</default>
|
||||
<summary>Display panels on all monitors</summary>
|
||||
<description>Specifies if a panel is shown on every monitors</description>
|
||||
</key>
|
||||
<key type="ai" name="available-monitors">
|
||||
<default>[]</default>
|
||||
<summary>Available monitors</summary>
|
||||
<description>Available gnome-shell (Mutter) monitors, internal use</description>
|
||||
</key>
|
||||
<key type="b" name="isolate-monitors">
|
||||
<default>false</default>
|
||||
<summary>Provide monitor isolation</summary>
|
||||
|
||||
@@ -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) {
|
||||
|
||||
21
src/prefs.js
21
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
|
||||
|
||||
Reference in New Issue
Block a user