Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions lib/Constants.vala
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ namespace Gala {
MULTITASKING_VIEW,
DOCK,
ZOOM,
CLOSE_WINDOW,
N_ACTIONS
}

Expand Down
13 changes: 9 additions & 4 deletions src/Widgets/MultitaskingView/MonitorClone.vala
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,26 @@
public class Gala.MonitorClone : ActorTarget {
public signal void window_selected (Meta.Window window);

public Meta.Display display { get; construct; }
public WindowManager wm { get; construct; }
public int monitor { get; construct; }

private WindowCloneContainer window_container;
private BackgroundManager background;

public MonitorClone (Meta.Display display, int monitor) {
Object (display: display, monitor: monitor);
public MonitorClone (WindowManager wm, int monitor) {
Object (wm: wm, monitor: monitor);
}

construct {
reactive = true;

unowned var display = wm.get_display ();

background = new BackgroundManager (display, monitor, false);

var scale = display.get_monitor_scale (monitor);

window_container = new WindowCloneContainer (display, scale);
window_container = new WindowCloneContainer (wm, scale);
window_container.window_selected.connect ((w) => { window_selected (w); });

display.window_entered_monitor.connect (window_entered);
Expand All @@ -58,6 +60,7 @@ public class Gala.MonitorClone : ActorTarget {
}

~MonitorClone () {
unowned var display = wm.get_display ();
display.window_entered_monitor.disconnect (window_entered);
display.window_left_monitor.disconnect (window_left);
}
Expand All @@ -66,6 +69,8 @@ public class Gala.MonitorClone : ActorTarget {
* Make sure the MonitorClone is at the location of the monitor on the stage
*/
public void update_allocation () {
unowned var display = wm.get_display ();

var monitor_geometry = display.get_monitor_geometry (monitor);

set_position (monitor_geometry.x, monitor_geometry.y);
Expand Down
4 changes: 2 additions & 2 deletions src/Widgets/MultitaskingView/MultitaskingView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public class Gala.MultitaskingView : ActorTarget, ActivatableComponent {
continue;
}

var monitor_clone = new MonitorClone (display, monitor);
var monitor_clone = new MonitorClone (wm, monitor);
monitor_clone.window_selected.connect (window_selected);
monitor_clone.visible = opened;

Expand Down Expand Up @@ -351,7 +351,7 @@ public class Gala.MultitaskingView : ActorTarget, ActivatableComponent {
unowned var manager = display.get_workspace_manager ();
var scale = display.get_monitor_scale (display.get_primary_monitor ());

var workspace = new WorkspaceClone (manager.get_workspace_by_index (num), scale);
var workspace = new WorkspaceClone (wm, manager.get_workspace_by_index (num), scale);
workspaces.insert_child_at_index (workspace, num);
icon_groups.add_group (workspace.icon_group);

Expand Down
114 changes: 78 additions & 36 deletions src/Widgets/MultitaskingView/WindowClone.vala
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ public class Gala.WindowClone : ActorTarget {
*/
public signal void request_reposition ();

public Meta.Display display { get; construct; }

public WindowManager wm { get; construct; }
public Meta.Window window { get; construct; }

/**
Expand Down Expand Up @@ -84,14 +83,17 @@ public class Gala.WindowClone : ActorTarget {
private ulong check_confirm_dialog_cb = 0;
private bool in_slot_animation = false;

private Clutter.Actor clone_container;
private Gala.CloseButton close_button;
private ActiveShape active_shape;
private Clutter.Actor window_icon;
private Tooltip window_title;

public WindowClone (Meta.Display display, Meta.Window window, float scale, bool overview_mode = false) {
private GestureController gesture_controller;

public WindowClone (WindowManager wm, Meta.Window window, float scale, bool overview_mode = false) {
Object (
display: display,
wm: wm,
window: window,
monitor_scale_factor: scale,
overview_mode: overview_mode
Expand All @@ -101,6 +103,9 @@ public class Gala.WindowClone : ActorTarget {
construct {
reactive = true;

gesture_controller = new GestureController (CLOSE_WINDOW, this, wm);
gesture_controller.enable_scroll (this, VERTICAL);

window.unmanaged.connect (unmanaged);
window.notify["fullscreen"].connect (check_shadow_requirements);
window.notify["maximized-horizontally"].connect (check_shadow_requirements);
Expand All @@ -126,13 +131,19 @@ public class Gala.WindowClone : ActorTarget {
add_action (drag_action);
}

window_title = new Tooltip ();
window_title.opacity = 0;

active_shape = new ActiveShape ();
active_shape.opacity = 0;

clone_container = new Clutter.Actor () {
pivot_point = { 0.5f, 0.5f }
};
add_target (new PropertyTarget (CLOSE_WINDOW, clone_container, "rotation-angle-x", typeof (double), 0.0, 90.0));

window_title = new Tooltip ();
window_title.opacity = 0;

add_child (active_shape);
add_child (clone_container);
add_child (window_title);

reallocate ();
Expand Down Expand Up @@ -183,13 +194,7 @@ public class Gala.WindowClone : ActorTarget {
}

clone = new Clutter.Clone (actor);
clone.set_content_scaling_filters (TRILINEAR, TRILINEAR);
add_child (clone);

set_child_below_sibling (active_shape, clone);
set_child_above_sibling (close_button, clone);
set_child_above_sibling (window_icon, clone);
set_child_above_sibling (window_title, clone);
clone_container.add_child (clone);

check_shadow_requirements ();
}
Expand Down Expand Up @@ -266,34 +271,74 @@ public class Gala.WindowClone : ActorTarget {
}

public override void start_progress (GestureAction action) {
update_hover_widgets (true);
if (action == MULTITASKING_VIEW) {
update_hover_widgets (true);
}
}

public override void update_progress (Gala.GestureAction action, double progress) {
if (action != CLOSE_WINDOW) {
return;
}

clone_container.rotation_angle_x = 90.0 * progress;

if (progress == 1.0 && get_current_commit (CLOSE_WINDOW) == 1.0) {
close_window (Meta.CURRENT_TIME);
}

update_hover_widgets ();
}

public override void commit_progress (Gala.GestureAction action, double to) {
if (action != CLOSE_WINDOW) {
return;
}

if (clone_container.rotation_angle_x == 90.0 && to == 1.0) {
close_window (Meta.CURRENT_TIME);
}
}

public override void end_progress (GestureAction action) {
update_hover_widgets (false);
switch (action) {
case MULTITASKING_VIEW:
update_hover_widgets (false);
break;
case CLOSE_WINDOW:
rotation_angle_x = 0;
break;
default:
break;
}
}

public override void allocate (Clutter.ActorBox box) {
base.allocate (box);

var input_rect = window.get_buffer_rect ();
var outer_rect = window.get_frame_rect ();
var clone_scale_factor = width / outer_rect.width;

// Compensate for invisible borders of the texture
float clone_x = (input_rect.x - outer_rect.x) * clone_scale_factor;
float clone_y = (input_rect.y - outer_rect.y) * clone_scale_factor;

var clone_container_alloc = InternalUtils.actor_box_from_rect (clone_x, clone_y, input_rect.width * clone_scale_factor, input_rect.height * clone_scale_factor);
clone_container.allocate (clone_container_alloc);

if (clone == null || (drag_action != null && drag_action.dragging)) {
return;
}

var input_rect = window.get_buffer_rect ();
var outer_rect = window.get_frame_rect ();
var clone_scale_factor = width / outer_rect.width;
unowned var display = wm.get_display ();

clone.set_scale (clone_scale_factor, clone_scale_factor);

float clone_width, clone_height;
clone.get_preferred_size (null, null, out clone_width, out clone_height);

// Compensate for invisible borders of the texture
float clone_x = (input_rect.x - outer_rect.x) * clone_scale_factor;
float clone_y = (input_rect.y - outer_rect.y) * clone_scale_factor;

var clone_alloc = InternalUtils.actor_box_from_rect (clone_x, clone_y, clone_width, clone_height);
var clone_alloc = InternalUtils.actor_box_from_rect (0, 0, clone_width, clone_height);
clone.allocate (clone_alloc);

Clutter.ActorBox shape_alloc = {
Expand Down Expand Up @@ -351,7 +396,7 @@ public class Gala.WindowClone : ActorTarget {

var duration = Utils.get_animation_duration (FADE_ANIMATION_DURATION);

var show = has_pointer && !in_slot_animation;
var show = has_pointer && !in_slot_animation && clone_container.rotation_angle_x == 0;

close_button.save_easing_state ();
close_button.set_easing_mode (Clutter.AnimationMode.LINEAR);
Expand Down Expand Up @@ -414,13 +459,8 @@ public class Gala.WindowClone : ActorTarget {
}

private void actor_clicked (uint32 button) {
switch (button) {
case Clutter.Button.PRIMARY:
selected ();
break;
case Clutter.Button.MIDDLE:
close_window (display.get_current_time ());
break;
if (button == Clutter.Button.PRIMARY) {
selected ();
}
}

Expand Down Expand Up @@ -479,7 +519,7 @@ public class Gala.WindowClone : ActorTarget {
close_button.opacity = 0;
window_title.opacity = 0;

display.set_cursor (Meta.Cursor.DND_IN_DRAG);
wm.get_display ().set_cursor (Meta.Cursor.DND_IN_DRAG);

return this;
}
Expand Down Expand Up @@ -532,7 +572,7 @@ public class Gala.WindowClone : ActorTarget {
}
}

display.set_cursor (hovered ? Meta.Cursor.DND_MOVE: Meta.Cursor.DND_IN_DRAG);
wm.get_display ().set_cursor (hovered ? Meta.Cursor.DND_MOVE: Meta.Cursor.DND_IN_DRAG);
}

/**
Expand All @@ -541,8 +581,10 @@ public class Gala.WindowClone : ActorTarget {
* otherwise we cancel the drag and animate back to our old place.
*/
private void drag_end (Clutter.Actor destination) {
unowned var display = wm.get_display ();

Meta.Workspace workspace = null;
var primary = window.get_display ().get_primary_monitor ();
var primary = display.get_primary_monitor ();

active_shape.show ();

Expand Down Expand Up @@ -631,7 +673,7 @@ public class Gala.WindowClone : ActorTarget {

request_reposition ();

display.set_cursor (Meta.Cursor.DEFAULT);
wm.get_display ().set_cursor (Meta.Cursor.DEFAULT);

if (duration > 0) {
ulong handler = 0;
Expand Down
15 changes: 11 additions & 4 deletions src/Widgets/MultitaskingView/WindowCloneContainer.vala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class Gala.WindowCloneContainer : ActorTarget {
public int padding_right { get; set; default = 12; }
public int padding_bottom { get; set; default = 12; }

public Meta.Display display { get; construct; }
public WindowManager wm { get; construct; }
public bool overview_mode { get; construct; }

private float _monitor_scale = 1.0f;
Expand All @@ -40,8 +40,8 @@ public class Gala.WindowCloneContainer : ActorTarget {
*/
private unowned WindowClone? current_window = null;

public WindowCloneContainer (Meta.Display display, float scale, bool overview_mode = false) {
Object (display: display, monitor_scale: scale, overview_mode: overview_mode);
public WindowCloneContainer (WindowManager wm, float scale, bool overview_mode = false) {
Object (wm: wm, monitor_scale: scale, overview_mode: overview_mode);
}

private void reallocate () {
Expand All @@ -64,9 +64,10 @@ public class Gala.WindowCloneContainer : ActorTarget {
}
windows.append (window);

unowned var display = wm.get_display ();
var windows_ordered = InternalUtils.sort_windows (display, windows);

var new_window = new WindowClone (display, window, monitor_scale, overview_mode);
var new_window = new WindowClone (wm, window, monitor_scale, overview_mode);

new_window.selected.connect ((clone) => window_selected (clone.window));
new_window.destroy.connect ((_new_window) => {
Expand Down Expand Up @@ -127,6 +128,8 @@ public class Gala.WindowCloneContainer : ActorTarget {
* during animations correct.
*/
private void restack_windows () {
unowned var display = wm.get_display ();

var children = get_children ();

var windows = new List<Meta.Window> ();
Expand Down Expand Up @@ -240,6 +243,8 @@ public class Gala.WindowCloneContainer : ActorTarget {
return;
}

unowned var display = wm.get_display ();

WindowClone? closest = null;

if (current_window == null) {
Expand Down Expand Up @@ -352,6 +357,8 @@ public class Gala.WindowCloneContainer : ActorTarget {
if (!opened) {
opened = true;

unowned var display = wm.get_display ();

if (current_window != null) {
current_window.active = false;
}
Expand Down
7 changes: 4 additions & 3 deletions src/Widgets/MultitaskingView/WorkspaceClone.vala
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ public class Gala.WorkspaceClone : ActorTarget {
*/
public signal void selected (bool close_view);

public WindowManager wm { get; construct; }
public Meta.Workspace workspace { get; construct; }
public IconGroup icon_group { get; private set; }
public WindowCloneContainer window_container { get; private set; }
Expand All @@ -160,8 +161,8 @@ public class Gala.WorkspaceClone : ActorTarget {

private uint hover_activate_timeout = 0;

public WorkspaceClone (Meta.Workspace workspace, float scale) {
Object (workspace: workspace, scale_factor: scale);
public WorkspaceClone (WindowManager wm, Meta.Workspace workspace, float scale) {
Object (wm: wm, workspace: workspace, scale_factor: scale);
}

construct {
Expand All @@ -178,7 +179,7 @@ public class Gala.WorkspaceClone : ActorTarget {
background = new FramedBackground (display);
background.add_action (background_click_action);

window_container = new WindowCloneContainer (display, scale_factor) {
window_container = new WindowCloneContainer (wm, scale_factor) {
width = monitor_geometry.width,
height = monitor_geometry.height,
};
Expand Down
2 changes: 1 addition & 1 deletion src/Widgets/WindowOverview.vala
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public class Gala.WindowOverview : ActorTarget, ActivatableComponent {
var geometry = display.get_monitor_geometry (i);
var scale = display.get_monitor_scale (i);

window_clone_container = new WindowCloneContainer (display, scale, true) {
window_clone_container = new WindowCloneContainer (wm, scale, true) {
padding_top = TOP_GAP,
padding_left = BORDER,
padding_right = BORDER,
Expand Down