Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lib/Gestures/ActorTarget.vala
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ public class Gala.ActorTarget : Clutter.Actor, GestureTarget {

private double[] current_progress;
private double[] current_commit;
private bool[] relayout_actions;
private Gee.List<GestureTarget> targets;

private int ongoing_animations = 0;

construct {
current_progress = new double[GestureAction.N_ACTIONS];
current_commit = new double[GestureAction.N_ACTIONS];
relayout_actions = new bool[GestureAction.N_ACTIONS];
targets = new Gee.ArrayList<GestureTarget> ();

#if HAS_MUTTER46
Expand All @@ -38,6 +40,10 @@ public class Gala.ActorTarget : Clutter.Actor, GestureTarget {
}
}

public void set_relayout_action (GestureAction action, bool relayout) {
relayout_actions[action] = relayout;
}

public void add_target (GestureTarget target) {
targets.add (target);
sync_target (target);
Expand Down Expand Up @@ -88,6 +94,11 @@ public class Gala.ActorTarget : Clutter.Actor, GestureTarget {
break;
case UPDATE:
update_progress (action, progress);

if (relayout_actions[action]) {
queue_relayout ();
}

break;
case COMMIT:
commit_progress (action, progress);
Expand Down
34 changes: 5 additions & 29 deletions src/Widgets/MultitaskingView/WindowClone.vala
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ public class Gala.WindowClone : ActorTarget, RootTarget {
add_child (window_icon);

set_child_below_sibling (window_icon, window_title);

update_targets ();
}

/**
Expand Down Expand Up @@ -227,39 +229,13 @@ public class Gala.WindowClone : ActorTarget, RootTarget {
&& window.get_workspace () != window.get_display ().get_workspace_manager ().get_active_workspace ()) || window.minimized;
}

/**
* Animate the window to the given slot
*/
public void take_slot (Mtk.Rectangle rect, bool animate) {
slot = rect;

if (animate) {
save_easing_state ();
set_easing_duration (Utils.get_animation_duration (MultitaskingView.ANIMATION_DURATION));
set_easing_mode (EASE_OUT_QUAD);
}

update_targets ();

if (animate) {
restore_easing_state ();
}
}

private void update_targets () {
remove_all_targets ();

if (slot == null) {
if (window_icon == null) {
return;
}

var window_rect = window.get_frame_rect ();
var monitor_geometry = window.display.get_monitor_geometry (window.get_monitor ());
remove_all_targets ();

add_target (new PropertyTarget (MULTITASKING_VIEW, this, "x", typeof (float), (float) (window_rect.x - monitor_geometry.x), (float) slot.x));
add_target (new PropertyTarget (MULTITASKING_VIEW, this, "y", typeof (float), (float) (window_rect.y - monitor_geometry.y), (float) slot.y));
add_target (new PropertyTarget (MULTITASKING_VIEW, this, "width", typeof (float), (float) window_rect.width, (float) slot.width));
add_target (new PropertyTarget (MULTITASKING_VIEW, this, "height", typeof (float), (float) window_rect.height, (float) slot.height));
add_target (new PropertyTarget (MULTITASKING_VIEW, this, "shadow-opacity", typeof (uint8), (uint8) 0u, (uint8) 255u));
if (should_fade ()) {
add_target (new PropertyTarget (MULTITASKING_VIEW, this, "opacity", typeof (uint8), (uint8) 0u, (uint8) 255u));
Expand All @@ -275,7 +251,7 @@ public class Gala.WindowClone : ActorTarget, RootTarget {
}

public override void update_progress (Gala.GestureAction action, double progress) {
if (action != CUSTOM || slot == null || !Meta.Prefs.get_gnome_animations ()) {
if (action != CUSTOM || !Meta.Prefs.get_gnome_animations ()) {
return;
}

Expand Down
65 changes: 53 additions & 12 deletions src/Widgets/MultitaskingView/WindowCloneContainer.vala
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ public class Gala.WindowCloneContainer : ActorTarget {
public signal void window_selected (Meta.Window window);
public signal void requested_close ();

public int padding_top { get; set; default = 12; }
public int padding_left { get; set; default = 12; }
public int padding_right { get; set; default = 12; }
public int padding_bottom { get; set; default = 12; }
public Mtk.Rectangle area { get; set; }

public WindowManager wm { get; construct; }
public WindowListModel windows { get; construct; }
Expand All @@ -23,6 +20,9 @@ public class Gala.WindowCloneContainer : ActorTarget {

private bool opened = false;

private HashTable<Clutter.Actor, Clutter.ActorBox?> target_allocations = new HashTable<Clutter.Actor, Clutter.ActorBox?> (null, null);
private HashTable<Clutter.Actor, Clutter.ActorBox?> origin_allocations = new HashTable<Clutter.Actor, Clutter.ActorBox?> (null, null);

/**
* The window that is currently selected via keyboard shortcuts.
* It is not necessarily the same as the active window.
Expand All @@ -36,6 +36,9 @@ public class Gala.WindowCloneContainer : ActorTarget {
construct {
on_items_changed (0, 0, windows.get_n_items ());
windows.items_changed.connect (on_items_changed);

set_relayout_action (MULTITASKING_VIEW, true);
set_relayout_action (SWITCH_WORKSPACE, true);
}

private void on_items_changed (uint position, uint removed, uint added) {
Expand Down Expand Up @@ -140,15 +143,53 @@ public class Gala.WindowCloneContainer : ActorTarget {
return (int) (seq_b - seq_a);
});

Mtk.Rectangle area = {
padding_left,
padding_top,
(int) width - padding_left - padding_right,
(int) height - padding_top - padding_bottom
};

target_allocations.remove_all ();
origin_allocations.remove_all ();
foreach (var tilable in calculate_grid_placement (area, windows)) {
tilable.clone.take_slot (tilable.rect, !view_toggle);
var geom = wm.get_display ().get_monitor_geometry (tilable.clone.window.get_monitor ());
var rect = tilable.clone.window.get_frame_rect ();

origin_allocations[tilable.clone] = InternalUtils.actor_box_from_rect (rect.x - geom.x, rect.y - geom.y, rect.width, rect.height);
target_allocations[tilable.clone] = InternalUtils.actor_box_from_rect (tilable.rect.x, tilable.rect.y, tilable.rect.width, tilable.rect.height);
}
}

protected override void allocate (Clutter.ActorBox box) {
set_allocation (box);

var static_windows = StaticWindowContainer.get_instance (wm.get_display ());
for (var child = get_first_child (); child != null; child = child.get_next_sibling ()) {
if (child is WindowClone && static_windows.is_static (child.window)) {
float x, y;
get_transformed_position (out x, out y);

var allocation = origin_allocations[child];
allocation.set_origin (allocation.x1 - x, allocation.y1 - y);
child.allocate (allocation);
continue;
}

var target_allocation = target_allocations[child];
var origin_allocation = origin_allocations[child];

if (target_allocation == null || origin_allocation == null) {
child.allocate ({0, 0, 0, 0});
continue;
}

if (!animating) {
child.save_easing_state ();
child.set_easing_duration (Utils.get_animation_duration (MultitaskingView.ANIMATION_DURATION));
child.set_easing_mode (EASE_OUT_QUAD);
}

child.allocate (
origin_allocation.interpolate (target_allocation, get_current_progress (MULTITASKING_VIEW))
);

if (!animating) {
child.restore_easing_state ();
}
}
}

Expand Down
27 changes: 21 additions & 6 deletions src/Widgets/MultitaskingView/WorkspaceClone.vala
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ public class Gala.WorkspaceClone : ActorTarget {
}
});

clip_to_allocation = true;

add_child (background);
add_child (window_container);

Expand Down Expand Up @@ -200,18 +202,31 @@ public class Gala.WorkspaceClone : ActorTarget {

var scale = (float)(monitor.height - Utils.scale_to_int (TOP_OFFSET + BOTTOM_OFFSET, monitor_scale)) / monitor.height;
var pivot_y = Utils.scale_to_int (TOP_OFFSET, monitor_scale) / (monitor.height - monitor.height * scale);
background.set_pivot_point (0.5f, pivot_y);
background.set_pivot_point (0f, pivot_y);

var initial_width = monitor.width;
var target_width = monitor.width * scale + WorkspaceRow.WORKSPACE_GAP * 2;
var target_width = monitor.width * scale;

var target_height = monitor.height * scale;

add_target (new PropertyTarget (MULTITASKING_VIEW, this, "width", typeof (float), (float) initial_width, (float) target_width));
add_target (new PropertyTarget (MULTITASKING_VIEW, window_container, "width", typeof (float), (float) target_height, (float) target_width));
add_target (new PropertyTarget (MULTITASKING_VIEW, this, "width", typeof (float), (float) initial_width + WorkspaceRow.WORKSPACE_GAP, (float) target_width + WorkspaceRow.WORKSPACE_GAP));
add_target (new PropertyTarget (MULTITASKING_VIEW, background, "scale-x", typeof (double), 1d, (double) scale));
add_target (new PropertyTarget (MULTITASKING_VIEW, background, "scale-y", typeof (double), 1d, (double) scale));

window_container.padding_top = Utils.scale_to_int (TOP_OFFSET, monitor_scale);
window_container.padding_left = window_container.padding_right = (int) (monitor.width - monitor.width * scale) / 2;
window_container.padding_bottom = Utils.scale_to_int (BOTTOM_OFFSET, monitor_scale);
background.x = WorkspaceRow.WORKSPACE_GAP / 2;
window_container.x = WorkspaceRow.WORKSPACE_GAP / 2;

window_container.area = {
12,
Utils.scale_to_int (TOP_OFFSET, monitor_scale),
(int) (target_width - 24),
(int) target_height
};
}

public override void update_progress (GestureAction action, double progress) {
// background.set_pivot_point (0.5f, 0f);
}

private void activate (bool close_view) {
Expand Down
3 changes: 2 additions & 1 deletion src/Widgets/MultitaskingView/WorkspaceRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ public class Gala.WorkspaceRow : ActorTarget {
set_allocation (allocation);

double progress = get_current_progress (SWITCH_WORKSPACE);
var monitor_width = display.get_monitor_geometry (display.get_primary_monitor ()).width;
int index = 0;
for (var child = get_first_child (); child != null; child = child.get_next_sibling ()) {
float preferred_width;
child.get_preferred_width (-1, null, out preferred_width);

var child_x = (float) Math.round ((progress + index) * (preferred_width + WORKSPACE_GAP));
var child_x = (float) Math.round ((progress + index) * preferred_width + (monitor_width - preferred_width) / 2);

child.allocate_preferred_size (child_x, 0);

Expand Down
5 changes: 1 addition & 4 deletions src/Widgets/WindowOverview.vala
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,7 @@ public class Gala.WindowOverview : ActorTarget, RootTarget, ActivatableComponent
model.items_changed.connect (on_items_changed);

window_clone_container = new WindowCloneContainer (wm, model, scale, true) {
padding_top = TOP_GAP,
padding_left = BORDER,
padding_right = BORDER,
padding_bottom = BOTTOM_GAP,
area = { BORDER, TOP_GAP, geometry.width - 2 * BORDER, geometry.height - TOP_GAP - BOTTOM_GAP },
width = geometry.width,
height = geometry.height,
x = geometry.x,
Expand Down
7 changes: 3 additions & 4 deletions src/WindowListModel.vala
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public class Gala.WindowListModel : Object, ListModel {
StaticWindowContainer.get_instance (display).window_changed.connect (check_window);
display.window_entered_monitor.connect ((monitor, win) => check_window (win));

// display.get_workspace_manager ().active_workspace_changed.connect (() => Idle.add_once (check_all));

notify.connect (check_all);

check_all ();
Expand Down Expand Up @@ -106,10 +108,7 @@ public class Gala.WindowListModel : Object, ListModel {
return false;
}

if (workspace_filter != null &&
(StaticWindowContainer.get_instance (display).is_static (window) ||
!window.located_on_workspace (workspace_filter))
) {
if (workspace_filter != null && !window.located_on_workspace (workspace_filter)) {
return false;
}

Expand Down