Skip to content

Commit

Permalink
ShellClients: Keep PanelClone around and move HideTracker reference t…
Browse files Browse the repository at this point in the history
…o PanelWindow

Preparation for using the PanelClone for smoother MultitaskingView animations on wayland
  • Loading branch information
leolost2605 committed May 26, 2024
1 parent fe650bf commit 6782287
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 28 deletions.
23 changes: 2 additions & 21 deletions src/ShellClients/PanelClone.vala
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,10 @@ public class Gala.PanelClone : Object {
public WindowManager wm { get; construct; }
public PanelWindow panel { get; construct; }

public Pantheon.Desktop.HideMode hide_mode {
get {
return hide_tracker.hide_mode;
}
set {
hide_tracker.hide_mode = value;
}
}

public bool panel_hidden { get; private set; default = false; }

private SafeWindowClone clone;
private Meta.WindowActor actor;
private HideTracker hide_tracker;

public PanelClone (WindowManager wm, PanelWindow panel) {
Object (wm: wm, panel: panel);
Expand All @@ -45,16 +35,7 @@ public class Gala.PanelClone : Object {
// but we want to keep it in sync with us
actor.notify["visible"].connect (update_visible);

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

hide_tracker = new HideTracker (wm.get_display (), panel);
hide_tracker.hide.connect (hide);
hide_tracker.show.connect (show);
notify["panel-hidden"].connect (update_visible);

update_visible ();
update_clone_position ();
Expand Down Expand Up @@ -89,7 +70,7 @@ public class Gala.PanelClone : Object {
}
}

private void hide () {
public void hide () {
if (panel_hidden) {
return;
}
Expand Down
26 changes: 19 additions & 7 deletions src/ShellClients/PanelWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ public class Gala.PanelWindow : Object {
public Meta.Side anchor;

private Barrier? barrier;
private HideTracker? hide_tracker;

private PanelClone? clone = null;
private PanelClone clone;

private int width = -1;
private int height = -1;
Expand All @@ -44,6 +45,15 @@ public class Gala.PanelWindow : Object {
});

window.stick ();

clone = new PanelClone (wm, this);
clone.notify["panel-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 ();
}
});
}

#if HAS_MUTTER46
Expand All @@ -69,14 +79,14 @@ public class Gala.PanelWindow : Object {
this.height = height;

position_window ();
set_hide_mode (clone == null ? Pantheon.Desktop.HideMode.NEVER : clone.hide_mode); // Resetup barriers etc.
set_hide_mode (hide_tracker == null ? Pantheon.Desktop.HideMode.NEVER : hide_tracker.hide_mode); // Resetup barriers etc.
}

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

position_window ();
set_hide_mode (clone == null ? Pantheon.Desktop.HideMode.NEVER : clone.hide_mode); // Resetup barriers etc.
set_hide_mode (hide_tracker == null ? Pantheon.Desktop.HideMode.NEVER : hide_tracker.hide_mode); // Resetup barriers etc.
}

private void position_window () {
Expand Down Expand Up @@ -131,15 +141,17 @@ public class Gala.PanelWindow : Object {
destroy_barrier ();

if (hide_mode == NEVER) {
clone = null;
hide_tracker = null;
make_exclusive ();
} else {
unmake_exclusive ();

if (clone == null) {
clone = new PanelClone (wm, this);
if (hide_tracker == null) {
hide_tracker = new HideTracker (wm.get_display (), this);
hide_tracker.show.connect (clone.show);
hide_tracker.hide.connect (clone.hide);
}
clone.hide_mode = hide_mode;
hide_tracker.hide_mode = hide_mode;

setup_barrier ();
}
Expand Down

0 comments on commit 6782287

Please sign in to comment.