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 . 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 start ( string id ) {
49+ animations_ongoing ++ ;
50+ update_visibility () ;
51+ }
4652
47- gesture_ongoing = true ;
53+ public override void update (string id , double progress ) {
54+ switch (id) {
55+ case MultitaskingView . GESTURE_ID:
56+ multitasking_view_progress = progress;
57+ break ;
4858
49- update_visibility (true );
59+ case GESTURE_ID :
60+ custom_progress = progress;
61+ break ;
5062
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 ));
63+ default:
64+ break ;
65+ }
5466
55- gesture_tracker . add_end_callback (with_gesture, (percentage, completions) = > {
56- gesture_ongoing = false ;
67+ update_property ();
68+ }
5769
58- if (completions != 0 ) {
59- current_state = new_state;
60- }
70+ public override void end (string id ) {
71+ animations_ongoing-- ;
72+ update_visibility ();
73+ }
6174
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- }
75+ private void update_visibility () {
76+ var visible = double . max (multitasking_view_progress, custom_progress) < 0.1 ;
77+ var animating = animations_ongoing > 0 ;
6978
70- if (pending_state != new_state) { // We have received new state while animating
71- animate (pending_state, gesture_tracker, false );
79+ if (! Meta . Util . is_wayland_compositor ()) {
80+ if (! visible) {
81+ Utils . x11_set_window_pass_through (window);
7282 } else {
73- pending_state = current_state ;
83+ Utils . x11_unset_window_pass_through (window) ;
7484 }
75- });
76- }
77-
78- private void update_visibility (bool animating ) {
79- var visible = (current_state & HIDING_STATES ) == 0 ;
85+ }
8086
81- actor . visible = animating || visible;
87+ window_actor . visible = animating || visible;
8288
8389 unowned var manager = ShellClientsManager . get_instance ();
8490 window. foreach_transient ((transient) = > {
8591 if (manager. is_itself_positioned (transient)) {
8692 return true ;
8793 }
8894
89- unowned var actor = (Meta . WindowActor ) transient. get_compositor_private ();
95+ unowned var window_actor = (Meta . WindowActor ) transient. get_compositor_private ();
9096
91- actor . visible = visible && ! animating;
97+ window_actor . visible = visible && ! animating;
9298
9399 return true ;
94100 });
@@ -104,12 +110,22 @@ public class Gala.ShellWindow : PositionedWindow {
104110 }
105111 }
106112
113+ private Type get_property_type () {
114+ switch (position) {
115+ case TOP :
116+ case BOTTOM :
117+ return typeof (float );
118+ default:
119+ return typeof (uint );
120+ }
121+ }
122+
107123 private Value calculate_value (bool hidden ) {
108124 switch (position) {
109125 case TOP :
110- return hidden ? - actor . height : 0f ;
126+ return hidden ? - window_actor . height : 0f ;
111127 case BOTTOM :
112- return hidden ? actor . height : 0f ;
128+ return hidden ? window_actor . height : 0f ;
113129 default:
114130 return hidden ? 0u : 255u ;
115131 }
0 commit comments