From 26221e5f32fe5e1002402e789098e1af86568881 Mon Sep 17 00:00:00 2001 From: Adi Shavit Date: Mon, 12 Jan 2026 22:02:58 +0200 Subject: [PATCH] Add Refresh option to system tray menu Adds a manual refresh option to the tray context menu, allowing users to force a monitor layout update without opening the UI. Useful when docking/undocking doesn't trigger automatic detection. Co-Authored-By: Claude Opus 4.5 --- .../LittleBigMouse.Ui.Avalonia/Main/MainService.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/LittleBigMouse.Ui/LittleBigMouse.Ui.Avalonia/Main/MainService.cs b/LittleBigMouse.Ui/LittleBigMouse.Ui.Avalonia/Main/MainService.cs index aa3ee6ea..c0b351e4 100644 --- a/LittleBigMouse.Ui/LittleBigMouse.Ui.Avalonia/Main/MainService.cs +++ b/LittleBigMouse.Ui/LittleBigMouse.Ui.Avalonia/Main/MainService.cs @@ -154,10 +154,11 @@ public async Task StartNotifierAsync() await _notify.AddMenuAsync(-1, "Start","Icon/Start", StartAsync); await _notify.AddMenuAsync(-1, "Stop","Icon/Stop", () => { - MonitorsLayout.Options.Enabled = false; + MonitorsLayout.Options.Enabled = false; MonitorsLayout.SaveEnabled(); return _littleBigMouseClientService.StopAsync(); }); + await _notify.AddMenuAsync(-1, "Refresh", "Icon/lbm_on", RefreshAsync); await _notify.AddMenuAsync(-1, "Exit", "Icon/sys/Close", QuitAsync); await _notify.SetIconAsync("Icon/lbm_off",128); @@ -181,6 +182,15 @@ async Task QuitAsync() Task StartAsync() => _littleBigMouseClientService.StartAsync(MonitorsLayout.ComputeZones()); + async Task RefreshAsync() + { + UpdateLayout(); + if (MonitorsLayout.Options.Enabled) + { + await StartAsync(); + } + } + bool _justConnected = false; async Task DaemonEventReceived(object? sender, LittleBigMouseServiceEventArgs args) {