Skip to content
Closed
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
20 changes: 1 addition & 19 deletions src/PantheonShell.vala
Original file line number Diff line number Diff line change
Expand Up @@ -243,25 +243,7 @@ namespace Gala {
return;
}

Meta.Side side = TOP;
switch (anchor) {
case TOP:
break;

case BOTTOM:
side = BOTTOM;
break;

case LEFT:
side = LEFT;
break;

case RIGHT:
side = RIGHT;
break;
}

ShellClientsManager.get_instance ().set_anchor (window, side);
ShellClientsManager.get_instance ().set_anchor (window, anchor);
}

internal static void focus_panel (Wl.Client client, Wl.Resource resource) {
Expand Down
32 changes: 19 additions & 13 deletions src/ShellClients/HideTracker.vala
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,7 @@ public class Gala.HideTracker : Object {
public Meta.Display display { get; construct; }
public unowned PanelWindow panel { get; construct; }

private Pantheon.Desktop.HideMode _hide_mode = NEVER;
public Pantheon.Desktop.HideMode hide_mode {
get {
return _hide_mode;
}
set {
_hide_mode = value;

setup_barrier ();
}
}
public Pantheon.Desktop.HideMode hide_mode { get; set; }

private Clutter.PanAction pan_action;

Expand Down Expand Up @@ -97,6 +87,16 @@ public class Gala.HideTracker : Object {
pan_action.pan.connect (on_pan);

display.get_stage ().add_action_full ("panel-swipe-gesture", CAPTURE, pan_action);

panel.notify["anchor"].connect (setup_barrier);

var monitor_manager = display.get_context ().get_backend ().get_monitor_manager ();
monitor_manager.monitors_changed.connect (() => {
setup_barrier (); //Make sure barriers are still on the primary monitor
schedule_update ();
});

setup_barrier ();
}

#if !HAS_MUTTER45
Expand Down Expand Up @@ -152,7 +152,13 @@ public class Gala.HideTracker : Object {
});
}

