From fdaed87778af3dfdb09ef2a2c57acb14b8250680 Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Wed, 11 Sep 2019 09:21:03 -0400 Subject: [PATCH] Remove panel corners when not at top position --- panel.js | 97 ++++++++++++++++++++++++++----------------------- panelManager.js | 2 +- transparency.js | 19 +++++++--- 3 files changed, 66 insertions(+), 52 deletions(-) diff --git a/panel.js b/panel.js index ebcffec..c11abf2 100644 --- a/panel.js +++ b/panel.js @@ -103,11 +103,13 @@ var dtpPanel = Utils.defineClass({ this.isSecondary = isSecondary; this._sessionStyle = null; - this._leftCorner = new Panel.PanelCorner(St.Side.LEFT); - this.add_actor(this._leftCorner.actor); - - this._rightCorner = new Panel.PanelCorner(St.Side.RIGHT); - this.add_actor(this._rightCorner.actor); + if (getPosition() == St.Side.TOP) { + this._leftCorner = new Panel.PanelCorner(St.Side.LEFT); + this.add_actor(this._leftCorner.actor); + + this._rightCorner = new Panel.PanelCorner(St.Side.RIGHT); + this.add_actor(this._rightCorner.actor); + } this._dtpSettingsSignalIds = []; @@ -178,7 +180,7 @@ var dtpPanel = Utils.defineClass({ this._adjustForOverview(); - this._setPanelPosition(true); + this._setPanelPosition(); this._HeightNotifyListener = this.panelBox.connect("notify::height", Lang.bind(this, function(){ this._setPanelPosition(); @@ -656,36 +658,39 @@ var dtpPanel = Utils.defineClass({ childBoxRight[varCoord.c2] = panelAllocVarSize; } - let childBoxLeftCorner = new Clutter.ActorBox(); - let [ , cornerSize] = this._leftCorner.actor[sizeFunc](-1); - childBoxLeftCorner[varCoord.c1] = 0; - childBoxLeftCorner[varCoord.c2] = cornerSize; - childBoxLeftCorner[fixedCoord.c1] = panelAllocFixedSize; - childBoxLeftCorner[fixedCoord.c2] = panelAllocFixedSize + cornerSize; + if (this._leftCorner) { + let childBoxLeftCorner = new Clutter.ActorBox(); + let [ , cornerSize] = this._leftCorner.actor[sizeFunc](-1); + childBoxLeftCorner[varCoord.c1] = 0; + childBoxLeftCorner[varCoord.c2] = cornerSize; + childBoxLeftCorner[fixedCoord.c1] = panelAllocFixedSize; + childBoxLeftCorner[fixedCoord.c2] = panelAllocFixedSize + cornerSize; - let childBoxRightCorner = new Clutter.ActorBox(); - [ , cornerSize] = this._rightCorner.actor[sizeFunc](-1); - childBoxRightCorner[varCoord.c1] = panelAllocVarSize - cornerSize; - childBoxRightCorner[varCoord.c2] = panelAllocVarSize; - childBoxRightCorner[fixedCoord.c1] = panelAllocFixedSize; - childBoxRightCorner[fixedCoord.c2] = panelAllocFixedSize + cornerSize; + let childBoxRightCorner = new Clutter.ActorBox(); + [ , cornerSize] = this._rightCorner.actor[sizeFunc](-1); + childBoxRightCorner[varCoord.c1] = panelAllocVarSize - cornerSize; + childBoxRightCorner[varCoord.c2] = panelAllocVarSize; + childBoxRightCorner[fixedCoord.c1] = panelAllocFixedSize; + childBoxRightCorner[fixedCoord.c2] = panelAllocFixedSize + cornerSize; + + this._leftCorner.actor.allocate(childBoxLeftCorner, flags); + this._rightCorner.actor.allocate(childBoxRightCorner, flags); + } this._leftBox.allocate(childBoxLeft, flags); this._centerBox.allocate(childBoxCenter, flags); this._rightBox.allocate(childBoxRight, flags); - this._leftCorner.actor.allocate(childBoxLeftCorner, flags); - this._rightCorner.actor.allocate(childBoxRightCorner, flags); }, - _setPanelPosition: function(verticalize) { + _setPanelPosition: function() { let container = this.intellihide && this.intellihide.enabled ? this.panelBox.get_parent() : this.panelBox; + let isVertical = checkIfVertical(); this.set_size(this.geom.w, this.geom.h); container.set_position(this.geom.x, this.geom.y) - if (verticalize) { - this._setVertical(this, checkIfVertical()); - } + this._setVertical(this._centerBox, isVertical); + this._setVertical(this._rightBox, isVertical); // styles for theming Object.keys(St.Side).forEach(p => { @@ -704,29 +709,29 @@ var dtpPanel = Utils.defineClass({ }, _setVertical: function(actor, isVertical) { - if (actor) { - if (actor instanceof St.BoxLayout) { - actor.vertical = isVertical; - } - - if (actor instanceof PanelMenu.ButtonBox) { - let child = actor.get_first_child(); - - if (child) { - let currentStyle = child.get_style(); - let style = 'padding: ' + (isVertical ? '6px 0' : '0'); - - if (currentStyle && currentStyle != style) { - style = currentStyle + (currentStyle.trim().slice(-1) != ';' ? ';' : '') + style; - } - - actor.set_width(isVertical ? size : -1); - child.set_style(style); - } - } - - actor.get_children().forEach(c => this._setVertical(c, isVertical)); + if (!actor) { + return; } + + if (actor instanceof St.BoxLayout) { + actor.vertical = isVertical; + } else if (actor instanceof PanelMenu.ButtonBox) { + let child = actor.get_first_child(); + + if (child) { + let currentStyle = child.get_style(); + let style = 'padding: ' + (isVertical ? '6px 0' : '0'); + + if (currentStyle && currentStyle != style) { + style = currentStyle + (currentStyle.trim().slice(-1) != ';' ? ';' : '') + style; + } + + actor.set_width(isVertical ? size : -1); + child.set_style(style); + } + } + + actor.get_children().forEach(c => this._setVertical(c, isVertical)); }, _formatVerticalClock: function() { diff --git a/panelManager.js b/panelManager.js index a32cb79..d43b369 100755 --- a/panelManager.js +++ b/panelManager.js @@ -548,7 +548,7 @@ function newSetBarrierSize(size) { //the hotcorner sizes are re-applied when the panelbox allocation changes and //the used size is the panelbox height. To prevent giant barriers when the panelbox //is vertical, set a max size here - this._oldSetBarrierSize(Math.min(size, 32)); + this._oldSetBarrierSize(Panel.size); } function newUpdatePanelBarrier(panel) { diff --git a/transparency.js b/transparency.js index 3c4ce3c..1cd2b8b 100644 --- a/transparency.js +++ b/transparency.js @@ -38,7 +38,10 @@ var DynamicTransparency = Utils.defineClass({ this.currentBackgroundColor = 0; this._initialPanelStyle = dtpPanel.get_style(); - this._initialPanelCornerStyle = dtpPanel._leftCorner.actor.get_style(); + + if (this._dtpPanel._leftCorner) { + this._initialPanelCornerStyle = dtpPanel._leftCorner.actor.get_style(); + } this._signalsHandler = new Utils.GlobalSignalsHandler(); this._bindSignals(); @@ -53,8 +56,11 @@ var DynamicTransparency = Utils.defineClass({ this._proximityManager.removeWatch(this._proximityWatchId); this._dtpPanel.set_style(this._initialPanelStyle); - this._dtpPanel._leftCorner.actor.set_style(this._initialPanelCornerStyle); - this._dtpPanel._rightCorner.actor.set_style(this._initialPanelCornerStyle); + + if (this._dtpPanel._leftCorner) { + this._dtpPanel._leftCorner.actor.set_style(this._initialPanelCornerStyle); + this._dtpPanel._rightCorner.actor.set_style(this._initialPanelCornerStyle); + } }, _bindSignals: function() { @@ -206,8 +212,11 @@ var DynamicTransparency = Utils.defineClass({ let cornerStyle = '-panel-corner-background-color: ' + this.currentBackgroundColor + transition; this._dtpPanel.panelBg.set_style('background-color: ' + this.currentBackgroundColor + transition + this._complementaryStyles); - this._dtpPanel._leftCorner.actor.set_style(cornerStyle); - this._dtpPanel._rightCorner.actor.set_style(cornerStyle); + + if (this._dtpPanel._leftCorner) { + this._dtpPanel._leftCorner.actor.set_style(cornerStyle); + this._dtpPanel._rightCorner.actor.set_style(cornerStyle); + } }, _setGradient: function() {