WindowIconActor: Support setting floating point scale on placement (#1636)

This commit is contained in:
David Hewitt 2023-04-11 06:46:11 +00:00 committed by GitHub
parent 3f4dfa6877
commit d7993f415f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 13 deletions

View File

@ -349,7 +349,7 @@ namespace Gala {
// single icon => big icon
if (n_windows == 1) {
var icon = (WindowIconActor) icon_container.get_child_at_index (0);
icon.place (0, 0, 64);
icon.place (0, 0, 64, scale_factor);
return false;
}
@ -494,7 +494,7 @@ namespace Gala {
continue;
}
window.place (x, y, size);
window.place (x, y, size, scale_factor);
x += InternalUtils.scale_to_int (size, scale_factor) + spacing;
if (x + InternalUtils.scale_to_int (size, scale_factor) >= scaled_size) {

View File

@ -24,7 +24,8 @@ namespace Gala {
public class WindowIconActor : Clutter.Actor {
public Meta.Window window { get; construct; }
private int icon_scale;
private float cur_icon_scale = 1.0f;
private float desired_icon_scale = 1.0f;
private int _icon_size;
/**
@ -35,17 +36,16 @@ namespace Gala {
get {
return _icon_size;
}
set {
var scale = InternalUtils.get_ui_scaling_factor ();
if (value == _icon_size && scale == icon_scale) {
private set {
if (value == _icon_size && cur_icon_scale == desired_icon_scale) {
return;
}
_icon_size = value;
icon_scale = scale;
cur_icon_scale = desired_icon_scale;
set_size (_icon_size * scale, _icon_size * scale);
var scaled_size = InternalUtils.scale_to_int (_icon_size, cur_icon_scale);
set_size (scaled_size, scaled_size);
fade_new_icon ();
}
@ -113,7 +113,6 @@ namespace Gala {
set_easing_duration (800);
window.notify["on-all-workspaces"].connect (on_all_workspaces_changed);
icon_scale = InternalUtils.get_ui_scaling_factor ();
}
~WindowIconActor () {
@ -133,12 +132,13 @@ namespace Gala {
* @param y The y coordinate to which to animate to
* @param size The size to which to animate to and display the icon in
*/
public void place (float x, float y, int size) {
public void place (float x, float y, int size, float scale) {
if (initial) {
save_easing_state ();
set_easing_duration (10);
}
desired_icon_scale = scale;
set_position (x, y);
icon_size = size;
@ -152,8 +152,7 @@ namespace Gala {
* Fades out the old icon and fades in the new icon
*/
private void fade_new_icon () {
var scale = InternalUtils.get_ui_scaling_factor ();
var new_icon = new WindowIcon (window, icon_size, scale);
var new_icon = new WindowIcon (window, icon_size, (int)Math.round (cur_icon_scale));
new_icon.add_constraint (new Clutter.BindConstraint (this, Clutter.BindCoordinate.SIZE, 0));
new_icon.opacity = 0;