public async Task <bool> Start() { _hook.Init(); ScreenConfiguration configuration = new ScreenConfiguration(); //there is some kind of dpi awareness bug here on windows. not sure exactly what's up. var displays = _hook.GetDisplays(); var count = displays.Count; var display = displays[0]; var s = configuration.AddScreen(display, display.GetDpi(), state.ClientName); for (int i = 1; i < count; i++) { display = displays[i]; s = configuration.AddScreenRight(s, display, display.GetDpi(), state.ClientName); } _connection.Start(); #if QUEUE_CLIENT _dispatcher.StartDispatcher(); #endif var localScreens = configuration.AllScreen; await _connection.Send(new CheckInMessage(state.ClientName, localScreens).GetBytes()); var checkIn = await _connection.WaitForCheckIn(); // server screens var screens = checkIn.Screens; ScreenConfiguration screenConfiguration = _screen.ScreenConfiguration; screenConfiguration.AddScreens(screens); screenConfiguration.AddScreensRight(localScreens); // Focus Current Client state.CurrentClientFocused = true; _hook.Hook.SetMousePos(state.LastPositionX, state.LastPositionY); _hook.Start(); return(true); }
void OnScreenConfig(IReadOnlyList <VirtualScreen> screens) { ScreenConfiguration screenConfiguration = _screen.ScreenConfiguration; screenConfiguration.AddScreensRight(screens); if (screenConfiguration.ValidVirtualCoordinate(state.VirtualX, state.VirtualY) != null) { return; } //coordinates are invalid, grab a screen var s = screenConfiguration.GetFurthestLeft(); state.VirtualX = s.X; state.VirtualY = s.Y; if (s.Client != state.ClientName) { return; } //set this local client to have 0,0 coords. then update the other clients with the new virtual position. state.LastPositionX = 0; state.LastPositionY = 0; _hook.SetMousePos(0, 0); }