Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panel.js: Only clip the panel size if necessary. #12592

Merged
merged 1 commit into from
Jan 1, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading