Rely on overview allocation, enough with the ghosts

This commit is contained in:
Charles Gagnon
2022-04-09 12:03:46 -04:00
parent d37e213fab
commit dab9820132
4 changed files with 35 additions and 52 deletions

View File

@@ -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
*/

View File

@@ -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();

View File

@@ -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 }));

View File

@@ -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);