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

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
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
128 changes: 0 additions & 128 deletions src/ShellClients/PanelClone.vala

This file was deleted.

80 changes: 58 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 <[email protected]>
*/

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);
}

hide_tracker.hide_mode = value;
}
}

private PanelClone clone;
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,34 @@ 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 (() => window_positioner.position = WindowPositioner.Position.from_anchor (anchor));
notify["anchor"].connect (() => position = 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);

notify["hidden"].connect (() => {
// When hidden changes schedule an update to make sure it's actually
// correct since things might have changed during the animation
if (hide_tracker != null) {
hide_tracker.schedule_update ();
}
});

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 +112,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);
}

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);
}

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 <[email protected]>
*/

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
26 changes: 23 additions & 3 deletions src/ShellClients/ShellClientsManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class Gala.ShellClientsManager : Object {
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 GLib.HashTable<Meta.Window, ShellWindow> positioned_windows = new GLib.HashTable<Meta.Window, ShellWindow> (null, null);

private ShellClientsManager (WindowManager wm) {
Object (wm: wm);
Expand Down Expand Up @@ -180,16 +180,36 @@ public class Gala.ShellClientsManager : Object {
return;
}

panel_windows[window].set_hide_mode (hide_mode);
panel_windows[window].hide_mode = hide_mode;
}

public void make_centered (Meta.Window window) requires (!is_itself_positioned (window)) {
positioned_windows[window] = new WindowPositioner (wm.get_display (), window, CENTER);
positioned_windows[window] = new ShellWindow (window, CENTER);

// connect_after so we make sure that any queued move is unqueued
window.unmanaging.connect_after ((_window) => positioned_windows.remove (_window));
}

public void add_state (ShellWindow.State state, GestureTracker gesture_tracker) {
foreach (var window in positioned_windows.get_values ()) {
window.add_state (state, gesture_tracker);
}

foreach (var window in panel_windows.get_values ()) {
window.add_state (state, gesture_tracker);
}
}

public void remove_state (ShellWindow.State state, GestureTracker gesture_tracker) {
foreach (var window in positioned_windows.get_values ()) {
window.remove_state (state, gesture_tracker);
}

foreach (var window in panel_windows.get_values ()) {
window.remove_state (state, gesture_tracker);
}
}

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