Skip to content

Commit 20bdf97

Browse files
committed
Introduce a shell group
1 parent e1c8dc9 commit 20bdf97

File tree

5 files changed

+93
-161
lines changed

5 files changed

+93
-161
lines changed

src/ShellClients/PanelClone.vala

+35-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
public class Gala.PanelClone : Object {
99
private const int ANIMATION_DURATION = 250;
1010

11-
public WindowManager wm { get; construct; }
11+
public WindowManagerGala wm { get; construct; }
1212
public unowned PanelWindow panel { get; construct; }
1313

1414
public Pantheon.Desktop.HideMode hide_mode {
@@ -37,16 +37,20 @@ public class Gala.PanelClone : Object {
3737
private GestureTracker default_gesture_tracker;
3838
private GestureTracker last_gesture_tracker;
3939

40+
private bool force_hide = false;
41+
4042
private HideTracker? hide_tracker;
4143

42-
public PanelClone (WindowManager wm, PanelWindow panel) {
44+
public PanelClone (WindowManagerGala wm, PanelWindow panel) {
4345
Object (wm: wm, panel: panel);
4446
}
4547

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

4951
actor = (Meta.WindowActor) panel.window.get_compositor_private ();
52+
actor.get_parent ().remove_child (actor);
53+
wm.shell_group.add_child (actor);
5054

5155
notify["panel-hidden"].connect (() => {
5256
// When hidden changes schedule an update to make sure it's actually
@@ -92,13 +96,16 @@ public class Gala.PanelClone : Object {
9296
return;
9397
}
9498

95-
new GesturePropertyTransition (actor, gesture_tracker, "translation-y", null, calculate_y (true)).start (with_gesture);
99+
update_transients_visible (false);
100+
101+
new GesturePropertyTransition (actor, gesture_tracker, "translation-y", null, calculate_y (true))
102+
.start (with_gesture, () => update_transients_visible (!panel_hidden));
96103

97104
gesture_tracker.add_success_callback (with_gesture, () => panel_hidden = true);
98105
}
99106

100107
private void show (GestureTracker gesture_tracker, bool with_gesture) {
101-
if (!panel_hidden || last_gesture_tracker.recognizing) {
108+
if (!panel_hidden || force_hide || last_gesture_tracker.recognizing) {
102109
return;
103110
}
104111

@@ -108,8 +115,31 @@ public class Gala.PanelClone : Object {
108115
Utils.x11_unset_window_pass_through (panel.window);
109116
}
110117

111-
new GesturePropertyTransition (actor, gesture_tracker, "translation-y", null, calculate_y (false)).start (with_gesture);
118+
new GesturePropertyTransition (actor, gesture_tracker, "translation-y", null, calculate_y (false))
119+
.start (with_gesture, () => update_transients_visible (!panel_hidden));
112120

113121
gesture_tracker.add_success_callback (with_gesture, () => panel_hidden = false);
114122
}
123+
124+
private void update_transients_visible (bool visible) {
125+
panel.window.foreach_transient ((transient) => {
126+
var actor = (Meta.WindowActor) transient.get_compositor_private ();
127+
128+
actor.visible = visible;
129+
130+
return true;
131+
});
132+
}
133+
134+
public void set_force_hide (bool force_hide, GestureTracker gesture_tracker, bool with_gesture) {
135+
this.force_hide = force_hide;
136+
137+
if (force_hide) {
138+
hide (gesture_tracker, with_gesture);
139+
} else if (hide_mode == NEVER) {
140+
show (gesture_tracker, with_gesture);
141+
} else {
142+
hide_tracker.update_overlap (gesture_tracker, with_gesture);
143+
}
144+
}
115145
}

src/ShellClients/PanelWindow.vala

+6-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
public class Gala.PanelWindow : Object {
99
private static HashTable<Meta.Window, Meta.Strut?> window_struts = new HashTable<Meta.Window, Meta.Strut?> (null, null);
1010

11-
public WindowManager wm { get; construct; }
11+
public WindowManagerGala wm { get; construct; }
1212
public Meta.Window window { get; construct; }
1313
public Pantheon.Desktop.Anchor anchor { get; construct set; }
1414

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

22-
public PanelWindow (WindowManager wm, Meta.Window window, Pantheon.Desktop.Anchor anchor) {
22+
public PanelWindow (WindowManagerGala wm, Meta.Window window, Pantheon.Desktop.Anchor anchor) {
2323
Object (wm: wm, window: window, anchor: anchor);
2424
}
2525

@@ -143,4 +143,8 @@ public class Gala.PanelWindow : Object {
143143
return TOP;
144144
}
145145
}
146+
147+
public void set_force_hide (bool force_hide, GestureTracker gesture_tracker, bool with_gesture) {
148+
clone.set_force_hide (force_hide, gesture_tracker, with_gesture);
149+
}
146150
}

src/ShellClients/ShellClientsManager.vala

+9-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
public class Gala.ShellClientsManager : Object {
99
private static ShellClientsManager instance;
1010

11-
public static void init (WindowManager wm) {
11+
public static void init (WindowManagerGala wm) {
1212
if (instance != null) {
1313
return;
1414
}
@@ -20,15 +20,15 @@ public class Gala.ShellClientsManager : Object {
2020
return instance;
2121
}
2222

23-
public WindowManager wm { get; construct; }
23+
public WindowManagerGala wm { get; construct; }
2424

2525
private NotificationsClient notifications_client;
2626
private ManagedClient[] protocol_clients = {};
2727

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

31-
private ShellClientsManager (WindowManager wm) {
31+
private ShellClientsManager (WindowManagerGala wm) {
3232
Object (wm: wm);
3333
}
3434

@@ -207,6 +207,12 @@ public class Gala.ShellClientsManager : Object {
207207
return positioned;
208208
}
209209

210+
public void set_force_hide_panels (bool force_hide, GestureTracker gesture_tracker, bool with_gesture) {
211+
foreach (var panel in panel_windows.get_values ()) {
212+
panel.set_force_hide (force_hide, gesture_tracker, with_gesture);
213+
}
214+
}
215+
210216
//X11 only
211217
private void parse_mutter_hints (Meta.Window window) requires (!Meta.Util.is_wayland_compositor ()) {
212218
if (window.mutter_hints == null) {

src/Widgets/MultitaskingView.vala

+2-109
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ namespace Gala {
3939

4040
private IconGroupContainer icon_groups;
4141
private Clutter.Actor workspaces;
42-
private Clutter.Actor dock_clones;
4342
private Clutter.Actor primary_monitor_container;
4443
private Clutter.BrightnessContrastEffect brightness_effect;
4544

@@ -83,8 +82,6 @@ namespace Gala {
8382

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

86-
dock_clones = new Clutter.Actor ();
87-
8885
brightness_effect = new Clutter.BrightnessContrastEffect ();
8986
update_brightness_effect ();
9087

@@ -101,7 +98,6 @@ namespace Gala {
10198
primary_monitor_container.add_child (icon_groups);
10299
primary_monitor_container.add_child (workspaces);
103100
add_child (primary_monitor_container);
104-
add_child (dock_clones);
105101

106102
unowned var manager = display.get_workspace_manager ();
107103
manager.workspace_added.connect (add_workspace);
@@ -675,9 +671,9 @@ namespace Gala {
675671
}
676672

677673
if (opening) {
678-
show_docks (with_gesture, is_cancel_animation);
674+
ShellClientsManager.get_instance ().set_force_hide_panels (true, multitasking_gesture_tracker, with_gesture);
679675
} else {
680-
hide_docks (with_gesture, is_cancel_animation);
676+
ShellClientsManager.get_instance ().set_force_hide_panels (false, multitasking_gesture_tracker, with_gesture);
681677
}
682678

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

697-
dock_clones.destroy_all_children ();
698-
699693
wm.pop_modal (modal_proxy);
700694
}
701695

@@ -716,107 +710,6 @@ namespace Gala {
716710
}
717711
}
718712

719-
private void show_docks (bool with_gesture, bool is_cancel_animation) {
720-
unowned GLib.List<Meta.WindowActor> window_actors = display.get_window_actors ();
721-
foreach (unowned Meta.WindowActor actor in window_actors) {
722-
const int MAX_OFFSET = 200;
723-
724-
if (actor.is_destroyed () || !actor.visible) {
725-
continue;
726-
}
727-
728-
unowned Meta.Window window = actor.get_meta_window ();
729-
var monitor = window.get_monitor ();
730-
731-
if (window.window_type != Meta.WindowType.DOCK) {
732-
continue;
733-
}
734-
735-
if (NotificationStack.is_notification (window)) {
736-
continue;
737-
}
738-
739-
if (display.get_monitor_in_fullscreen (monitor)) {
740-
continue;
741-
}
742-
743-
var monitor_geom = display.get_monitor_geometry (monitor);
744-
745-
var window_geom = window.get_frame_rect ();
746-
var top = monitor_geom.y + MAX_OFFSET > window_geom.y;
747-
var bottom = monitor_geom.y + monitor_geom.height - MAX_OFFSET < window_geom.y;
748-
749-
if (!top && !bottom) {
750-
continue;
751-
}
752-
753-
var initial_x = actor.x;
754-
var initial_y = actor.y;
755-
var target_y = (top)
756-
? actor.y - actor.height
757-
: actor.y + actor.height;
758-
759-
var clone = new SafeWindowClone (window, true);
760-
dock_clones.add_child (clone);
761-
762-
clone.set_position (initial_x, initial_y);
763-
764-
GestureTracker.OnUpdate on_animation_update = (percentage) => {
765-
var y = GestureTracker.animation_value (initial_y, target_y, percentage);
766-
clone.y = y;
767-
};
768-
769-
GestureTracker.OnEnd on_animation_end = (percentage, completions) => {
770-
if (completions == 0) {
771-
return;
772-
}
773-
774-
clone.save_easing_state ();
775-
clone.set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD);
776-
clone.set_easing_duration ((!is_cancel_animation && AnimationsSettings.get_enable_animations ()) ? ANIMATION_DURATION : 0);
777-
clone.y = target_y;
778-
clone.restore_easing_state ();
779-
};
780-
781-
if (!with_gesture || !AnimationsSettings.get_enable_animations ()) {
782-
on_animation_end (1, 1, 0);
783-
} else {
784-
multitasking_gesture_tracker.connect_handlers (null, (owned) on_animation_update, (owned) on_animation_end);
785-
}
786-
}
787-
}
788-
789-
private void hide_docks (bool with_gesture, bool is_cancel_animation) {
790-
foreach (unowned var child in dock_clones.get_children ()) {
791-
var dock = (Clutter.Clone) child;
792-
var initial_y = dock.y;
793-
var target_y = dock.source.y;
794-
795-
GestureTracker.OnUpdate on_animation_update = (percentage) => {
796-
var y = GestureTracker.animation_value (initial_y, target_y, percentage);
797-
dock.y = y;
798-
};
799-
800-
GestureTracker.OnEnd on_animation_end = (percentage, completions) => {
801-
if (completions == 0) {
802-
return;
803-
}
804-
805-
dock.save_easing_state ();
806-
dock.set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD);
807-
dock.set_easing_duration (AnimationsSettings.get_animation_duration (ANIMATION_DURATION));
808-
dock.y = target_y;
809-
dock.restore_easing_state ();
810-
};
811-
812-
if (!with_gesture || !AnimationsSettings.get_enable_animations ()) {
813-
on_animation_end (1, 1, 0);
814-
} else {
815-
multitasking_gesture_tracker.connect_handlers (null, (owned) on_animation_update, (owned) on_animation_end);
816-
}
817-
}
818-
}
819-
820713
private bool keybinding_filter (Meta.KeyBinding binding) {
821714
var action = Meta.Prefs.get_keybinding_action (binding.get_name ());
822715

0 commit comments

Comments
 (0)