예제 #1
0
        private async void OnControlAssumed(object sender, ClientConnectionChangedEventArgs e)
        {
            await EnsureInitialized();

            await mutableStateLock.WaitAsync();

            string desktopName = e.DesktopName.NormalizeDesktopName();

            if (localState is LocalState.Controlling controlling)
            {
                var client = await workspaceNetwork.GetClientDesktop(controlling.ActiveDesktop.Name);

                if (client != null)
                {
                    DebugMessage($"controlling {controlling.ActiveDesktop.Name}, relinquishing");
                    await client.RelinquishControl();
                }
            }

            HashSet <string> by;

            if (localState is LocalState.Controlled controlled)
            {
                by = new HashSet <string>(controlled.By);
            }
            else
            {
                by = new HashSet <string>();
            }
            DebugMessage($"adding {desktopName} to controlled by");
            by.Add(desktopName);
            localState = new LocalState.Controlled(by);
            DebugMessage("unblocking local input");
            inputManager.BlockInput(false);

            mutableStateLock.Release();
        }