mirror of
https://github.com/elementary/gala.git
synced 2024-12-25 10:13:04 +03:00
Also fix destroying (#920)
This commit is contained in:
parent
981378c7c1
commit
598ab52023
@ -63,38 +63,40 @@ public class Gala.NotificationStack : Object {
|
||||
update_stack_allocation ();
|
||||
}
|
||||
|
||||
public void show_notification (Meta.WindowActor notification) {
|
||||
public void show_notification (Meta.WindowActor notification, bool animate) {
|
||||
notification.set_pivot_point (0.5f, 0.5f);
|
||||
|
||||
unowned Meta.Window window = notification.get_meta_window ();
|
||||
window.stick ();
|
||||
|
||||
|
||||
var scale = Utils.get_ui_scaling_factor ();
|
||||
|
||||
var opacity_transition = new Clutter.PropertyTransition ("opacity");
|
||||
opacity_transition.set_from_value (0);
|
||||
opacity_transition.set_to_value (255);
|
||||
if (animate) {
|
||||
var opacity_transition = new Clutter.PropertyTransition ("opacity");
|
||||
opacity_transition.set_from_value (0);
|
||||
opacity_transition.set_to_value (255);
|
||||
|
||||
var flip_transition = new Clutter.KeyframeTransition ("rotation-angle-x");
|
||||
flip_transition.set_from_value (90.0);
|
||||
flip_transition.set_to_value (0.0);
|
||||
flip_transition.set_key_frames ({ 0.6 });
|
||||
flip_transition.set_values ({ -10.0 });
|
||||
var flip_transition = new Clutter.KeyframeTransition ("rotation-angle-x");
|
||||
flip_transition.set_from_value (90.0);
|
||||
flip_transition.set_to_value (0.0);
|
||||
flip_transition.set_key_frames ({ 0.6 });
|
||||
flip_transition.set_values ({ -10.0 });
|
||||
|
||||
var entry = new Clutter.TransitionGroup ();
|
||||
entry.duration = 400;
|
||||
entry.add_transition (opacity_transition);
|
||||
entry.add_transition (flip_transition);
|
||||
var entry = new Clutter.TransitionGroup ();
|
||||
entry.duration = 400;
|
||||
entry.add_transition (opacity_transition);
|
||||
entry.add_transition (flip_transition);
|
||||
|
||||
notification.transitions_completed.connect (() => notification.remove_all_transitions ());
|
||||
notification.add_transition (TRANSITION_ENTRY_NAME, entry);
|
||||
notification.transitions_completed.connect (() => notification.remove_all_transitions ());
|
||||
notification.add_transition (TRANSITION_ENTRY_NAME, entry);
|
||||
}
|
||||
|
||||
/**
|
||||
* We will make space for the incomming notification
|
||||
* by shifting all current notifications by height
|
||||
* and then add it to the notifications list.
|
||||
*/
|
||||
update_positions (notification.height);
|
||||
update_positions (animate, notification.height);
|
||||
|
||||
move_window (notification, stack_x, stack_y + TOP_OFFSET + ADDITIONAL_MARGIN * scale);
|
||||
notifications.insert (0, notification);
|
||||
@ -116,19 +118,24 @@ public class Gala.NotificationStack : Object {
|
||||
stack_y = area.y;
|
||||
}
|
||||
|
||||
private void update_positions (float add_y = 0.0f) {
|
||||
private void update_positions (bool animate, float add_y = 0.0f) {
|
||||
var scale = Utils.get_ui_scaling_factor ();
|
||||
var y = stack_y + TOP_OFFSET + add_y + ADDITIONAL_MARGIN * scale;
|
||||
var i = notifications.size;
|
||||
var delay_step = i > 0 ? 150 / i : 0;
|
||||
foreach (var actor in notifications) {
|
||||
actor.save_easing_state ();
|
||||
actor.set_easing_mode (Clutter.AnimationMode.EASE_OUT_BACK);
|
||||
actor.set_easing_duration (200);
|
||||
actor.set_easing_delay ((i--) * delay_step);
|
||||
if (animate) {
|
||||
actor.save_easing_state ();
|
||||
actor.set_easing_mode (Clutter.AnimationMode.EASE_OUT_BACK);
|
||||
actor.set_easing_duration (200);
|
||||
actor.set_easing_delay ((i--) * delay_step);
|
||||
}
|
||||
|
||||
move_window (actor, -1, (int)y);
|
||||
actor.restore_easing_state ();
|
||||
|
||||
if (animate) {
|
||||
actor.restore_easing_state ();
|
||||
}
|
||||
|
||||
// For some reason get_transition doesn't work later when we need to restore it
|
||||
unowned Clutter.Transition? transition = actor.get_transition ("position");
|
||||
@ -138,17 +145,22 @@ public class Gala.NotificationStack : Object {
|
||||
}
|
||||
}
|
||||
|
||||
public void destroy_notification (Meta.WindowActor notification) {
|
||||
notification.save_easing_state ();
|
||||
notification.set_easing_duration (100);
|
||||
notification.set_easing_mode (Clutter.AnimationMode.EASE_IN_QUAD);
|
||||
notification.opacity = 0;
|
||||
public void destroy_notification (Meta.WindowActor notification, bool animate) {
|
||||
if (animate) {
|
||||
notification.save_easing_state ();
|
||||
notification.set_easing_duration (100);
|
||||
notification.set_easing_mode (Clutter.AnimationMode.EASE_IN_QUAD);
|
||||
notification.opacity = 0;
|
||||
|
||||
notification.x += stack_width;
|
||||
notification.restore_easing_state ();
|
||||
notification.x += stack_width;
|
||||
notification.restore_easing_state ();
|
||||
} else {
|
||||
notification.opacity = 0;
|
||||
notification.x += stack_width;
|
||||
}
|
||||
|
||||
notifications.remove (notification);
|
||||
update_positions ();
|
||||
update_positions (animate);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1459,7 +1459,10 @@ namespace Gala {
|
||||
|
||||
public override void map (Meta.WindowActor actor) {
|
||||
var window = actor.get_meta_window ();
|
||||
if (!enable_animations) {
|
||||
|
||||
// Notifications are a special case and have to be always be handled
|
||||
// regardless of the animation setting
|
||||
if (!enable_animations && window.window_type != Meta.WindowType.NOTIFICATION) {
|
||||
actor.show ();
|
||||
map_completed (actor);
|
||||
|
||||
@ -1575,7 +1578,7 @@ namespace Gala {
|
||||
|
||||
break;
|
||||
case Meta.WindowType.NOTIFICATION:
|
||||
notification_stack.show_notification (actor);
|
||||
notification_stack.show_notification (actor, enable_animations);
|
||||
map_completed (actor);
|
||||
|
||||
break;
|
||||
@ -1590,7 +1593,7 @@ namespace Gala {
|
||||
|
||||
ws_assoc.remove (window);
|
||||
|
||||
if (!enable_animations) {
|
||||
if (!enable_animations && window.window_type != Meta.WindowType.NOTIFICATION) {
|
||||
destroy_completed (actor);
|
||||
|
||||
// only NORMAL windows have icons
|
||||
@ -1677,15 +1680,23 @@ namespace Gala {
|
||||
});
|
||||
break;
|
||||
case Meta.WindowType.NOTIFICATION:
|
||||
destroying.add (actor);
|
||||
notification_stack.destroy_notification (actor);
|
||||
if (enable_animations) {
|
||||
destroying.add (actor);
|
||||
}
|
||||
|
||||
ulong destroy_handler_id = 0UL;
|
||||
destroy_handler_id = actor.transitions_completed.connect (() => {
|
||||
actor.disconnect (destroy_handler_id);
|
||||
destroying.remove (actor);
|
||||
notification_stack.destroy_notification (actor, enable_animations);
|
||||
|
||||
if (enable_animations) {
|
||||
ulong destroy_handler_id = 0UL;
|
||||
destroy_handler_id = actor.transitions_completed.connect (() => {
|
||||
actor.disconnect (destroy_handler_id);
|
||||
destroying.remove (actor);
|
||||
destroy_completed (actor);
|
||||
});
|
||||
} else {
|
||||
destroy_completed (actor);
|
||||
});
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
destroy_completed (actor);
|
||||
|
Loading…
Reference in New Issue
Block a user