Skip to content

Commit

Permalink
Introduce a shell group
Browse files Browse the repository at this point in the history
  • Loading branch information
leolost2605 committed Dec 24, 2024
1 parent 7b9f195 commit 0342c6d
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 156 deletions.
22 changes: 19 additions & 3 deletions src/ShellClients/PanelClone.vala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
public class Gala.PanelClone : Object {
private const int ANIMATION_DURATION = 250;

public WindowManager wm { get; construct; }
public WindowManagerGala wm { get; construct; }
public unowned PanelWindow panel { get; construct; }

public Pantheon.Desktop.HideMode hide_mode {
Expand Down Expand Up @@ -37,16 +37,20 @@ public class Gala.PanelClone : Object {
private GestureTracker default_gesture_tracker;
private GestureTracker last_gesture_tracker;

private bool force_hide = false;

private HideTracker? hide_tracker;

public PanelClone (WindowManager wm, PanelWindow panel) {
public PanelClone (WindowManagerGala wm, PanelWindow panel) {
Object (wm: wm, panel: panel);
}

construct {
last_gesture_tracker = default_gesture_tracker = new GestureTracker (ANIMATION_DURATION, ANIMATION_DURATION);

actor = (Meta.WindowActor) panel.window.get_compositor_private ();
actor.get_parent ().remove_child (actor);
wm.shell_group.add_child (actor);

notify["panel-hidden"].connect (() => {
// When hidden changes schedule an update to make sure it's actually
Expand Down Expand Up @@ -98,7 +102,7 @@ public class Gala.PanelClone : Object {
}

private void show (GestureTracker gesture_tracker, bool with_gesture) {
if (!panel_hidden || last_gesture_tracker.recognizing) {
if (!panel_hidden || force_hide || last_gesture_tracker.recognizing) {
return;
}

Expand All @@ -112,4 +116,16 @@ public class Gala.PanelClone : Object {

gesture_tracker.add_success_callback (with_gesture, () => panel_hidden = false);
}

public void set_force_hide (bool force_hide, GestureTracker gesture_tracker, bool with_gesture) {
this.force_hide = force_hide;

if (force_hide) {
hide (gesture_tracker, with_gesture);
} else if (hide_mode == NEVER) {
show (gesture_tracker, with_gesture);
} else {
hide_tracker.update_overlap (gesture_tracker, with_gesture);
}
}
}
8 changes: 6 additions & 2 deletions src/ShellClients/PanelWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
public class Gala.PanelWindow : Object {
private static HashTable<Meta.Window, Meta.Strut?> window_struts = new HashTable<Meta.Window, Meta.Strut?> (null, null);

public WindowManager wm { get; construct; }
public WindowManagerGala wm { get; construct; }
public Meta.Window window { get; construct; }
public Pantheon.Desktop.Anchor anchor { get; construct set; }

Expand All @@ -19,7 +19,7 @@ public class Gala.PanelWindow : Object {
private int width = -1;
private int height = -1;

public PanelWindow (WindowManager wm, Meta.Window window, Pantheon.Desktop.Anchor anchor) {
public PanelWindow (WindowManagerGala wm, Meta.Window window, Pantheon.Desktop.Anchor anchor) {
Object (wm: wm, window: window, anchor: anchor);
}

Expand Down Expand Up @@ -143,4 +143,8 @@ public class Gala.PanelWindow : Object {
return TOP;
}
}

public void set_force_hide (bool force_hide, GestureTracker gesture_tracker, bool with_gesture) {
clone.set_force_hide (force_hide, gesture_tracker, with_gesture);
}
}
12 changes: 9 additions & 3 deletions src/ShellClients/ShellClientsManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
public class Gala.ShellClientsManager : Object {
private static ShellClientsManager instance;

public static void init (WindowManager wm) {
public static void init (WindowManagerGala wm) {
if (instance != null) {
return;
}
Expand All @@ -20,15 +20,15 @@ public class Gala.ShellClientsManager : Object {
return instance;
}

public WindowManager wm { get; construct; }
public WindowManagerGala wm { get; construct; }

private NotificationsClient notifications_client;
private ManagedClient[] protocol_clients = {};

private GLib.HashTable<Meta.Window, PanelWindow> panel_windows = new GLib.HashTable<Meta.Window, PanelWindow> (null, null);
private GLib.HashTable<Meta.Window, WindowPositioner> positioned_windows = new GLib.HashTable<Meta.Window, WindowPositioner> (null, null);

private ShellClientsManager (WindowManager wm) {
private ShellClientsManager (WindowManagerGala wm) {
Object (wm: wm);
}

Expand Down Expand Up @@ -207,6 +207,12 @@ public class Gala.ShellClientsManager : Object {
return positioned;
}

public void set_force_hide_panels (bool force_hide, GestureTracker gesture_tracker, bool with_gesture) {
foreach (var panel in panel_windows.get_values ()) {
panel.set_force_hide (force_hide, gesture_tracker, with_gesture);
}
}

//X11 only
private void parse_mutter_hints (Meta.Window window) requires (!Meta.Util.is_wayland_compositor ()) {
if (window.mutter_hints == null) {
Expand Down
111 changes: 2 additions & 109 deletions src/Widgets/MultitaskingView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ namespace Gala {

private IconGroupContainer icon_groups;
private Clutter.Actor workspaces;
private Clutter.Actor dock_clones;
private Clutter.Actor primary_monitor_container;
private Clutter.BrightnessContrastEffect brightness_effect;

Expand Down Expand Up @@ -83,8 +82,6 @@ namespace Gala {

icon_groups = new IconGroupContainer (display.get_monitor_scale (display.get_primary_monitor ()));

dock_clones = new Clutter.Actor ();

brightness_effect = new Clutter.BrightnessContrastEffect ();
update_brightness_effect ();

Expand All @@ -101,7 +98,6 @@ namespace Gala {
primary_monitor_container.add_child (icon_groups);
primary_monitor_container.add_child (workspaces);
add_child (primary_monitor_container);
add_child (dock_clones);

unowned var manager = display.get_workspace_manager ();
manager.workspace_added.connect (add_workspace);
Expand Down Expand Up @@ -675,9 +671,9 @@ namespace Gala {
}

if (opening) {
show_docks (with_gesture, is_cancel_animation);
ShellClientsManager.get_instance ().set_force_hide_panels (true, multitasking_gesture_tracker, with_gesture);
} else {
hide_docks (with_gesture, is_cancel_animation);
ShellClientsManager.get_instance ().set_force_hide_panels (false, multitasking_gesture_tracker, with_gesture);
}

GestureTracker.OnEnd on_animation_end = (percentage, completions) => {
Expand All @@ -694,8 +690,6 @@ namespace Gala {
wm.window_group.show ();
wm.top_window_group.show ();

dock_clones.destroy_all_children ();

wm.pop_modal (modal_proxy);
}

Expand All @@ -716,107 +710,6 @@ namespace Gala {
}
}

private void show_docks (bool with_gesture, bool is_cancel_animation) {
unowned GLib.List<Meta.WindowActor> window_actors = display.get_window_actors ();
foreach (unowned Meta.WindowActor actor in window_actors) {
const int MAX_OFFSET = 200;

if (actor.is_destroyed () || !actor.visible) {
continue;
}

unowned Meta.Window window = actor.get_meta_window ();
var monitor = window.get_monitor ();

if (window.window_type != Meta.WindowType.DOCK) {
continue;
}

if (NotificationStack.is_notification (window)) {
continue;
}

if (display.get_monitor_in_fullscreen (monitor)) {
continue;
}

var monitor_geom = display.get_monitor_geometry (monitor);

var window_geom = window.get_frame_rect ();
var top = monitor_geom.y + MAX_OFFSET > window_geom.y;
var bottom = monitor_geom.y + monitor_geom.height - MAX_OFFSET < window_geom.y;

if (!top && !bottom) {
continue;
}

var initial_x = actor.x;
var initial_y = actor.y;
var target_y = (top)
? actor.y - actor.height
: actor.y + actor.height;

var clone = new SafeWindowClone (window, true);
dock_clones.add_child (clone);

clone.set_position (initial_x, initial_y);

GestureTracker.OnUpdate on_animation_update = (percentage) => {
var y = GestureTracker.animation_value (initial_y, target_y, percentage);
clone.y = y;
};

GestureTracker.OnEnd on_animation_end = (percentage, completions) => {
if (completions == 0) {
return;
}

clone.save_easing_state ();
clone.set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD);
clone.set_easing_duration ((!is_cancel_animation && AnimationsSettings.get_enable_animations ()) ? ANIMATION_DURATION : 0);
clone.y = target_y;
clone.restore_easing_state ();
};

if (!with_gesture || !AnimationsSettings.get_enable_animations ()) {
on_animation_end (1, 1, 0);
} else {
multitasking_gesture_tracker.connect_handlers (null, (owned) on_animation_update, (owned) on_animation_end);
}
}
}

private void hide_docks (bool with_gesture, bool is_cancel_animation) {
foreach (unowned var child in dock_clones.get_children ()) {
var dock = (Clutter.Clone) child;
var initial_y = dock.y;
var target_y = dock.source.y;

GestureTracker.OnUpdate on_animation_update = (percentage) => {
var y = GestureTracker.animation_value (initial_y, target_y, percentage);
dock.y = y;
};

GestureTracker.OnEnd on_animation_end = (percentage, completions) => {
if (completions == 0) {
return;
}

dock.save_easing_state ();
dock.set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD);
dock.set_easing_duration (AnimationsSettings.get_animation_duration (ANIMATION_DURATION));
dock.y = target_y;
dock.restore_easing_state ();
};

if (!with_gesture || !AnimationsSettings.get_enable_animations ()) {
on_animation_end (1, 1, 0);
} else {
multitasking_gesture_tracker.connect_handlers (null, (owned) on_animation_update, (owned) on_animation_end);
}
}
}

private bool keybinding_filter (Meta.KeyBinding binding) {
var action = Meta.Prefs.get_keybinding_action (binding.get_name ());

Expand Down
Loading

0 comments on commit 0342c6d

Please sign in to comment.