Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WindowClone: Make close button and title respect animations key #1551

Merged
merged 5 commits into from Feb 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions data/gala.appdata.xml.in
Expand Up @@ -29,6 +29,7 @@
<issue url="https://github.com/elementary/gala/issues/1517">The second time I click on a workspace, all applications in that workspace close</issue>
<issue url="https://github.com/elementary/gala/issues/1482">Duplicate "Plus" workspaces</issue>
<issue url="https://github.com/elementary/gala/issues/1203">Artifact around non native apps in the overview mode</issue>
<issue url="https://github.com/elementary/gala/issues/507">Close buttons in Multitasking View don't respect animations key</issue>
<issue url="https://github.com/elementary/gala/issues/1505">"Not responding" dialog and not responding app close after inactivity</issue>
<issue url="https://github.com/elementary/gala/issues/1185">Unmaximize effect not working with mutter >= 3.38</issue>
<issue url="https://github.com/elementary/gala/issues/1536">Several (un-)maximize animations are not played</issue>
Expand Down
7 changes: 4 additions & 3 deletions src/Widgets/MonitorClone.vala
Expand Up @@ -26,15 +26,16 @@ namespace Gala {
public class MonitorClone : Clutter.Actor {
public signal void window_selected (Meta.Window window);

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

private WindowCloneContainer window_container;
private BackgroundManager background;

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

construct {
Expand All @@ -43,7 +44,7 @@ namespace Gala {
background = new BackgroundManager (display, monitor, false);
background.set_easing_duration (MultitaskingView.ANIMATION_DURATION);

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

Expand Down
4 changes: 2 additions & 2 deletions src/Widgets/MultitaskingView.vala
Expand Up @@ -146,7 +146,7 @@ namespace Gala {
if (monitor == primary)
continue;

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

Expand Down Expand Up @@ -403,7 +403,7 @@ namespace Gala {

private void add_workspace (int num) {
unowned Meta.WorkspaceManager manager = display.get_workspace_manager ();
var workspace = new WorkspaceClone (manager.get_workspace_by_index (num), multitasking_gesture_tracker);
var workspace = new WorkspaceClone (wm, manager.get_workspace_by_index (num), multitasking_gesture_tracker);
workspace.window_selected.connect (window_selected);
workspace.selected.connect (activate_workspace);

Expand Down
36 changes: 24 additions & 12 deletions src/Widgets/WindowClone.vala
Expand Up @@ -27,6 +27,8 @@ public class Gala.WindowClone : Clutter.Actor {
*/
public signal void request_reposition ();

public WindowManager wm { get; construct; }

public Meta.Window window { get; construct; }

/**
Expand Down Expand Up @@ -86,8 +88,8 @@ public class Gala.WindowClone : Clutter.Actor {
private Clutter.Actor window_icon;
private Tooltip window_title;

public WindowClone (Meta.Window window, GestureTracker? gesture_tracker, bool overview_mode = false) {
Object (window: window, gesture_tracker: gesture_tracker, overview_mode: overview_mode);
public WindowClone (WindowManager wm, Meta.Window window, GestureTracker? gesture_tracker, bool overview_mode = false) {
Object (wm: wm, window: window, gesture_tracker: gesture_tracker, overview_mode: overview_mode);
}

construct {
Expand Down Expand Up @@ -119,7 +121,6 @@ public class Gala.WindowClone : Clutter.Actor {

close_button = Utils.create_close_button ();
close_button.opacity = 0;
close_button.set_easing_duration (FADE_ANIMATION_DURATION);
close_button.button_press_event.connect (() => {
close_window ();
return Gdk.EVENT_STOP;
Expand All @@ -137,7 +138,6 @@ public class Gala.WindowClone : Clutter.Actor {

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

active_shape = new ActiveShape ();
active_shape.opacity = 0;
Expand Down Expand Up @@ -464,14 +464,34 @@ public class Gala.WindowClone : Clutter.Actor {
return Gdk.EVENT_PROPAGATE;
}

close_button.save_easing_state ();
close_button.set_easing_mode (Clutter.AnimationMode.LINEAR);
close_button.set_easing_duration (wm.enable_animations ? FADE_ANIMATION_DURATION : 0);
close_button.opacity = in_slot_animation ? 0 : 255;
close_button.restore_easing_state ();

window_title.save_easing_state ();
window_title.set_easing_mode (Clutter.AnimationMode.LINEAR);
window_title.set_easing_duration (wm.enable_animations ? FADE_ANIMATION_DURATION : 0);
window_title.opacity = in_slot_animation ? 0 : 255;
window_title.restore_easing_state ();

return Gdk.EVENT_PROPAGATE;
}

public override bool leave_event (Clutter.CrossingEvent event) {
close_button.save_easing_state ();
close_button.set_easing_mode (Clutter.AnimationMode.LINEAR);
close_button.set_easing_duration (wm.enable_animations ? FADE_ANIMATION_DURATION : 0);
close_button.opacity = 0;
close_button.restore_easing_state ();

window_title.save_easing_state ();
window_title.set_easing_mode (Clutter.AnimationMode.LINEAR);
window_title.set_easing_duration (wm.enable_animations ? FADE_ANIMATION_DURATION : 0);
window_title.opacity = 0;
window_title.restore_easing_state ();

return Gdk.EVENT_PROPAGATE;
}

Expand All @@ -482,11 +502,6 @@ public class Gala.WindowClone : Clutter.Actor {
public void place_widgets (int dest_width, int dest_height) {
var scale_factor = InternalUtils.get_ui_scaling_factor ();

close_button.save_easing_state ();
window_title.save_easing_state ();
close_button.set_easing_duration (0);
window_title.set_easing_duration (0);

var close_button_size = CLOSE_WINDOW_ICON_SIZE * scale_factor;
close_button.set_size (close_button_size, close_button_size);

Expand All @@ -502,9 +517,6 @@ public class Gala.WindowClone : Clutter.Actor {
window_title.set_text (window.get_title () ?? "", false);
window_title.set_max_width (dest_width - (TITLE_MAX_WIDTH_MARGIN * scale_factor));
set_window_title_position (dest_width, dest_height);

close_button.restore_easing_state ();
window_title.restore_easing_state ();
}

private void toggle_shadow (bool show) {
Expand Down
7 changes: 4 additions & 3 deletions src/Widgets/WindowCloneContainer.vala
Expand Up @@ -27,6 +27,7 @@ namespace Gala {
public int padding_right { get; set; default = 12; }
public int padding_bottom { get; set; default = 12; }

public WindowManager wm { get; construct; }
public GestureTracker? gesture_tracker { get; construct; }
public bool overview_mode { get; construct; }

Expand All @@ -38,8 +39,8 @@ namespace Gala {
*/
private WindowClone? current_window;

public WindowCloneContainer (GestureTracker? gesture_tracker, bool overview_mode = false) {
Object (gesture_tracker: gesture_tracker, overview_mode: overview_mode);
public WindowCloneContainer (WindowManager wm, GestureTracker? gesture_tracker, bool overview_mode = false) {
Object (wm: wm, gesture_tracker: gesture_tracker, overview_mode: overview_mode);
}

construct {
Expand All @@ -66,7 +67,7 @@ namespace Gala {

var windows_ordered = display.sort_windows_by_stacking (windows);

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

new_window.selected.connect (window_selected_cb);
new_window.destroy.connect (window_destroyed);
Expand Down
2 changes: 1 addition & 1 deletion src/Widgets/WindowOverview.vala
Expand Up @@ -150,7 +150,7 @@ public class Gala.WindowOverview : Clutter.Actor, ActivatableComponent {
for (var i = 0; i < display.get_n_monitors (); i++) {
var geometry = display.get_monitor_geometry (i);

var container = new WindowCloneContainer (null, true) {
var container = new WindowCloneContainer (wm, null, true) {
padding_top = TOP_GAP,
padding_left = BORDER,
padding_right = BORDER,
Expand Down
7 changes: 4 additions & 3 deletions src/Widgets/WorkspaceClone.vala
Expand Up @@ -134,6 +134,7 @@ namespace Gala {
*/
public signal void selected (bool close_view);

public WindowManager wm { get; construct; }
public Meta.Workspace workspace { get; construct; }
public GestureTracker gesture_tracker { get; construct; }
public IconGroup icon_group { get; private set; }
Expand All @@ -159,8 +160,8 @@ namespace Gala {

private uint hover_activate_timeout = 0;

public WorkspaceClone (Meta.Workspace workspace, GestureTracker gesture_tracker) {
Object (workspace: workspace, gesture_tracker: gesture_tracker);
public WorkspaceClone (WindowManager wm, Meta.Workspace workspace, GestureTracker gesture_tracker) {
Object (wm: wm, workspace: workspace, gesture_tracker: gesture_tracker);
}

construct {
Expand All @@ -176,7 +177,7 @@ namespace Gala {
return false;
});

window_container = new WindowCloneContainer (gesture_tracker);
window_container = new WindowCloneContainer (wm, gesture_tracker);
window_container.window_selected.connect ((w) => { window_selected (w); });
window_container.set_size (monitor_geometry.width, monitor_geometry.height);
display.restacked.connect (window_container.restack_windows);
Expand Down