mirror of
https://github.com/immense/Remotely.git
synced 2025-10-26 11:27:15 +00:00
Fix monitor switching.
This commit is contained in:
parent
308e3fa938
commit
def7f558a0
@ -2,7 +2,7 @@
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:Remotely.Desktop.Win"
|
||||
StartupUri="MainWindow.xaml" DispatcherUnhandledException="Application_DispatcherUnhandledException" Exit="Application_Exit" Startup="Application_Startup">
|
||||
StartupUri="MainWindow.xaml" DispatcherUnhandledException="Application_DispatcherUnhandledException" Startup="Application_Startup">
|
||||
<Application.Resources>
|
||||
<Style x:Key="TitlebarButton" TargetType="Button">
|
||||
<Setter Property="Background" Value="#FF464646"></Setter>
|
||||
|
||||
@ -36,17 +36,5 @@ namespace Remotely.Desktop.Win
|
||||
Environment.Exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
private void Application_Exit(object sender, ExitEventArgs e)
|
||||
{
|
||||
var conductor = ServiceContainer.Instance.GetService<Conductor>();
|
||||
foreach (var viewer in conductor.Viewers.Values)
|
||||
{
|
||||
viewer.DisconnectRequested = true;
|
||||
conductor.InvokeViewerRemoved(viewer.ViewerConnectionID);
|
||||
}
|
||||
System.Windows.Forms.Application.Exit();
|
||||
Environment.Exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,6 +28,7 @@ namespace Remotely.Desktop.Win.ViewModels
|
||||
private string sessionID;
|
||||
public MainWindowViewModel()
|
||||
{
|
||||
Application.Current.Exit += Application_Exit;
|
||||
Current = this;
|
||||
|
||||
BuildServices();
|
||||
@ -43,6 +44,7 @@ namespace Remotely.Desktop.Win.ViewModels
|
||||
}
|
||||
|
||||
public static MainWindowViewModel Current { get; private set; }
|
||||
|
||||
public static IServiceProvider Services => ServiceContainer.Instance;
|
||||
|
||||
public ICommand ChangeServerCommand
|
||||
@ -58,6 +60,7 @@ namespace Remotely.Desktop.Win.ViewModels
|
||||
}
|
||||
|
||||
public Conductor Conductor { get; }
|
||||
|
||||
public CursorIconWatcher CursorIconWatcher { get; private set; }
|
||||
|
||||
public ICommand ElevateToAdminCommand
|
||||
@ -146,6 +149,7 @@ namespace Remotely.Desktop.Win.ViewModels
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public string SessionID
|
||||
{
|
||||
get => sessionID;
|
||||
@ -157,11 +161,18 @@ namespace Remotely.Desktop.Win.ViewModels
|
||||
}
|
||||
|
||||
public ObservableCollection<Viewer> Viewers { get; } = new ObservableCollection<Viewer>();
|
||||
|
||||
public void CopyLink()
|
||||
{
|
||||
Clipboard.SetText($"{Host}/RemoteControl?sessionID={SessionID?.Replace(" ", "")}");
|
||||
}
|
||||
|
||||
public async Task GetSessionID()
|
||||
{
|
||||
await Conductor.CasterSocket.SendDeviceInfo(Conductor.ServiceID, Environment.MachineName, Conductor.DeviceID);
|
||||
await Conductor.CasterSocket.GetSessionID();
|
||||
}
|
||||
|
||||
public async Task Init()
|
||||
{
|
||||
SessionID = "Retrieving...";
|
||||
@ -198,7 +209,7 @@ namespace Remotely.Desktop.Win.ViewModels
|
||||
});
|
||||
};
|
||||
|
||||
Conductor.CasterSocket.Connection.Reconnected += async (arg) =>
|
||||
Conductor.CasterSocket.Connection.Reconnected += async (arg) =>
|
||||
{
|
||||
await GetSessionID();
|
||||
};
|
||||
@ -213,12 +224,6 @@ namespace Remotely.Desktop.Win.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public async Task GetSessionID()
|
||||
{
|
||||
await Conductor.CasterSocket.SendDeviceInfo(Conductor.ServiceID, Environment.MachineName, Conductor.DeviceID);
|
||||
await Conductor.CasterSocket.GetSessionID();
|
||||
}
|
||||
|
||||
public void PromptForHostName()
|
||||
{
|
||||
var prompt = new HostNamePrompt();
|
||||
@ -242,6 +247,17 @@ namespace Remotely.Desktop.Win.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private void Application_Exit(object sender, ExitEventArgs e)
|
||||
{
|
||||
App.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
foreach (var viewer in Viewers)
|
||||
{
|
||||
viewer.DisconnectRequested = true;
|
||||
}
|
||||
Viewers.Clear();
|
||||
});
|
||||
}
|
||||
private void BuildServices()
|
||||
{
|
||||
var serviceCollection = new ServiceCollection();
|
||||
|
||||
@ -185,20 +185,25 @@ namespace Remotely.ScreenCast.Win.Services
|
||||
var device = directxScreens[SelectedScreen].Device;
|
||||
var texture2D = directxScreens[SelectedScreen].Texture2D;
|
||||
|
||||
|
||||
// Try to get duplicated frame within given time is ms
|
||||
var result = duplicatedOutput.TryAcquireNextFrame(100,
|
||||
var result = duplicatedOutput.TryAcquireNextFrame(20,
|
||||
out var duplicateFrameInformation,
|
||||
out var screenResource);
|
||||
|
||||
if (result.Failure && result.Code != SharpDX.DXGI.ResultCode.WaitTimeout.Code)
|
||||
if (result.Failure)
|
||||
{
|
||||
Logger.Write($"TryAcquireFrame error. Code: {result.Code}");
|
||||
NeedsInit = true;
|
||||
return;
|
||||
if (result.Code == SharpDX.DXGI.ResultCode.WaitTimeout.Code)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Write($"TryAcquireFrame error. Code: {result.Code}");
|
||||
NeedsInit = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (duplicateFrameInformation.AccumulatedFrames == 0)
|
||||
{
|
||||
try
|
||||
|
||||
@ -442,7 +442,7 @@ export function UpdateDisplays(selectedDisplay, displayNames) {
|
||||
}
|
||||
ScreenSelectBar.appendChild(button);
|
||||
button.onclick = (ev) => {
|
||||
this.SendSelectScreen(displayNames[i]);
|
||||
MainRc.MessageSender.SendSelectScreen(displayNames[i]);
|
||||
document.querySelectorAll("#screenSelectBar .horizontal-bar-button").forEach(button => {
|
||||
button.classList.remove("toggled");
|
||||
});
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -489,7 +489,7 @@ export function UpdateDisplays(selectedDisplay: string, displayNames: string[])
|
||||
}
|
||||
ScreenSelectBar.appendChild(button);
|
||||
button.onclick = (ev: MouseEvent) => {
|
||||
this.SendSelectScreen(displayNames[i]);
|
||||
MainRc.MessageSender.SendSelectScreen(displayNames[i]);
|
||||
document.querySelectorAll("#screenSelectBar .horizontal-bar-button").forEach(button => {
|
||||
button.classList.remove("toggled");
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user