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 const string GESTURE_ID = " shell-window" ;
10+
11+ public Clutter . Actor ? actor { get { return window_actor; } }
1512
16- private const State HIDING_STATES = CUSTOM_HIDDEN | MULTITASKING_VIEW ;
13+ private Meta . WindowActor window_actor;
14+ private double custom_progress = 0 ;
15+ private double multitasking_view_progress = 0 ;
1716
18- private Meta . WindowActor actor;
19- private State pending_state = DESKTOP ;
20- private State current_state = DESKTOP ;
17+ private int animations_ongoing = 0 ;
2118
22- private bool gesture_ongoing = false ;
19+ private PropertyTarget property_target ;
2320
2421 public ShellWindow (Meta .Window window , Position position , Variant ? position_data = null ) {
2522 base (window, position, position_data);
2623 }
2724
2825 construct {
29- actor = (Meta . WindowActor ) window. get_compositor_private ();
26+ window_actor = (Meta . WindowActor ) window. get_compositor_private ();
27+
28+ window_actor. notify[" height" ]. connect (update_target);
29+ notify[" position" ]. connect (update_target);
30+ update_target ();
3031 }
3132
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);
33+ private void update_target () {
34+ property_target = new PropertyTarget (
35+ GESTURE_ID , window_actor,
36+ get_animation_property (),
37+ get_property_type (),
38+ calculate_value (false ),
39+ calculate_value (true )
40+ );
3541 }
3642
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 );
43+ private void update_property ( ) {
44+ var hidden_progress = double . max (custom_progress, multitasking_view_progress) ;
45+ property_target . propagate ( UPDATE , GESTURE_ID , hidden_progress );
4046 }
4147
42- private void animate (State new_state , GestureTracker gesture_tracker , bool with_gesture ) {
43- if (new_state == current_state || gesture_ongoing) {
44- return ;
45- }
48+ public override void propagate (UpdateType update_type , string id , double progress ) {
49+ switch (update_type) {
50+ case START :
51+ animations_ongoing++ ;
52+ update_visibility ();
53+ break ;
4654
47- gesture_ongoing = true ;
55+ case UPDATE :
56+ on_update (id, progress);
57+ break ;
4858
49- update_visibility (true );
59+ case END :
60+ animations_ongoing-- ;
61+ update_visibility ();
62+ break ;
5063
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 ));
64+ default:
65+ break ;
66+ }
67+ }
5468
55- gesture_tracker. add_end_callback (with_gesture, (percentage, completions) = > {
56- gesture_ongoing = false ;
69+ private void on_update (string id , double progress ) {
70+ switch (id) {
71+ case MultitaskingView . GESTURE_ID:
72+ multitasking_view_progress = progress;
73+ break ;
5774
58- if (completions != 0 ) {
59- current_state = new_state ;
60- }
75+ case GESTURE_ID :
76+ custom_progress = progress ;
77+ break ;
6178
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- }
79+ default:
80+ break ;
81+ }
6982
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- });
83+ update_property ();
7684 }
7785
78- private void update_visibility (bool animating ) {
79- var visible = (current_state & HIDING_STATES ) == 0 ;
86+ private void update_visibility () {
87+ var visible = double . max (multitasking_view_progress, custom_progress) < 0.1 ;
88+ var animating = animations_ongoing > 0 ;
89+
90+ if (! Meta . Util . is_wayland_compositor ()) {
91+ if (! visible) {
92+ Utils . x11_set_window_pass_through (window);
93+ } else {
94+ Utils . x11_unset_window_pass_through (window);
95+ }
96+ }
8097
81- actor . visible = animating || visible;
98+ window_actor . visible = animating || visible;
8299
83100 unowned var manager = ShellClientsManager . get_instance ();
84101 window. foreach_transient ((transient) = > {
85102 if (manager. is_itself_positioned (transient)) {
86103 return true ;
87104 }
88105
89- unowned var actor = (Meta . WindowActor ) transient. get_compositor_private ();
106+ unowned var window_actor = (Meta . WindowActor ) transient. get_compositor_private ();
90107
91- actor . visible = visible && ! animating;
108+ window_actor . visible = visible && ! animating;
92109
93110 return true ;
94111 });
@@ -104,12 +121,22 @@ public class Gala.ShellWindow : PositionedWindow {
104121 }
105122 }
106123
124+ private Type get_property_type () {
125+ switch (position) {
126+ case TOP :
127+ case BOTTOM :
128+ return typeof (float );
129+ default:
130+ return typeof (uint );
131+ }
132+ }
133+
107134 private Value calculate_value (bool hidden ) {
108135 switch (position) {
109136 case TOP :
110- return hidden ? - actor . height : 0f ;
137+ return hidden ? - window_actor . height : 0f ;
111138 case BOTTOM :
112- return hidden ? actor . height : 0f ;
139+ return hidden ? window_actor . height : 0f ;
113140 default:
114141 return hidden ? 0u : 255u ;
115142 }
0 commit comments