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
This commit is contained in:
parent
b6d47c18c3
commit
b6e57a5ae8
@ -1,7 +1,7 @@
|
|||||||
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
||||||
/* exported CloseDialog */
|
/* 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 Dialog = imports.ui.dialog;
|
||||||
const Main = imports.ui.main;
|
const Main = imports.ui.main;
|
||||||
@ -46,6 +46,18 @@ var CloseDialog = GObject.registerClass({
|
|||||||
return new Dialog.MessageDialogContent({ icon, title, subtitle });
|
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() {
|
_initDialog() {
|
||||||
if (this._dialog)
|
if (this._dialog)
|
||||||
return;
|
return;
|
||||||
@ -64,6 +76,11 @@ var CloseDialog = GObject.registerClass({
|
|||||||
key: Clutter.Escape });
|
key: Clutter.Escape });
|
||||||
|
|
||||||
global.focus_manager.add_group(this._dialog);
|
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() {
|
_addWindowEffect() {
|
||||||
@ -145,10 +162,10 @@ var CloseDialog = GObject.registerClass({
|
|||||||
this._addWindowEffect();
|
this._addWindowEffect();
|
||||||
this._initDialog();
|
this._initDialog();
|
||||||
|
|
||||||
this._dialog.scale_y = 0;
|
this._dialog._dialog.scale_y = 0;
|
||||||
this._dialog.set_pivot_point(0.5, 0.5);
|
this._dialog._dialog.set_pivot_point(0.5, 0.5);
|
||||||
|
|
||||||
this._dialog.ease({
|
this._dialog._dialog.ease({
|
||||||
scale_y: 1,
|
scale_y: 1,
|
||||||
mode: Clutter.AnimationMode.LINEAR,
|
mode: Clutter.AnimationMode.LINEAR,
|
||||||
duration: DIALOG_TRANSITION_TIME,
|
duration: DIALOG_TRANSITION_TIME,
|
||||||
@ -175,7 +192,7 @@ var CloseDialog = GObject.registerClass({
|
|||||||
this._dialog = null;
|
this._dialog = null;
|
||||||
this._removeWindowEffect();
|
this._removeWindowEffect();
|
||||||
|
|
||||||
dialog.ease({
|
dialog._dialog.ease({
|
||||||
scale_y: 0,
|
scale_y: 0,
|
||||||
mode: Clutter.AnimationMode.LINEAR,
|
mode: Clutter.AnimationMode.LINEAR,
|
||||||
duration: DIALOG_TRANSITION_TIME,
|
duration: DIALOG_TRANSITION_TIME,
|
||||||
|
Loading…
Reference in New Issue
Block a user