Add option to hide from windows on monitor

gh-2223
This commit is contained in:
Charles Gagnon
2025-04-09 18:47:20 -04:00
parent eb6366ef3e
commit 94aaacd241
6 changed files with 114 additions and 19 deletions

View File

@@ -338,9 +338,13 @@
</key> </key>
<key type="b" name="intellihide-hide-from-windows"> <key type="b" name="intellihide-hide-from-windows">
<default>false</default> <default>false</default>
<summary>Only hide from windows</summary> <summary>Only hide from overlapping windows</summary>
<description>Dictates if the dash should only hide when in conflict with windows</description> <description>Dictates if the dash should only hide when in conflict with windows</description>
</key> </key>
<key type="b" name="intellihide-hide-from-monitor-windows">
<default>false</default>
<summary>Only hide from windows on monitor</summary>
</key>
<key name="intellihide-behaviour" enum="org.gnome.shell.extensions.dash-to-panel.proximityBehavior"> <key name="intellihide-behaviour" enum="org.gnome.shell.extensions.dash-to-panel.proximityBehavior">
<default>'FOCUSED_WINDOWS'</default> <default>'FOCUSED_WINDOWS'</default>
<summary>Intellihide behaviour</summary> <summary>Intellihide behaviour</summary>

View File

@@ -17,6 +17,7 @@
import Clutter from 'gi://Clutter' import Clutter from 'gi://Clutter'
import Meta from 'gi://Meta' import Meta from 'gi://Meta'
import Mtk from 'gi://Mtk'
import Shell from 'gi://Shell' import Shell from 'gi://Shell'
import St from 'gi://St' import St from 'gi://St'
@@ -92,9 +93,18 @@ export const Intellihide = class {
this._setTrackPanel(true) this._setTrackPanel(true)
this._bindGeneralSignals() this._bindGeneralSignals()
if (SETTINGS.get_boolean('intellihide-hide-from-windows')) { if (this._hidesFromWindows()) {
let watched = SETTINGS.get_boolean('intellihide-hide-from-windows')
? this._panelBox.get_parent()
: new Mtk.Rectangle({
x: this._monitor.x,
y: this._monitor.y,
width: this._monitor.width,
height: this._monitor.height,
})
this._proximityWatchId = this._proximityManager.createWatch( this._proximityWatchId = this._proximityManager.createWatch(
this._panelBox.get_parent(), watched,
this._dtpPanel.monitor.index, this._dtpPanel.monitor.index,
Proximity.Mode[SETTINGS.get_string('intellihide-behaviour')], Proximity.Mode[SETTINGS.get_string('intellihide-behaviour')],
0, 0,
@@ -193,6 +203,13 @@ export const Intellihide = class {
this.enable() this.enable()
} }
_hidesFromWindows() {
return (
SETTINGS.get_boolean('intellihide-hide-from-windows') ||
SETTINGS.get_boolean('intellihide-hide-from-monitor-windows')
)
}
_changeEnabledStatus() { _changeEnabledStatus() {
let intellihide = SETTINGS.get_boolean('intellihide') let intellihide = SETTINGS.get_boolean('intellihide')
let onlySecondary = SETTINGS.get_boolean('intellihide-only-secondary') let onlySecondary = SETTINGS.get_boolean('intellihide-only-secondary')
@@ -223,6 +240,7 @@ export const Intellihide = class {
[ [
'changed::intellihide-use-pressure', 'changed::intellihide-use-pressure',
'changed::intellihide-hide-from-windows', 'changed::intellihide-hide-from-windows',
'changed::intellihide-hide-from-monitor-windows',
'changed::intellihide-behaviour', 'changed::intellihide-behaviour',
'changed::intellihide-pressure-threshold', 'changed::intellihide-pressure-threshold',
'changed::intellihide-pressure-time', 'changed::intellihide-pressure-time',
@@ -417,7 +435,7 @@ export const Intellihide = class {
return !mouseBtnIsPressed return !mouseBtnIsPressed
} }
if (!SETTINGS.get_boolean('intellihide-hide-from-windows')) { if (!this._hidesFromWindows()) {
return this._hover return this._hover
} }

View File

@@ -1542,18 +1542,49 @@ const Preferences = class {
this._settings.bind( this._settings.bind(
'intellihide-hide-from-windows', 'intellihide-hide-from-windows',
this._builder.get_object('intellihide_window_hide_switch'), this._builder.get_object('intellihide_window_hide_button'),
'active', 'active',
Gio.SettingsBindFlags.DEFAULT, Gio.SettingsBindFlags.DEFAULT,
) )
this._settings.bind( this._settings.bind(
'intellihide-hide-from-windows', 'intellihide-hide-from-monitor-windows',
this._builder.get_object('intellihide_behaviour_options'), this._builder.get_object('intellihide_window_monitor_hide_button'),
'sensitive', 'active',
Gio.SettingsBindFlags.DEFAULT, Gio.SettingsBindFlags.DEFAULT,
) )
let setIntellihideBehaviorSensitivity = () => {
let overlappingButton = this._builder.get_object(
'intellihide_window_hide_button',
)
let hideFromMonitorWindows = this._settings.get_boolean(
'intellihide-hide-from-monitor-windows',
)
if (hideFromMonitorWindows) overlappingButton.set_active(false)
overlappingButton.set_sensitive(!hideFromMonitorWindows)
this._builder
.get_object('intellihide_behaviour_options')
.set_sensitive(
this._settings.get_boolean('intellihide-hide-from-windows') ||
hideFromMonitorWindows,
)
}
this._settings.connect(
'changed::intellihide-hide-from-windows',
setIntellihideBehaviorSensitivity,
)
this._settings.connect(
'changed::intellihide-hide-from-monitor-windows',
setIntellihideBehaviorSensitivity,
)
setIntellihideBehaviorSensitivity()
this._settings.bind( this._settings.bind(
'intellihide-behaviour', 'intellihide-behaviour',
this._builder.get_object('intellihide_behaviour_combo'), this._builder.get_object('intellihide_behaviour_combo'),

View File

@@ -34,14 +34,23 @@ export const Mode = {
MAXIMIZED_WINDOWS: 2, MAXIMIZED_WINDOWS: 2,
} }
export class ProximityWatch { class ProximityRectWatch {
constructor(actor, monitorIndex, mode, xThreshold, yThreshold, handler) { constructor(rect, monitorIndex, mode, xThreshold, yThreshold, handler) {
this.actor = actor this.rect = rect
this.monitorIndex = monitorIndex this.monitorIndex = monitorIndex
this.overlap = false this.overlap = false
this.mode = mode this.mode = mode
this.threshold = [xThreshold, yThreshold] this.threshold = [xThreshold, yThreshold]
this.handler = handler this.handler = handler
}
destroy() {}
}
class ProximityActorWatch extends ProximityRectWatch {
constructor(actor, monitorIndex, mode, xThreshold, yThreshold, handler) {
super(null, monitorIndex, mode, xThreshold, yThreshold, handler)
this.actor = actor
this._allocationChangedId = actor.connect('notify::allocation', () => this._allocationChangedId = actor.connect('notify::allocation', () =>
this._updateWatchRect(), this._updateWatchRect(),
@@ -79,9 +88,14 @@ export const ProximityManager = class {
this._setFocusedWindow() this._setFocusedWindow()
} }
createWatch(actor, monitorIndex, mode, xThreshold, yThreshold, handler) { createWatch(watched, monitorIndex, mode, xThreshold, yThreshold, handler) {
let watch = new ProximityWatch( let constr =
actor, watched instanceof Mtk.Rectangle
? ProximityRectWatch
: ProximityActorWatch
let watch = new constr(
watched,
monitorIndex, monitorIndex,
mode, mode,
xThreshold, xThreshold,

View File

@@ -44,10 +44,38 @@
<object class="AdwPreferencesGroup"> <object class="AdwPreferencesGroup">
<child> <child>
<object class="AdwActionRow"> <object class="AdwActionRow">
<property name="title" translatable="yes">Only hide the panel when it is obstructed by windows</property> <property name="title" translatable="yes">Only hide the panel from windows</property>
<child> <child>
<object class="GtkSwitch" id="intellihide_window_hide_switch"> <object class="GtkBox">
<property name="valign">center</property> <property name="margin-end">10</property>
<child>
<object class="GtkCheckButton" id="intellihide_window_hide_button">
<property name="receives-default">False</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Overlapping</property>
<property name="name">4</property>
<property name="use-markup">True</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox">
<child>
<object class="GtkCheckButton" id="intellihide_window_monitor_hide_button">
<property name="receives-default">False</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">On same monitor</property>
<property name="name">4</property>
<property name="use-markup">True</property>
</object>
</child>
</object> </object>
</child> </child>
</object> </object>
@@ -73,7 +101,7 @@
<object class="AdwPreferencesGroup"> <object class="AdwPreferencesGroup">
<child> <child>
<object class="AdwActionRow"> <object class="AdwActionRow">
<property name="title" translatable="yes">Require pressure at the edge of the screen to reveal the panel</property> <property name="title" translatable="yes">Require pressure at the edge of the monitor to reveal the panel</property>
<child> <child>
<object class="GtkSwitch" id="intellihide_use_pressure_switch"> <object class="GtkSwitch" id="intellihide_use_pressure_switch">
<property name="valign">center</property> <property name="valign">center</property>

View File

@@ -108,7 +108,7 @@
<object class="AdwPreferencesGroup" id="position_group_on_monitor2"> <object class="AdwPreferencesGroup" id="position_group_on_monitor2">
<child> <child>
<object class="AdwActionRow"> <object class="AdwActionRow">
<property name="title" translatable="yes">Panel screen position</property> <property name="title" translatable="yes">Panel monitor position</property>
<child> <child>
<object class="GtkToggleButton" id="position_bottom_button"> <object class="GtkToggleButton" id="position_bottom_button">
<property name="active">True</property> <property name="active">True</property>