private void RefreshWindows(ScreenSetupReason reason, bool displaysChanged) { CairoLogger.Instance.Debug("WindowManager: Refreshing screen information for existing windows"); // TODO: Handle these as events in respective classes // update screens of stale windows if (Settings.Instance.EnableMenuBarMultiMon) { foreach (Screen screen in ScreenState) { MenuBar bar = GetScreenWindow(MenuBarWindows, screen); if (bar != null) { bar.Screen = screen; bar.SetScreenPosition(); } } } else if (MenuBarWindows.Count > 0) { MenuBarWindows[0].Screen = Screen.PrimaryScreen; MenuBarWindows[0].SetScreenPosition(); } if (Settings.Instance.EnableTaskbarMultiMon) { foreach (Screen screen in ScreenState) { Taskbar bar = GetScreenWindow(TaskbarWindows, screen); if (bar != null) { bar.Screen = screen; bar.SetScreenPosition(); } } } else if (TaskbarWindows.Count > 0) { TaskbarWindows[0].Screen = Screen.PrimaryScreen; TaskbarWindows[0].SetScreenPosition(); } // notify event subscribers WindowManagerEventArgs args = new WindowManagerEventArgs { DisplaysChanged = displaysChanged, Reason = reason }; ScreensChanged?.Invoke(this, args); }