45 review

This commit is contained in:
Charles Gagnon
2023-09-23 07:09:34 -04:00
parent e63fac1361
commit b9541861e9
4 changed files with 42 additions and 58 deletions

View File

@@ -30,6 +30,7 @@ import St from 'gi://St';
import * as Main from 'resource:///org/gnome/shell/ui/main.js';
import * as WindowManager from 'resource:///org/gnome/shell/ui/windowManager.js';
import {WindowPreview} from 'resource:///org/gnome/shell/ui/windowPreview.js';
import {InjectionManager} from 'resource:///org/gnome/shell/extensions/extension.js';
import {SETTINGS} from './extension.js';
const GS_HOTKEYS_KEY = 'switch-to-application-';
@@ -46,6 +47,7 @@ const T2 = 'numberOverlayTimeout';
export const Overview = class {
constructor() {
this._injectionManager = new InjectionManager();
this._numHotkeys = 10;
}
@@ -63,7 +65,7 @@ export const Overview = class {
this._optionalClickToExit();
this._toggleDash();
this._adaptAlloc(true);
this._adaptAlloc();
this._signalsHandler.add([
SETTINGS,
@@ -79,9 +81,9 @@ export const Overview = class {
this._signalsHandler.destroy();
this._injectionsHandler.destroy();
this._timeoutsHandler.destroy();
this._injectionManager.clear();
this._toggleDash(true);
this._adaptAlloc();
// Remove key bindings
this._disableHotKeys();
@@ -102,41 +104,39 @@ export const Overview = class {
overviewControls.dash.set_height(height);
}
_adaptAlloc(enable) {
_adaptAlloc() {
let overviewControls = Main.overview._overview._controls
let proto = Object.getPrototypeOf(overviewControls)
let allocFunc = null
if (enable)
allocFunc = (box) => {
let focusedPanel = this._panel.panelManager.focusedMonitorPanel
this._injectionManager.overrideMethod(Object.getPrototypeOf(overviewControls), 'vfunc_allocate',
(originalAllocate) =>
(box) => {
let focusedPanel = this._panel.panelManager.focusedMonitorPanel
if (focusedPanel) {
let position = focusedPanel.geom.position
let isBottom = position == St.Side.BOTTOM
if (focusedPanel) {
let position = focusedPanel.geom.position
let isBottom = position == St.Side.BOTTOM
if (focusedPanel.intellihide?.enabled) {
// Panel intellihide is enabled (struts aren't taken into account on overview allocation),
// dynamically modify the overview box to follow the reveal/hide animation
let { transitioning, finalState, progress } = overviewControls._stateAdjustment.getStateTransitionParams()
let size = focusedPanel.geom[focusedPanel.checkIfVertical() ? 'w' : 'h'] *
(transitioning ? Math.abs((finalState != 0 ? 0 : 1) - progress) : 1)
if (focusedPanel.intellihide?.enabled) {
// Panel intellihide is enabled (struts aren't taken into account on overview allocation),
// dynamically modify the overview box to follow the reveal/hide animation
let { transitioning, finalState, progress } = overviewControls._stateAdjustment.getStateTransitionParams()
let size = focusedPanel.geom[focusedPanel.checkIfVertical() ? 'w' : 'h'] *
(transitioning ? Math.abs((finalState != 0 ? 0 : 1) - progress) : 1)
if (isBottom || position == St.Side.RIGHT)
box[focusedPanel.fixedCoord.c2] -= size
else
box[focusedPanel.fixedCoord.c1] += size
} else if (isBottom)
// 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
box.y2 -= focusedPanel.geom.h
if (isBottom || position == St.Side.RIGHT)
box[focusedPanel.fixedCoord.c2] -= size
else
box[focusedPanel.fixedCoord.c1] += size
} else if (isBottom)
// 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
box.y2 -= focusedPanel.geom.h
}
originalAllocate.call(overviewControls, box)
}
proto.vfunc_allocate.call(overviewControls, box)
}
Utils.hookVfunc(proto, 'allocate', allocFunc)
);
}
/**

View File

@@ -53,7 +53,7 @@ import * as Progress from './progress.js';
import * as Intellihide from './intellihide.js';
import * as Transparency from './transparency.js';
import {SETTINGS, DESKTOPSETTINGS, PERSISTENTSTORAGE} from './extension.js';
import {gettext as _} from 'resource:///org/gnome/shell/extensions/extension.js';
import {gettext as _, InjectionManager} from 'resource:///org/gnome/shell/extensions/extension.js';
let tracker = Shell.WindowTracker.get_default();
export const panelBoxes = ['_leftBox', '_centerBox', '_rightBox'];
@@ -73,6 +73,7 @@ export const Panel = GObject.registerClass({
this._timeoutsHandler = new Utils.TimeoutsHandler();
this._signalsHandler = new Utils.GlobalSignalsHandler();
this._injectionManager = new InjectionManager();
this.panelManager = panelManager;
this.panelStyle = new PanelStyle.PanelStyle();
@@ -180,12 +181,12 @@ export const Panel = GObject.registerClass({
this._setPanelPosition();
if (!this.isStandalone) {
Utils.hookVfunc(Object.getPrototypeOf(this.panel), 'allocate', (box) => this._mainPanelAllocate(box));
this._injectionManager.overrideMethod(Object.getPrototypeOf(this.panel), 'vfunc_allocate', () => (box) => this._mainPanelAllocate(box));
// remove the extra space before the clock when the message-indicator is displayed
if (DateMenu.IndicatorPad) {
Utils.hookVfunc(DateMenu.IndicatorPad.prototype, 'get_preferred_width', () => [0,0]);
Utils.hookVfunc(DateMenu.IndicatorPad.prototype, 'get_preferred_height', () => [0,0]);
this._injectionManager.overrideMethod(DateMenu.IndicatorPad.prototype, 'vfunc_get_preferred_width', () => () => [0,0]);
this._injectionManager.overrideMethod(DateMenu.IndicatorPad.prototype, 'vfunc_get_preferred_height', () => () => [0,0]);
}
}
@@ -373,12 +374,7 @@ export const Panel = GObject.registerClass({
delete Utils.getIndicators(this.statusArea[systemMenuName]._volumeOutput)._dtpIgnoreScroll;
if (DateMenu.IndicatorPad) {
Utils.hookVfunc(DateMenu.IndicatorPad.prototype, 'get_preferred_width', DateMenu.IndicatorPad.prototype.vfunc_get_preferred_width);
Utils.hookVfunc(DateMenu.IndicatorPad.prototype, 'get_preferred_height', DateMenu.IndicatorPad.prototype.vfunc_get_preferred_height);
}
Utils.hookVfunc(Object.getPrototypeOf(this.panel), 'allocate', Object.getPrototypeOf(this.panel).vfunc_allocate);
this._injectionManager.clear();
this.panel._delegate = this.panel;
} else {

View File

@@ -46,6 +46,7 @@ import * as LookingGlass from 'resource:///org/gnome/shell/ui/lookingGlass.js';
import * as Main from 'resource:///org/gnome/shell/ui/main.js';
import * as PanelMenu from 'resource:///org/gnome/shell/ui/panelMenu.js';
import * as Layout from 'resource:///org/gnome/shell/ui/layout.js';
import {InjectionManager} from 'resource:///org/gnome/shell/extensions/extension.js';
import {SETTINGS} from './extension.js';
import {SecondaryMonitorDisplay, WorkspacesView} from 'resource:///org/gnome/shell/ui/workspacesView.js';
@@ -55,6 +56,7 @@ export const PanelManager = class {
constructor() {
this.overview = new Overview.Overview();
this.panelsElementPositions = {};
this._injectionManager = new InjectionManager();
this._saveMonitors();
}
@@ -102,7 +104,7 @@ export const PanelManager = class {
if (BoxPointer.BoxPointer.prototype.vfunc_get_preferred_height) {
let panelManager = this;
Utils.hookVfunc(BoxPointer.BoxPointer.prototype, 'get_preferred_height', function(forWidth) {
this._injectionManager.overrideMethod(BoxPointer.BoxPointer.prototype, 'vfunc_get_preferred_height', () => function(forWidth) {
let alloc = { min_size: 0, natural_size: 0 };
[alloc.min_size, alloc.natural_size] = this.vfunc_get_preferred_height(forWidth);
@@ -253,9 +255,7 @@ export const PanelManager = class {
}
});
if (BoxPointer.BoxPointer.prototype.vfunc_get_preferred_height) {
Utils.hookVfunc(BoxPointer.BoxPointer.prototype, 'get_preferred_height', BoxPointer.BoxPointer.prototype.vfunc_get_preferred_height);
}
this._injectionManager.clear();
if (Main.layoutManager.primaryMonitor) {
Main.layoutManager.panelBox.set_position(Main.layoutManager.primaryMonitor.x, Main.layoutManager.primaryMonitor.y);

View File

@@ -33,8 +33,6 @@ import * as Util from 'resource:///org/gnome/shell/misc/util.js';
import * as Main from 'resource:///org/gnome/shell/ui/main.js';
import * as MessageTray from 'resource:///org/gnome/shell/ui/messageTray.js';
const Gi = imports._gi;
const SCROLL_TIME = Util.SCROLL_TIME / (Util.SCROLL_TIME > 1 ? 1000 : 1);
// simplify global signals and function injections handling
@@ -279,16 +277,6 @@ export const mergeObjects = function(main, bck) {
return main;
};
export const hookVfunc = function(proto, symbol, func) {
if (!func) return
if (Gi.gobject_prototype_symbol && proto[Gi.gobject_prototype_symbol]) {
proto[Gi.gobject_prototype_symbol][Gi.hook_up_vfunc_symbol] (symbol, func);
} else {
proto[Gi.hook_up_vfunc_symbol] (symbol, func);
}
};
export const getTrackedActorData = (actor) => {
let trackedIndex = Main.layoutManager._findActor(actor);