diff --git a/Desktop.Linux/ViewModels/MainWindowViewModel.cs b/Desktop.Linux/ViewModels/MainWindowViewModel.cs index b309164f1..9da0fbf2a 100644 --- a/Desktop.Linux/ViewModels/MainWindowViewModel.cs +++ b/Desktop.Linux/ViewModels/MainWindowViewModel.cs @@ -224,13 +224,13 @@ private void BuildServices() }); serviceCollection.AddSingleton(); - serviceCollection.AddSingleton(); + serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); - serviceCollection.AddTransient(); + serviceCollection.AddTransient(); ServiceContainer.Instance = serviceCollection.BuildServiceProvider(); diff --git a/ScreenCast.Linux/Program.cs b/ScreenCast.Linux/Program.cs index 7c0bc683f..93339faf5 100644 --- a/ScreenCast.Linux/Program.cs +++ b/ScreenCast.Linux/Program.cs @@ -60,14 +60,14 @@ private static void BuildServices() }); serviceCollection.AddSingleton(); - serviceCollection.AddSingleton(); + serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); - serviceCollection.AddTransient(); + serviceCollection.AddTransient(); ServiceContainer.Instance = serviceCollection.BuildServiceProvider(); } diff --git a/ScreenCast.Linux/Services/X11Input.cs b/ScreenCast.Linux/Services/KeyboardMouseInputLinux.cs similarity index 98% rename from ScreenCast.Linux/Services/X11Input.cs rename to ScreenCast.Linux/Services/KeyboardMouseInputLinux.cs index b11cf963a..27e99152e 100644 --- a/ScreenCast.Linux/Services/X11Input.cs +++ b/ScreenCast.Linux/Services/KeyboardMouseInputLinux.cs @@ -10,9 +10,9 @@ namespace Remotely.ScreenCast.Linux.Services { - public class X11Input : IKeyboardMouseInput + public class KeyboardMouseInputLinux : IKeyboardMouseInput { - public X11Input() + public KeyboardMouseInputLinux() { Display = LibX11.XOpenDisplay(null); } diff --git a/ScreenCast.Linux/Services/X11Capture.cs b/ScreenCast.Linux/Services/ScreenCapturerLinux.cs similarity index 98% rename from ScreenCast.Linux/Services/X11Capture.cs rename to ScreenCast.Linux/Services/ScreenCapturerLinux.cs index f6fb76c0d..9a989da32 100644 --- a/ScreenCast.Linux/Services/X11Capture.cs +++ b/ScreenCast.Linux/Services/ScreenCapturerLinux.cs @@ -11,10 +11,10 @@ namespace Remotely.ScreenCast.Linux.Services { - public class X11Capture : IScreenCapturer + public class ScreenCapturerLinux : IScreenCapturer { private readonly Dictionary x11Screens = new Dictionary(); - public X11Capture() + public ScreenCapturerLinux() { Display = LibX11.XOpenDisplay(null); Init(); diff --git a/ScreenCast.Win/Services/ScreenCapturerWin.cs b/ScreenCast.Win/Services/ScreenCapturerWin.cs index ea4caebad..19bcd3260 100644 --- a/ScreenCast.Win/Services/ScreenCapturerWin.cs +++ b/ScreenCast.Win/Services/ScreenCapturerWin.cs @@ -77,20 +77,14 @@ public ScreenCapturerWin() public Bitmap PreviousFrame { get; set; } public string SelectedScreen { get; private set; } = Screen.PrimaryScreen.DeviceName; private Graphics Graphic { get; set; } + public void Dispose() { - foreach (var output in directxScreens.Values) - { - output.Dispose(); - } - directxScreens.Clear(); - device?.Dispose(); - adapter?.Dispose(); - factory?.Dispose(); + DisposeDirectX(); + CurrentFrame?.Dispose(); PreviousFrame?.Dispose(); } - public IEnumerable GetDisplayNames() => Screen.AllScreens.Select(x => x.DeviceName); public void GetNextFrame() @@ -146,6 +140,7 @@ public void Init() InitBitBlt(); InitDirectX(); } + public void SetSelectedScreen(string displayName) { if (displayName == SelectedScreen) @@ -167,6 +162,17 @@ public void SetSelectedScreen(string displayName) ScreenChanged?.Invoke(this, CurrentScreenBounds); } + private void DisposeDirectX() + { + foreach (var output in directxScreens.Values) + { + output.Dispose(); + } + directxScreens.Clear(); + device?.Dispose(); + adapter?.Dispose(); + factory?.Dispose(); + } private void GetBitBltFrame() { try @@ -268,6 +274,7 @@ private void GetDirectXFrame() private void InitBitBlt() { + bitBltScreens.Clear(); Graphic = Graphics.FromImage(CurrentFrame); for (var i = 0; i < Screen.AllScreens.Length; i++) { @@ -276,7 +283,7 @@ private void InitBitBlt() } private void InitDirectX() { - Dispose(); + DisposeDirectX(); factory = new Factory1();