From f69d935774e5764984ee9841a2140382274d6fab Mon Sep 17 00:00:00 2001 From: wheaney <42350981+wheaney@users.noreply.github.com> Date: Sun, 6 Oct 2024 13:39:15 -0700 Subject: [PATCH] Improve how we determine whether we're at display-start or display-end --- gnome/src/xrEffect.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/gnome/src/xrEffect.js b/gnome/src/xrEffect.js index 6b1421b..8590e0f 100644 --- a/gnome/src/xrEffect.js +++ b/gnome/src/xrEffect.js @@ -324,8 +324,11 @@ export const XREffect = GObject.registerClass({ constructor(params = {}) { super(params); - this._is_display_distance_at_end = false; this._distance_ease_timeline = null; + this.connect('notify::toggle-display-distance-start', this._handle_display_distance_properties_change.bind(this)); + this.connect('notify::toggle-display-distance-end', this._handle_display_distance_properties_change.bind(this)); + this.connect('notify::display-distance', this._handle_display_distance_properties_change.bind(this)); + this._handle_display_distance_properties_change(); const calibrating = GdkPixbuf.Pixbuf.new_from_file(`${Globals.extension_dir}/textures/calibrating.png`); this.calibratingImage = new Clutter.Image(); @@ -338,6 +341,12 @@ export const XREffect = GObject.registerClass({ customBanner.width, customBanner.height, customBanner.rowstride); } + _handle_display_distance_properties_change() { + const distance_from_end = Math.abs(this.display_distance - this.toggle_display_distance_end); + const distance_from_start = Math.abs(this.display_distance - this.toggle_display_distance_start); + this._is_display_distance_at_end = distance_from_end < distance_from_start; + } + _change_distance() { if (this._distance_ease_timeline?.is_playing()) this._distance_ease_timeline.stop(); @@ -351,7 +360,6 @@ export const XREffect = GObject.registerClass({ this._distance_ease_timeline.get_progress() * (toggle_display_distance_target - this._distance_ease_start); }); - this._is_display_distance_at_end = !this._is_display_distance_at_end; this._distance_ease_timeline.start(); }