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 type="b" name="intellihide-hide-from-windows">
<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>
</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">
<default>'FOCUSED_WINDOWS'</default>
<summary>Intellihide behaviour</summary>

View File

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

View File

@@ -1542,18 +1542,49 @@ const Preferences = class {
this._settings.bind(
'intellihide-hide-from-windows',
this._builder.get_object('intellihide_window_hide_switch'),
this._builder.get_object('intellihide_window_hide_button'),
'active',
Gio.SettingsBindFlags.DEFAULT,
)
this._settings.bind(
'intellihide-hide-from-windows',
this._builder.get_object('intellihide_behaviour_options'),
'sensitive',
'intellihide-hide-from-monitor-windows',
this._builder.get_object('intellihide_window_monitor_hide_button'),
'active',
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(
'intellihide-behaviour',
this._builder.get_object('intellihide_behaviour_combo'),

View File

@@ -34,14 +34,23 @@ export const Mode = {
MAXIMIZED_WINDOWS: 2,
}
export class ProximityWatch {
constructor(actor, monitorIndex, mode, xThreshold, yThreshold, handler) {
this.actor = actor
class ProximityRectWatch {
constructor(rect, monitorIndex, mode, xThreshold, yThreshold, handler) {
this.rect = rect
this.monitorIndex = monitorIndex
this.overlap = false
this.mode = mode
this.threshold = [xThreshold, yThreshold]
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._updateWatchRect(),
@@ -79,9 +88,14 @@ export const ProximityManager = class {
this._setFocusedWindow()
}
createWatch(actor, monitorIndex, mode, xThreshold, yThreshold, handler) {
let watch = new ProximityWatch(
actor,
createWatch(watched, monitorIndex, mode, xThreshold, yThreshold, handler) {
let constr =
watched instanceof Mtk.Rectangle
? ProximityRectWatch
: ProximityActorWatch
let watch = new constr(
watched,
monitorIndex,
mode,
xThreshold,

View File

@@ -44,10 +44,38 @@
<object class="AdwPreferencesGroup">
<child>
<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>
<object class="GtkSwitch" id="intellihide_window_hide_switch">
<property name="valign">center</property>
<object class="GtkBox">
<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>
</child>
</object>
@@ -73,7 +101,7 @@
<object class="AdwPreferencesGroup">
<child>
<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>
<object class="GtkSwitch" id="intellihide_use_pressure_switch">
<property name="valign">center</property>

View File

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