@@ -79,6 +79,7 @@ def __init__(self, monitor_id: int = 0, **kwargs):
7979 monitor = monitor_id ,
8080 )
8181
82+ self ._animation_queue = []
8283 self .anchor_var = ""
8384 self .margin_var = ""
8485
@@ -549,9 +550,6 @@ def _on_workspace_changed(self, _, event):
549550
550551 def update_rail (self , workspace_id , initial_setup = False ):
551552 """Update the workspace rail position based on the workspace button"""
552- if self .is_animating_rail and not initial_setup :
553- return
554-
555553 logger .info (f"Updating rail for workspace { workspace_id } " )
556554 workspaces = self .children_workspaces
557555 active_button = next (
@@ -568,10 +566,13 @@ def update_rail(self, workspace_id, initial_setup=False):
568566 return
569567
570568 if initial_setup :
571- GLib .idle_add ( self ._position_rail_initially , active_button )
569+ GLib .timeout_add ( 1000 , self ._position_rail_initially , active_button )
572570 else :
573- self .is_animating_rail = True
574- GLib .idle_add (self ._update_rail_with_animation , active_button )
571+ if self .is_animating_rail :
572+ self ._animation_queue .append ((self ._update_rail_with_animation , active_button ))
573+ else :
574+ self .is_animating_rail = True
575+ GLib .idle_add (self ._update_rail_with_animation , active_button )
575576
576577 def _position_rail_initially (self , active_button ):
577578 allocation = active_button .get_allocation ()
@@ -633,15 +634,16 @@ def _update_rail_with_animation(self, active_button):
633634 )
634635
635636 if target_pos == self .current_rail_pos :
636- self .is_animating_rail = False
637+ self ._trigger_pending_animations ()
637638 return False
638639
639640 distance = target_pos - self .current_rail_pos
640641 stretched_size = self .current_rail_size + abs (distance )
641642 stretch_pos = target_pos if distance < 0 else self .current_rail_pos
642643
643- stretch_duration = 0.1
644- shrink_duration = 0.15
644+ decimator = len (self ._animation_queue ) + 1
645+ stretch_duration = 0.1 / decimator
646+ shrink_duration = 0.15 / decimator
645647
646648 reduced_diameter = max (2 , int (diameter - abs (distance / 10.0 )))
647649
@@ -700,14 +702,23 @@ def _shrink_rail(self, target_pos, target_size, duration):
700702 )
701703 return False
702704
705+ def _trigger_pending_animations (self ):
706+ if self ._animation_queue :
707+ next_anim = self ._animation_queue .pop (0 )
708+ GLib .idle_add (* next_anim )
709+ return True
710+ else :
711+ self .is_animating_rail = False
712+ return False
713+
703714 def _finalize_rail_animation (self , final_pos , final_size ):
704715 """Finalize animation and update state."""
705716 self .current_rail_pos = final_pos
706717 self .current_rail_size = final_size
707- self . is_animating_rail = False
708- logger .info (
709- f"Rail animation finished at pos={ self .current_rail_pos } , size={ self .current_rail_size } "
710- )
718+ if not self . _trigger_pending_animations ():
719+ logger .info (
720+ f"Rail animation finished at pos={ self .current_rail_pos } , size={ self .current_rail_size } "
721+ )
711722 return False
712723
713724 @property
0 commit comments