From 6eaab5ada0df3950cfc1d1061b7ded8f42ccf40d Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Sun, 3 May 2020 21:27:40 -0400 Subject: [PATCH] Adjust latest for larger scale factors --- appIcons.js | 23 +++++++++++------------ extension.js | 2 +- panel.js | 7 ++++--- progress.js | 2 +- transparency.js | 2 +- utils.js | 8 ++++++++ windowPreview.js | 2 +- 7 files changed, 27 insertions(+), 19 deletions(-) diff --git a/appIcons.js b/appIcons.js index a37d259..56b8a7d 100644 --- a/appIcons.js +++ b/appIcons.js @@ -168,7 +168,7 @@ var taskbarAppIcon = Utils.defineClass({ this._updateWindowTitle(); this._updateWindowTitleStyle(); - this._scaleFactorChangedId = St.ThemeContext.get_for_stage(global.stage).connect('changed', () => this._updateWindowTitleStyle()); + this._scaleFactorChangedId = Utils.getStageTheme().connect('changed', () => this._updateWindowTitleStyle()); box.add_child(this._dtpIconContainer); box.add_child(this._windowTitle); @@ -316,7 +316,7 @@ var taskbarAppIcon = Utils.defineClass({ global.window_manager.disconnect(this._switchWorkspaceId); if(this._scaleFactorChangedId) - St.ThemeContext.get_for_stage(global.stage).disconnect(this._scaleFactorChangedId); + Utils.getStageTheme().disconnect(this._scaleFactorChangedId); if (this._hoverChangeId) { this.actor.disconnect(this._hoverChangeId); @@ -474,16 +474,16 @@ var taskbarAppIcon = Utils.defineClass({ _updateWindowTitleStyle: function() { if (this._windowTitle) { let useFixedWidth = Me.settings.get_boolean('group-apps-use-fixed-width'); - let variableWidth = !useFixedWidth || this.dtpPanel.taskbar.fullScrollView; + let variableWidth = !useFixedWidth || Panel.checkIfVertical() || this.dtpPanel.taskbar.fullScrollView; let fontWeight = Me.settings.get_string('group-apps-label-font-weight'); - let maxLabelWidth = Me.settings.get_int('group-apps-label-max-width') * - St.ThemeContext.get_for_stage(global.stage).scale_factor; - + let scaleFactor = Utils.getScaleFactor(); + let maxLabelWidth = Me.settings.get_int('group-apps-label-max-width') * scaleFactor; + this._windowTitle[(maxLabelWidth > 0 ? 'show' : 'hide')](); this._windowTitle.clutter_text.natural_width = useFixedWidth ? maxLabelWidth : 0; this._windowTitle.clutter_text.natural_width_set = useFixedWidth; - this._windowTitle.set_width(variableWidth ? -1 : maxLabelWidth + TITLE_RIGHT_PADDING); + this._windowTitle.set_width(variableWidth ? -1 : maxLabelWidth + TITLE_RIGHT_PADDING * scaleFactor); this._windowTitle.set_style('font-size: ' + Me.settings.get_int('group-apps-label-font-size') + 'px;' + 'font-weight: ' + fontWeight + ';' + @@ -514,7 +514,7 @@ var taskbarAppIcon = Utils.defineClass({ let highlightMargin = isWide ? Me.settings.get_int('dot-size') : 0; if(!this.window) { - let containerWidth = this._dtpIconContainer.get_width() / St.ThemeContext.get_for_stage(global.stage).scale_factor; + let containerWidth = this._dtpIconContainer.get_width() / Utils.getScaleFactor();; let backgroundSize = containerWidth + "px " + (containerWidth - (pos == DOT_POSITION.BOTTOM ? highlightMargin : 0)) + "px;"; @@ -958,7 +958,7 @@ var taskbarAppIcon = Utils.defineClass({ }, _getRunningIndicatorSize: function() { - return Me.settings.get_int('dot-size') * St.ThemeContext.get_for_stage(global.stage).scale_factor; + return Me.settings.get_int('dot-size') * Utils.getScaleFactor(); }, _getRunningIndicatorColor: function(isFocused) { @@ -1165,11 +1165,10 @@ var taskbarAppIcon = Utils.defineClass({ // We apply an overall scale factor that might come from a HiDPI monitor. // Clutter dimensions are in physical pixels, but CSS measures are in logical // pixels, so make sure to consider the scale. - let scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor; // Set the font size to something smaller than the whole icon so it is // still visible. The border radius is large to make the shape circular let [minWidth, natWidth] = this._dtpIconContainer.get_preferred_width(-1); - let font_size = Math.round(Math.max(12, 0.3 * natWidth) / scaleFactor); + let font_size = Math.round(Math.max(12, 0.3 * natWidth) / Utils.getScaleFactor()); let size = Math.round(font_size * 1.3); let label = bin.child; let style = 'font-size: ' + font_size + 'px;' + @@ -1641,7 +1640,7 @@ var ShowAppsIconWrapper = Utils.defineClass({ if (customIconPath) { this._iconActor.gicon = new Gio.FileIcon({ file: Gio.File.new_for_path(customIconPath) }); } - + return this._iconActor; }; diff --git a/extension.js b/extension.js index a1f6d39..eb41e83 100644 --- a/extension.js +++ b/extension.js @@ -74,7 +74,7 @@ function _enable() { // Disable Ubuntu Dock let extensionOrder = (extensionSystem.extensionOrder || extensionSystem._extensionOrder); - St.ThemeContext.get_for_stage(global.stage).get_theme().unload_stylesheet(ubuntuDock.stylesheet); + Utils.getStageTheme().get_theme().unload_stylesheet(ubuntuDock.stylesheet); ubuntuDock.stateObj.disable(); disabledUbuntuDock = true; ubuntuDock.state = 2; //ExtensionState.DISABLED diff --git a/panel.js b/panel.js index 2878b7f..b66ea3f 100644 --- a/panel.js +++ b/panel.js @@ -348,7 +348,7 @@ var dtpPanel = Utils.defineClass({ this._signalsHandler.add( // this is to catch changes to the theme or window scale factor [ - St.ThemeContext.get_for_stage(global.stage), + Utils.getStageTheme(), 'changed', () => this._resetGeometry() ], @@ -650,7 +650,8 @@ var dtpPanel = Utils.defineClass({ //centered relatively to the monitor. This looks misaligned, adjust it here so it //is centered like the rest of the overview elements. let paddingSide = getPosition() == St.Side.LEFT ? 'left' : 'right'; - let style = offset ? 'padding-' + paddingSide + ':' + offset + 'px;' : null; + let scaleFactor = Utils.getScaleFactor(); + let style = offset ? 'padding-' + paddingSide + ':' + (offset / scaleFactor) + 'px;' : null; let searchEntry = Main.overview._searchEntry || Main.overview._overview._searchEntry; searchEntry.get_parent().set_style(style); @@ -692,7 +693,7 @@ var dtpPanel = Utils.defineClass({ }, getGeometry: function() { - let scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor || 1; + let scaleFactor = Utils.getScaleFactor(); let panelBoxTheme = this.panelBox.get_theme_node(); let lrPadding = panelBoxTheme.get_padding(St.Side.RIGHT) + panelBoxTheme.get_padding(St.Side.LEFT); let topPadding = panelBoxTheme.get_padding(St.Side.TOP); diff --git a/progress.js b/progress.js index 8a74c9a..0b8c0e3 100644 --- a/progress.js +++ b/progress.js @@ -419,7 +419,7 @@ var ProgressIndicator = Utils.defineClass({ }, _drawProgressOverlay: function(area) { - let scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor; + let scaleFactor = Utils.getScaleFactor(); let [surfaceWidth, surfaceHeight] = area.get_surface_size(); let cr = area.get_context(); diff --git a/transparency.js b/transparency.js index c557518..835f88a 100644 --- a/transparency.js +++ b/transparency.js @@ -71,7 +71,7 @@ var DynamicTransparency = Utils.defineClass({ _bindSignals: function() { this._signalsHandler.add( [ - St.ThemeContext.get_for_stage(global.stage), + Utils.getStageTheme(), 'changed', () => this._updateAllAndSet() ], diff --git a/utils.js b/utils.js index b07c6be..8fbb280 100644 --- a/utils.js +++ b/utils.js @@ -294,6 +294,14 @@ var getWorkspaceCount = function() { return DisplayWrapper.getWorkspaceManager().n_workspaces; }; +var getStageTheme = function() { + return St.ThemeContext.get_for_stage(global.stage); +}; + +var getScaleFactor = function() { + return getStageTheme().scale_factor || 1; +}; + var findIndex = function(array, predicate) { if (Array.prototype.findIndex) { return array.findIndex(predicate); diff --git a/windowPreview.js b/windowPreview.js index 86aa044..2cad787 100644 --- a/windowPreview.js +++ b/windowPreview.js @@ -416,7 +416,7 @@ var PreviewMenu = Utils.defineClass({ isLeftButtons = Meta.prefs_get_button_layout().left_buttons.indexOf(Meta.ButtonFunction.CLOSE) >= 0; isTopHeader = Me.settings.get_string('window-preview-title-position') == 'TOP'; isManualStyling = Me.settings.get_boolean('window-preview-manual-styling'); - scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor; + scaleFactor = Utils.getScaleFactor(); headerHeight = Me.settings.get_boolean('window-preview-show-title') ? HEADER_HEIGHT * scaleFactor : 0; animationTime = Me.settings.get_int('window-preview-animation-time') * .001; aspectRatio.x = {