mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-04 18:26:39 +02:00
## Summary of the Pull Request CursorWrap wraps on the outer edge of monitors, if a user is swapping between a laptop and docked laptop with external monitors the user might want to only enable wrapping when connected to external monitors, and disable when only on the laptop. <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist - [ ] Closes: #45198 - [ ] Closes: #45154 - [ ] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected - [ ] **Tests:** Added/updated and all pass - [ ] **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) - [ ] **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: #xxx ## Detailed Description of the Pull Request / Additional comments Currently CursorWrap will wrap around the horizontal/vertical edges of monitors, if the user has more than one monitor the outer edges are used as wrap targets, if the user only has one monitor (perhaps a laptop) wrapping might be temporarily disabled until additional external monitors are added (such as being plugged into a dock or using a USB-C monitor). The new option will disable wrapping if only a single monitor is detected, monitor detection is dynamic. ## Validation Steps Performed Validated on a Surface Laptop 7 Pro (Intel) with a USB-C External Monitor. --------- Co-authored-by: Niels Laute <niels.laute@live.nl>
70 lines
2.4 KiB
C#
70 lines
2.4 KiB
C#
// 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.Collections.Generic;
|
|
using System.Text.Json.Serialization;
|
|
using ManagedCommon;
|
|
using Microsoft.PowerToys.Settings.UI.Library.Helpers;
|
|
using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
|
|
|
|
namespace Microsoft.PowerToys.Settings.UI.Library
|
|
{
|
|
public class CursorWrapSettings : BasePTModuleSettings, ISettingsConfig, IHotkeyConfig
|
|
{
|
|
public const string ModuleName = "CursorWrap";
|
|
|
|
[JsonPropertyName("properties")]
|
|
public CursorWrapProperties Properties { get; set; }
|
|
|
|
public CursorWrapSettings()
|
|
{
|
|
Name = ModuleName;
|
|
Properties = new CursorWrapProperties();
|
|
Version = "1.0";
|
|
}
|
|
|
|
public string GetModuleName()
|
|
{
|
|
return Name;
|
|
}
|
|
|
|
public ModuleType GetModuleType() => ModuleType.CursorWrap;
|
|
|
|
public HotkeyAccessor[] GetAllHotkeyAccessors()
|
|
{
|
|
var hotkeyAccessors = new List<HotkeyAccessor>
|
|
{
|
|
new HotkeyAccessor(
|
|
() => Properties.ActivationShortcut,
|
|
value => Properties.ActivationShortcut = value ?? Properties.DefaultActivationShortcut,
|
|
"MouseUtils_CursorWrap_ActivationShortcut"),
|
|
};
|
|
|
|
return hotkeyAccessors.ToArray();
|
|
}
|
|
|
|
// This can be utilized in the future if the settings.json file is to be modified/deleted.
|
|
public bool UpgradeSettingsConfiguration()
|
|
{
|
|
bool settingsUpgraded = false;
|
|
|
|
// Add WrapMode property if it doesn't exist (for users upgrading from older versions)
|
|
if (Properties.WrapMode == null)
|
|
{
|
|
Properties.WrapMode = new IntProperty(0); // Default to Both
|
|
settingsUpgraded = true;
|
|
}
|
|
|
|
// Add DisableCursorWrapOnSingleMonitor property if it doesn't exist (for users upgrading from older versions)
|
|
if (Properties.DisableCursorWrapOnSingleMonitor == null)
|
|
{
|
|
Properties.DisableCursorWrapOnSingleMonitor = new BoolProperty(false); // Default to false
|
|
settingsUpgraded = true;
|
|
}
|
|
|
|
return settingsUpgraded;
|
|
}
|
|
}
|
|
}
|