55 * Authored by: Leonhard Kargl <[email protected] > 66 */
77
8- public class Gala.ShellWindow : PositionedWindow {
9- [Flags ]
10- public enum State {
11- CUSTOM_HIDDEN ,
12- MULTITASKING_VIEW ,
13- DESKTOP
14- }
8+ public class Gala.ShellWindow : PositionedWindow , GestureTarget {
9+ public Clutter . Actor ? actor { get { return window_actor; } }
1510
16- private const State HIDING_STATES = CUSTOM_HIDDEN | MULTITASKING_VIEW ;
11+ private Meta . WindowActor window_actor;
12+ private double custom_progress = 0 ;
13+ private double multitasking_view_progress = 0 ;
1714
18- private Meta . WindowActor actor;
19- private State pending_state = DESKTOP ;
20- private State current_state = DESKTOP ;
15+ private int animations_ongoing = 0 ;
2116
22- private bool gesture_ongoing = false ;
17+ private PropertyTarget property_target ;
2318
2419 public ShellWindow (Meta .Window window , Position position , Variant ? position_data = null ) {
2520 base (window, position, position_data);
2621 }
2722
2823 construct {
29- actor = (Meta . WindowActor ) window. get_compositor_private ();
24+ window_actor = (Meta . WindowActor ) window. get_compositor_private ();
25+
26+ window_actor. notify[" height" ]. connect (update_target);
27+ notify[" position" ]. connect (update_target);
28+ update_target ();
3029 }
3130
32- public void add_state (State state , GestureTracker gesture_tracker , bool with_gesture ) {
33- pending_state |= state;
34- animate (pending_state, gesture_tracker, with_gesture);
31+ private void update_target () {
32+ property_target = new PropertyTarget (
33+ DOCK , window_actor,
34+ get_animation_property (),
35+ get_property_type (),
36+ calculate_value (false ),
37+ calculate_value (true )
38+ );
3539 }
3640
37- public void remove_state ( State state , GestureTracker gesture_tracker , bool with_gesture ) {
38- pending_state & = ~state ;
39- animate (pending_state, gesture_tracker, with_gesture );
41+ private void update_property ( ) {
42+ var hidden_progress = double . max (custom_progress, multitasking_view_progress) ;
43+ property_target . propagate ( UPDATE , DOCK , hidden_progress );
4044 }
4145
42- private void animate (State new_state , GestureTracker gesture_tracker , bool with_gesture ) {
43- if (new_state == current_state || gesture_ongoing) {
44- return ;
45- }
46+ public override void propagate (UpdateType update_type , GestureAction action , double progress ) {
47+ switch (update_type) {
48+ case START :
49+ animations_ongoing++ ;
50+ update_visibility ();
51+ break ;
4652
47- gesture_ongoing = true ;
53+ case UPDATE :
54+ on_update (action, progress);
55+ break ;
4856
49- update_visibility (true );
57+ case END :
58+ animations_ongoing-- ;
59+ update_visibility ();
60+ break ;
5061
51- new GesturePropertyTransition (
52- actor, gesture_tracker, get_animation_property (), null , calculate_value ((new_state & HIDING_STATES ) != 0 )
53- ). start (with_gesture, () = > update_visibility (false ));
62+ default:
63+ break ;
64+ }
65+ }
5466
55- gesture_tracker. add_end_callback (with_gesture, (percentage, completions) = > {
56- gesture_ongoing = false ;
67+ private void on_update (GestureAction action , double progress ) {
68+ switch (action) {
69+ case MULTITASKING_VIEW :
70+ multitasking_view_progress = progress;
71+ break ;
5772
58- if (completions != 0 ) {
59- current_state = new_state ;
60- }
73+ case DOCK :
74+ custom_progress = progress ;
75+ break ;
6176
62- if (! Meta . Util . is_wayland_compositor ()) {
63- if ((current_state & HIDING_STATES ) != 0 ) {
64- Utils . x11_set_window_pass_through (window);
65- } else {
66- Utils . x11_unset_window_pass_through (window);
67- }
68- }
77+ default:
78+ break ;
79+ }
6980
70- if (pending_state != new_state) { // We have received new state while animating
71- animate (pending_state, gesture_tracker, false );
72- } else {
73- pending_state = current_state;
74- }
75- });
81+ update_property ();
7682 }
7783
78- private void update_visibility (bool animating ) {
79- var visible = (current_state & HIDING_STATES ) == 0 ;
84+ private void update_visibility () {
85+ var visible = double . max (multitasking_view_progress, custom_progress) < 0.1 ;
86+ var animating = animations_ongoing > 0 ;
87+
88+ if (! Meta . Util . is_wayland_compositor ()) {
89+ if (! visible) {
90+ Utils . x11_set_window_pass_through (window);
91+ } else {
92+ Utils . x11_unset_window_pass_through (window);
93+ }
94+ }
8095
81- actor . visible = animating || visible;
96+ window_actor . visible = animating || visible;
8297
8398 unowned var manager = ShellClientsManager . get_instance ();
8499 window. foreach_transient ((transient) = > {
85100 if (manager. is_itself_positioned (transient)) {
86101 return true ;
87102 }
88103
89- unowned var actor = (Meta . WindowActor ) transient. get_compositor_private ();
104+ unowned var window_actor = (Meta . WindowActor ) transient. get_compositor_private ();
90105
91- actor . visible = visible && ! animating;
106+ window_actor . visible = visible && ! animating;
92107
93108 return true ;
94109 });
@@ -104,12 +119,22 @@ public class Gala.ShellWindow : PositionedWindow {
104119 }
105120 }
106121
122+ private Type get_property_type () {
123+ switch (position) {
124+ case TOP :
125+ case BOTTOM :
126+ return typeof (float );
127+ default:
128+ return typeof (uint );
129+ }
130+ }
131+
107132 private Value calculate_value (bool hidden ) {
108133 switch (position) {
109134 case TOP :
110- return hidden ? - actor . height : 0f ;
135+ return hidden ? - window_actor . height : 0f ;
111136 case BOTTOM :
112- return hidden ? actor . height : 0f ;
137+ return hidden ? window_actor . height : 0f ;
113138 default:
114139 return hidden ? 0u : 255u ;
115140 }
0 commit comments