From dab9820132cb338a94ef7d740e195e544121ef13 Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Sat, 9 Apr 2022 12:03:46 -0400 Subject: [PATCH] Rely on overview allocation, enough with the ghosts --- overview.js | 35 ++++++++++++++++++++++++++++++----- panel.js | 40 +++------------------------------------- panelManager.js | 4 ++-- utils.js | 8 -------- 4 files changed, 35 insertions(+), 52 deletions(-) diff --git a/overview.js b/overview.js index fc4b7dc..70857b1 100644 --- a/overview.js +++ b/overview.js @@ -41,7 +41,11 @@ const WorkspaceThumbnail = imports.ui.workspaceThumbnail; const Meta = imports.gi.Meta; const GS_HOTKEYS_KEY = 'switch-to-application-'; -const DASH_MARGIN = 60; + +// When the dash is shown, workspace window preview bottom labels go over it (default +// gnome-shell behavior), but when the extension hides the dash, leave some space +// so those labels don't go over a bottom panel +const LABEL_MARGIN = 60; //timeout names const T1 = 'swipeEndTimeout'; @@ -64,7 +68,9 @@ var Overview = class { this._optionalHotKeys(); this._optionalNumberOverlay(); this._optionalClickToExit(); + this._toggleDash(); + this._adaptAlloc(true); this._signalsHandler.add([ Me.settings, @@ -81,6 +87,7 @@ var Overview = class { this._injectionsHandler.destroy(); this._toggleDash(true); + this._adaptAlloc(); // Remove key bindings this._disableHotKeys(); @@ -94,16 +101,34 @@ var Overview = class { } let visibilityFunc = visible ? 'show' : 'hide'; - let height = -1; + let height = visible ? -1 : LABEL_MARGIN; let overviewControls = Main.overview._overview._controls; - if (!visible && this._panel.geom.position == St.Side.BOTTOM) - height = this._panel.geom.h + DASH_MARGIN - overviewControls.dash.actor[visibilityFunc](); overviewControls.dash.actor.set_height(height); } + _adaptAlloc(enable) { + let overviewControls = Main.overview._overview._controls + let proto = Object.getPrototypeOf(overviewControls) + let allocFunc = null + + if (enable) + allocFunc = (box) => { + // The default overview allocation is very good and takes into account external + // struts, everywhere but the bottom where the dash is usually fixed anyway. + // If there is a bottom panel under the dash location, give it some space here + let focusedPanel = this._panel.panelManager.focusedMonitorPanel + + if (focusedPanel?.geom.position == St.Side.BOTTOM) + box.y2 -= focusedPanel.geom.h + + proto.vfunc_allocate.call(overviewControls, box) + } + + Utils.hookVfunc(proto, 'allocate', allocFunc) + } + /** * Isolate overview to open new windows for inactive apps */ diff --git a/panel.js b/panel.js index 8d881b2..a5af66b 100644 --- a/panel.js +++ b/panel.js @@ -184,28 +184,11 @@ var Panel = GObject.registerClass({ this.geom = this.getGeometry(); - // The overview uses the panel height as a margin by way of a "ghost" transparent Clone - // This pushes everything down, which isn't desired when the panel is moved to the bottom - // I'm adding a 2nd ghost panel and will resize the top or bottom ghost depending on the panel position - this._myPanelGhost = new Clutter.Actor({ - x: this.geom.x, - y: this.geom.y , - reactive: false, - opacity: 0 - }); - let isTop = this.geom.position == St.Side.TOP; - if (isTop) { - if (Config.PACKAGE_VERSION < '42') { - this.panel._leftCorner = this.panel._leftCorner || new GSPanel.PanelCorner(St.Side.LEFT); - this.panel._rightCorner = this.panel._rightCorner || new GSPanel.PanelCorner(St.Side.RIGHT); - } - - Main.overview._overview.insert_child_at_index(this._myPanelGhost, 0); - } else { - let overviewControls = Main.overview._overview._controls || Main.overview._controls; - Main.overview._overview.add_actor(this._myPanelGhost); + if (isTop && Config.PACKAGE_VERSION < '42') { + this.panel._leftCorner = this.panel._leftCorner || new GSPanel.PanelCorner(St.Side.LEFT); + this.panel._rightCorner = this.panel._rightCorner || new GSPanel.PanelCorner(St.Side.RIGHT); } if (Config.PACKAGE_VERSION < '42' && this.panel._leftCorner) { @@ -280,8 +263,6 @@ var Panel = GObject.registerClass({ this.panel.actor.add_style_class_name('dashtopanelMainPanel ' + this.getOrientation()); - this._setPanelGhostSize(); - this._timeoutsHandler.add([T2, Me.settings.get_int('intellihide-enable-start-delay'), () => this.intellihide = new Intellihide.Intellihide(this)]); this._signalsHandler.add( @@ -404,8 +385,6 @@ var Panel = GObject.registerClass({ this.menuManager._changeMenu = this.menuManager._oldChangeMenu; - this._myPanelGhost.get_parent().remove_actor(this._myPanelGhost); - panelBoxes.forEach(b => delete this[b].allocate); this._unmappedButtons.forEach(a => this._disconnectVisibleId(a)); @@ -700,10 +679,6 @@ var Panel = GObject.registerClass({ return Me.persistentStorage[propName].pop(); } - _setPanelGhostSize() { - this._myPanelGhost.set_size(this.width, this.checkIfVertical() ? 1 : this.height); - } - _adjustForOverview() { let isFocusedMonitor = this.panelManager.checkIfFocusedMonitor(this.monitor); let isOverview = !!Main.overview.visibleTarget; @@ -711,19 +686,10 @@ var Panel = GObject.registerClass({ let isShown = !isOverview || isOverviewFocusedMonitor; this.panelBox[isShown ? 'show' : 'hide'](); - - if (isOverview) { - this._myPanelGhost[isOverviewFocusedMonitor ? 'show' : 'hide'](); - - if (isOverviewFocusedMonitor) { - Utils.getPanelGhost().set_size(1, this.geom.position == St.Side.TOP ? 0 : 32); - } - } } _resetGeometry() { this.geom = this.getGeometry(); - this._setPanelGhostSize(); this._setPanelPosition(); this.taskbar.resetAppIcons(true); this.dynamicTransparency.updateExternalStyle(); diff --git a/panelManager.js b/panelManager.js index d793e4e..8468128 100755 --- a/panelManager.js +++ b/panelManager.js @@ -272,8 +272,6 @@ var PanelManager = class { Main.overview._overview._controls._workspacesDisplay._updateWorkspacesViews = this._oldUpdateWorkspacesViews; - Utils.getPanelGhost().set_size(-1, -1); - LookingGlass.LookingGlass.prototype._resize = LookingGlass.LookingGlass.prototype._oldResize; delete LookingGlass.LookingGlass.prototype._oldResize; @@ -284,6 +282,8 @@ var PanelManager = class { } setFocusedMonitor(monitor) { + this.focusedMonitorPanel = this.allPanels.find(p => p.monitor == monitor) + if (!this.checkIfFocusedMonitor(monitor)) { Main.overview._overview.clear_constraints(); Main.overview._overview.add_constraint(new Layout.MonitorConstraint({ index: monitor.index })); diff --git a/utils.js b/utils.js index 2ed6e6a..216ea1e 100644 --- a/utils.js +++ b/utils.js @@ -526,14 +526,6 @@ var getPoint = function(coords) { return new Clutter.Point(coords); } -var getPanelGhost = function() { - if (!Main.overview._panelGhost) { - return Main.overview._overview.get_first_child(); - } - - return Main.overview._panelGhost; -} - var notify = function(text, iconName, action, isTransient) { let source = new MessageTray.SystemNotificationSource(); let notification = new MessageTray.Notification(source, 'Dash to Panel', text);