Skip to content

Commit

Permalink
[MouseWithoutBorders] - moving Common.Helper.cs -> Core\Helper.cs - m…
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeclayton committed Feb 21, 2025
1 parent e4288d0 commit f208794
Show file tree
Hide file tree
Showing 13 changed files with 572 additions and 568 deletions.
526 changes: 0 additions & 526 deletions src/modules/MouseWithoutBorders/App/Class/Common.Helper.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ internal static void SetupMachineNameAndID()

internal static void Init()
{
_ = Common.GetUserName();
_ = Helper.GetUserName();
Common.GeneratedKey = true;

try
Expand Down Expand Up @@ -148,7 +148,7 @@ internal static void Init()

private static void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
{
Common.WndProcCounter++;
Helper.WndProcCounter++;

if (e.Mode is PowerModes.Resume or PowerModes.Suspend)
{
Expand All @@ -167,21 +167,21 @@ private static void CreateHelperThreads()
watchDogThread.Start();
*/

helper = new Thread(new ThreadStart(HelperThread), "Helper Thread");
helper = new Thread(new ThreadStart(Helper.HelperThread), "Helper Thread");
helper.SetApartmentState(ApartmentState.STA);
helper.Start();
}

private static void AskHelperThreadsToExit(int waitTime)
{
signalHelperToExit = true;
signalWatchDogToExit = true;
Helper.signalHelperToExit = true;
Helper.signalWatchDogToExit = true;
_ = EvSwitch.Set();

int c = 0;
if (helper != null && c < waitTime)
{
while (signalHelperToExit)
while (Helper.signalHelperToExit)
{
Thread.Sleep(1);
}
Expand Down Expand Up @@ -251,7 +251,7 @@ internal static void ReleaseAllKeys()
private static void NetworkChange_NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
{
Logger.LogDebug("NetworkAvailabilityEventArgs.IsAvailable: " + e.IsAvailable.ToString(CultureInfo.InvariantCulture));
Common.WndProcCounter++;
Helper.WndProcCounter++;
ScheduleReopenSocketsDueToNetworkChanges(!e.IsAvailable);
}

Expand Down
2 changes: 1 addition & 1 deletion src/modules/MouseWithoutBorders/App/Class/Common.WinAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ internal static void CheckForDesktopSwitchEvent(bool cleanupIfExit)
{
if (!IsMyDesktopActive() || Common.CurrentProcess.SessionId != NativeMethods.WTSGetActiveConsoleSessionId())
{
Common.RunDDHelper(true);
Helper.RunDDHelper(true);
int waitCount = 20;

while (NativeMethods.WTSGetActiveConsoleSessionId() == 0xFFFFFFFF && waitCount > 0)
Expand Down
12 changes: 7 additions & 5 deletions src/modules/MouseWithoutBorders/App/Class/Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,10 @@ internal Common()
private static bool runOnLogonDesktop;
private static bool runOnScrSaverDesktop;

private static int[] toggleIcons;
private static int toggleIconsIndex;
#pragma warning disable SA1307 // Accessible fields should begin with upper-case letter
internal static int[] toggleIcons;
internal static int toggleIconsIndex;
#pragma warning restore SA1307
internal const int TOGGLE_ICONS_SIZE = 4;
internal const int ICON_ONE = 0;
internal const int ICON_ALL = 1;
Expand Down Expand Up @@ -667,7 +669,7 @@ internal static void PrepareScreenCapture()
{
Common.DoSomethingInUIThread(() =>
{
if (!DragDrop.MouseDown && Common.SendMessageToHelper(0x401, IntPtr.Zero, IntPtr.Zero) > 0)
if (!DragDrop.MouseDown && Helper.SendMessageToHelper(0x401, IntPtr.Zero, IntPtr.Zero) > 0)
{
Common.MMSleep(0.2);
InputSimulation.SendKey(new KEYBDDATA() { wVk = (int)VK.SNAPSHOT });
Expand All @@ -676,14 +678,14 @@ internal static void PrepareScreenCapture()
Logger.LogDebug("PrepareScreenCapture: SNAPSHOT simulated.");

_ = NativeMethods.MoveWindow(
(IntPtr)NativeMethods.FindWindow(null, Common.HELPER_FORM_TEXT),
(IntPtr)NativeMethods.FindWindow(null, Helper.HELPER_FORM_TEXT),
MachineStuff.DesktopBounds.Left,
MachineStuff.DesktopBounds.Top,
MachineStuff.DesktopBounds.Right - MachineStuff.DesktopBounds.Left,
MachineStuff.DesktopBounds.Bottom - MachineStuff.DesktopBounds.Top,
false);

_ = Common.SendMessageToHelper(0x406, IntPtr.Zero, IntPtr.Zero, false);
_ = Helper.SendMessageToHelper(0x406, IntPtr.Zero, IntPtr.Zero, false);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/modules/MouseWithoutBorders/App/Class/InputHook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ private int MouseHookProc(int nCode, int wParam, IntPtr lParam)
local = true;
if (Common.MainFormVisible && !DragDrop.IsDropping)
{
Common.MainFormDot();
Helper.MainFormDot();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ internal static uint SendMouse(MOUSEDATA md)

if (Common.MainFormVisible && !DragDrop.IsDropping)
{
Common.MainFormDot();
Helper.MainFormDot();
}

return rv;
Expand Down
5 changes: 3 additions & 2 deletions src/modules/MouseWithoutBorders/App/Class/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
using StreamJsonRpc;

using Logger = MouseWithoutBorders.Core.Logger;
using SettingsHelper = Microsoft.PowerToys.Settings.UI.Library.Utilities.Helper;
using Thread = MouseWithoutBorders.Core.Thread;

[module: SuppressMessage("Microsoft.MSInternal", "CA904:DeclareTypesInMicrosoftOrSystemNamespace", Scope = "namespace", Target = "MouseWithoutBorders", Justification = "Dotnet port with style preservation")]
Expand Down Expand Up @@ -128,7 +129,7 @@ private static void Main()
{
if (args.Length > 2)
{
Helper.UserLocalAppDataPath = args[2].Trim();
SettingsHelper.UserLocalAppDataPath = args[2].Trim();
}
}

Expand Down Expand Up @@ -235,7 +236,7 @@ private static void Main()
Application.SetCompatibleTextRenderingDefault(false);

Common.Init();
Common.WndProcCounter++;
Core.Helper.WndProcCounter++;

var formScreen = new FrmScreen();

Expand Down
3 changes: 2 additions & 1 deletion src/modules/MouseWithoutBorders/App/Class/Setting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
using Settings.UI.Library.Attributes;

using Lock = System.Threading.Lock;
using SettingsHelper = Microsoft.PowerToys.Settings.UI.Library.Utilities.Helper;

[module: SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "MouseWithoutBorders.Properties.Setting.Values.#LoadIntSetting(System.String,System.Int32)", Justification = "Dotnet port with style preservation")]
[module: SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "MouseWithoutBorders.Properties.Setting.Values.#SaveSetting(System.String,System.Object)", Justification = "Dotnet port with style preservation")]
Expand Down Expand Up @@ -193,7 +194,7 @@ internal Settings()
{
_settingsUtils = new SettingsUtils();

_watcher = Helper.GetFileWatcher("MouseWithoutBorders", "settings.json", () =>
_watcher = SettingsHelper.GetFileWatcher("MouseWithoutBorders", "settings.json", () =>
{
try
{
Expand Down
2 changes: 1 addition & 1 deletion src/modules/MouseWithoutBorders/App/Core/DragDrop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ internal static void DragDropStep04()
{
if (!IsDropping)
{
IntPtr h = (IntPtr)NativeMethods.FindWindow(null, Common.HELPER_FORM_TEXT);
IntPtr h = (IntPtr)NativeMethods.FindWindow(null, Helper.HELPER_FORM_TEXT);
if (h.ToInt32() > 0)
{
_ = Interlocked.Exchange(ref dragDropStep05ExCalledByIpc, 0);
Expand Down
Loading

0 comments on commit f208794

Please sign in to comment.