From a349beff32f4064a1cfd5a45a5b13ccc1c99a9f6 Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Sun, 23 Jun 2019 23:56:49 -0400 Subject: [PATCH] Add clipping container to panelbox --- intellihide.js | 31 ++++++++++++++++++++++++++----- utils.js | 6 ++++++ windowPreview.js | 4 +--- 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/intellihide.js b/intellihide.js index e725715..1b4bd83 100644 --- a/intellihide.js +++ b/intellihide.js @@ -89,7 +89,7 @@ var Intellihide = Utils.defineClass({ if (this._dtpSettings.get_boolean('intellihide-hide-from-windows')) { this._proximityWatchId = this._proximityManager.createWatch( - this._panelBox, + this._clipContainer, Proximity.Mode[this._dtpSettings.get_string('intellihide-behaviour')], 0, 0, overlap => { @@ -123,7 +123,10 @@ var Intellihide = Utils.defineClass({ destroy: function() { this._dtpSettings.disconnect(this._intellihideChangedId); this._dtpSettings.disconnect(this._intellihideOnlySecondaryChangedId); - this.disable(); + + if (this._enabled) { + this.disable(); + } }, toggle: function() { @@ -213,8 +216,25 @@ var Intellihide = Utils.defineClass({ _setTrackPanel: function(reset, enable) { if (!reset) { Main.layoutManager._untrackActor(this._panelBox); - Main.layoutManager._trackActor(this._panelBox, { affectsStruts: !enable, trackFullscreen: !enable }); - + + if (enable) { + this._clipContainer = new Clutter.Actor(); + Utils.setClip(this._clipContainer, this._panelBox.x, this._panelBox.y, this._panelBox.width, this._panelBox.height); + + Main.layoutManager.uiGroup.remove_actor(this._panelBox); + this._clipContainer.add_child(this._panelBox); + this._panelBox.set_position(0, 0); + + Main.layoutManager.addChrome(this._clipContainer, { affectsInputRegion: false }); + Main.layoutManager.trackChrome(this._panelBox, { affectsInputRegion: true, affectsStruts: false, trackFullscreen: false }); + } else { + this._panelBox.set_position(this._clipContainer.x, this._clipContainer.y); + Main.layoutManager.removeChrome(this._clipContainer); + + this._clipContainer.remove_child(this._panelBox); + Main.layoutManager.addChrome(this._panelBox, { affectsStruts: true, trackFullscreen: true }); + } + this._panelBox.track_hover = enable; this._panelBox.reactive = enable; this._panelBox.visible = enable ? enable : this._panelBox.visible; @@ -274,7 +294,8 @@ var Intellihide = Utils.defineClass({ if (!this._panelBox.hover && !Main.overview.visible && ((this._panelAtTop && y <= this._monitor.y + 1) || (!this._panelAtTop && y >= this._monitor.y + this._monitor.height - 1)) && - (x > this._monitor.x && x < this._monitor.x + this._monitor.width)) { + ((x > this._monitor.x && x < this._monitor.x + this._monitor.width) && + (y > this._monitor.y && y < this._monitor.y + this._monitor.height))) { this._queueUpdatePanelPosition(true); } }, diff --git a/utils.js b/utils.js index 6441d17..963312a 100644 --- a/utils.js +++ b/utils.js @@ -334,6 +334,12 @@ var wrapActor = function(actor) { } }; +var setClip = function(actor, x, y, width, height) { + actor.set_clip(0, 0, width, height); + actor.set_position(x, y); + actor.set_size(width, height); +}; + var addKeybinding = function(key, settings, handler, modes) { if (!Main.wm._allowedKeybindings[key]) { Main.wm.addKeybinding( diff --git a/windowPreview.js b/windowPreview.js index ce42944..840ac64 100644 --- a/windowPreview.js +++ b/windowPreview.js @@ -441,9 +441,7 @@ var PreviewMenu = Utils.defineClass({ y = this._panelWrapper.monitor.y + this._panelWrapper.monitor.height - (panelSize + panelBoxTheme.get_padding(St.Side.BOTTOM) + previewSize + headerHeight); } - this.set_clip(0, 0, w, h); - this.set_position(x, y); - this.set_size(w, h); + Utils.setClip(this, x, y, w, h); }, _updatePosition: function() {