Skip to content

Commit

Permalink
Introduce a shell group (#2195)
Browse files Browse the repository at this point in the history
Co-authored-by: Leo <[email protected]>
  • Loading branch information
leolost2605 and lenemter authored Jan 17, 2025
1 parent 045be35 commit eca9b14
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 46 deletions.
10 changes: 10 additions & 0 deletions src/InternalUtils.vala
Original file line number Diff line number Diff line change
Expand Up @@ -388,5 +388,15 @@ namespace Gala {
Clutter.get_default_backend ().get_default_seat ().bell_notify ();
#endif
}

public static void update_transients_visible (Meta.Window window, bool visible) {
window.foreach_transient ((transient) => {
unowned var actor = (Meta.WindowActor) transient.get_compositor_private ();

actor.visible = visible;

return true;
});
}
}
}
2 changes: 1 addition & 1 deletion src/ShellClients/HideTracker.vala
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public class Gala.HideTracker : Object {
});
}

private void update_overlap () {
public void update_overlap () {
overlap = false;
focus_overlap = false;
focus_maximized_overlap = false;
Expand Down
24 changes: 21 additions & 3 deletions src/ShellClients/PanelClone.vala
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public class Gala.PanelClone : Object {
}
});

wm.get_display ().in_fullscreen_changed.connect (check_hide);

