Skip to content

Commit

Permalink
panel.js: Only clip the panel size if necessary. (#12592)
Browse files Browse the repository at this point in the history
Panel clipping occurs to prevent a hidden panel from being visible
on an adjacent monitor edge. In some monitor configurations it can
affect actor event picking, and the enter-events that trigger panel
visibility are missed.

Regardless of the pick problem, clipping should only be necessary if:
- There's more than a single monitor.
- There is at least a partial common edge shared by two monitors.
- There is an auto- or intelligently-hidden panel enabled on that edge.
  • Loading branch information
mtwebster authored Jan 1, 2025
1 parent 7ccb18a commit 4e87c99
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions js/ui/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2772,6 +2772,13 @@ Panel.prototype = {
* current position in order to calculate the exposed size.
*/
_setClipRegion: function(hidden, offset) {
if (!this._shouldClipPanel()) {
// important during monitor layout changes.
this.actor.remove_clip(); // no-op if there wasn't any clipping to begin with.
Main.layoutManager.updateChrome()
return;
}

let animating = typeof offset === "number";
let isHorizontal = this.panelPosition == PanelLoc.top
|| this.panelPosition == PanelLoc.bottom;
Expand Down Expand Up @@ -2839,6 +2846,56 @@ Panel.prototype = {
Main.layoutManager.updateChrome()
},

_shouldClipPanel: function() {
const n_monitors = global.display.get_n_monitors();

if (n_monitors === 1) {
return false;
}

for (let i = 0; i < n_monitors; i++) {
if (i === this.monitorIndex) {
continue;
}

const m_rect = global.display.get_monitor_geometry(i);
const test_rect = new Meta.Rectangle();

switch (this.panelPosition) {
case PanelLoc.top:
case PanelLoc.bottom:
test_rect.x = this.actor.x;
test_rect.width = this.actor.width;
test_rect.height = this.height;

if (this.panelPosition === PanelLoc.top) {
test_rect.y = this.monitor.y - this.height;
} else {
test_rect.y = this.monitor.y + this.monitor.height;
}
break;
case PanelLoc.left:
case PanelLoc.right:
test_rect.y = this.actor.y;
test_rect.height = this.actor.height;
test_rect.width = this.height;

if (this.panelPosition === PanelLoc.left) {
test_rect.x = this.monitor.x - this.height;
} else {
test_rect.x = this.monitor.x + this.monitor.width;
}
break;
}

if (m_rect.overlap(test_rect)) {
return true;
}
}

return false;
},

/**
* _moveResizePanel:
*
Expand Down

0 comments on commit 4e87c99

Please sign in to comment.