Skip to content

Commit

Permalink
Call ReopenTaskbars instead of complete restart.
Browse files Browse the repository at this point in the history
  • Loading branch information
MKKNinetyTwo authored Nov 14, 2024
1 parent c00a39a commit bc158a5
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions RetroBar/Utilities/ExplorerMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class ExplorerMonitor : IDisposable
private bool _ExplorerMonitorIsMonitoring;
private MonitorWindow _explorerMonitor;

public void ExplorerMonitorStart()
public void ExplorerMonitorStart(WindowManager _windowManagerReference)
{
if(_ExplorerMonitorIsMonitoring) // Prevent multiple monitors.
{
Expand All @@ -19,7 +19,7 @@ public void ExplorerMonitorStart()
else
{
_ExplorerMonitorIsMonitoring = true; // We will set flag to true to prevent multiple monitors.
_explorerMonitor = new MonitorWindow(); // Start monitoring.
_explorerMonitor = new MonitorWindow(_windowManagerReference); // Start monitoring.
}
}

Expand All @@ -31,11 +31,12 @@ public void Dispose()
// NativeWindow implementation for monitoring
private class MonitorWindow : NativeWindow, IDisposable
{
//private readonly WindowManager _windowManager;
private WindowManager _windowManager;
private static readonly int TaskbarCreatedMessage = NativeMethods.RegisterWindowMessage("TaskbarCreated");

public MonitorWindow()
public MonitorWindow(WindowManager _windowManagerReference)
{
_windowManager = _windowManagerReference;
CreateHandle(new CreateParams());
}

Expand All @@ -45,15 +46,11 @@ protected override void WndProc(ref Message m)
{
try
{
//_windowManager.ReopenTaskbars(); // Reopen taskbars if explorer.exe is restarted.
string appPath = Process.GetCurrentProcess().MainModule?.FileName;
Process.Start(appPath); // Start a new instance of RetroBar
Environment.Exit(0); // Exit the current instance of RetroBar
_windowManager.ReopenTaskbars(); // Reopen taskbars if explorer.exe is restarted.
}
catch (Exception ex)
{
//Debug.WriteLine($"Error handling TaskbarCreated message on ExplorerMonitor: {ex.Message}");
Debug.WriteLine($"Error restarting RetroBar: {ex.Message}");
Debug.WriteLine($"Error handling TaskbarCreated message on ExplorerMonitor: {ex.Message}");
}
}

Expand Down

0 comments on commit bc158a5

Please sign in to comment.