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

Move panel hiding to the shell clients #2239

Merged
merged 20 commits into from
Jan 26, 2025
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions src/Gestures/GestureTracker.vala
Original file line number Diff line number Diff line change
Expand Up @@ -204,18 +204,16 @@ public class Gala.GestureTracker : Object {
}

/**
* Connects a callback that will only be called if != 0 completions were made.
* Connects a callback that will be called as soon as the gesture finishes.
* If with_gesture is false it will be called immediately, otherwise once {@link on_end} is emitted.
*/
public void add_success_callback (bool with_gesture, owned OnEnd callback) {
public void add_end_callback (bool with_gesture, owned OnEnd callback) {
if (!with_gesture) {
callback (1, 1, min_animation_duration);
} else {
ulong handler_id = on_end.connect ((percentage, completions, duration) => {
if (completions != 0) {
callback (percentage, completions, duration);
}
});
ulong handler_id = on_end.connect ((percentage, cancel_action, duration) =>
callback (percentage, cancel_action, duration)
);
handlers.add (handler_id);
}
}
Expand Down
10 changes: 0 additions & 10 deletions src/InternalUtils.vala
Original file line number Diff line number Diff line change
Expand Up @@ -388,15 +388,5 @@ 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;
});
}
}
}
4 changes: 4 additions & 0 deletions src/ShellClients/HideTracker.vala
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@ public class Gala.HideTracker : Object {
}

private void trigger_hide () {
if (hide_timeout_id != 0) {
return;
}

// Don't hide if we have transients, e.g. an open popover, dialog, etc.
var has_transients = false;
panel.window.foreach_transient (() => {
Expand Down
128 changes: 0 additions & 128 deletions src/ShellClients/PanelClone.vala

This file was deleted.

72 changes: 50 additions & 22 deletions src/ShellClients/PanelWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,44 @@
* Authored by: Leonhard Kargl <leo.kargl@proton.me>
*/

public class Gala.PanelWindow : Object {
public class Gala.PanelWindow : ShellWindow {
private const int ANIMATION_DURATION = 250;

private static HashTable<Meta.Window, Meta.Strut?> window_struts = new HashTable<Meta.Window, Meta.Strut?> (null, null);

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

private WindowPositioner window_positioner;
public Pantheon.Desktop.HideMode hide_mode {
get {
return hide_tracker == null ? Pantheon.Desktop.HideMode.NEVER : hide_tracker.hide_mode;
}
set {
if (value == NEVER) {
hide_tracker = null;
show ();
make_exclusive ();
return;
} else if (hide_tracker == null) {
unmake_exclusive ();

hide_tracker = new HideTracker (wm.get_display (), this);
hide_tracker.hide.connect (hide);
hide_tracker.show.connect (show);
}

private PanelClone clone;
hide_tracker.hide_mode = value;
}
}

private GestureTracker default_gesture_tracker;
private HideTracker? hide_tracker;

private int width = -1;
private int height = -1;

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

construct {
Expand All @@ -30,22 +52,26 @@ public class Gala.PanelWindow : Object {
}
});

window.stick ();

clone = new PanelClone (wm, this);

unowned var display = wm.get_display ();

window_positioner = new WindowPositioner (display, window, WindowPositioner.Position.from_anchor (anchor));
notify["anchor"].connect (() => position = Position.from_anchor (anchor));

notify["anchor"].connect (() => window_positioner.position = WindowPositioner.Position.from_anchor (anchor));

unowned var workspace_manager = display.get_workspace_manager ();
unowned var workspace_manager = window.display.get_workspace_manager ();
workspace_manager.workspace_added.connect (update_strut);
workspace_manager.workspace_removed.connect (update_strut);

window.size_changed.connect (update_strut);
window.position_changed.connect (update_strut);

default_gesture_tracker = new GestureTracker (ANIMATION_DURATION, ANIMATION_DURATION);

window.display.in_fullscreen_changed.connect (() => {
if (wm.get_display ().get_monitor_in_fullscreen (window.get_monitor ())) {
hide ();
} else if (hide_mode == NEVER) {
show ();
} else {
hide_tracker.update_overlap ();
}
});
}

#if HAS_MUTTER45
Expand Down Expand Up @@ -78,22 +104,24 @@ public class Gala.PanelWindow : Object {
update_strut ();
}

public void set_hide_mode (Pantheon.Desktop.HideMode hide_mode) {
clone.hide_mode = hide_mode;
private void hide () {
add_state (CUSTOM_HIDDEN, default_gesture_tracker, false);
}

if (hide_mode == NEVER) {
make_exclusive ();
} else {
unmake_exclusive ();
private void show () {
if (window.display.get_monitor_in_fullscreen (window.get_monitor ())) {
return;
}

remove_state (CUSTOM_HIDDEN, default_gesture_tracker, false);
}

private void make_exclusive () {
update_strut ();
}

private void update_strut () {
if (clone.hide_mode != NEVER) {
if (hide_mode != NEVER) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Authored by: Leonhard Kargl <leo.kargl@proton.me>
*/

public class Gala.WindowPositioner : Object {
public class Gala.PositionedWindow : Object {
public enum Position {
TOP,
BOTTOM,
Expand All @@ -21,7 +21,6 @@ public class Gala.WindowPositioner : Object {
}
}

public Meta.Display display { get; construct; }
public Meta.Window window { get; construct; }
/**
* This may only be set after the window was shown.
Expand All @@ -30,8 +29,8 @@ public class Gala.WindowPositioner : Object {
public Position position { get; construct set; }
public Variant? position_data { get; construct set; }

public WindowPositioner (Meta.Display display, Meta.Window window, Position position, Variant? position_data = null) {
Object (display: display, window: window, position: position, position_data: position_data);
public PositionedWindow (Meta.Window window, Position position, Variant? position_data = null) {
Object (window: window, position: position, position_data: position_data);
}

construct {
Expand All @@ -41,7 +40,7 @@ public class Gala.WindowPositioner : Object {
window.position_changed.connect (position_window);
window.shown.connect (position_window);

unowned var monitor_manager = display.get_context ().get_backend ().get_monitor_manager ();
unowned var monitor_manager = window.display.get_context ().get_backend ().get_monitor_manager ();
monitor_manager.monitors_changed.connect (position_window);
monitor_manager.monitors_changed_internal.connect (position_window);

Expand All @@ -51,8 +50,8 @@ public class Gala.WindowPositioner : Object {

private void position_window () {
int x = 0, y = 0;

var window_rect = window.get_frame_rect ();
unowned var display = window.display;

switch (position) {
case CENTER:
Expand Down
Loading
Loading