Idle.add_once (() => {
if (hide_mode == NEVER) {
show ();
Expand Down Expand Up @@ -89,22 +91,38 @@ public class Gala.PanelClone : Object {
return;
}

new GesturePropertyTransition (actor, default_gesture_tracker, "translation-y", null, calculate_translation_y (true)).start (false);
InternalUtils.update_transients_visible (panel.window, false);

new GesturePropertyTransition (
actor, default_gesture_tracker, "translation-y", null, calculate_translation_y (true)
).start (false, () => InternalUtils.update_transients_visible (panel.window, !panel_hidden));

default_gesture_tracker.add_success_callback (false, () => panel_hidden = true);
}

private void show () {
if (!panel_hidden || default_gesture_tracker.recognizing) {
if (!panel_hidden || default_gesture_tracker.recognizing || wm.get_display ().get_monitor_in_fullscreen (panel.window.get_monitor ())) {
return;
}

if (!Meta.Util.is_wayland_compositor ()) {
Utils.x11_unset_window_pass_through (panel.window);
}

new GesturePropertyTransition (actor, default_gesture_tracker, "translation-y", null, calculate_translation_y (false)).start (false);
new GesturePropertyTransition (
actor, default_gesture_tracker, "translation-y", null, calculate_translation_y (false)
).start (false, () => InternalUtils.update_transients_visible (panel.window, !panel_hidden));

default_gesture_tracker.add_success_callback (false, () => panel_hidden = false);
}

private void check_hide () {
if (wm.get_display ().get_monitor_in_fullscreen (panel.window.get_monitor ())) {
hide ();
} else if (hide_mode == NEVER) {
show ();
} else {
hide_tracker.update_overlap ();
}
}
}
2 changes: 1 addition & 1 deletion src/ShellClients/ShellClientsManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public class Gala.ShellClientsManager : Object {
}

private bool is_itself_positioned (Meta.Window window) {
return (window in positioned_windows) || (window in panel_windows);
return (window in positioned_windows) || (window in panel_windows) || NotificationStack.is_notification (window);
}

public bool is_positioned_window (Meta.Window window) {
Expand Down
8 changes: 5 additions & 3 deletions src/Widgets/MultitaskingView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace Gala {
private GestureTracker multitasking_gesture_tracker;
private GestureTracker workspace_gesture_tracker;

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

private Meta.Display display;
private ModalProxy modal_proxy;
Expand All @@ -53,7 +53,7 @@ namespace Gala {
}
}

public MultitaskingView (WindowManager wm) {
public MultitaskingView (WindowManagerGala wm) {
Object (wm: wm);
}

Expand Down Expand Up @@ -631,6 +631,7 @@ namespace Gala {
wm.background_group.hide ();
wm.window_group.hide ();
wm.top_window_group.hide ();
wm.shell_group.hide ();
show ();
grab_key_focus ();

Expand Down Expand Up @@ -693,6 +694,7 @@ namespace Gala {
wm.background_group.show ();
wm.window_group.show ();
wm.top_window_group.show ();
wm.shell_group.show ();

dock_clones.destroy_all_children ();

Expand Down Expand Up @@ -721,7 +723,7 @@ namespace Gala {
foreach (unowned Meta.WindowActor actor in window_actors) {
const int MAX_OFFSET = 200;

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

Expand Down
77 changes: 39 additions & 38 deletions src/WindowManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ namespace Gala {
*/
public Clutter.Actor top_window_group { get; protected set; }

public Clutter.Actor notification_group { get; protected set; }
/**
* The group that contains all WindowActors that make shell elements, that is all windows reported as
* ShellClientsManager.is_positioned_window.
* It will (eventually) never be hidden by other components and is always on top of everything. Therefore elements are
* responsible themselves for hiding depending on the state we are currently in (e.g. normal desktop, open multitasking view, fullscreen, etc.).
*/
public Clutter.Actor shell_group { get; private set; }

/**
* {@inheritDoc}
Expand Down Expand Up @@ -104,8 +110,6 @@ namespace Gala {
private bool animating_switch_workspace = false;
private bool switch_workspace_with_gesture = false;

private signal void window_created (Meta.Window window);

/**
* Amount of pixels to move on the nudge animation.
*/
Expand Down Expand Up @@ -253,14 +257,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,8 +289,16 @@ namespace Gala {
}

// Add the remaining components that should be on top
notification_group = new Clutter.Actor ();
ui_group.add_child (notification_group);
shell_group = new Clutter.Actor ();
ui_group.add_child (shell_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);
Expand Down Expand Up @@ -381,12 +385,14 @@ namespace Gala {

update_input_area ();

display.window_created.connect ((window) => window_created (window));

var scroll_action = new SuperScrollAction (display);
scroll_action.triggered.connect (handle_super_scroll);
stage.add_action_full ("wm-super-scroll-action", CAPTURE, scroll_action);

display.window_created.connect ((window) =>
InternalUtils.wait_for_window_actor_visible (window, check_shell_window)
);

stage.show ();

plugin_manager.load_waiting_plugins ();
Expand Down Expand Up @@ -1162,6 +1168,17 @@ namespace Gala {
show_window_menu (window, menu, rect.x, rect.y);
}

private void check_shell_window (Meta.WindowActor actor) {
unowned var window = actor.get_meta_window ();
if (ShellClientsManager.get_instance ().is_positioned_window (window)) {
InternalUtils.clutter_actor_reparent (actor, shell_group);
}

if (NotificationStack.is_notification (window)) {
notification_stack.show_notification (actor);
}
}

/*
* effects
*/
Expand Down Expand Up @@ -1436,12 +1453,8 @@ namespace Gala {
actor.remove_all_transitions ();
actor.show ();

// Notifications are a special case and have to be always be handled
// (also regardless of the animation setting)
// Notifications initial animation is handled by the notification stack
if (NotificationStack.is_notification (window)) {
InternalUtils.clutter_actor_reparent (actor, notification_group);
notification_stack.show_notification (actor);

map_completed (actor);
return;
}
Expand Down Expand Up @@ -1843,7 +1856,6 @@ namespace Gala {
private List<Clutter.Actor>? windows;
private List<Clutter.Actor>? parents;
private List<Clutter.Actor>? tmp_actors;
private ulong switch_workspace_window_created_id = 0;
private Clutter.Actor? out_group;
private Clutter.Actor? in_group;
private Clutter.Actor? wallpaper;
Expand Down Expand Up @@ -1932,7 +1944,10 @@ namespace Gala {
continue;
}

if (!window.showing_on_its_workspace () || move_primary_only && !window.is_on_primary_monitor ()) {
if (!window.showing_on_its_workspace () ||
move_primary_only && !window.is_on_primary_monitor () ||
actor.get_parent () == shell_group
) {
continue;
}

Expand Down Expand Up @@ -2045,17 +2060,6 @@ namespace Gala {

prepare_workspace_switch (from, to, direction);

// while a workspace is being switched mutter doesn't map windows
// TODO: currently only notifications are handled here, other windows should be too
switch_workspace_window_created_id = window_created.connect ((window) => {
if (NotificationStack.is_notification (window)) {
InternalUtils.wait_for_window_actor_visible (window, (actor) => {
InternalUtils.clutter_actor_reparent (actor, notification_group);
notification_stack.show_notification (actor);
});
}
});

var animation_mode = Clutter.AnimationMode.EASE_OUT_CUBIC;

var x2 = -in_group.x;
Expand Down Expand Up @@ -2127,11 +2131,8 @@ namespace Gala {
return;
}

if (switch_workspace_window_created_id > 0) {
disconnect (switch_workspace_window_created_id);
switch_workspace_window_created_id = 0;
}
end_switch_workspace ();

if (!is_nudge_animation) {
switch_workspace_completed ();
}
Expand All @@ -2157,7 +2158,7 @@ namespace Gala {
}

private void end_switch_workspace () {
if (windows == null || parents == null)
if ((windows == null || parents == null) && tmp_actors == null)
return;

unowned var display = get_display ();
Expand Down

0 comments on commit eca9b14

Please sign in to comment.