private void update_overlap () {
/**
* Immediately updates the overlap. Usually {@link schedule_update} should be used instead which
* internally calls this but throttles it since it's a somewhat expensive operation.
* On very rare use cases however it is required to update immediately. In that case you can call
* this directly.
*/
public void update_overlap () {
overlap = false;
focus_overlap = false;
focus_maximized_overlap = false;
Expand All @@ -171,7 +177,7 @@ public class Gala.HideTracker : Object {
continue;
}

if (!panel.get_custom_window_rect ().overlap (window.get_frame_rect ())) {
if (!panel.window.get_frame_rect ().overlap (window.get_frame_rect ())) {
continue;
}

Expand Down
50 changes: 41 additions & 9 deletions src/ShellClients/PanelClone.vala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class Gala.PanelClone : Object {
private const int ANIMATION_DURATION = 250;

public WindowManager wm { get; construct; }
public unowned PanelWindow panel { get; construct; }
public unowned PanelWindow? panel { get; construct; }

public Pantheon.Desktop.HideMode hide_mode {
get {
Expand All @@ -35,6 +35,8 @@ public class Gala.PanelClone : Object {
private SafeWindowClone clone;
private Meta.WindowActor actor;

private bool window_ready = false;

private HideTracker? hide_tracker;

public PanelClone (WindowManager wm, PanelWindow panel) {
Expand Down Expand Up @@ -67,16 +69,38 @@ public class Gala.PanelClone : Object {
// https://github.com/elementary/gala/issues/2080
panel.window.focused.connect (update_visible);

panel.window.unmanaging.connect (() => panel = null);

update_visible ();
update_clone_position ();

Idle.add_once (() => {
if (hide_mode == NEVER) {
show ();
} else {
hide_tracker.schedule_update ();
}
});
if (Meta.Util.is_wayland_compositor ()) {
// We want to wait for the window to be actually shown before revealing and then still a bit
// more since at the beginning it might be doing some relayouting (e.g. the dock only knows
// its size after it got a dbus connection to gala) which disrupts the animation.
panel.window.shown.connect (() => Timeout.add (100, () => {
if (panel == null) {
return Source.REMOVE; // The window was unmanaged while we were waiting
}

window_ready = true;
// In the best case we are ready before the manager stops waiting so the on_ready usually
// doesn't do anything. However if the client stalls for some reason or it crashed and has now
// been restarted it will show immediately.
on_ready ();

ShellClientsManager.get_instance ().notify_client_ready ();

return Source.REMOVE;
}));
} else {
// On X the window was already shown when it requests being a panel so just mark it ready
window_ready = true;
on_ready ();
ShellClientsManager.get_instance ().notify_client_ready ();
}

ShellClientsManager.get_instance ().notify["is-waiting"].connect (on_ready);
}

private void update_visible () {
Expand Down Expand Up @@ -146,7 +170,7 @@ public class Gala.PanelClone : Object {
}

private void show () {
if (!panel_hidden) {
if (!panel_hidden || !window_ready || ShellClientsManager.get_instance ().is_waiting) {
return;
}

Expand All @@ -171,4 +195,12 @@ public class Gala.PanelClone : Object {
panel_hidden = false;
}
}

private void on_ready () {
if (hide_mode == NEVER) {
show ();
} else {
hide_tracker.update_overlap ();
}
}
}
115 changes: 30 additions & 85 deletions src/ShellClients/PanelWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,22 @@ public class Gala.PanelWindow : Object {
public WindowManager wm { get; construct; }
public Meta.Window window { get; construct; }

public bool hidden { get; private set; default = false; }
public Pantheon.Desktop.Anchor anchor { get; construct set; }

public Meta.Side anchor;
private WindowPositioner window_positioner;

public DelegateActor delegate_actor;
private PanelClone clone;

private uint idle_move_id = 0;

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

public PanelWindow (WindowManager wm, Meta.Window window, Meta.Side anchor) {
Object (wm: wm, window: window);

// Meta.Side seems to be currently not supported as GLib.Object property ...?
// At least it always crashed for me with some paramspec, g_type_fundamental backtrace
this.anchor = anchor;
public PanelWindow (WindowManager wm, Meta.Window window, Pantheon.Desktop.Anchor anchor) {
Object (wm: wm, window: window, anchor: anchor);
}

construct {
window.size_changed.connect (position_window);

window.unmanaging.connect (() => {
if (idle_move_id != 0) {
Source.remove (idle_move_id);
}

if (window_struts.remove (window)) {
update_struts ();
}
Expand All @@ -49,13 +37,18 @@ public class Gala.PanelWindow : Object {
delegate_actor = new DelegateActor ((Meta.WindowActor) window.get_compositor_private ());
clone = new PanelClone (wm, this);

var monitor_manager = wm.get_display ().get_context ().get_backend ().get_monitor_manager ();
monitor_manager.monitors_changed.connect (() => update_anchor (anchor));
monitor_manager.monitors_changed_internal.connect (() => update_anchor (anchor));
var display = wm.get_display ();

var workspace_manager = wm.get_display ().get_workspace_manager ();
var workspace_manager = 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);

window_positioner = new WindowPositioner (display, window, WindowPositioner.Position.from_anchor (anchor));

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

#if HAS_MUTTER45
Expand Down Expand Up @@ -87,73 +80,9 @@ public class Gala.PanelWindow : Object {
this.width = width;
this.height = height;

position_window ();
set_hide_mode (clone.hide_mode); // Resetup barriers etc.
}

public void update_anchor (Meta.Side anchor) {
this.anchor = anchor;

position_window ();
set_hide_mode (clone.hide_mode); // Resetup barriers etc.
}

private void position_window () {
var display = wm.get_display ();
var monitor_geom = display.get_monitor_geometry (display.get_primary_monitor ());
var window_rect = window.get_frame_rect ();

switch (anchor) {
case TOP:
position_window_top (monitor_geom, window_rect);
break;

case BOTTOM:
position_window_bottom (monitor_geom, window_rect);
break;

default:
warning ("Side not supported yet");
break;
}

update_strut ();
}

#if HAS_MUTTER45
private void position_window_top (Mtk.Rectangle monitor_geom, Mtk.Rectangle window_rect) {
#else
private void position_window_top (Meta.Rectangle monitor_geom, Meta.Rectangle window_rect) {
#endif
var x = monitor_geom.x + (monitor_geom.width - window_rect.width) / 2;

move_window_idle (x, monitor_geom.y);
}

#if HAS_MUTTER45
private void position_window_bottom (Mtk.Rectangle monitor_geom, Mtk.Rectangle window_rect) {
#else
private void position_window_bottom (Meta.Rectangle monitor_geom, Meta.Rectangle window_rect) {
#endif
var x = monitor_geom.x + (monitor_geom.width - window_rect.width) / 2;
var y = monitor_geom.y + monitor_geom.height - window_rect.height;

move_window_idle (x, y);
}

private void move_window_idle (int x, int y) {
if (idle_move_id != 0) {
Source.remove (idle_move_id);
}

idle_move_id = Idle.add (() => {
window.move_frame (false, x, y);

idle_move_id = 0;
return Source.REMOVE;
});
}

public void set_hide_mode (Pantheon.Desktop.HideMode hide_mode) {
clone.hide_mode = hide_mode;

Expand All @@ -177,7 +106,7 @@ public class Gala.PanelWindow : Object {

Meta.Strut strut = {
rect,
anchor
side_from_anchor (anchor)
};

window_struts[window] = strut;
Expand All @@ -203,4 +132,20 @@ public class Gala.PanelWindow : Object {
update_struts ();
}
}

private Meta.Side side_from_anchor (Pantheon.Desktop.Anchor anchor) {
switch (anchor) {
case BOTTOM:
return BOTTOM;

case LEFT:
return LEFT;

case RIGHT:
return RIGHT;

default:
return TOP;
}
}
}
Loading
Loading