From 96bfd1f8bedb02105f7b3c292667ae29e571b50d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Mon, 8 Jun 2020 17:52:57 +0200 Subject: [PATCH] workspace: Adjust for close button side in chromeWidth When the close button is shown on the left side of the WindowClone, we also need to return its width in chromeWidth() on the left side instead of the right side, so do that. https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1298 --- js/ui/workspace.js | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/js/ui/workspace.js b/js/ui/workspace.js index 97b5f8cc9..a64ed0b99 100644 --- a/js/ui/workspace.js +++ b/js/ui/workspace.js @@ -308,8 +308,9 @@ var WindowClone = GObject.registerClass({ }); const layout = Meta.prefs_get_button_layout(); - const side = layout.left_buttons.includes(Meta.ButtonFunction.CLOSE) - ? St.Side.LEFT : St.Side.RIGHT; + this._closeButtonSide = + layout.left_buttons.includes(Meta.ButtonFunction.CLOSE) + ? St.Side.LEFT : St.Side.RIGHT; this._closeButton = new St.Button({ visible: false, @@ -324,7 +325,7 @@ var WindowClone = GObject.registerClass({ source: this._border, align_axis: Clutter.AlignAxis.X_AXIS, pivot_point: new Graphene.Point({ x: 0.5, y: -1 }), - factor: side === St.Side.LEFT ? 0 : 1, + factor: this._closeButtonSide === St.Side.LEFT ? 0 : 1, })); this._closeButton.add_constraint(new Clutter.AlignConstraint({ source: this._border, @@ -395,16 +396,26 @@ var WindowClone = GObject.registerClass({ const [, closeButtonHeight] = this._closeButton.get_preferred_height(-1); const [, titleHeight] = this._title.get_preferred_height(-1); - return [this._borderSize + closeButtonHeight / 2, - Math.max(this._borderSize, (titleHeight / 2) + (this._borderSize / 2))]; + const topOversize = this._borderSize + closeButtonHeight / 2; + const bottomOversize = Math.max( + this._borderSize, + (titleHeight / 2) + (this._borderSize / 2)); + + return [topOversize, bottomOversize]; } chromeWidths() { this._border.ensure_style(); const [, closeButtonWidth] = this._closeButton.get_preferred_width(-1); - return [this._borderSize, - this._borderSize + closeButtonWidth / 2]; + const leftOversize = this._closeButtonSide === St.Side.LEFT + ? this._borderSize + closeButtonWidth / 2 + : this._borderSize; + const rightOversize = this._closeButtonSide === St.Side.LEFT + ? this._borderSize + : this._borderSize + closeButtonWidth / 2; + + return [leftOversize, rightOversize]; } showOverlay(animate) {