diff --git a/data/gala.gschema.xml b/data/gala.gschema.xml index b727649b0..55d15b95f 100644 --- a/data/gala.gschema.xml +++ b/data/gala.gschema.xml @@ -205,7 +205,7 @@ true Enable Animations - Whether animations should be displayed. Note: This is a global key, it changes the behaviour of the window manager, the panel etc. + DEPRECATED: This key is deprecated and ignored. diff --git a/lib/AnimationsSettings.vala b/lib/AnimationsSettings.vala deleted file mode 100644 index e3247cb06..000000000 --- a/lib/AnimationsSettings.vala +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SPDX-License-Identifier: GPL-3.0-or-later - * SPDX-FileCopyrightText: 2024 elementary, Inc. (https://elementary.io) - */ - -namespace AnimationsSettings { - private GLib.Settings? animations_settings; - private bool enable_animations = true; - - /** - * Whether animations should be displayed. - */ - public bool get_enable_animations () { - if (animations_settings == null) { - animations_settings = new GLib.Settings ("io.elementary.desktop.wm.animations"); - animations_settings.changed["enable-animations"].connect (() => { - enable_animations = animations_settings.get_boolean ("enable-animations"); - }); - - enable_animations = animations_settings.get_boolean ("enable-animations"); - } - - return enable_animations; - } - - /** - * Utility that returns the given duration or 0 if animations are disabled. - */ - public uint get_animation_duration (uint duration) { - return get_enable_animations () ? duration : 0; - } -} diff --git a/lib/Utils.vala b/lib/Utils.vala index 308dd4ac4..ee24a724b 100644 --- a/lib/Utils.vala +++ b/lib/Utils.vala @@ -456,5 +456,12 @@ namespace Gala { regions.remove (window); X.Fixes.destroy_region (xdisplay, region); } + + /** + * Utility that returns the given duration or 0 if animations are disabled. + */ + public static uint get_animation_duration (uint duration) { + return Meta.Prefs.get_gnome_animations () ? duration : 0; + } } } diff --git a/lib/meson.build b/lib/meson.build index 0a37bcd65..477825dd2 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -1,6 +1,5 @@ gala_lib_sources = files( 'ActivatableComponent.vala', - 'AnimationsSettings.vala', 'App.vala', 'AppCache.vala', 'AppSystem.vala', diff --git a/plugins/pip/PopupWindow.vala b/plugins/pip/PopupWindow.vala index c1c3b30fe..4f6c2901e 100644 --- a/plugins/pip/PopupWindow.vala +++ b/plugins/pip/PopupWindow.vala @@ -137,7 +137,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { opacity = 0; save_easing_state (); - set_easing_duration (AnimationsSettings.get_animation_duration (200)); + set_easing_duration (Utils.get_animation_duration (200)); opacity = 255; restore_easing_state (); } @@ -145,7 +145,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { public override void hide () { opacity = 255; - var duration = AnimationsSettings.get_animation_duration (200); + var duration = Utils.get_animation_duration (200); save_easing_state (); set_easing_duration (duration); opacity = 0; @@ -167,7 +167,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { #else public override bool enter_event (Clutter.CrossingEvent event) { #endif - var duration = AnimationsSettings.get_animation_duration (300); + var duration = Utils.get_animation_duration (300); close_button.save_easing_state (); close_button.set_easing_duration (duration); @@ -187,7 +187,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { #else public override bool leave_event (Clutter.CrossingEvent event) { #endif - var duration = AnimationsSettings.get_animation_duration (300); + var duration = Utils.get_animation_duration (300); close_button.save_easing_state (); close_button.set_easing_duration (duration); @@ -309,7 +309,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { } private void on_close_click_clicked () { - var duration = AnimationsSettings.get_animation_duration (FADE_OUT_TIMEOUT); + var duration = Utils.get_animation_duration (FADE_OUT_TIMEOUT); save_easing_state (); set_easing_duration (duration); @@ -433,7 +433,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { var screen_limit_start_y = workarea_rect.y + SCREEN_MARGIN; var screen_limit_end_y = workarea_rect.y + workarea_rect.height - SCREEN_MARGIN - height; - var duration = AnimationsSettings.get_animation_duration (300); + var duration = Utils.get_animation_duration (300); save_easing_state (); set_easing_mode (Clutter.AnimationMode.EASE_OUT_BACK); @@ -446,7 +446,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { private bool place_window_off_screen () { off_screen = false; - var duration = AnimationsSettings.get_animation_duration (300); + var duration = Utils.get_animation_duration (300); save_easing_state (); set_easing_mode (Clutter.AnimationMode.EASE_OUT_BACK); diff --git a/src/Background/BackgroundManager.vala b/src/Background/BackgroundManager.vala index 3e0dc52ea..a178009f3 100644 --- a/src/Background/BackgroundManager.vala +++ b/src/Background/BackgroundManager.vala @@ -61,7 +61,7 @@ public class Gala.BackgroundManager : Meta.BackgroundGroup, Gala.BackgroundManag return; } - if (animate && AnimationsSettings.get_enable_animations ()) { + if (animate && Meta.Prefs.get_gnome_animations ()) { var transition = new Clutter.PropertyTransition ("opacity"); transition.set_from_value (255); transition.set_to_value (0); diff --git a/src/Gestures/GestureController.vala b/src/Gestures/GestureController.vala index e3e8bd1f8..183aa9618 100644 --- a/src/Gestures/GestureController.vala +++ b/src/Gestures/GestureController.vala @@ -141,7 +141,7 @@ public class Gala.GestureController : Object { direction_multiplier = -1; } - if (snap && !AnimationsSettings.get_enable_animations ()) { + if (snap && !Meta.Prefs.get_gnome_animations ()) { prepare (); finish (0, progress + direction_multiplier); recognizing = false; @@ -231,7 +231,7 @@ public class Gala.GestureController : Object { return; } - if (!AnimationsSettings.get_enable_animations ()) { + if (!Meta.Prefs.get_gnome_animations ()) { progress = clamped_to; target.propagate (END, action, calculate_bounded_progress ()); return; diff --git a/src/Gestures/GesturePropertyTransition.vala b/src/Gestures/GesturePropertyTransition.vala index 29b9985fc..cea6f536b 100644 --- a/src/Gestures/GesturePropertyTransition.vala +++ b/src/Gestures/GesturePropertyTransition.vala @@ -167,7 +167,7 @@ public class Gala.GesturePropertyTransition : Object { actor.save_easing_state (); actor.set_easing_mode (EASE_OUT_QUAD); - actor.set_easing_duration (AnimationsSettings.get_animation_duration (calculated_duration)); + actor.set_easing_duration (Utils.get_animation_duration (calculated_duration)); actor.set_property (property, value_from_float (target_value)); actor.restore_easing_state (); @@ -179,14 +179,14 @@ public class Gala.GesturePropertyTransition : Object { } }; - if (with_gesture && AnimationsSettings.get_enable_animations ()) { + if (with_gesture && Meta.Prefs.get_gnome_animations ()) { gesture_tracker.connect_handlers (on_animation_begin, on_animation_update, on_animation_end); } else { on_animation_begin (0); if (overshoot_upper_clamp < 1) { actor.save_easing_state (); actor.set_easing_mode (EASE_OUT_QUAD); - actor.set_easing_duration (AnimationsSettings.get_animation_duration (gesture_tracker.min_animation_duration)); + actor.set_easing_duration (Utils.get_animation_duration (gesture_tracker.min_animation_duration)); actor.set_property (property, value_from_float ((float) overshoot_upper_clamp * (to_value_float - from_value_float) + from_value_float)); actor.restore_easing_state (); diff --git a/src/NotificationStack.vala b/src/NotificationStack.vala index fd07649f1..16be9b51b 100644 --- a/src/NotificationStack.vala +++ b/src/NotificationStack.vala @@ -62,7 +62,7 @@ public class Gala.NotificationStack : Object { var window_rect = window.get_frame_rect (); window.stick (); - if (AnimationsSettings.get_enable_animations ()) { + if (Meta.Prefs.get_gnome_animations ()) { // Don't flicker at the beginning of the animation notification.opacity = 0; notification.rotation_angle_x = 90; @@ -131,7 +131,7 @@ public class Gala.NotificationStack : Object { continue; } - if (AnimationsSettings.get_enable_animations ()) { + if (Meta.Prefs.get_gnome_animations ()) { actor.save_easing_state (); actor.set_easing_mode (Clutter.AnimationMode.EASE_OUT_BACK); actor.set_easing_duration (200); @@ -140,7 +140,7 @@ public class Gala.NotificationStack : Object { move_window (actor, -1, (int)y); - if (AnimationsSettings.get_enable_animations ()) { + if (Meta.Prefs.get_gnome_animations ()) { actor.restore_easing_state (); } @@ -161,7 +161,7 @@ public class Gala.NotificationStack : Object { } public void destroy_notification (Meta.WindowActor notification) { - if (AnimationsSettings.get_enable_animations ()) { + if (Meta.Prefs.get_gnome_animations ()) { notification.save_easing_state (); notification.set_easing_duration (100); notification.set_easing_mode (Clutter.AnimationMode.EASE_IN_QUAD); diff --git a/src/Widgets/IconGroup.vala b/src/Widgets/IconGroup.vala index b2800019b..1c2b9d511 100644 --- a/src/Widgets/IconGroup.vala +++ b/src/Widgets/IconGroup.vala @@ -168,7 +168,7 @@ public class Gala.IconGroup : CanvasActor { if (animate) { icon.save_easing_state (); icon.set_easing_mode (Clutter.AnimationMode.LINEAR); - icon.set_easing_duration (AnimationsSettings.get_animation_duration (200)); + icon.set_easing_duration (Utils.get_animation_duration (200)); icon.opacity = 0; icon.restore_easing_state (); diff --git a/src/Widgets/MultitaskingView.vala b/src/Widgets/MultitaskingView.vala index 8d387b97f..e9983ac67 100644 --- a/src/Widgets/MultitaskingView.vala +++ b/src/Widgets/MultitaskingView.vala @@ -224,7 +224,7 @@ namespace Gala { } public void play_nudge_animation (Meta.MotionDirection direction) { - if (!AnimationsSettings.get_enable_animations ()) { + if (!Meta.Prefs.get_gnome_animations ()) { return; } diff --git a/src/Widgets/ScreenShield.vala b/src/Widgets/ScreenShield.vala index 06f47988a..ecd40bd03 100644 --- a/src/Widgets/ScreenShield.vala +++ b/src/Widgets/ScreenShield.vala @@ -330,7 +330,7 @@ public class Gala.ScreenShield : Clutter.Actor { grab_key_focus (); modal_proxy = wm.push_modal (this); - if (AnimationsSettings.get_enable_animations () && animate) { + if (Meta.Prefs.get_gnome_animations () && animate) { animate_and_lock (animation_time); } else { _set_active (true); diff --git a/src/Widgets/WindowClone.vala b/src/Widgets/WindowClone.vala index 3e9b2fa11..f49845ec2 100644 --- a/src/Widgets/WindowClone.vala +++ b/src/Widgets/WindowClone.vala @@ -46,7 +46,7 @@ public class Gala.WindowClone : ActorTarget { public bool active { set { active_shape.save_easing_state (); - active_shape.set_easing_duration (AnimationsSettings.get_animation_duration (FADE_ANIMATION_DURATION)); + active_shape.set_easing_duration (Utils.get_animation_duration (FADE_ANIMATION_DURATION)); active_shape.opacity = value ? 255 : 0; active_shape.restore_easing_state (); } @@ -247,7 +247,7 @@ public class Gala.WindowClone : ActorTarget { if (animate) { save_easing_state (); - set_easing_duration (AnimationsSettings.get_animation_duration (MultitaskingView.ANIMATION_DURATION)); + set_easing_duration (Utils.get_animation_duration (MultitaskingView.ANIMATION_DURATION)); set_easing_mode (EASE_OUT_QUAD); } @@ -374,7 +374,7 @@ public class Gala.WindowClone : ActorTarget { in_slot_animation = animating; } - var duration = AnimationsSettings.get_animation_duration (FADE_ANIMATION_DURATION); + var duration = Utils.get_animation_duration (FADE_ANIMATION_DURATION); var show = has_pointer && !in_slot_animation; @@ -472,7 +472,7 @@ public class Gala.WindowClone : ActorTarget { active_shape.hide (); var scale = window_icon.width / clone.width; - var duration = AnimationsSettings.get_animation_duration (FADE_ANIMATION_DURATION); + var duration = Utils.get_animation_duration (FADE_ANIMATION_DURATION); clone.get_transformed_position (out abs_x, out abs_y); clone.save_easing_state (); @@ -534,7 +534,7 @@ public class Gala.WindowClone : ActorTarget { var scale = hovered ? 0.4 : 1.0; var opacity = hovered ? 0 : 255; uint duration = hovered && insert_thumb != null ? insert_thumb.delay : 100; - duration = AnimationsSettings.get_animation_duration (duration); + duration = Utils.get_animation_duration (duration); window_icon.save_easing_state (); @@ -636,7 +636,7 @@ public class Gala.WindowClone : ActorTarget { private void drag_canceled () { get_parent ().remove_child (this); - var duration = AnimationsSettings.get_animation_duration (MultitaskingView.ANIMATION_DURATION); + var duration = Utils.get_animation_duration (MultitaskingView.ANIMATION_DURATION); // Adding to the previous parent will automatically update it to take it's slot // so to animate it we set the easing diff --git a/src/Widgets/WindowIconActor.vala b/src/Widgets/WindowIconActor.vala index 0e73eca6e..256f51ea7 100644 --- a/src/Widgets/WindowIconActor.vala +++ b/src/Widgets/WindowIconActor.vala @@ -52,7 +52,7 @@ public class Gala.WindowIconActor : Clutter.Actor { set { if (_temporary && !value) { remove_transition ("pulse"); - } else if (!_temporary && value && AnimationsSettings.get_enable_animations ()) { + } else if (!_temporary && value && Meta.Prefs.get_gnome_animations ()) { var transition = new Clutter.TransitionGroup () { duration = 800, auto_reverse = true, @@ -134,7 +134,7 @@ public class Gala.WindowIconActor : Clutter.Actor { new_icon.save_easing_state (); new_icon.set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD); - new_icon.set_easing_duration (AnimationsSettings.get_animation_duration (500)); + new_icon.set_easing_duration (Utils.get_animation_duration (500)); new_icon.restore_easing_state (); if (icon == null) { diff --git a/src/Widgets/WindowSwitcher/WindowSwitcher.vala b/src/Widgets/WindowSwitcher/WindowSwitcher.vala index d19a132e7..abcc166ba 100644 --- a/src/Widgets/WindowSwitcher/WindowSwitcher.vala +++ b/src/Widgets/WindowSwitcher/WindowSwitcher.vala @@ -418,7 +418,7 @@ public class Gala.WindowSwitcher : CanvasActor { } save_easing_state (); - set_easing_duration (AnimationsSettings.get_animation_duration (ANIMATION_DURATION)); + set_easing_duration (Utils.get_animation_duration (ANIMATION_DURATION)); opacity = show ? 255 : 0; restore_easing_state (); } diff --git a/src/Widgets/WorkspaceInsertThumb.vala b/src/Widgets/WorkspaceInsertThumb.vala index d5a533961..cbf9bf834 100644 --- a/src/Widgets/WorkspaceInsertThumb.vala +++ b/src/Widgets/WorkspaceInsertThumb.vala @@ -78,7 +78,7 @@ public class Gala.WorkspaceInsertThumb : Clutter.Actor { private new void transform (bool expand) { save_easing_state (); set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD); - set_easing_duration (AnimationsSettings.get_animation_duration (200)); + set_easing_duration (Utils.get_animation_duration (200)); if (!expand) { remove_transition ("pulse"); @@ -96,7 +96,7 @@ public class Gala.WorkspaceInsertThumb : Clutter.Actor { } private void add_pulse_animation () { - if (!AnimationsSettings.get_enable_animations ()) { + if (!Meta.Prefs.get_gnome_animations ()) { return; } diff --git a/src/WindowManager.vala b/src/WindowManager.vala index 7b5c721b3..e1c7cae1b 100644 --- a/src/WindowManager.vala +++ b/src/WindowManager.vala @@ -648,7 +648,7 @@ namespace Gala { } private void play_nudge_animation (Meta.MotionDirection direction) { - if (!AnimationsSettings.get_enable_animations ()) { + if (!Meta.Prefs.get_gnome_animations ()) { return; } @@ -709,7 +709,7 @@ namespace Gala { } unowned var bottom_actor = (Meta.WindowActor) bottom_window.get_compositor_private (); - if (AnimationsSettings.get_enable_animations ()) { + if (Meta.Prefs.get_gnome_animations ()) { animate_bottom_window_scale (bottom_actor); } @@ -737,7 +737,7 @@ namespace Gala { } unowned var actor = (Meta.WindowActor) window.get_compositor_private (); - if (AnimationsSettings.get_enable_animations ()) { + if (Meta.Prefs.get_gnome_animations ()) { var op_trans = new Clutter.KeyframeTransition ("opacity") { duration = fade_out_duration, remove_on_complete = true, @@ -1144,7 +1144,7 @@ namespace Gala { tile_preview.set_size (rect.width, rect.height); tile_preview.show (); - if (AnimationsSettings.get_enable_animations ()) { + if (Meta.Prefs.get_gnome_animations ()) { tile_preview.save_easing_state (); tile_preview.set_easing_mode (Clutter.AnimationMode.EASE_IN_OUT_QUAD); tile_preview.set_easing_duration (duration); @@ -1199,7 +1199,7 @@ namespace Gala { which_change = which_change_local; old_rect_size_change = old_frame_rect; - if (AnimationsSettings.get_enable_animations ()) { + if (Meta.Prefs.get_gnome_animations ()) { latest_window_snapshot = Utils.get_window_actor_snapshot (actor, old_frame_rect); } } @@ -1242,7 +1242,7 @@ namespace Gala { } public override void minimize (Meta.WindowActor actor) { - if (!AnimationsSettings.get_enable_animations () || + if (!Meta.Prefs.get_gnome_animations () || actor.get_meta_window ().window_type != Meta.WindowType.NORMAL) { minimize_completed (actor); return; @@ -1312,7 +1312,6 @@ namespace Gala { } private void maximize (Meta.WindowActor actor, int ex, int ey, int ew, int eh) { - unowned var window = actor.get_meta_window (); if (window.maximized_horizontally && behavior_settings.get_boolean ("move-maximized-workspace") || window.fullscreen && behavior_settings.get_boolean ("move-fullscreened-workspace")) { @@ -1321,7 +1320,7 @@ namespace Gala { kill_window_effects (actor); - if (!AnimationsSettings.get_enable_animations () || + if (!Meta.Prefs.get_gnome_animations () || latest_window_snapshot == null || window.window_type != Meta.WindowType.NORMAL) { return; @@ -1403,7 +1402,7 @@ namespace Gala { } public override void unminimize (Meta.WindowActor actor) { - if (!AnimationsSettings.get_enable_animations ()) { + if (!Meta.Prefs.get_gnome_animations ()) { actor.show (); unminimize_completed (actor); return; @@ -1463,7 +1462,7 @@ namespace Gala { return; } - if (!AnimationsSettings.get_enable_animations ()) { + if (!Meta.Prefs.get_gnome_animations ()) { map_completed (actor); if (InternalUtils.get_window_is_normal (window) && window.get_layer () == Meta.StackLayer.BOTTOM) { @@ -1582,13 +1581,13 @@ namespace Gala { actor.remove_all_transitions (); if (NotificationStack.is_notification (window)) { - if (AnimationsSettings.get_enable_animations ()) { + if (Meta.Prefs.get_gnome_animations ()) { destroying.add (actor); } notification_stack.destroy_notification (actor); - if (AnimationsSettings.get_enable_animations ()) { + if (Meta.Prefs.get_gnome_animations ()) { ulong destroy_handler_id = 0UL; destroy_handler_id = actor.transitions_completed.connect (() => { actor.disconnect (destroy_handler_id); @@ -1602,7 +1601,7 @@ namespace Gala { return; } - if (!AnimationsSettings.get_enable_animations ()) { + if (!Meta.Prefs.get_gnome_animations ()) { destroy_completed (actor); if (window.window_type == Meta.WindowType.NORMAL) { @@ -1696,7 +1695,7 @@ namespace Gala { kill_window_effects (actor); - if (!AnimationsSettings.get_enable_animations () || + if (!Meta.Prefs.get_gnome_animations () || latest_window_snapshot == null || window.window_type != Meta.WindowType.NORMAL) { return; @@ -2050,7 +2049,7 @@ namespace Gala { } public override void switch_workspace (int from, int to, Meta.MotionDirection direction) { - if (!AnimationsSettings.get_enable_animations () + if (!Meta.Prefs.get_gnome_animations () || (direction != Meta.MotionDirection.LEFT && direction != Meta.MotionDirection.RIGHT) || animating_switch_workspace || workspace_view.is_opened () diff --git a/src/Zoom.vala b/src/Zoom.vala index ba33d933b..ce13b3176 100644 --- a/src/Zoom.vala +++ b/src/Zoom.vala @@ -109,7 +109,7 @@ public class Gala.Zoom : Object, GestureTarget { case UPDATE: var target_zoom = (float) progress * 10 + 1; - if (!AnimationsSettings.get_enable_animations ()) { + if (!Meta.Prefs.get_gnome_animations ()) { var delta = target_zoom - current_zoom; if (delta.abs () >= SHORTCUT_DELTA - float.EPSILON) { target_zoom = current_zoom + ((delta > 0) ? SHORTCUT_DELTA : -SHORTCUT_DELTA);