From f0e59ea0882649d6a2cae80a713e8102e66067c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Tue, 15 Oct 2019 16:20:09 +0200 Subject: [PATCH] closeDialog: Fix dialog size when using geometry scaling The close dialog is added as a child to MetaWindowActor, and, in Wayland sessions, since commit [1] MetaWindowActor applies a transformation matrix which scales all it's children using the geometry scale factor. Now because the dialog actor is not a window (i.e. a MetaSurfaceActor), but a subclass of StWidget, the scale factor is also applied to the properties of the dialog by StThemeNode, so we end up applying the geometry scale twice to the close dialog. Fix this by applying the inverted scale to the dialog, which leaves the scaling only to MetaWindowActor. This means we also can't apply a pivot point other than 0 to the dialog actor, so apply the 0.5-pivot point to the `_dialog` child of the Dialog class (the actual visible dialog box) and also perform scaling animations on this child. [1] https://gitlab.gnome.org/GNOME/mutter/commit/fb9e8768 https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/783 --- js/ui/closeDialog.js | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/js/ui/closeDialog.js b/js/ui/closeDialog.js index 6d0519f8e..5cbeb9c5c 100644 --- a/js/ui/closeDialog.js +++ b/js/ui/closeDialog.js @@ -1,7 +1,7 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- /* exported CloseDialog */ -const { Clutter, Gio, GLib, GObject, Meta, Shell } = imports.gi; +const { Clutter, Gio, GLib, GObject, Meta, Shell, St } = imports.gi; const Dialog = imports.ui.dialog; const Main = imports.ui.main; @@ -46,6 +46,18 @@ var CloseDialog = GObject.registerClass({ return new Dialog.MessageDialogContent({ icon, title, subtitle }); } + _updateScale() { + // Since this is a child of MetaWindowActor (which, in Wayland sessions, + // applies the geometry scale factor to its children itself, see + // meta_window_actor_set_geometry_scale()), make sure we don't apply + // the factor twice in the end. + if (!Meta.is_wayland_compositor()) + return; + + let { scaleFactor } = St.ThemeContext.get_for_stage(global.stage); + this._dialog.set_scale(1 / scaleFactor, 1 / scaleFactor); + } + _initDialog() { if (this._dialog) return; @@ -64,6 +76,11 @@ var CloseDialog = GObject.registerClass({ key: Clutter.Escape }); global.focus_manager.add_group(this._dialog); + + let themeContext = St.ThemeContext.get_for_stage(global.stage); + themeContext.connect('notify::scale-factor', this._updateScale.bind(this)); + + this._updateScale(); } _addWindowEffect() { @@ -145,10 +162,10 @@ var CloseDialog = GObject.registerClass({ this._addWindowEffect(); this._initDialog(); - this._dialog.scale_y = 0; - this._dialog.set_pivot_point(0.5, 0.5); + this._dialog._dialog.scale_y = 0; + this._dialog._dialog.set_pivot_point(0.5, 0.5); - this._dialog.ease({ + this._dialog._dialog.ease({ scale_y: 1, mode: Clutter.AnimationMode.LINEAR, duration: DIALOG_TRANSITION_TIME, @@ -175,7 +192,7 @@ var CloseDialog = GObject.registerClass({ this._dialog = null; this._removeWindowEffect(); - dialog.ease({ + dialog._dialog.ease({ scale_y: 0, mode: Clutter.AnimationMode.LINEAR, duration: DIALOG_TRANSITION_TIME,