~voldyman/gala/scale-large-notification-icon

« back to all changes in this revision

Viewing changes to src/WindowManager.vala

  • Committer: Rico Tzschichholz
  • Date: 2015-03-12 14:00:26 UTC
  • Revision ID: ricotz@ubuntu.com-20150312140026-b2tawqvwpbuw8jmo
Cache AnimationSettings.get_default () and properties which are re-used

Show diffs side-by-side

added added

removed removed

Lines of Context:
709
709
 
710
710
                public override void minimize (WindowActor actor)
711
711
                {
712
 
                        if (!AnimationSettings.get_default ().enable_animations ||
713
 
                                AnimationSettings.get_default ().minimize_duration == 0 ||
714
 
                                actor.get_meta_window ().window_type != WindowType.NORMAL) {
 
712
                        unowned AnimationSettings animation_settings = AnimationSettings.get_default ();
 
713
                        var duration = animation_settings.minimize_duration;
 
714
                        
 
715
                        if (!animation_settings.enable_animations
 
716
                                || duration == 0
 
717
                                || actor.get_meta_window ().window_type != WindowType.NORMAL) {
715
718
                                minimize_completed (actor);
716
719
                                return;
717
720
                        }
735
738
                                actor.scale_center_x = anchor_x;
736
739
                                actor.scale_center_y = anchor_y;
737
740
 
738
 
                                actor.animate (Clutter.AnimationMode.EASE_IN_EXPO, AnimationSettings.get_default ().minimize_duration,
 
741
                                actor.animate (Clutter.AnimationMode.EASE_IN_EXPO, duration,
739
742
                                        scale_x:scale_x, scale_y:scale_y,opacity:0).completed.connect (() => {
740
743
 
741
744
                                        actor.scale_center_x = actor.scale_center_y = 0;
750
753
                                actor.scale_center_x = width / 2.0f - actor.x;
751
754
                                actor.scale_center_y = height - actor.y;
752
755
 
753
 
                                actor.animate (Clutter.AnimationMode.EASE_IN_EXPO, AnimationSettings.get_default ().minimize_duration,
 
756
                                actor.animate (Clutter.AnimationMode.EASE_IN_EXPO, duration,
754
757
                                        scale_x : 0.0f, scale_y : 0.0f, opacity : 0).completed.connect (() => {
755
758
 
756
759
                                        actor.set_pivot_point (0, 0);
765
768
 
766
769
                public override void maximize (WindowActor actor, int ex, int ey, int ew, int eh)
767
770
                {
768
 
                        var duration = AnimationSettings.get_default ().snap_duration;
 
771
                        unowned AnimationSettings animation_settings = AnimationSettings.get_default ();
 
772
                        var duration = animation_settings.snap_duration;
769
773
 
770
 
                        if (!AnimationSettings.get_default ().enable_animations || duration == 0) {
 
774
                        if (!animation_settings.enable_animations
 
775
                                || duration == 0) {
771
776
                                maximize_completed (actor);
772
777
                                return;
773
778
                        }
860
865
#if HAS_MUTTER314
861
866
                public override void unminimize (WindowActor actor)
862
867
                {
863
 
                        if (!AnimationSettings.get_default ().enable_animations) {
 
868
                        unowned AnimationSettings animation_settings = AnimationSettings.get_default ();
 
869
 
 
870
                        if (!animation_settings.enable_animations) {
864
871
                                actor.show ();
865
872
                                unminimize_completed (actor);
866
873
                                return;
873
880
 
874
881
                        switch (window.window_type) {
875
882
                                case WindowType.NORMAL:
876
 
                                        if (AnimationSettings.get_default ().minimize_duration == 0) {
 
883
                                        var duration = animation_settings.minimize_duration;
 
884
                                        if (duration == 0) {
877
885
                                                unminimize_completed (actor);
878
886
                                                return;
879
887
                                        }
884
892
                                        actor.scale_x = 0.01f;
885
893
                                        actor.scale_y = 0.1f;
886
894
                                        actor.opacity = 0;
887
 
                                        actor.animate (Clutter.AnimationMode.EASE_OUT_EXPO, AnimationSettings.get_default ().minimize_duration,
 
895
                                        actor.animate (Clutter.AnimationMode.EASE_OUT_EXPO, duration,
888
896
                                                scale_x:1.0f, scale_y:1.0f, opacity:255)
889
897
                                                .completed.connect ( () => {
890
898
 
902
910
 
903
911
                public override void map (WindowActor actor)
904
912
                {
905
 
                        if (!AnimationSettings.get_default ().enable_animations) {
 
913
                        unowned AnimationSettings animation_settings = AnimationSettings.get_default ();
 
914
 
 
915
                        if (!animation_settings.enable_animations) {
906
916
                                actor.show ();
907
917
                                map_completed (actor);
908
918
                                return;
915
925
 
916
926
                        switch (window.window_type) {
917
927
                                case WindowType.NORMAL:
918
 
                                        if (AnimationSettings.get_default ().open_duration == 0) {
 
928
                                        var duration = animation_settings.open_duration;
 
929
                                        if (duration == 0) {
919
930
                                                map_completed (actor);
920
931
                                                return;
921
932
                                        }
926
937
                                        actor.scale_x = 0.01f;
927
938
                                        actor.scale_y = 0.1f;
928
939
                                        actor.opacity = 0;
929
 
                                        actor.animate (Clutter.AnimationMode.EASE_OUT_EXPO, AnimationSettings.get_default ().open_duration,
 
940
                                        actor.animate (Clutter.AnimationMode.EASE_OUT_EXPO, duration,
930
941
                                                scale_x:1.0f, scale_y:1.0f, opacity:255)
931
942
                                                .completed.connect ( () => {
932
943
 
937
948
                                case WindowType.MENU:
938
949
                                case WindowType.DROPDOWN_MENU:
939
950
                                case WindowType.POPUP_MENU:
940
 
                                        if (AnimationSettings.get_default ().menu_duration == 0) {
 
951
                                        var duration = animation_settings.menu_duration;
 
952
                                        if (duration == 0) {
941
953
                                                map_completed (actor);
942
954
                                                return;
943
955
                                        }
949
961
                                        actor.scale_x = 0.9f;
950
962
                                        actor.scale_y = 0.9f;
951
963
                                        actor.opacity = 0;
952
 
                                        actor.animate (Clutter.AnimationMode.EASE_OUT_QUAD, AnimationSettings.get_default ().menu_duration,
 
964
                                        actor.animate (Clutter.AnimationMode.EASE_OUT_QUAD, duration,
953
965
                                                scale_x:1.0f, scale_y:1.0f, opacity:255)
954
966
                                                .completed.connect ( () => {
955
967
 
987
999
 
988
1000
                public override void destroy (WindowActor actor)
989
1001
                {
 
1002
                        unowned AnimationSettings animation_settings = AnimationSettings.get_default ();
990
1003
                        var window = actor.get_meta_window ();
991
1004
 
992
 
                        if (!AnimationSettings.get_default ().enable_animations) {
 
1005
                        if (!animation_settings.enable_animations) {
993
1006
                                destroy_completed (actor);
994
1007
 
995
1008
                                // only NORMAL windows have icons
1003
1016
 
1004
1017
                        switch (window.window_type) {
1005
1018
                                case WindowType.NORMAL:
1006
 
                                        if (AnimationSettings.get_default ().close_duration == 0) {
 
1019
                                        var duration = animation_settings.close_duration;
 
1020
                                        if (duration == 0) {
1007
1021
                                                destroy_completed (actor);
1008
1022
                                                return;
1009
1023
                                        }
1012
1026
 
1013
1027
                                        actor.scale_gravity = Clutter.Gravity.CENTER;
1014
1028
                                        actor.show ();
1015
 
                                        actor.animate (Clutter.AnimationMode.LINEAR, AnimationSettings.get_default ().close_duration,
 
1029
                                        actor.animate (Clutter.AnimationMode.LINEAR, duration,
1016
1030
                                                scale_x:0.8f, scale_y:0.8f, opacity:0)
1017
1031
                                                .completed.connect ( () => {
1018
1032
 
1039
1053
                                case WindowType.MENU:
1040
1054
                                case WindowType.DROPDOWN_MENU:
1041
1055
                                case WindowType.POPUP_MENU:
1042
 
                                        if (AnimationSettings.get_default ().menu_duration == 0) {
 
1056
                                        var duration = animation_settings.menu_duration;
 
1057
                                        if (duration == 0) {
1043
1058
                                                destroy_completed (actor);
1044
1059
                                                return;
1045
1060
                                        }
1046
1061
 
1047
1062
                                        destroying.add (actor);
1048
1063
 
1049
 
                                        actor.animate (Clutter.AnimationMode.EASE_OUT_QUAD, AnimationSettings.get_default ().menu_duration,
 
1064
                                        actor.animate (Clutter.AnimationMode.EASE_OUT_QUAD, duration,
1050
1065
                                                scale_x:0.8f, scale_y:0.8f, opacity:0)
1051
1066
                                                .completed.connect ( () => {
1052
1067
 
1062
1077
 
1063
1078
                public override void unmaximize (Meta.WindowActor actor, int ex, int ey, int ew, int eh)
1064
1079
                {
1065
 
                        var duration = AnimationSettings.get_default ().snap_duration;
 
1080
                        unowned AnimationSettings animation_settings = AnimationSettings.get_default ();
 
1081
                        var duration = animation_settings.snap_duration;
1066
1082
 
1067
 
                        if (!AnimationSettings.get_default ().enable_animations || duration == 0) {
 
1083
                        if (!animation_settings.enable_animations
 
1084
                                || duration == 0) {
1068
1085
                                unmaximize_completed (actor);
1069
1086
                                return;
1070
1087
                        }
1182
1199
 
1183
1200
                public override void switch_workspace (int from, int to, MotionDirection direction)
1184
1201
                {
1185
 
                        if (!AnimationSettings.get_default ().enable_animations
1186
 
                                || AnimationSettings.get_default ().workspace_switch_duration == 0
 
1202
                        unowned AnimationSettings animation_settings = AnimationSettings.get_default ();
 
1203
                        var animation_duration = animation_settings.workspace_switch_duration;
 
1204
 
 
1205
                        if (!animation_settings.enable_animations
 
1206
                                || animation_duration == 0
1187
1207
                                || (direction != MotionDirection.LEFT && direction != MotionDirection.RIGHT)) {
1188
1208
                                switch_workspace_completed ();
1189
1209
                                return;
1339
1359
                        in_group.width = out_group.width = move_primary_only ? monitor_geom.width : screen_width;
1340
1360
                        in_group.height = out_group.height = move_primary_only ? monitor_geom.height : screen_height;
1341
1361
 
1342
 
                        var animation_duration = AnimationSettings.get_default ().workspace_switch_duration;
1343
1362
                        var animation_mode = Clutter.AnimationMode.EASE_OUT_CUBIC;
1344
1363
 
1345
1364
                        out_group.set_easing_mode (animation_mode);