From 0ea8dea63183cd99f8b123f68a5153890c52931c Mon Sep 17 00:00:00 2001 From: Leonhard Kargl Date: Tue, 24 Sep 2024 20:19:15 +0200 Subject: [PATCH] Don't create ALL BackgroundWindows new if monitors change --- src/ShellClients/BackgroundWindow.vala | 8 ++++++-- src/ShellClients/ShellClientsManager.vala | 9 +++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/ShellClients/BackgroundWindow.vala b/src/ShellClients/BackgroundWindow.vala index 4195db054..572fed59f 100644 --- a/src/ShellClients/BackgroundWindow.vala +++ b/src/ShellClients/BackgroundWindow.vala @@ -25,10 +25,14 @@ public class Gala.BackgroundWindow : Object { providing_window = new_window; + providing_window.unmanaging.connect (on_window_unmanaging); + + reposition (); + } + + public void reposition () { var monitor_geom = display.get_monitor_geometry (monitor_index); providing_window.move_frame (false, monitor_geom.x, monitor_geom.y); - - providing_window.unmanaging.connect (on_window_unmanaging); } private void on_window_unmanaging () { diff --git a/src/ShellClients/ShellClientsManager.vala b/src/ShellClients/ShellClientsManager.vala index 020f37195..56aecb7b9 100644 --- a/src/ShellClients/ShellClientsManager.vala +++ b/src/ShellClients/ShellClientsManager.vala @@ -53,9 +53,14 @@ public class Gala.ShellClientsManager : Object { private void update_background_windows () { var display = wm.get_display (); - background_windows = new BackgroundWindow[display.get_n_monitors ()]; + background_windows.resize (display.get_n_monitors ()); + for (int i = 0; i < background_windows.length; i++) { - background_windows[i] = new BackgroundWindow (display, i); + if (background_windows[i] == null) { + background_windows[i] = new BackgroundWindow (display, i); + } else { + background_windows[i].reposition (); + } } }