ShellClients: Keep clone only destroy HideTracker (#1915)

This commit is contained in:
Leonhard 2024-05-28 18:51:25 +02:00 committed by GitHub
parent f0d58b90fe
commit 8e361c31c2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 28 additions and 18 deletions

View File

@ -21,6 +21,8 @@ public class Gala.HideTracker : Object {
private bool focus_overlap = false;
private bool focus_maximized_overlap = false;
private Meta.Window current_focus_window;
private uint update_timeout_id = 0;
public HideTracker (Meta.Display display, PanelWindow panel) {
@ -28,7 +30,9 @@ public class Gala.HideTracker : Object {
}
construct {
var current_focus_window = display.focus_window;
// Can't be local otherwise we get a memory leak :(
// See https://gitlab.gnome.org/GNOME/vala/-/issues/1548
current_focus_window = display.focus_window;
track_focus_window (current_focus_window);
display.notify["focus-window"].connect (() => {
untrack_focus_window (current_focus_window);

View File

@ -13,9 +13,19 @@ public class Gala.PanelClone : Object {
public Pantheon.Desktop.HideMode hide_mode {
get {
return hide_tracker.hide_mode;
return hide_tracker == null ? Pantheon.Desktop.HideMode.NEVER : hide_tracker.hide_mode;
}
set {
if (value == NEVER) {
hide_tracker = null;
show ();
return;
} else if (hide_tracker == null) {
hide_tracker = new HideTracker (wm.get_display (), panel);
hide_tracker.hide.connect (hide);
hide_tracker.show.connect (show);
}
hide_tracker.hide_mode = value;
}
}
@ -24,7 +34,8 @@ public class Gala.PanelClone : Object {
private SafeWindowClone clone;
private Meta.WindowActor actor;
private HideTracker hide_tracker;
private HideTracker? hide_tracker;
public PanelClone (WindowManager wm, PanelWindow panel) {
Object (wm: wm, panel: panel);
@ -49,13 +60,11 @@ public class Gala.PanelClone : Object {
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 ();
if (hide_tracker != null) {
hide_tracker.schedule_update ();
}
});
hide_tracker = new HideTracker (wm.get_display (), panel);
hide_tracker.hide.connect (hide);
hide_tracker.show.connect (show);
update_visible ();
update_clone_position ();
}

View File

@ -19,7 +19,7 @@ public class Gala.PanelWindow : Object {
private Barrier? barrier;
private PanelClone? clone = null;
private PanelClone clone;
private int width = -1;
private int height = -1;
@ -44,6 +44,8 @@ public class Gala.PanelWindow : Object {
});
window.stick ();
clone = new PanelClone (wm, this);
}
#if HAS_MUTTER46
@ -69,14 +71,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 (clone.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 (clone.hide_mode); // Resetup barriers etc.
}
private void position_window () {
@ -128,19 +130,14 @@ public class Gala.PanelWindow : Object {
}
public void set_hide_mode (Pantheon.Desktop.HideMode hide_mode) {
clone.hide_mode = hide_mode;
destroy_barrier ();
if (hide_mode == NEVER) {
clone = null;
make_exclusive ();
} else {
unmake_exclusive ();
if (clone == null) {
clone = new PanelClone (wm, this);
}
clone.hide_mode = hide_mode;
setup_barrier ();
}
}