Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ready for Review - [Mouse Without Borders] - refactoring "Common" classes (Part 4) - #35155 #37579

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Next Next commit
[MouseWithoutBorders] - moving Common.Event.cs -> Core\Event.cs - #35155
  • Loading branch information
mikeclayton committed Feb 21, 2025
commit c31e671e6ea37c91e0e1642b5db9bd957f4c7bd0
277 changes: 0 additions & 277 deletions src/modules/MouseWithoutBorders/App/Class/Common.Event.cs

This file was deleted.

4 changes: 2 additions & 2 deletions src/modules/MouseWithoutBorders/App/Class/Common.Helper.cs
Original file line number Diff line number Diff line change
@@ -103,9 +103,9 @@ private static void HelperThread()
Logger.LogDebug($"+++++ Moving mouse to {MachineStuff.SwitchLocation.X}, {MachineStuff.SwitchLocation.Y}");

// MaxXY = 65535 so 100k is safe.
if (MachineStuff.SwitchLocation.X > XY_BY_PIXEL - 100000 || MachineStuff.SwitchLocation.Y > XY_BY_PIXEL - 100000)
if (MachineStuff.SwitchLocation.X > Event.XY_BY_PIXEL - 100000 || MachineStuff.SwitchLocation.Y > Event.XY_BY_PIXEL - 100000)
{
InputSimulation.MoveMouse(MachineStuff.SwitchLocation.X - XY_BY_PIXEL, MachineStuff.SwitchLocation.Y - XY_BY_PIXEL);
InputSimulation.MoveMouse(MachineStuff.SwitchLocation.X - Event.XY_BY_PIXEL, MachineStuff.SwitchLocation.Y - Event.XY_BY_PIXEL);
}
else
{
24 changes: 13 additions & 11 deletions src/modules/MouseWithoutBorders/App/Class/Common.cs
Original file line number Diff line number Diff line change
@@ -114,7 +114,9 @@ internal Common()
internal const int NETWORK_STREAM_BUF_SIZE = 1024 * 1024;
internal static readonly EventWaitHandle EvSwitch = new(false, EventResetMode.AutoReset);
private static Point lastPos;
private static int switchCount;
#pragma warning disable SA1307 // Accessible fields should begin with upper-case names
internal static int switchCount;
#pragma warning restore SA1307
private static long lastReconnectByHotKeyTime;
private static int tcpPort;
private static bool secondOpenSocketTry;
@@ -543,7 +545,7 @@ internal static void SendNextMachine(ID hostMachine, ID nextMachine, Point reque
internal static void SendAwakeBeat()
{
if (!Common.RunOnLogonDesktop && !Common.RunOnScrSaverDesktop && Common.IsMyDesktopActive() &&
Setting.Values.BlockScreenSaver && lastRealInputEventCount != Common.RealInputEventCount)
Setting.Values.BlockScreenSaver && lastRealInputEventCount != Event.RealInputEventCount)
{
SendPackage(ID.ALL, PackageType.Awake);
}
@@ -552,21 +554,21 @@ internal static void SendAwakeBeat()
SendHeartBeat();
}

lastInputEventCount = Common.InputEventCount;
lastRealInputEventCount = Common.RealInputEventCount;
lastInputEventCount = Event.InputEventCount;
lastRealInputEventCount = Event.RealInputEventCount;
}

internal static void HumanBeingDetected()
{
if (lastInputEventCount == Common.InputEventCount)
if (lastInputEventCount == Event.InputEventCount)
{
if (!Common.RunOnLogonDesktop && !Common.RunOnScrSaverDesktop && Common.IsMyDesktopActive())
{
PokeMyself();
}
}

lastInputEventCount = Common.InputEventCount;
lastInputEventCount = Event.InputEventCount;
}

private static void PokeMyself()
@@ -581,7 +583,7 @@ private static void PokeMyself()
InputSimulation.MoveMouseRelative(-x, -y);
Thread.Sleep(50);

if (lastInputEventCount != Common.InputEventCount)
if (lastInputEventCount != Event.InputEventCount)
{
break;
}
@@ -590,8 +592,8 @@ private static void PokeMyself()

internal static void InitLastInputEventCount()
{
lastInputEventCount = Common.InputEventCount;
lastRealInputEventCount = Common.RealInputEventCount;
lastInputEventCount = Event.InputEventCount;
lastRealInputEventCount = Event.RealInputEventCount;
}

internal static void SendHello()
@@ -956,8 +958,8 @@ internal static void SkSend(DATA data, uint? exceptDes, bool includeHandShakingS
{
// SwitchToMachine(MachineName.Trim());
MachineStuff.NewDesMachineID = DesMachineID = MachineID;
MachineStuff.SwitchLocation.X = XY_BY_PIXEL + myLastX;
MachineStuff.SwitchLocation.Y = XY_BY_PIXEL + myLastY;
MachineStuff.SwitchLocation.X = Event.XY_BY_PIXEL + Event.myLastX;
MachineStuff.SwitchLocation.Y = Event.XY_BY_PIXEL + Event.myLastY;
MachineStuff.SwitchLocation.ResetCount();
EvSwitch.Set();
}
Loading
Oops, something went wrong.