Skip to content

Commit

Permalink
Add a shell group
Browse files Browse the repository at this point in the history
  • Loading branch information
leolost2605 committed Dec 21, 2024
1 parent 92793a9 commit e1c05b5
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 52 deletions.
41 changes: 20 additions & 21 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 @@ -41,17 +41,20 @@ public class Gala.PanelClone : Object {

private HideTracker? hide_tracker;

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

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

clone = new SafeWindowClone (panel.window, true);
wm.ui_group.add_child (clone);
wm.shell_group.add_child (clone);

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

// WindowActor position and Window position aren't necessarily the same.
// The clone needs the actor position
actor.notify["x"].connect (update_clone_position);
Expand All @@ -69,10 +72,6 @@ public class Gala.PanelClone : Object {
}
});

// Make sure the actor is visible once it's focused FIXME: better event not only focused
// https://github.com/elementary/gala/issues/2080
panel.window.focused.connect (update_visible);

update_visible ();
update_clone_position ();

Expand All @@ -87,12 +86,6 @@ public class Gala.PanelClone : Object {

private void update_visible () {
actor.visible = !panel_hidden;

if (actor.visible && !wm.get_display ().get_monitor_in_fullscreen (panel.window.get_monitor ())) {
// The actor has just been revealed, make sure it's at the top
// https://github.com/elementary/gala/issues/2080
actor.get_parent ().set_child_above_sibling (actor, null);
}
}

private void update_clone_position () {
Expand Down Expand Up @@ -144,7 +137,9 @@ public class Gala.PanelClone : Object {
}

private void show (GestureTracker gesture_tracker, bool with_gesture) {
if (!panel_hidden || force_hide || last_gesture_tracker != null && last_gesture_tracker.recognizing) {
if (!panel_hidden || force_hide || last_gesture_tracker != null && last_gesture_tracker.recognizing
|| (wm.get_display ().get_monitor_in_fullscreen (panel.window.get_monitor ()) && !panel.window.has_focus ())
) {
return;
}

Expand All @@ -162,15 +157,19 @@ public class Gala.PanelClone : Object {
});
}

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

if (force_hide) {
private void check_hide (bool should_hide, GestureTracker gesture_tracker, bool with_gesture) {
if (should_hide) {
hide (gesture_tracker, with_gesture);
} else if (hide_mode == NEVER) {
show (gesture_tracker, with_gesture);
} else {
} else if (hide_tracker != null) {
hide_tracker.update_overlap (gesture_tracker, with_gesture);
} else {
show (gesture_tracker, with_gesture);
}
}

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

check_hide (force_hide, gesture_tracker, with_gesture);
}
}
4 changes: 2 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
6 changes: 3 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
45 changes: 27 additions & 18 deletions src/Widgets/MultitaskingView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -676,29 +676,38 @@ namespace Gala {
ShellClientsManager.get_instance ().set_force_hide_panels (false, multitasking_gesture_tracker, with_gesture);
}

// The callback needs to run at the same frame as the others (e.g. PanelClone) so we can't do a simple Timeout here
// The actual transition does nothing here, since the opacity just stays at 255
new GesturePropertyTransition (this, multitasking_gesture_tracker, "opacity", null, 255u).start (with_gesture, (completions) => {
if (!opening) {
foreach (var container in window_containers_monitors) {
container.visible = false;
}
GestureTracker.OnEnd on_animation_end = (percentage, completions) => {
var animation_duration = completions == 0 ? 0 : ANIMATION_DURATION;
Timeout.add (animation_duration, () => {
if (!opening) {
foreach (var container in window_containers_monitors) {
container.visible = false;
}

hide ();
hide ();

wm.background_group.show ();
wm.window_group.show ();
wm.top_window_group.show ();
wm.background_group.show ();
wm.window_group.show ();
wm.top_window_group.show ();

wm.pop_modal (modal_proxy);
}
wm.pop_modal (modal_proxy);
}

animating = false;
animating = false;

if (completions == 0) {
toggle (false, true);
}
});
if (completions == 0) {
toggle (false, true);
}

return Source.REMOVE;
});
};

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

private bool keybinding_filter (Meta.KeyBinding binding) {
Expand Down
21 changes: 13 additions & 8 deletions src/WindowManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ namespace Gala {
*/
public Gala.ActivatableComponent workspace_view { get; protected set; }

public Clutter.Actor shell_group { get; private set; }

public PointerLocator pointer_locator { get; private set; }

private SystemBackground system_background;
Expand Down Expand Up @@ -253,14 +255,6 @@ namespace Gala {
stage.remove_child (top_window_group);
ui_group.add_child (top_window_group);

#if HAS_MUTTER44
var feedback_group = display.get_compositor ().get_feedback_group ();
#else
var feedback_group = display.get_feedback_group ();
#endif
stage.remove_child (feedback_group);
ui_group.add_child (feedback_group);

// Initialize plugins and add default components if no plugin overrides them
unowned var plugin_manager = PluginManager.get_default ();
plugin_manager.initialize (this);
Expand Down Expand Up @@ -293,9 +287,20 @@ namespace Gala {
}

// Add the remaining components that should be on top
shell_group = new Clutter.Actor ();
ui_group.add_child (shell_group);

notification_group = new Clutter.Actor ();
ui_group.add_child (notification_group);

#if HAS_MUTTER44
var feedback_group = display.get_compositor ().get_feedback_group ();
#else
var feedback_group = display.get_feedback_group ();
#endif
stage.remove_child (feedback_group);
ui_group.add_child (feedback_group);

pointer_locator = new PointerLocator (display);
ui_group.add_child (pointer_locator);
ui_group.add_child (new DwellClickTimer (display));
Expand Down

0 comments on commit e1c05b5

Please sign in to comment.