make backwards compatible to gnome 41 again

This commit is contained in:
Philipp Unger
2022-03-16 20:41:21 +01:00
parent b7c6780320
commit 3065323788
3 changed files with 99 additions and 12 deletions

View File

@@ -99,6 +99,7 @@ var dtpPanel = Utils.defineClass({
this._sessionStyle = null;
this._unmappedButtons = [];
this._elementGroups = [];
this.cornerSize = 0;
let position = this.getPosition();
@@ -203,12 +204,30 @@ var dtpPanel = Utils.defineClass({
let isTop = this.geom.position == St.Side.TOP;
if (isTop) {
this.panel._leftCorner = this.panel._leftCorner || new Panel.PanelCorner(St.Side.LEFT);
this.panel._rightCorner = this.panel._rightCorner || new Panel.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 (Config.PACKAGE_VERSION < '42' && this.panel._leftCorner) {
Utils.wrapActor(this.panel._leftCorner);
Utils.wrapActor(this.panel._rightCorner);
if (isTop) {
if (this.isStandalone) {
this.panel.actor.add_child(this.panel._leftCorner.actor);
this.panel.actor.add_child(this.panel._rightCorner.actor);
}
} else if (Config.PACKAGE_VERSION >= '3.32') {
this.panel.actor.remove_child(this.panel._leftCorner.actor);
this.panel.actor.remove_child(this.panel._rightCorner.actor);
}
}
this._setPanelPosition();
if (!this.isStandalone) {
@@ -375,7 +394,8 @@ var dtpPanel = Utils.defineClass({
this._timeoutsHandler.destroy();
this._signalsHandler.destroy();
this._disablePanelCornerSignals();
this.panel.actor.remove_child(this.taskbar.actor);
this._setAppmenuVisible(false);
@@ -422,6 +442,11 @@ var dtpPanel = Utils.defineClass({
});
}
if (Config.PACKAGE_VERSION < '42' && !this.panel._leftCorner.actor.mapped) {
this.panel.actor.add_child(this.panel._leftCorner.actor);
this.panel.actor.add_child(this.panel._rightCorner.actor);
}
this._setShowDesktopButton(false);
delete Utils.getIndicators(this.statusArea.aggregateMenu._volume)._dtpIgnoreScroll;
@@ -488,6 +513,26 @@ var dtpPanel = Utils.defineClass({
this._updateGroupedElements(panelPositions);
this._disablePanelCornerSignals();
if (Config.PACKAGE_VERSION < '42' && this.getPosition() == St.Side.TOP) {
let visibleElements = panelPositions.filter(pp => pp.visible);
let connectCorner = (corner, button) => {
corner._button = button;
corner._buttonStyleChangedSignalId = button.connect('style-changed', () => {
corner.set_style_pseudo_class(button.get_style_pseudo_class());
});
}
if (visibleElements[0].element == Pos.ACTIVITIES_BTN) {
connectCorner(this.panel._leftCorner, this.statusArea.activities);
}
if (visibleElements[visibleElements.length - 1].element == Pos.SYSTEM_MENU) {
connectCorner(this.panel._rightCorner, this.statusArea.aggregateMenu);
}
}
this.panel.actor.hide();
this.panel.actor.show();
},
@@ -542,6 +587,20 @@ var dtpPanel = Utils.defineClass({
});
},
_disablePanelCornerSignals: function() {
if (Config.PACKAGE_VERSION < '42') {
if (this.panel._rightCorner && this.panel._rightCorner._buttonStyleChangedSignalId) {
this.panel._rightCorner._button.disconnect(this.panel._rightCorner._buttonStyleChangedSignalId);
delete this.panel._rightCorner._buttonStyleChangedSignalId;
}
if (this.panel._leftCorner && this.panel._leftCorner._buttonStyleChangedSignalId) {
this.panel._leftCorner._button.disconnect(this.panel._leftCorner._buttonStyleChangedSignalId);
delete this.panel._leftCorner._buttonStyleChangedSignalId;
}
}
},
_bindSettingsChanges: function() {
let isVertical = this.checkIfVertical();
@@ -949,17 +1008,30 @@ var dtpPanel = Utils.defineClass({
if (this.geom.position == St.Side.TOP) {
let childBoxLeftCorner = new Clutter.ActorBox();
let childBoxRightCorner = new Clutter.ActorBox();
let currentCornerSize = this.cornerSize;
let panelAllocFixedSize = box[this.fixedCoord.c2] - box[this.fixedCoord.c1];
if (Config.PACKAGE_VERSION < '42') {
[ , this.cornerSize] = this.panel._leftCorner.actor[this.sizeFunc](-1);
}
childBoxLeftCorner[this.varCoord.c1] = 0;
childBoxLeftCorner[this.varCoord.c2] = 0;
childBoxLeftCorner[this.varCoord.c2] = this.cornerSize;
childBoxLeftCorner[this.fixedCoord.c1] = panelAllocFixedSize;
childBoxLeftCorner[this.fixedCoord.c2] = panelAllocFixedSize;
childBoxLeftCorner[this.fixedCoord.c2] = panelAllocFixedSize + this.cornerSize;
childBoxRightCorner[this.varCoord.c1] = box[this.varCoord.c2];
childBoxRightCorner[this.varCoord.c1] = box[this.varCoord.c2] - this.cornerSize;
childBoxRightCorner[this.varCoord.c2] = box[this.varCoord.c2];
childBoxRightCorner[this.fixedCoord.c1] = panelAllocFixedSize;
childBoxRightCorner[this.fixedCoord.c2] = panelAllocFixedSize;
childBoxRightCorner[this.fixedCoord.c2] = panelAllocFixedSize + this.cornerSize;
if (Config.PACKAGE_VERSION < '42') {
Utils.allocate(this.panel._leftCorner.actor, childBoxLeftCorner, flags);
Utils.allocate(this.panel._rightCorner.actor, childBoxRightCorner, flags);
if (this.cornerSize != currentCornerSize) {
this._setPanelClip();
}
}
}
},
@@ -986,7 +1058,7 @@ var dtpPanel = Utils.defineClass({
_setPanelClip: function(clipContainer) {
clipContainer = clipContainer || this.panelBox.get_parent();
this._timeoutsHandler.add([T7, 0, () => Utils.setClip(clipContainer, clipContainer.x, clipContainer.y, this.panelBox.width, this.panelBox.height)]);
this._timeoutsHandler.add([T7, 0, () => Utils.setClip(clipContainer, clipContainer.x, clipContainer.y, this.panelBox.width, this.panelBox.height + this.cornerSize)]);
},
_onButtonPress: function(actor, event) {

View File

@@ -21,6 +21,7 @@ const Lang = imports.lang;
const Main = imports.ui.main;
const Meta = imports.gi.Meta;
const St = imports.gi.St;
const Config = imports.misc.config;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const Panel = Me.imports.panel;
@@ -39,6 +40,10 @@ var DynamicTransparency = Utils.defineClass({
this._initialPanelStyle = dtpPanel.panel.actor.get_style();
if (Config.PACKAGE_VERSION < '42' && this._dtpPanel.geom.position == St.Side.TOP) {
this._initialPanelCornerStyle = dtpPanel.panel._leftCorner.actor.get_style();
}
this._signalsHandler = new Utils.GlobalSignalsHandler();
this._bindSignals();
@@ -52,6 +57,11 @@ var DynamicTransparency = Utils.defineClass({
this._proximityManager.removeWatch(this._proximityWatchId);
this._dtpPanel.panel.actor.set_style(this._initialPanelStyle);
if (Config.PACKAGE_VERSION < '42' && this._dtpPanel.geom.position == St.Side.TOP) {
this._dtpPanel.panel._leftCorner.actor.set_style(this._initialPanelCornerStyle);
this._dtpPanel.panel._rightCorner.actor.set_style(this._initialPanelCornerStyle);
}
},
updateExternalStyle: function() {
@@ -211,6 +221,12 @@ var DynamicTransparency = Utils.defineClass({
let transition = 'transition-duration:' + this.animationDuration;
this._dtpPanel.set_style('background-color: ' + this.currentBackgroundColor + transition + this._complementaryStyles);
if (Config.PACKAGE_VERSION < '42' && this._dtpPanel.geom.position == St.Side.TOP) {
let cornerStyle = '-panel-corner-background-color: ' + this.currentBackgroundColor + transition;
this._dtpPanel.panel._leftCorner.actor.set_style(cornerStyle);
this._dtpPanel.panel._rightCorner.actor.set_style(cornerStyle);
}
},
_setGradient: function() {

View File

@@ -358,12 +358,11 @@ var mergeObjects = function(main, bck) {
var hookVfunc = function(proto, symbol, func) {
if (Gi.hook_up_vfunc_symbol && func) {
//gjs > 1.53.3
proto[Gi.gobject_prototype_symbol][Gi.hook_up_vfunc_symbol](symbol, func);
} else {
//On older gjs, this is how to hook vfunc. It is buggy and can't be used reliably to replace
//already hooked functions. Since it's our only use for it, disabled for now (and probably forever)
//Gi.hook_up_vfunc(proto, symbol, func);
if (Config.PACKAGE_VERSION < '42') {
proto[Gi.hook_up_vfunc_symbol](symbol, func);
} else {
proto[Gi.gobject_prototype_symbol][Gi.hook_up_vfunc_symbol](symbol, func);
}
}
};