From ed3c3e072e55a3c00e2f0a3ab8f810a36bce2c2c Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Mon, 16 Dec 2019 22:10:05 -0500 Subject: [PATCH] Adjust for gnome-shell 3.35.2 breaking changes --- appIcons.js | 49 ++++++++++++++++++++++++++++++++++++++++-------- overview.js | 11 ++++++----- panel.js | 43 +++++++++++++++++++++++------------------- panelManager.js | 28 ++++++++++++++++++++++++--- taskbar.js | 2 +- utils.js | 32 +++++++++++++++++++++++++++++++ windowPreview.js | 2 +- 7 files changed, 130 insertions(+), 37 deletions(-) diff --git a/appIcons.js b/appIcons.js index 2a672be..b0ca766 100644 --- a/appIcons.js +++ b/appIcons.js @@ -129,6 +129,7 @@ var taskbarAppIcon = Utils.defineClass({ this.callParent('_init', appInfo.app, iconParams); Utils.wrapActor(this.icon); + Utils.wrapActor(this); this._dot.set_width(0); this._isGroupApps = Me.settings.get_boolean('group-apps'); @@ -288,6 +289,11 @@ var taskbarAppIcon = Utils.defineClass({ Utils.DisplayWrapper.getScreen().disconnect(this._windowEnteredMonitorId); Utils.DisplayWrapper.getScreen().disconnect(this._windowLeftMonitorId); } + + if (this.setStyleTimeoutId) { + Mainloop.source_remove(this.setStyleTimeoutId); + this.setStyleTimeoutId = 0; + } if(this._switchWorkspaceId) global.window_manager.disconnect(this._switchWorkspaceId); @@ -509,13 +515,16 @@ var taskbarAppIcon = Utils.defineClass({ inlineStyle += "background-color: " + cssHexTocssRgba(highlightColor, Me.settings.get_int('focus-highlight-opacity') * 0.01); } - if(this._dotsContainer.get_style() != inlineStyle) { + if(this._dotsContainer.get_style() != inlineStyle && this._dotsContainer.mapped) { if (!this._isGroupApps) { //when the apps are ungrouped, set the style synchronously so the icons don't jump around on taskbar redraw this._dotsContainer.set_style(inlineStyle); - } else { + } else if (!this.setStyleTimeoutId) { //graphical glitches if i dont set this on a timeout - Mainloop.timeout_add(0, Lang.bind(this, function() { this._dotsContainer.set_style(inlineStyle); })); + this.setStyleTimeoutId = Mainloop.timeout_add(0, Lang.bind(this, function() { + this._dotsContainer.set_style(inlineStyle); + this.setStyleTimeoutId = 0; + })); } } }, @@ -1579,11 +1588,7 @@ var ShowAppsIconWrapper = Utils.defineClass({ // Re-use appIcon methods this._removeMenuTimeout = AppDisplay.AppIcon.prototype._removeMenuTimeout; this._setPopupTimeout = AppDisplay.AppIcon.prototype._setPopupTimeout; - this._onButtonPress = AppDisplay.AppIcon.prototype._onButtonPress; this._onKeyboardPopupMenu = AppDisplay.AppIcon.prototype._onKeyboardPopupMenu; - this._onLeaveEvent = AppDisplay.AppIcon.prototype._onLeaveEvent; - this._onTouchEvent = AppDisplay.AppIcon.prototype._onTouchEvent; - this._onMenuPoppedDown = AppDisplay.AppIcon.prototype._onMenuPoppedDown; // No action on clicked (showing of the appsview is controlled elsewhere) this._onClicked = Lang.bind(this, function(actor, button) { @@ -1627,6 +1632,34 @@ var ShowAppsIconWrapper = Utils.defineClass({ this.setShowAppsPadding(); }, + + _onButtonPress: function(_actor, event) { + let button = event.get_button(); + if (button == 1) { + this._setPopupTimeout(); + } else if (button == 3) { + this.popupMenu(); + return Clutter.EVENT_STOP; + } + return Clutter.EVENT_PROPAGATE; + }, + + _onLeaveEvent: function(_actor, _event) { + this.actor.fake_release(); + this._removeMenuTimeout(); + }, + + _onTouchEvent: function(actor, event) { + if (event.type() == Clutter.EventType.TOUCH_BEGIN) + this._setPopupTimeout(); + + return Clutter.EVENT_PROPAGATE; + }, + + _onMenuPoppedDown: function() { + this.actor.sync_hover(); + this.emit('menu-state-changed', false); + }, setShowAppsPadding: function() { let padding = getIconPadding(); @@ -1641,7 +1674,7 @@ var ShowAppsIconWrapper = Utils.defineClass({ this.actor.fake_release(); if (!this._menu) { - this._menu = new MyShowAppsIconMenu(this, Me.settings); + this._menu = new MyShowAppsIconMenu(this.actor); this._menu.connect('open-state-changed', Lang.bind(this, function(menu, isPoppedUp) { if (!isPoppedUp) this._onMenuPoppedDown(); diff --git a/overview.js b/overview.js index fb180db..f327a9e 100644 --- a/overview.js +++ b/overview.js @@ -71,7 +71,7 @@ var dtpOverview = Utils.defineClass({ this._toggleDash(true); // reset stored icon size to the default dash - Main.overview.dashIconSize = Main.overview._controls.dash.iconSize; + Utils.setDashIconSize((Main.overview._overview._controls || Main.overview._controls).dash.iconSize); // Remove key bindings this._disableHotKeys(); @@ -92,12 +92,13 @@ var dtpOverview = Utils.defineClass({ let visibilityFunc = visible ? 'show' : 'hide'; let width = visible ? -1 : 1; - - Main.overview._controls.dash.actor[visibilityFunc](); - Main.overview._controls.dash.actor.set_width(width); + let overviewControls = Main.overview._overview._controls || Main.overview._controls; + + overviewControls.dash.actor[visibilityFunc](); + overviewControls.dash.actor.set_width(width); // This force the recalculation of the icon size - Main.overview._controls.dash._maxHeight = -1; + overviewControls.dash._maxHeight = -1; }, /** diff --git a/panel.js b/panel.js index b06a859..43c1b79 100644 --- a/panel.js +++ b/panel.js @@ -137,9 +137,12 @@ var dtpPanel = Utils.defineClass({ if (position == 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); + + Utils.wrapActor(this._leftCorner); + Utils.wrapActor(this._rightCorner); + + this.add_actor(this._leftCorner.actor); this.add_actor(this._rightCorner.actor); } @@ -205,7 +208,7 @@ var dtpPanel = Utils.defineClass({ } if (this.statusArea.aggregateMenu) { - this.statusArea.aggregateMenu._volume.indicators._dtpIgnoreScroll = 1; + Utils.getIndicators(this.statusArea.aggregateMenu._volume)._dtpIgnoreScroll = 1; } this.geom = this.getGeometry(); @@ -223,12 +226,14 @@ var dtpPanel = Utils.defineClass({ if (this.geom.position == St.Side.TOP) { Main.overview._overview.insert_child_at_index(this._myPanelGhost, 0); } else { + let overviewControls = Main.overview._overview._controls || Main.overview._controls; + if (this.geom.position == St.Side.BOTTOM) { Main.overview._overview.add_actor(this._myPanelGhost); } else if (this.geom.position == St.Side.LEFT) { - Main.overview._controls._group.insert_child_at_index(this._myPanelGhost, 0); + overviewControls._group.insert_child_at_index(this._myPanelGhost, 0); } else { - Main.overview._controls._group.add_actor(this._myPanelGhost); + overviewControls._group.add_actor(this._myPanelGhost); } } @@ -258,7 +263,7 @@ var dtpPanel = Utils.defineClass({ this._timeoutsHandler.add([T1, 0, () => this.dynamicTransparency = new Transparency.DynamicTransparency(this)]); this.taskbar = new Taskbar.taskbar(this); - Main.overview.dashIconSize = this.taskbar.iconSize; + Utils.setDashIconSize(this.taskbar.iconSize); this.container.insert_child_above(this.taskbar.actor, null); @@ -299,7 +304,7 @@ var dtpPanel = Utils.defineClass({ this.taskbar, 'icon-size-changed', Lang.bind(this, function() { - Main.overview.dashIconSize = this.taskbar.iconSize; + Utils.setDashIconSize(this.taskbar.iconSize); }) ], [ @@ -314,10 +319,10 @@ var dtpPanel = Utils.defineClass({ // which given the customization is usually much smaller. // I can't easily disconnect the original signal [ - Main.overview._controls.dash, + (Main.overview._overview._controls || Main.overview._controls).dash, 'icon-size-changed', Lang.bind(this, function() { - Main.overview.dashIconSize = this.taskbar.iconSize; + Utils.setDashIconSize(this.taskbar.iconSize); }) ], [ @@ -410,7 +415,7 @@ var dtpPanel = Utils.defineClass({ this.taskbar.destroy(); // reset stored icon size to the default dash - Main.overview.dashIconSize = Main.overview._controls.dash.iconSize; + Utils.setDashIconSize((Main.overview._overview._controls || Main.overview._controls).dash.iconSize); this.menuManager._changeMenu = this.menuManager._oldChangeMenu; @@ -431,7 +436,7 @@ var dtpPanel = Utils.defineClass({ this._displayShowDesktopButton(false); if (this.statusArea.aggregateMenu) { - delete this.statusArea.aggregateMenu._volume.indicators._dtpIgnoreScroll; + delete Utils.getIndicators(this.statusArea.aggregateMenu._volume)._dtpIgnoreScroll; setMenuArrow(this.statusArea.aggregateMenu._indicators.get_last_child(), St.Side.TOP); } @@ -582,7 +587,7 @@ var dtpPanel = Utils.defineClass({ this._myPanelGhost[isOverviewFocusedMonitor ? 'show' : 'hide'](); if (isOverviewFocusedMonitor) { - Main.overview._panelGhost.set_height(this.geom.position == St.Side.TOP ? 0 : Main.panel.height); + Utils.getPanelGhost().set_height(this.geom.position == St.Side.TOP ? 0 : Main.panel.height); } } }, @@ -1118,20 +1123,20 @@ var dtpSecondaryAggregateMenu = Utils.defineClass({ } if (this._thunderbolt) { - this._indicators.add_child(this._thunderbolt.indicators); + this._indicators.add_child(Utils.getIndicators(this._thunderbolt)); } - this._indicators.add_child(this._screencast.indicators); + this._indicators.add_child(Utils.getIndicators(this._screencast)); if (this._nightLight) { - this._indicators.add_child(this._nightLight.indicators); + this._indicators.add_child(Utils.getIndicators(this._nightLight)); } if (this._network) { - this._indicators.add_child(this._network.indicators); + this._indicators.add_child(Utils.getIndicators(this._network)); } if (this._bluetooth) { - this._indicators.add_child(this._bluetooth.indicators); + this._indicators.add_child(Utils.getIndicators(this._bluetooth)); } - this._indicators.add_child(this._volume.indicators); - this._indicators.add_child(this._power.indicators); + this._indicators.add_child(Utils.getIndicators(this._volume)); + this._indicators.add_child(Utils.getIndicators(this._power)); this._indicators.add_child(PopupMenu.arrowIcon(St.Side.BOTTOM)); this.menu.addMenuItem(this._volume.menu); diff --git a/panelManager.js b/panelManager.js index 581c2c7..a98b3d4 100755 --- a/panelManager.js +++ b/panelManager.js @@ -34,6 +34,7 @@ const Proximity = Me.imports.proximity; const Taskbar = Me.imports.taskbar; const Utils = Me.imports.utils; +const Config = imports.misc.config; const Lang = imports.lang; const Gi = imports._gi; const Clutter = imports.gi.Clutter; @@ -41,6 +42,7 @@ const Meta = imports.gi.Meta; const Shell = imports.gi.Shell; const St = imports.gi.St; +const AppDisplay = imports.ui.appDisplay; const BoxPointer = imports.ui.boxpointer; const Dash = imports.ui.dash; const IconGrid = imports.ui.iconGrid; @@ -56,7 +58,10 @@ var dtpPanelManager = Utils.defineClass({ _init: function() { this.overview = new Overview.dtpOverview(); - Main.overview.viewSelector.appDisplay._views.forEach(v => Utils.wrapActor(v.view._grid)); + Main.overview.viewSelector.appDisplay._views.forEach(v => { + Utils.wrapActor(v.view); + Utils.wrapActor(v.view._grid); + }); }, enable: function(reset) { @@ -69,6 +74,8 @@ var dtpPanelManager = Utils.defineClass({ this.proximityManager = new Proximity.ProximityManager(); Utils.wrapActor(Main.panel); + Utils.wrapActor(Main.overview.dash || 0); + Main.panel.actor.hide(); Main.layoutManager.panelBox.height = 0; @@ -120,6 +127,11 @@ var dtpPanelManager = Utils.defineClass({ this._oldViewSelectorAnimateOut = Main.overview.viewSelector._animateOut; Main.overview.viewSelector._animateOut = Lang.bind(this.primaryPanel, newViewSelectorAnimateOut); + if (Config.PACKAGE_VERSION > '3.35.1') { + this._oldDoSpringAnimation = AppDisplay.BaseAppView.prototype._doSpringAnimation; + AppDisplay.BaseAppView.prototype._doSpringAnimation = newDoSpringAnimation; + } + this._oldUpdatePanelBarrier = Main.layoutManager._updatePanelBarrier; Main.layoutManager._updatePanelBarrier = (panel) => { let panelUpdates = panel ? [panel] : this.allPanels; @@ -249,9 +261,9 @@ var dtpPanelManager = Utils.defineClass({ Main.overview._relayout(); Main.overview.viewSelector._workspacesDisplay._updateWorkspacesViews = this._oldUpdateWorkspacesViews; - Main.overview.getShowAppsButton = this._oldGetShowAppsButton; - Main.overview._panelGhost.set_height(Main.panel.actor.height); + Utils.getPanelGhost().set_height(Main.panel.actor.height); + Main.panel.actor.show(); Main.layoutManager.panelBox.set_height(-1); @@ -259,6 +271,10 @@ var dtpPanelManager = Utils.defineClass({ Utils.hookVfunc(Dash.DashItemContainer.prototype, 'allocate', function(box, flags) { this.vfunc_allocate(box, flags); }); } + if (this._oldDoSpringAnimation) { + AppDisplay.BaseAppView.prototype._doSpringAnimation = this._oldDoSpringAnimation; + } + LookingGlass.LookingGlass.prototype._resize = LookingGlass.LookingGlass.prototype._oldResize; delete LookingGlass.LookingGlass.prototype._oldResize; @@ -406,6 +422,7 @@ var dtpPanelManager = Utils.defineClass({ } else view = new WorkspacesView.WorkspacesView(i); + Utils.wrapActor(view); view.actor.connect('scroll-event', this._onScrollEvent.bind(this)); if (i == Main.layoutManager.primaryIndex && view.scrollAdjustment) { this._scrollAdjustment = view.scrollAdjustment; @@ -494,6 +511,11 @@ function newViewSelectorAnimateOut(page) { } } +function newDoSpringAnimation(animationDirection) { + this._grid.opacity = 255; + this._grid.animateSpring(animationDirection, Main.overview.getShowAppsButton()); +} + function newUpdateHotCorners() { // destroy old hot corners this.hotCorners.forEach(function(corner) { diff --git a/taskbar.js b/taskbar.js index 253dc12..d7f5771 100644 --- a/taskbar.js +++ b/taskbar.js @@ -220,7 +220,7 @@ var taskbar = Utils.defineClass({ let fade1 = new St.Widget({ style_class: 'scrollview-fade', reactive: false }); let fade2 = new St.Widget({ style_class: 'scrollview-fade', reactive: false, - pivot_point: new Clutter.Point({ x: .5, y: .5 }), + pivot_point: Utils.getPoint({ x: .5, y: .5 }), rotation_angle_z: 180 }); fade1.set_style(fadeStyle); diff --git a/utils.js b/utils.js index 2af1172..ea9c824 100644 --- a/utils.js +++ b/utils.js @@ -430,6 +430,38 @@ var animateWindowOpacity = function(window, tweenOpts) { } }; +var setDashIconSize = function(size) { + if ('dash' in Main.overview) { + Main.overview.dash.iconSize = size; + } else { + Main.overview.dashIconSize = size; + } +}; + +var getIndicators = function(delegate) { + if (delegate instanceof St.BoxLayout) { + return delegate; + } + + return delegate.indicators; +} + +var getPoint = function(coords) { + if (Config.PACKAGE_VERSION > '3.35.1') { + return new imports.gi.Graphene.Point(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); diff --git a/windowPreview.js b/windowPreview.js index 5e87aa4..f6f5893 100644 --- a/windowPreview.js +++ b/windowPreview.js @@ -532,7 +532,7 @@ var PreviewMenu = Utils.defineClass({ let fadeWidget = new St.Widget({ reactive: false, - pivot_point: new Clutter.Point({ x: .5, y: .5 }), + pivot_point: Utils.getPoint({ x: .5, y: .5 }), rotation_angle_z: end ? 180 : 0, style: fadeStyle, x: x, y: y,