mirror of
https://github.com/elementary/gala.git
synced 2024-09-11 15:15:39 +03:00
Workspaces in multitasking view should not animate as if they are stacked (#1002)
This commit is contained in:
parent
0d0d4a5fd3
commit
9aee122c18
@ -300,7 +300,6 @@ namespace Gala {
|
|||||||
* positions immediately.
|
* positions immediately.
|
||||||
*/
|
*/
|
||||||
void update_positions (bool animate) {
|
void update_positions (bool animate) {
|
||||||
var scale = InternalUtils.get_ui_scaling_factor ();
|
|
||||||
#if HAS_MUTTER330
|
#if HAS_MUTTER330
|
||||||
unowned Meta.WorkspaceManager manager = display.get_workspace_manager ();
|
unowned Meta.WorkspaceManager manager = display.get_workspace_manager ();
|
||||||
var active_index = manager.get_active_workspace ().index ();
|
var active_index = manager.get_active_workspace ().index ();
|
||||||
@ -312,7 +311,7 @@ namespace Gala {
|
|||||||
foreach (var child in workspaces.get_children ()) {
|
foreach (var child in workspaces.get_children ()) {
|
||||||
unowned WorkspaceClone workspace_clone = (WorkspaceClone) child;
|
unowned WorkspaceClone workspace_clone = (WorkspaceClone) child;
|
||||||
var index = workspace_clone.workspace.index ();
|
var index = workspace_clone.workspace.index ();
|
||||||
var dest_x = index * (workspace_clone.width - (150 * scale));
|
var dest_x = workspace_clone.multitasking_view_x ();
|
||||||
|
|
||||||
if (index == active_index) {
|
if (index == active_index) {
|
||||||
active_x = dest_x;
|
active_x = dest_x;
|
||||||
@ -647,7 +646,9 @@ namespace Gala {
|
|||||||
child.remove_all_transitions ();
|
child.remove_all_transitions ();
|
||||||
}
|
}
|
||||||
|
|
||||||
update_positions (false);
|
if (!gesture_animation_director.canceling) {
|
||||||
|
update_positions (false);
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var child in workspaces.get_children ()) {
|
foreach (var child in workspaces.get_children ()) {
|
||||||
unowned WorkspaceClone workspace = (WorkspaceClone) child;
|
unowned WorkspaceClone workspace = (WorkspaceClone) child;
|
||||||
|
@ -128,6 +128,12 @@ namespace Gala {
|
|||||||
*/
|
*/
|
||||||
const int HOVER_ACTIVATE_DELAY = 400;
|
const int HOVER_ACTIVATE_DELAY = 400;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The MultitaskingView shows the workspaces overlapping them WorkspaceClone.X_OFFSET pixels
|
||||||
|
* making it possible to move windows to the next/previous workspace.
|
||||||
|
*/
|
||||||
|
public const int X_OFFSET = 150;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A window has been selected, the MultitaskingView should consider activating
|
* A window has been selected, the MultitaskingView should consider activating
|
||||||
* and closing the view.
|
* and closing the view.
|
||||||
@ -350,6 +356,35 @@ namespace Gala {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The position on the X axis of this workspace.
|
||||||
|
*/
|
||||||
|
public float multitasking_view_x () {
|
||||||
|
var scale_factor = InternalUtils.get_ui_scaling_factor ();
|
||||||
|
return workspace.index () * (width - (X_OFFSET * scale_factor));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The amount of pixels the workspace is overlapped in the X axis.
|
||||||
|
*/
|
||||||
|
float current_x_overlap () {
|
||||||
|
var scale_factor = InternalUtils.get_ui_scaling_factor ();
|
||||||
|
#if HAS_MUTTER330
|
||||||
|
var display = workspace.get_display ();
|
||||||
|
unowned Meta.WorkspaceManager manager = display.get_workspace_manager ();
|
||||||
|
var active_index = manager.get_active_workspace ().index ();
|
||||||
|
#else
|
||||||
|
var screen = workspace.get_screen ();
|
||||||
|
var active_index = screen.get_active_workspace ().index ();
|
||||||
|
#endif
|
||||||
|
if (workspace.index () == active_index) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
var x_offset = X_OFFSET * scale_factor + WindowManagerGala.WORKSPACE_GAP;
|
||||||
|
return (workspace.index () < active_index) ? -x_offset : x_offset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility function to shrink a MetaRectangle on all sides for the given amount.
|
* Utility function to shrink a MetaRectangle on all sides for the given amount.
|
||||||
* Negative amounts will scale it instead.
|
* Negative amounts will scale it instead.
|
||||||
@ -387,16 +422,23 @@ namespace Gala {
|
|||||||
|
|
||||||
var monitor = screen.get_monitor_geometry (screen.get_primary_monitor ());
|
var monitor = screen.get_monitor_geometry (screen.get_primary_monitor ());
|
||||||
#endif
|
#endif
|
||||||
|
var initial_x = gesture_animation_director.canceling ? x : x + current_x_overlap ();
|
||||||
|
var target_x = multitasking_view_x ();
|
||||||
|
|
||||||
var scale = (float)(monitor.height - TOP_OFFSET * scale_factor - BOTTOM_OFFSET * scale_factor) / monitor.height;
|
var scale = (float)(monitor.height - TOP_OFFSET * scale_factor - BOTTOM_OFFSET * scale_factor) / monitor.height;
|
||||||
var pivotY = TOP_OFFSET * scale_factor / (monitor.height - monitor.height * scale);
|
var pivotY = TOP_OFFSET * scale_factor / (monitor.height - monitor.height * scale);
|
||||||
|
|
||||||
update_size (monitor);
|
update_size (monitor);
|
||||||
|
|
||||||
GestureAnimationDirector.OnBegin on_animation_begin = () => {
|
GestureAnimationDirector.OnBegin on_animation_begin = () => {
|
||||||
|
x = initial_x;
|
||||||
background.set_pivot_point (0.5f, pivotY);
|
background.set_pivot_point (0.5f, pivotY);
|
||||||
};
|
};
|
||||||
|
|
||||||
GestureAnimationDirector.OnUpdate on_animation_update = (percentage) => {
|
GestureAnimationDirector.OnUpdate on_animation_update = (percentage) => {
|
||||||
|
var x = GestureAnimationDirector.animation_value (initial_x, target_x, percentage);
|
||||||
|
set_x (x);
|
||||||
|
|
||||||
double update_scale = (double)GestureAnimationDirector.animation_value (1.0f, (float)scale, percentage);
|
double update_scale = (double)GestureAnimationDirector.animation_value (1.0f, (float)scale, percentage);
|
||||||
background.set_scale (update_scale, update_scale);
|
background.set_scale (update_scale, update_scale);
|
||||||
};
|
};
|
||||||
@ -406,6 +448,12 @@ namespace Gala {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
save_easing_state ();
|
||||||
|
set_easing_duration (MultitaskingView.ANIMATION_DURATION);
|
||||||
|
set_easing_mode (MultitaskingView.ANIMATION_MODE);
|
||||||
|
set_x (target_x);
|
||||||
|
restore_easing_state ();
|
||||||
|
|
||||||
background.save_easing_state ();
|
background.save_easing_state ();
|
||||||
background.set_easing_duration (MultitaskingView.ANIMATION_DURATION);
|
background.set_easing_duration (MultitaskingView.ANIMATION_DURATION);
|
||||||
background.set_easing_mode (MultitaskingView.ANIMATION_MODE);
|
background.set_easing_mode (MultitaskingView.ANIMATION_MODE);
|
||||||
@ -453,10 +501,16 @@ namespace Gala {
|
|||||||
|
|
||||||
opened = false;
|
opened = false;
|
||||||
|
|
||||||
|
var initial_x = gesture_animation_director.canceling ? x : multitasking_view_x ();
|
||||||
|
var target_x = multitasking_view_x () + current_x_overlap ();
|
||||||
|
|
||||||
double initial_scale_x, initial_scale_y;
|
double initial_scale_x, initial_scale_y;
|
||||||
background.get_scale (out initial_scale_x, out initial_scale_y);
|
background.get_scale (out initial_scale_x, out initial_scale_y);
|
||||||
|
|
||||||
GestureAnimationDirector.OnUpdate on_animation_update = (percentage) => {
|
GestureAnimationDirector.OnUpdate on_animation_update = (percentage) => {
|
||||||
|
var x = GestureAnimationDirector.animation_value (initial_x, target_x, percentage);
|
||||||
|
set_x (x);
|
||||||
|
|
||||||
double scale_x = (double) GestureAnimationDirector.animation_value ((float) initial_scale_x, 1.0f, percentage);
|
double scale_x = (double) GestureAnimationDirector.animation_value ((float) initial_scale_x, 1.0f, percentage);
|
||||||
double scale_y = (double) GestureAnimationDirector.animation_value ((float) initial_scale_y, 1.0f, percentage);
|
double scale_y = (double) GestureAnimationDirector.animation_value ((float) initial_scale_y, 1.0f, percentage);
|
||||||
background.set_scale (scale_x, scale_y);
|
background.set_scale (scale_x, scale_y);
|
||||||
@ -467,6 +521,12 @@ namespace Gala {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
save_easing_state ();
|
||||||
|
set_easing_duration (MultitaskingView.ANIMATION_DURATION);
|
||||||
|
set_easing_mode (MultitaskingView.ANIMATION_MODE);
|
||||||
|
set_x (target_x);
|
||||||
|
restore_easing_state ();
|
||||||
|
|
||||||
background.save_easing_state ();
|
background.save_easing_state ();
|
||||||
background.set_easing_duration (MultitaskingView.ANIMATION_DURATION);
|
background.set_easing_duration (MultitaskingView.ANIMATION_DURATION);
|
||||||
background.set_easing_mode (MultitaskingView.ANIMATION_MODE);
|
background.set_easing_mode (MultitaskingView.ANIMATION_MODE);
|
||||||
|
@ -102,7 +102,10 @@ namespace Gala {
|
|||||||
private bool animating_switch_workspace = false;
|
private bool animating_switch_workspace = false;
|
||||||
private GestureAnimationDirector gesture_animation_director;
|
private GestureAnimationDirector gesture_animation_director;
|
||||||
|
|
||||||
private const int WORKSPACE_GAP = 24;
|
/**
|
||||||
|
* Gap to show between workspaces while switching between them.
|
||||||
|
*/
|
||||||
|
public const int WORKSPACE_GAP = 24;
|
||||||
|
|
||||||
construct {
|
construct {
|
||||||
gesture_animation_director = new GestureAnimationDirector ();
|
gesture_animation_director = new GestureAnimationDirector ();
|
||||||
|
Loading…
Reference in New Issue
Block a user