2023-05-15 23:32:26 +01:00
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System ;
using System.Collections ;
using System.Collections.Generic ;
using System.Diagnostics ;
using System.Diagnostics.CodeAnalysis ;
using System.Globalization ;
using System.IO ;
using System.IO.Abstractions ;
using System.Linq ;
using System.Security.Cryptography ;
2024-07-22 16:49:45 +02:00
using System.Text.Json.Serialization ;
2023-05-15 23:32:26 +01:00
using System.Threading.Tasks ;
using System.Windows.Forms ;
2024-09-16 16:09:43 -04:00
2024-07-22 16:49:45 +02:00
using global : : PowerToys . GPOWrapper ;
2023-05-15 23:32:26 +01:00
using Microsoft.PowerToys.Settings.UI.Library ;
using Microsoft.PowerToys.Settings.UI.Library.Utilities ;
// <summary>
// Application settings.
// </summary>
// <history>
// 2008 created by Truong Do (ductdo).
// 2009-... modified by Truong Do (TruongDo).
// 2023- Included in PowerToys.
// </history>
using Microsoft.Win32 ;
2024-10-18 17:32:08 +01:00
using MouseWithoutBorders.Core ;
2024-04-02 01:09:47 +02:00
using Settings.UI.Library.Attributes ;
2023-05-15 23:32:26 +01:00
2025-01-17 15:41:39 +00:00
using Lock = System . Threading . Lock ;
2025-03-17 22:05:36 +00:00
using SettingsHelper = Microsoft . PowerToys . Settings . UI . Library . Utilities . Helper ;
2025-01-17 15:41:39 +00:00
2023-05-15 23:32:26 +01:00
[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")]
[module: SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "MouseWithoutBorders.Properties.Setting.Values.#LoadStringSetting(System.String,System.String)", Justification = "Dotnet port with style preservation")]
[module: SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "MouseWithoutBorders.Properties.Setting.Values.#SaveSettingQWord(System.String,System.Int64)", Justification = "Dotnet port with style preservation")]
namespace MouseWithoutBorders.Class
{
internal class Settings
{
internal bool Changed ;
2023-12-28 13:37:13 +03:00
private readonly SettingsUtils _settingsUtils ;
2024-11-13 12:36:45 -05:00
private readonly Lock _loadingSettingsLock = new Lock ( ) ;
2023-05-15 23:32:26 +01:00
private readonly IFileSystemWatcher _watcher ;
private MouseWithoutBordersProperties _properties ;
private MouseWithoutBordersSettings _settings ;
// Avoid instantly saving every change to the file when updating properties.
public bool PauseInstantSaving { get ; set ; }
private void UpdateSettingsFromJson ( )
{
try
{
if ( ! _settingsUtils . SettingsExists ( "MouseWithoutBorders" ) )
{
var defaultSettings = new MouseWithoutBordersSettings ( ) ;
if ( ! Common . RunOnLogonDesktop )
{
defaultSettings . Save ( _settingsUtils ) ;
}
}
var settings = _settingsUtils . GetSettingsOrDefault < MouseWithoutBordersSettings > ( "MouseWithoutBorders" ) ;
if ( settings ! = null )
{
PauseInstantSaving = true ;
var last_properties = _properties ;
_settings = settings ;
_properties = settings . Properties ;
// Keep track of the need to resend the machine matrix.
bool shouldSendMachineMatrix = false ;
// Keep track of the need to save into the settings file.
bool shouldSaveNewSettingsValues = false ;
if ( last_properties ! = null )
{
// Same as in CheckBoxCircle_CheckedChanged
if ( last_properties . WrapMouse ! = _settings . Properties . WrapMouse )
{
shouldSendMachineMatrix = true ;
}
// Same as CheckBoxDrawMouse_CheckedChanged
if ( last_properties . DrawMouseCursor ! = _settings . Properties . DrawMouseCursor & & ! _settings . Properties . DrawMouseCursor )
{
CustomCursor . ShowFakeMouseCursor ( int . MinValue , int . MinValue ) ;
}
if ( ! Enumerable . SequenceEqual ( last_properties . MachineMatrixString , _settings . Properties . MachineMatrixString ) )
{
_properties . MachineMatrixString = _settings . Properties . MachineMatrixString ;
2025-02-21 08:31:44 +00:00
MachineStuff . MachineMatrix = null ; // Forces read next time it's needed.
2023-05-15 23:32:26 +01:00
shouldSendMachineMatrix = true ;
}
var shouldReopenSockets = false ;
if ( Common . MyKey ! = _properties . SecurityKey . Value )
{
Common . MyKey = _properties . SecurityKey . Value ;
shouldReopenSockets = true ;
}
if ( shouldReopenSockets )
{
SocketStuff . InvalidKeyFound = false ;
Common . ReopenSocketDueToReadError = true ;
Common . ReopenSockets ( true ) ;
}
if ( shouldSendMachineMatrix )
{
2025-02-21 08:31:44 +00:00
MachineStuff . SendMachineMatrix ( ) ;
2023-05-15 23:32:26 +01:00
shouldSaveNewSettingsValues = true ;
}
if ( shouldSaveNewSettingsValues )
{
SaveSettings ( ) ;
}
}
}
}
catch ( IOException ex )
{
2024-10-18 17:32:08 +01:00
EventLogger . LogEvent ( $"Failed to read settings: {ex.Message}" , System . Diagnostics . EventLogEntryType . Error ) ;
2023-05-15 23:32:26 +01:00
}
PauseInstantSaving = false ;
}
public void SaveSettings ( )
{
if ( ! Common . RunOnLogonDesktop )
{
SaveSettingsToJson ( ( MouseWithoutBordersProperties ) _properties . Clone ( ) ) ;
}
}
private void SaveSettingsToJson ( MouseWithoutBordersProperties properties_to_save )
{
_settings . Properties = properties_to_save ;
_ = Task . Factory . StartNew (
( ) = >
{
bool saved = false ;
for ( int i = 0 ; i < 5 ; + + i )
{
try
{
lock ( _loadingSettingsLock )
{
_settings . Save ( _settingsUtils ) ;
}
saved = true ;
}
catch ( IOException ex )
{
2024-10-18 17:32:08 +01:00
EventLogger . LogEvent ( $"Failed to write settings: {ex.Message}" , System . Diagnostics . EventLogEntryType . Error ) ;
2023-05-15 23:32:26 +01:00
}
if ( saved )
{
break ;
}
else
{
Thread . Sleep ( 500 ) ;
}
}
} ,
System . Threading . CancellationToken . None ,
TaskCreationOptions . None ,
TaskScheduler . Default ) ;
}
internal Settings ( )
{
_settingsUtils = new SettingsUtils ( ) ;
2025-03-17 22:05:36 +00:00
_watcher = SettingsHelper . GetFileWatcher ( "MouseWithoutBorders" , "settings.json" , ( ) = >
2023-05-15 23:32:26 +01:00
{
try
{
UpdateSettingsFromJson ( ) ;
}
catch ( Exception ex )
{
2024-10-18 17:32:08 +01:00
EventLogger . LogEvent ( $"Failed to update settings: {ex.Message}" , System . Diagnostics . EventLogEntryType . Error ) ;
2023-05-15 23:32:26 +01:00
}
} ) ;
UpdateSettingsFromJson ( ) ;
}
internal string Username { get ; set ; }
internal bool IsMyKeyRandom { get ; set ; }
internal string MachineMatrixString
{
get
{
lock ( _loadingSettingsLock )
{
return string . Join ( "," , _properties . MachineMatrixString ) ;
}
}
set
{
lock ( _loadingSettingsLock )
{
_properties . MachineMatrixString = new List < string > ( value . Split ( "," ) ) ;
if ( ! PauseInstantSaving )
{
SaveSettings ( ) ;
}
}
}
}
internal string MachinePoolString
{
get
{
lock ( _loadingSettingsLock )
{
return _properties . MachinePool . Value ;
}
}
set
{
lock ( _loadingSettingsLock )
{
if ( ! value . Equals ( _properties . MachinePool . Value , StringComparison . OrdinalIgnoreCase ) )
{
_properties . MachinePool . Value = value ;
}
}
}
}
internal string MyID = > Application . ProductName + " Application" ;
internal string MyIdEx = > Application . ProductName + " Application-Ex" ;
internal bool ShareClipboard
{
get
{
2024-07-22 16:49:45 +02:00
if ( GPOWrapper . GetConfiguredMwbClipboardSharingEnabledValue ( ) = = GpoRuleConfigured . Disabled )
{
return false ;
}
2023-05-15 23:32:26 +01:00
lock ( _loadingSettingsLock )
{
return _properties . ShareClipboard ;
}
}
set
{
2024-07-22 16:49:45 +02:00
if ( ShareClipboardIsGpoConfigured )
{
return ;
}
2023-05-15 23:32:26 +01:00
lock ( _loadingSettingsLock )
{
_properties . ShareClipboard = value ;
}
}
}
2024-07-22 16:49:45 +02:00
[CmdConfigureIgnore]
[JsonIgnore]
internal bool ShareClipboardIsGpoConfigured = > GPOWrapper . GetConfiguredMwbClipboardSharingEnabledValue ( ) = = GpoRuleConfigured . Disabled ;
2023-05-15 23:32:26 +01:00
internal bool TransferFile
{
get
{
2024-07-22 16:49:45 +02:00
if ( GPOWrapper . GetConfiguredMwbFileTransferEnabledValue ( ) = = GpoRuleConfigured . Disabled )
{
return false ;
}
2023-05-15 23:32:26 +01:00
lock ( _loadingSettingsLock )
{
return _properties . TransferFile ;
}
}
set
{
2024-07-22 16:49:45 +02:00
if ( TransferFileIsGpoConfigured )
{
return ;
}
2023-05-15 23:32:26 +01:00
_properties . TransferFile = value ;
}
}
2024-07-22 16:49:45 +02:00
[CmdConfigureIgnore]
[JsonIgnore]
internal bool TransferFileIsGpoConfigured = > GPOWrapper . GetConfiguredMwbFileTransferEnabledValue ( ) = = GpoRuleConfigured . Disabled ;
2023-05-15 23:32:26 +01:00
internal bool MatrixOneRow
{
get
{
lock ( _loadingSettingsLock )
{
return _properties . MatrixOneRow ;
}
}
set
{
lock ( _loadingSettingsLock )
{
2023-05-29 18:00:23 +02:00
_properties . MatrixOneRow = value ;
2023-05-15 23:32:26 +01:00
if ( ! PauseInstantSaving )
{
SaveSettings ( ) ;
}
}
}
}
internal bool MatrixCircle
{
get
{
lock ( _loadingSettingsLock )
{
return _properties . WrapMouse ;
}
}
set
{
lock ( _loadingSettingsLock )
{
_properties . WrapMouse = value ;
if ( ! PauseInstantSaving )
{
SaveSettings ( ) ;
}
}
}
}
internal int EasyMouse
{
get
{
lock ( _loadingSettingsLock )
{
return _properties . EasyMouse . Value ;
}
}
set
{
lock ( _loadingSettingsLock )
{
_properties . EasyMouse . Value = value ;
if ( ! PauseInstantSaving )
{
// Easy Mouse can be enabled or disabled through a shortcut, so a save is required.
SaveSettings ( ) ;
}
}
}
}
internal bool BlockMouseAtCorners
{
get
{
lock ( _loadingSettingsLock )
{
return _properties . BlockMouseAtScreenCorners ;
}
}
set
{
lock ( _loadingSettingsLock )
{
_properties . BlockMouseAtScreenCorners = value ;
}
}
}
feat(MouseWithoutBorders): Prevent Easy Mouse from moving to another machine when an application is running in fullscreen mode. (#39854)
<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request
This PR adds a new feature to Easy Mouse, it is now possible to toggle a
setting that will prevent Easy Mouse to switch away from the host
machine when the foreground application is running in full screen mode,
requiring the user to first alt tab out of the application before
performing the switch, this also comes with a way to allow the switch on
specific apps.

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist
- [x] **Closes:** #32197
- [x] **Communication:** I've discussed this with core contributors
already. If work hasn't been agreed, this work might be rejected
- [ ] **Tests:** Added/updated and all pass
- [x] **Localization:** All end user facing strings can be localized
- [ ] **Dev docs:** Added/updated
- [ ] **New binaries:** Added on the required places
- [ ] [JSON for
signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [x] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: MicrosoftDocs/windows-dev-docs#5470
<!-- Provide a more detailed description of the PR, other things fixed
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments
This PR changes the way Easy Mouse checks wherever it should move to
another machine, after checking that the corresponding setting is
enabled and that we are trying to move away from the host machine, it
will run a test using native WinAPI methods to get the foreground window
and check if it is running in full screen.
If it is, it will then check the name of the executable against a list
of ignored app configured by the user, if the executable is found in
that list, the switch will be allowed despite the application running in
full screen.
These new settings were moved along with the original Easy Mouse toggle
to a new "Easy Mouse" setting group to avoid cluttering the Keyboard
shortcuts group.
This feature will only work when used from the controller machine, as I
didn't find a way to easily check for running application on a remote
machine that didn't involved touching the sockets, I felt like such a
change would be out of scope for this issue.
<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
I had a hard time writing tests and didn't achieve anything meaningful
enough to be included, I may require some guidance on how to properly
write tests for this project.
I tested my changes by running my modified version of
MouseWithoutBorders on my machines, which I did for a few days now, It
allowed me to catch a few bugs, but it has been running smoothly
otherwise.
My changes didn't seemed to have caused any automated tests to fail.
It may require some additional testing for setups including more than
two machines.
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Kai Tao (from Dev Box) <kaitao@microsoft.com>
Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Gordon Lam (SH) <yeelam@microsoft.com>
2025-08-22 14:42:36 +02:00
internal bool DisableEasyMouseWhenForegroundWindowIsFullscreen
{
get
{
lock ( _loadingSettingsLock )
{
return _properties . DisableEasyMouseWhenForegroundWindowIsFullscreen ;
}
}
set
{
lock ( _loadingSettingsLock )
{
_properties . DisableEasyMouseWhenForegroundWindowIsFullscreen = value ;
}
}
}
internal HashSet < string > EasyMouseFullscreenSwitchBlockExcludedApps
{
get
{
lock ( _loadingSettingsLock )
{
return _properties . EasyMouseFullscreenSwitchBlockExcludedApps . Value ;
}
}
set
{
lock ( _loadingSettingsLock )
{
_properties . EasyMouseFullscreenSwitchBlockExcludedApps . Value = value ;
}
}
}
2023-05-15 23:32:26 +01:00
internal string Enc ( string st , bool dec , DataProtectionScope protectionScope )
{
if ( st = = null | | st . Length < 1 )
{
return string . Empty ;
}
byte [ ] ep = Common . GetBytesU ( st ) ;
byte [ ] rv , st2 ;
if ( dec )
{
st2 = Convert . FromBase64String ( st ) ;
rv = ProtectedData . Unprotect ( st2 , ep , protectionScope ) ;
return Common . GetStringU ( rv ) ;
}
else
{
st2 = Common . GetBytesU ( st ) ;
rv = ProtectedData . Protect ( st2 , ep , protectionScope ) ;
return Convert . ToBase64String ( rv ) ;
}
}
internal string MyKey
{
get
{
lock ( _loadingSettingsLock )
{
if ( _properties . SecurityKey . Value . Length ! = 0 )
{
2024-10-18 17:32:08 +01:00
Logger . LogDebug ( "GETSECKEY: Key was already loaded/set: " + _properties . SecurityKey . Value ) ;
2023-05-15 23:32:26 +01:00
return _properties . SecurityKey . Value ;
}
else
{
string randomKey = Common . CreateDefaultKey ( ) ;
_properties . SecurityKey . Value = randomKey ;
return randomKey ;
}
}
}
set
{
lock ( _loadingSettingsLock )
{
_properties . SecurityKey . Value = value ;
if ( ! PauseInstantSaving )
{
SaveSettings ( ) ;
}
}
}
}
internal int MyKeyDaysToExpire
{
get
{
lock ( _loadingSettingsLock )
{
return int . MaxValue ; // TODO(@yuyoyuppe): do we still need expiration mechanics now?
}
}
}
2024-07-17 15:51:38 +02:00
// Note(@htcfreek): Settings UI CheckBox is disabled in frmMatrix.cs > FrmMatrix_Load()
// Note(@htcfreek): If this settings gets implemented in the future we need a Group Policy for it!
2023-05-15 23:32:26 +01:00
internal bool DisableCAD
{
get
{
return false ;
}
}
2024-07-17 15:51:38 +02:00
// Note(@htcfreek): Settings UI CheckBox is disabled in frmMatrix.cs > FrmMatrix_Load()
// Note(@htcfreek): If this settings gets implemented in the future we need a Group Policy for it!
2023-05-15 23:32:26 +01:00
internal bool HideLogonLogo
{
get
{
return false ;
}
}
internal bool HideMouse
{
get
{
lock ( _loadingSettingsLock )
{
return _properties . HideMouseAtScreenEdge ;
}
}
set
{
lock ( _loadingSettingsLock )
{
_properties . HideMouseAtScreenEdge = value ;
}
}
}
internal bool BlockScreenSaver
{
get
{
2024-07-22 16:49:45 +02:00
if ( GPOWrapper . GetConfiguredMwbDisallowBlockingScreensaverValue ( ) = = GpoRuleConfigured . Enabled )
{
return false ;
}
2023-05-15 23:32:26 +01:00
lock ( _loadingSettingsLock )
{
return _properties . BlockScreenSaverOnOtherMachines ;
}
}
set
{
2024-07-22 16:49:45 +02:00
if ( BlockScreenSaverIsGpoConfigured )
{
return ;
}
2023-05-15 23:32:26 +01:00
lock ( _loadingSettingsLock )
{
_properties . BlockScreenSaverOnOtherMachines = value ;
}
}
}
2024-07-22 16:49:45 +02:00
[CmdConfigureIgnore]
[JsonIgnore]
internal bool BlockScreenSaverIsGpoConfigured = > GPOWrapper . GetConfiguredMwbDisallowBlockingScreensaverValue ( ) = = GpoRuleConfigured . Enabled ;
2023-05-15 23:32:26 +01:00
internal bool MoveMouseRelatively
{
get
{
lock ( _loadingSettingsLock )
{
return _properties . MoveMouseRelatively ;
}
}
set
{
lock ( _loadingSettingsLock )
{
_properties . MoveMouseRelatively = value ;
}
}
}
internal string LastPersonalizeLogonScr
{
get
{
return string . Empty ;
}
}
internal uint DesMachineID
{
get
{
lock ( _loadingSettingsLock )
{
return ( uint ) _properties . MachineID . Value ;
}
}
set
{
lock ( _loadingSettingsLock )
{
_properties . MachineID . Value = ( int ) value ;
}
}
}
internal int LastX
{
get
{
lock ( _loadingSettingsLock )
{
return _properties . LastX . Value ;
}
}
set
{
lock ( _loadingSettingsLock )
{
Common . LastX = value ;
_properties . LastX . Value = value ;
}
}
}
internal int LastY
{
get
{
lock ( _loadingSettingsLock )
{
return _properties . LastY . Value ;
}
}
set
{
lock ( _loadingSettingsLock )
{
Common . LastY = value ;
_properties . LastY . Value = value ;
}
}
}
internal int PackageID
{
get
{
lock ( _loadingSettingsLock )
{
return _properties . PackageID . Value ;
}
}
set
{
lock ( _loadingSettingsLock )
{
_properties . PackageID . Value = value ;
}
}
}
internal bool FirstRun
{
get
{
lock ( _loadingSettingsLock )
{
return _properties . FirstRun ;
}
}
set
{
lock ( _loadingSettingsLock )
{
_properties . FirstRun = value ;
if ( ! PauseInstantSaving )
{
SaveSettings ( ) ;
}
}
}
}
internal int HotKeySwitchMachine
{
get
{
lock ( _loadingSettingsLock )
{
return _properties . HotKeySwitchMachine . Value ;
}
}
set
{
lock ( _loadingSettingsLock )
{
_properties . HotKeySwitchMachine . Value = value ;
}
}
}
2023-07-26 13:46:41 +02:00
internal HotkeySettings HotKeySwitch2AllPC
2023-05-15 23:32:26 +01:00
{
get
{
lock ( _loadingSettingsLock )
{
2023-07-26 13:46:41 +02:00
return _properties . Switch2AllPCShortcut ;
2023-05-15 23:32:26 +01:00
}
}
}
2023-07-26 13:46:41 +02:00
internal HotkeySettings HotKeyToggleEasyMouse
2023-05-15 23:32:26 +01:00
{
get
{
lock ( _loadingSettingsLock )
{
2023-07-26 13:46:41 +02:00
return _properties . ToggleEasyMouseShortcut ;
2023-05-15 23:32:26 +01:00
}
}
set
{
lock ( _loadingSettingsLock )
{
2023-07-26 13:46:41 +02:00
_properties . ToggleEasyMouseShortcut = value ;
2023-05-15 23:32:26 +01:00
}
}
}
2023-07-26 13:46:41 +02:00
internal HotkeySettings HotKeyLockMachine
2023-05-15 23:32:26 +01:00
{
get
{
lock ( _loadingSettingsLock )
{
2023-07-26 13:46:41 +02:00
return _properties . LockMachineShortcut ;
2023-05-15 23:32:26 +01:00
}
}
set
{
lock ( _loadingSettingsLock )
{
2023-07-26 13:46:41 +02:00
_properties . LockMachineShortcut = value ;
2023-05-15 23:32:26 +01:00
}
}
}
2023-07-26 13:46:41 +02:00
internal HotkeySettings HotKeyReconnect
2023-05-15 23:32:26 +01:00
{
get
{
lock ( _loadingSettingsLock )
{
2023-07-26 13:46:41 +02:00
return _properties . ReconnectShortcut ;
2023-05-15 23:32:26 +01:00
}
}
set
{
lock ( _loadingSettingsLock )
{
2023-07-26 13:46:41 +02:00
_properties . ReconnectShortcut = value ;
2023-05-15 23:32:26 +01:00
}
}
}
2023-07-26 13:46:41 +02:00
internal int HotKeyExitMM
{
get
{
return 0 ;
}
}
2023-05-15 23:32:26 +01:00
private int switchCount ;
internal int SwitchCount
{
get
{
return switchCount ;
}
set
{
switchCount = value ;
if ( ! PauseInstantSaving )
{
SaveSettings ( ) ;
}
}
}
internal int DumpObjectsLevel = > 6 ;
internal int TcpPort = > _properties . TCPPort . Value ;
internal bool DrawMouse
{
get
{
lock ( _loadingSettingsLock )
{
return _properties . DrawMouseCursor ;
}
}
set
{
lock ( _loadingSettingsLock )
{
_properties . DrawMouseCursor = value ;
}
}
}
2024-04-02 01:09:47 +02:00
[CmdConfigureIgnore]
2023-05-15 23:32:26 +01:00
internal bool DrawMouseEx
{
get
{
lock ( _loadingSettingsLock )
{
return _properties . DrawMouseEx ;
}
}
set
{
lock ( _loadingSettingsLock )
{
_properties . DrawMouseEx = value ;
}
}
}
internal bool ReverseLookup
{
get
{
2024-07-22 16:49:45 +02:00
if ( GPOWrapper . GetConfiguredMwbValidateRemoteIpValue ( ) = = GpoRuleConfigured . Enabled )
{
return true ;
}
else if ( GPOWrapper . GetConfiguredMwbValidateRemoteIpValue ( ) = = GpoRuleConfigured . Disabled )
{
return false ;
}
2023-05-15 23:32:26 +01:00
lock ( _loadingSettingsLock )
{
return _properties . ValidateRemoteMachineIP ;
}
}
set
{
2024-07-22 16:49:45 +02:00
if ( ReverseLookupIsGpoConfigured )
{
return ;
}
2023-05-15 23:32:26 +01:00
lock ( _loadingSettingsLock )
{
_properties . ValidateRemoteMachineIP = value ;
}
}
}
2024-07-22 16:49:45 +02:00
[CmdConfigureIgnore]
[JsonIgnore]
internal bool ReverseLookupIsGpoConfigured = > GPOWrapper . GetConfiguredMwbValidateRemoteIpValue ( ) = = GpoRuleConfigured . Enabled | | GPOWrapper . GetConfiguredMwbValidateRemoteIpValue ( ) = = GpoRuleConfigured . Disabled ;
2023-05-15 23:32:26 +01:00
internal bool SameSubNetOnly
{
get
{
2024-07-22 16:49:45 +02:00
if ( GPOWrapper . GetConfiguredMwbSameSubnetOnlyValue ( ) = = GpoRuleConfigured . Enabled )
{
return true ;
}
else if ( GPOWrapper . GetConfiguredMwbSameSubnetOnlyValue ( ) = = GpoRuleConfigured . Disabled )
{
return false ;
}
2023-05-15 23:32:26 +01:00
lock ( _loadingSettingsLock )
{
return _properties . SameSubnetOnly ;
}
}
set
{
2024-07-22 16:49:45 +02:00
if ( SameSubNetOnlyIsGpoConfigured )
{
return ;
}
2023-05-15 23:32:26 +01:00
lock ( _loadingSettingsLock )
{
_properties . SameSubnetOnly = value ;
}
}
}
2024-07-22 16:49:45 +02:00
[CmdConfigureIgnore]
[JsonIgnore]
internal bool SameSubNetOnlyIsGpoConfigured = > GPOWrapper . GetConfiguredMwbSameSubnetOnlyValue ( ) = = GpoRuleConfigured . Enabled | | GPOWrapper . GetConfiguredMwbSameSubnetOnlyValue ( ) = = GpoRuleConfigured . Disabled ;
2023-05-15 23:32:26 +01:00
internal string Name2IP
{
get
{
2024-07-22 16:49:45 +02:00
if ( GPOWrapper . GetConfiguredMwbDisableUserDefinedIpMappingRulesValue ( ) = = GpoRuleConfigured . Enabled )
{
return string . Empty ;
}
2023-05-15 23:32:26 +01:00
lock ( _loadingSettingsLock )
{
return _properties . Name2IP . Value ;
}
}
set
{
2024-07-22 16:49:45 +02:00
if ( Name2IpIsGpoConfigured )
{
return ;
}
2023-05-15 23:32:26 +01:00
lock ( _loadingSettingsLock )
{
_properties . Name2IP . Value = value ;
}
}
}
2024-07-22 16:49:45 +02:00
[CmdConfigureIgnore]
[JsonIgnore]
internal bool Name2IpIsGpoConfigured = > GPOWrapper . GetConfiguredMwbDisableUserDefinedIpMappingRulesValue ( ) = = GpoRuleConfigured . Enabled ;
[CmdConfigureIgnore]
[JsonIgnore]
internal string Name2IpPolicyList = > GPOWrapper . GetConfiguredMwbPolicyDefinedIpMappingRules ( ) ;
[CmdConfigureIgnore]
[JsonIgnore]
internal bool Name2IpPolicyListIsGpoConfigured = > ! string . IsNullOrWhiteSpace ( Name2IpPolicyList ) ;
2023-05-15 23:32:26 +01:00
internal bool FirstCtrlShiftS
{
get
{
lock ( _loadingSettingsLock )
{
return _properties . FirstCtrlShiftS ;
}
}
set
{
lock ( _loadingSettingsLock )
{
_properties . FirstCtrlShiftS = value ;
}
}
}
2023-05-30 09:45:27 +01:00
// Was a value read from registry on original Mouse Without Border, but default should be true. We wrongly released it as false, so we're forcing true here.
// This value wasn't changeable from UI, anyway.
internal bool StealFocusWhenSwitchingMachine = > true ;
2023-05-15 23:32:26 +01:00
private string deviceId ;
internal string DeviceId
{
get
{
string newGuid = Guid . NewGuid ( ) . ToString ( ) ;
if ( deviceId = = null | | deviceId . Length ! = newGuid . Length )
{
string defaultId = newGuid ;
lock ( _loadingSettingsLock )
{
_properties . DeviceID = defaultId ;
deviceId = _properties . DeviceID . Value ;
if ( deviceId . Equals ( defaultId , StringComparison . OrdinalIgnoreCase ) )
{
return _properties . DeviceID . Value ;
}
}
}
return deviceId ;
}
}
private int? machineId ;
internal int MachineId
{
get
{
lock ( _loadingSettingsLock )
{
machineId ? ? = ( machineId = _properties . MachineID . Value ) . Value ;
if ( machineId = = 0 )
{
_properties . MachineID . Value = Common . Ran . Next ( ) ;
machineId = _properties . MachineID . Value ;
}
}
return machineId . Value ;
}
set
{
lock ( _loadingSettingsLock )
{
_properties . MachineID . Value = value ;
}
}
}
internal bool OneWayControlMode = > false ;
internal bool OneWayClipboardMode = > false ;
internal bool ShowClipNetStatus
{
get
{
lock ( _loadingSettingsLock )
{
return _properties . ShowClipboardAndNetworkStatusMessages ;
}
}
set
{
lock ( _loadingSettingsLock )
{
_properties . ShowClipboardAndNetworkStatusMessages = value ;
}
}
}
internal bool ShowOriginalUI
{
get
{
2024-07-22 16:49:45 +02:00
if ( GPOWrapper . GetConfiguredMwbUseOriginalUserInterfaceValue ( ) = = GpoRuleConfigured . Disabled )
{
return false ;
}
2023-05-15 23:32:26 +01:00
lock ( _loadingSettingsLock )
{
return _properties . ShowOriginalUI ;
}
}
set
{
2024-07-22 16:49:45 +02:00
if ( GPOWrapper . GetConfiguredMwbUseOriginalUserInterfaceValue ( ) = = GpoRuleConfigured . Disabled )
{
return ;
}
2023-05-15 23:32:26 +01:00
lock ( _loadingSettingsLock )
{
_properties . ShowOriginalUI = value ;
}
}
}
2023-05-31 15:50:48 +01:00
// If starting the service fails, work in not service mode.
internal bool UseService
{
get
{
2025-02-12 18:49:26 +00:00
if ( GPOWrapper . GetConfiguredMwbAllowServiceModeValue ( ) = = GpoRuleConfigured . Disabled )
{
return false ;
}
2023-05-31 15:50:48 +01:00
lock ( _loadingSettingsLock )
{
return _properties . UseService ;
}
}
set
{
2025-02-12 18:49:26 +00:00
if ( AllowServiceModeIsGpoConfigured )
{
return ;
}
2023-05-31 15:50:48 +01:00
lock ( _loadingSettingsLock )
{
_properties . UseService = value ;
if ( ! PauseInstantSaving )
{
SaveSettings ( ) ;
}
}
}
}
2025-02-12 18:49:26 +00:00
[CmdConfigureIgnore]
[JsonIgnore]
internal bool AllowServiceModeIsGpoConfigured = > GPOWrapper . GetConfiguredMwbAllowServiceModeValue ( ) = = GpoRuleConfigured . Disabled ;
2024-07-17 15:51:38 +02:00
// Note(@htcfreek): Settings UI CheckBox is disabled in frmMatrix.cs > FrmMatrix_Load()
2023-05-15 23:32:26 +01:00
internal bool SendErrorLogV2
{
get
{
return false ;
}
}
}
public static class Setting
{
internal static Settings Values = new Settings ( ) ;
}
}