wm: improve nudge effect on attempting to switch to non existent workspace

Changed nudge effect to use KeyframeTransition
Check if nudge effect isn't already played before adding the transition to prevent spasms
This commit is contained in:
Tigran Gabrielyan 2014-08-07 15:48:45 +02:00 committed by Tom Beckmann
commit 1f98418798

View File

@ -301,25 +301,33 @@ namespace Gala
{
var screen = get_screen ();
var display = screen.get_display ();
var old_index = screen.get_active_workspace_index ();
var neighbor = screen.get_active_workspace ().get_neighbor (direction);
var active_workspace = screen.get_active_workspace ();
var neighbor = active_workspace.get_neighbor (direction);
neighbor.activate (display.get_current_time ());
// if we didnt switch, show a nudge-over animation. need to take the indices
// here since the changing only applies after the animation ends
if ((old_index == 0
&& direction == MotionDirection.LEFT)
|| (old_index == screen.n_workspaces - 1
&& direction == MotionDirection.RIGHT)) {
var dest = (direction == MotionDirection.LEFT ? 32.0f : -32.0f);
ui_group.animate (Clutter.AnimationMode.LINEAR, 100, x:dest);
Timeout.add (210, () => {
ui_group.animate (Clutter.AnimationMode.LINEAR, 150, x:0.0f);
return false;
});
if (neighbor != active_workspace) {
neighbor.activate (display.get_current_time ());
return;
}
// if we didnt switch, show a nudge-over animation if one is not already in progress
if (ui_group.get_transition ("nudge") != null)
return;
var dest = (direction == MotionDirection.LEFT ? 32.0f : -32.0f);
double[] keyframes = { 0.28, 0.58 };
GLib.Value[] x = { dest, dest };
var nudge = new Clutter.KeyframeTransition ("x");
nudge.duration = 360;
nudge.remove_on_complete = true;
nudge.progress_mode = Clutter.AnimationMode.LINEAR;
nudge.set_from_value (0.0f);
nudge.set_to_value (0.0f);
nudge.set_key_frames (keyframes);
nudge.set_values (x);
ui_group.add_transition ("nudge", nudge);
}
public void update_input_area ()