mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-03 09:46:54 +02:00
Cmdpal Powertoys Extension: Support mouse without borders easy mouse … (#45350)
## Description You don't have to go to powertoys settings to * toggle the mouse move from machine to another * you can trigger reconnect when connection lost from cmdpal * You can toggle whether kbm is turning on or not from cmdpal <!-- 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 Add several missing cmd to powretoys cmdpal extension <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist - [ ] Closes: #xxx <!-- - [ ] Closes: #yyy (add separate lines for additional resolved issues) --> - [ ] **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 <!-- 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 <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed https://github.com/user-attachments/assets/9ea019f7-988b-4542-afc5-a80f0fc99ef8 For the kbm toggle, when it's off, kbm will not map anything, if it's on, kbm will take effect For the mouse without borders, add these two functionality as command <img width="1182" height="158" alt="image" src="https://github.com/user-attachments/assets/27f526b1-9c91-4923-be6c-e505673f5892" /> And verified for the two command, works as expected
This commit is contained in:
1
.github/actions/spell-check/expect.txt
vendored
1
.github/actions/spell-check/expect.txt
vendored
@@ -797,6 +797,7 @@ MAPPEDTOSAMEKEY
|
|||||||
MAPTOSAMESHORTCUT
|
MAPTOSAMESHORTCUT
|
||||||
MAPVK
|
MAPVK
|
||||||
MARKDOWNPREVIEWHANDLERCPP
|
MARKDOWNPREVIEWHANDLERCPP
|
||||||
|
MAXDWORD
|
||||||
MAXSHORTCUTSIZE
|
MAXSHORTCUTSIZE
|
||||||
maxversiontested
|
maxversiontested
|
||||||
MBM
|
MBM
|
||||||
|
|||||||
@@ -2,7 +2,19 @@
|
|||||||
|
|
||||||
<?include $(sys.CURRENTDIR)\Common.wxi?>
|
<?include $(sys.CURRENTDIR)\Common.wxi?>
|
||||||
|
|
||||||
|
<?define KeyboardManagerAssetsFiles=?>
|
||||||
|
<?define KeyboardManagerAssetsFilesPath=$(var.BinDir)\Assets\KeyboardManager\?>
|
||||||
|
|
||||||
<Fragment>
|
<Fragment>
|
||||||
|
<DirectoryRef Id="BaseApplicationsAssetsFolder">
|
||||||
|
<Directory Id="KeyboardManagerAssetsInstallFolder" Name="KeyboardManager" />
|
||||||
|
</DirectoryRef>
|
||||||
|
|
||||||
|
<DirectoryRef Id="KeyboardManagerAssetsInstallFolder" FileSource="$(var.KeyboardManagerAssetsFilesPath)">
|
||||||
|
<!-- Generated by generateFileComponents.ps1 -->
|
||||||
|
<!--KeyboardManagerAssetsFiles_Component_Def-->
|
||||||
|
</DirectoryRef>
|
||||||
|
|
||||||
<DirectoryRef Id="INSTALLFOLDER">
|
<DirectoryRef Id="INSTALLFOLDER">
|
||||||
<Directory Id="KeyboardManagerEditorInstallFolder" Name="KeyboardManagerEditor" />
|
<Directory Id="KeyboardManagerEditorInstallFolder" Name="KeyboardManagerEditor" />
|
||||||
<Directory Id="KeyboardManagerEngineInstallFolder" Name="KeyboardManagerEngine" />
|
<Directory Id="KeyboardManagerEngineInstallFolder" Name="KeyboardManagerEngine" />
|
||||||
@@ -44,6 +56,7 @@
|
|||||||
<RegistryKey Root="$(var.RegistryScope)" Key="Software\Classes\powertoys\components">
|
<RegistryKey Root="$(var.RegistryScope)" Key="Software\Classes\powertoys\components">
|
||||||
<RegistryValue Type="string" Name="RemoveKeyboardManagerFolder" Value="" KeyPath="yes" />
|
<RegistryValue Type="string" Name="RemoveKeyboardManagerFolder" Value="" KeyPath="yes" />
|
||||||
</RegistryKey>
|
</RegistryKey>
|
||||||
|
<RemoveFolder Id="RemoveFolderKeyboardManagerAssetsInstallFolder" Directory="KeyboardManagerAssetsInstallFolder" On="uninstall" />
|
||||||
<RemoveFolder Id="RemoveFolderKeyboardManagerEditorFolder" Directory="KeyboardManagerEditorInstallFolder" On="uninstall" />
|
<RemoveFolder Id="RemoveFolderKeyboardManagerEditorFolder" Directory="KeyboardManagerEditorInstallFolder" On="uninstall" />
|
||||||
<RemoveFolder Id="RemoveFolderKeyboardManagerEngineFolder" Directory="KeyboardManagerEngineInstallFolder" On="uninstall" />
|
<RemoveFolder Id="RemoveFolderKeyboardManagerEngineFolder" Directory="KeyboardManagerEngineInstallFolder" On="uninstall" />
|
||||||
</Component>
|
</Component>
|
||||||
|
|||||||
@@ -172,6 +172,10 @@ Generate-FileComponents -fileListName "HostsAssetsFiles" -wxsFilePath $PSScriptR
|
|||||||
Generate-FileList -fileDepsJson "" -fileListName ImageResizerAssetsFiles -wxsFilePath $PSScriptRoot\ImageResizer.wxs -depsPath "$PSScriptRoot..\..\..\$platform\Release\WinUI3Apps\Assets\ImageResizer"
|
Generate-FileList -fileDepsJson "" -fileListName ImageResizerAssetsFiles -wxsFilePath $PSScriptRoot\ImageResizer.wxs -depsPath "$PSScriptRoot..\..\..\$platform\Release\WinUI3Apps\Assets\ImageResizer"
|
||||||
Generate-FileComponents -fileListName "ImageResizerAssetsFiles" -wxsFilePath $PSScriptRoot\ImageResizer.wxs
|
Generate-FileComponents -fileListName "ImageResizerAssetsFiles" -wxsFilePath $PSScriptRoot\ImageResizer.wxs
|
||||||
|
|
||||||
|
#KeyboardManager
|
||||||
|
Generate-FileList -fileDepsJson "" -fileListName KeyboardManagerAssetsFiles -wxsFilePath $PSScriptRoot\KeyboardManager.wxs -depsPath "$PSScriptRoot..\..\..\$platform\Release\Assets\KeyboardManager"
|
||||||
|
Generate-FileComponents -fileListName "KeyboardManagerAssetsFiles" -wxsFilePath $PSScriptRoot\KeyboardManager.wxs
|
||||||
|
|
||||||
# Light Switch Service
|
# Light Switch Service
|
||||||
Generate-FileList -fileDepsJson "" -fileListName LightSwitchFiles -wxsFilePath $PSScriptRoot\LightSwitch.wxs -depsPath "$PSScriptRoot..\..\..\$platform\Release\LightSwitchService"
|
Generate-FileList -fileDepsJson "" -fileListName LightSwitchFiles -wxsFilePath $PSScriptRoot\LightSwitch.wxs -depsPath "$PSScriptRoot..\..\..\$platform\Release\LightSwitchService"
|
||||||
Generate-FileComponents -fileListName "LightSwitchFiles" -wxsFilePath $PSScriptRoot\LightSwitch.wxs
|
Generate-FileComponents -fileListName "LightSwitchFiles" -wxsFilePath $PSScriptRoot\LightSwitch.wxs
|
||||||
|
|||||||
@@ -287,8 +287,26 @@ namespace winrt::PowerToys::Interop::implementation
|
|||||||
{
|
{
|
||||||
return CommonSharedConstants::POWER_DISPLAY_TERMINATE_APP_MESSAGE;
|
return CommonSharedConstants::POWER_DISPLAY_TERMINATE_APP_MESSAGE;
|
||||||
}
|
}
|
||||||
|
hstring Constants::MWBToggleEasyMouseEvent()
|
||||||
|
{
|
||||||
|
return CommonSharedConstants::MWB_TOGGLE_EASY_MOUSE_EVENT;
|
||||||
|
}
|
||||||
|
hstring Constants::MWBReconnectEvent()
|
||||||
|
{
|
||||||
|
return CommonSharedConstants::MWB_RECONNECT_EVENT;
|
||||||
|
}
|
||||||
|
|
||||||
hstring Constants::OpenNewKeyboardManagerEvent()
|
hstring Constants::OpenNewKeyboardManagerEvent()
|
||||||
{
|
{
|
||||||
return CommonSharedConstants::OPEN_NEW_KEYBOARD_MANAGER_EVENT;
|
return CommonSharedConstants::OPEN_NEW_KEYBOARD_MANAGER_EVENT;
|
||||||
}
|
}
|
||||||
|
hstring Constants::ToggleKeyboardManagerActiveEvent()
|
||||||
|
{
|
||||||
|
return CommonSharedConstants::TOGGLE_KEYBOARD_MANAGER_ACTIVE_EVENT;
|
||||||
}
|
}
|
||||||
|
hstring Constants::KeyboardManagerEngineInstanceMutex()
|
||||||
|
{
|
||||||
|
return CommonSharedConstants::KEYBOARD_MANAGER_ENGINE_INSTANCE_MUTEX;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,11 @@ namespace winrt::PowerToys::Interop::implementation
|
|||||||
static hstring PowerDisplayToggleMessage();
|
static hstring PowerDisplayToggleMessage();
|
||||||
static hstring PowerDisplayApplyProfileMessage();
|
static hstring PowerDisplayApplyProfileMessage();
|
||||||
static hstring PowerDisplayTerminateAppMessage();
|
static hstring PowerDisplayTerminateAppMessage();
|
||||||
|
static hstring MWBToggleEasyMouseEvent();
|
||||||
|
static hstring MWBReconnectEvent();
|
||||||
static hstring OpenNewKeyboardManagerEvent();
|
static hstring OpenNewKeyboardManagerEvent();
|
||||||
|
static hstring ToggleKeyboardManagerActiveEvent();
|
||||||
|
static hstring KeyboardManagerEngineInstanceMutex();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,3 +89,4 @@ namespace winrt::PowerToys::Interop::factory_implementation
|
|||||||
{
|
{
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,12 @@ namespace PowerToys
|
|||||||
static String PowerDisplayToggleMessage();
|
static String PowerDisplayToggleMessage();
|
||||||
static String PowerDisplayApplyProfileMessage();
|
static String PowerDisplayApplyProfileMessage();
|
||||||
static String PowerDisplayTerminateAppMessage();
|
static String PowerDisplayTerminateAppMessage();
|
||||||
|
static String MWBToggleEasyMouseEvent();
|
||||||
|
static String MWBReconnectEvent();
|
||||||
static String OpenNewKeyboardManagerEvent();
|
static String OpenNewKeyboardManagerEvent();
|
||||||
|
static String ToggleKeyboardManagerActiveEvent();
|
||||||
|
static String KeyboardManagerEngineInstanceMutex();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -172,11 +172,18 @@ namespace CommonSharedConstants
|
|||||||
|
|
||||||
// Path to events used by Keyboard Manager
|
// Path to events used by Keyboard Manager
|
||||||
const wchar_t OPEN_NEW_KEYBOARD_MANAGER_EVENT[] = L"Local\\PowerToysOpenNewKeyboardManagerEvent-9c1d2e3f-4b5a-6c7d-8e9f-0a1b2c3d4e5f";
|
const wchar_t OPEN_NEW_KEYBOARD_MANAGER_EVENT[] = L"Local\\PowerToysOpenNewKeyboardManagerEvent-9c1d2e3f-4b5a-6c7d-8e9f-0a1b2c3d4e5f";
|
||||||
|
const wchar_t TOGGLE_KEYBOARD_MANAGER_ACTIVE_EVENT[] = L"Local\\PowerToysToggleKeyboardManagerActiveEvent-7f3a1d5c-2e94-4ff4-8b6a-90fd2bc4d2a7";
|
||||||
|
const wchar_t KEYBOARD_MANAGER_ENGINE_INSTANCE_MUTEX[] = L"Local\\PowerToys_KBMEngine_InstanceMutex";
|
||||||
|
|
||||||
// used from quick access window
|
// used from quick access window
|
||||||
const wchar_t CMDPAL_SHOW_EVENT[] = L"Local\\PowerToysCmdPal-ShowEvent-62336fcd-8611-4023-9b30-091a6af4cc5a";
|
const wchar_t CMDPAL_SHOW_EVENT[] = L"Local\\PowerToysCmdPal-ShowEvent-62336fcd-8611-4023-9b30-091a6af4cc5a";
|
||||||
const wchar_t CMDPAL_EXIT_EVENT[] = L"Local\\PowerToysCmdPal-ExitEvent-eb73f6be-3f22-4b36-aee3-62924ba40bfd";
|
const wchar_t CMDPAL_EXIT_EVENT[] = L"Local\\PowerToysCmdPal-ExitEvent-eb73f6be-3f22-4b36-aee3-62924ba40bfd";
|
||||||
|
|
||||||
|
// Path to the events used by MouseWithoutBorders
|
||||||
|
const wchar_t MWB_TOGGLE_EASY_MOUSE_EVENT[] = L"Local\\PowerToysMWB-ToggleEasyMouseEvent-a9c8d7b6-e5f4-3c2a-1b0d-9e8f7a6b5c4d";
|
||||||
|
const wchar_t MWB_RECONNECT_EVENT[] = L"Local\\PowerToysMWB-ReconnectEvent-b8d7c6a5-f4e3-2b1c-0a9d-8e7f6a5b4c3d";
|
||||||
|
|
||||||
// Max DWORD for key code to disable keys.
|
// Max DWORD for key code to disable keys.
|
||||||
const DWORD VK_DISABLED = 0x100;
|
const DWORD VK_DISABLED = 0x100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -229,6 +229,7 @@ namespace MouseWithoutBorders.Class
|
|||||||
if (!Common.RunOnLogonDesktop)
|
if (!Common.RunOnLogonDesktop)
|
||||||
{
|
{
|
||||||
StartSettingSyncThread();
|
StartSettingSyncThread();
|
||||||
|
CommandEventHandler.StartListening();
|
||||||
}
|
}
|
||||||
|
|
||||||
Application.EnableVisualStyles();
|
Application.EnableVisualStyles();
|
||||||
|
|||||||
114
src/modules/MouseWithoutBorders/App/Core/CommandEventHandler.cs
Normal file
114
src/modules/MouseWithoutBorders/App/Core/CommandEventHandler.cs
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
// 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.Threading;
|
||||||
|
|
||||||
|
using MouseWithoutBorders.Class;
|
||||||
|
using PowerToys.Interop;
|
||||||
|
|
||||||
|
namespace MouseWithoutBorders.Core
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Handles command events from external sources (e.g., Command Palette).
|
||||||
|
/// Uses named events for inter-process communication, following the same pattern as other PowerToys modules.
|
||||||
|
/// </summary>
|
||||||
|
internal static class CommandEventHandler
|
||||||
|
{
|
||||||
|
private static CancellationTokenSource _cancellationTokenSource;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Starts listening for command events on background threads.
|
||||||
|
/// </summary>
|
||||||
|
public static void StartListening()
|
||||||
|
{
|
||||||
|
_cancellationTokenSource = new CancellationTokenSource();
|
||||||
|
CancellationToken exitToken = _cancellationTokenSource.Token;
|
||||||
|
|
||||||
|
// Start listener for Toggle Easy Mouse event
|
||||||
|
StartEventListener(Constants.MWBToggleEasyMouseEvent(), ToggleEasyMouse, exitToken);
|
||||||
|
|
||||||
|
// Start listener for Reconnect event
|
||||||
|
StartEventListener(Constants.MWBReconnectEvent(), Reconnect, exitToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Stops listening for command events.
|
||||||
|
/// </summary>
|
||||||
|
public static void StopListening()
|
||||||
|
{
|
||||||
|
_cancellationTokenSource?.Cancel();
|
||||||
|
_cancellationTokenSource?.Dispose();
|
||||||
|
_cancellationTokenSource = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void StartEventListener(string eventName, Action callback, CancellationToken cancel)
|
||||||
|
{
|
||||||
|
new System.Threading.Thread(() =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, eventName);
|
||||||
|
WaitHandle[] waitHandles = new WaitHandle[] { cancel.WaitHandle, eventHandle };
|
||||||
|
|
||||||
|
while (!cancel.IsCancellationRequested)
|
||||||
|
{
|
||||||
|
int result = WaitHandle.WaitAny(waitHandles);
|
||||||
|
if (result == 1)
|
||||||
|
{
|
||||||
|
// Execute callback on UI thread using Common.DoSomethingInUIThread
|
||||||
|
Common.DoSomethingInUIThread(callback);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Cancellation requested
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.Log($"Error in event listener for {eventName}: {ex.Message}");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
{ IsBackground = true, Name = $"MWB-{eventName}-Listener" }.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Toggles Easy Mouse between Enabled and Disabled states.
|
||||||
|
/// This is the same logic used by the hotkey handler.
|
||||||
|
/// </summary>
|
||||||
|
public static void ToggleEasyMouse()
|
||||||
|
{
|
||||||
|
if (Common.RunOnLogonDesktop || Common.RunOnScrSaverDesktop)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
EasyMouseOption easyMouseOption = (EasyMouseOption)Setting.Values.EasyMouse;
|
||||||
|
|
||||||
|
if (easyMouseOption is EasyMouseOption.Disable or EasyMouseOption.Enable)
|
||||||
|
{
|
||||||
|
Setting.Values.EasyMouse = (int)(easyMouseOption == EasyMouseOption.Disable ? EasyMouseOption.Enable : EasyMouseOption.Disable);
|
||||||
|
|
||||||
|
Common.ShowToolTip($"Easy Mouse has been toggled to [{(EasyMouseOption)Setting.Values.EasyMouse}].", 3000);
|
||||||
|
|
||||||
|
Logger.Log($"Easy Mouse toggled to {(EasyMouseOption)Setting.Values.EasyMouse} via command event.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initiates a reconnection attempt to all machines.
|
||||||
|
/// This is the same logic used by the hotkey handler.
|
||||||
|
/// </summary>
|
||||||
|
public static void Reconnect()
|
||||||
|
{
|
||||||
|
Common.ShowToolTip("Reconnecting...", 2000);
|
||||||
|
Common.LastReconnectByHotKeyTime = Common.GetTick();
|
||||||
|
InitAndCleanup.PleaseReopenSocket = InitAndCleanup.REOPEN_WHEN_HOTKEY;
|
||||||
|
|
||||||
|
Logger.Log("Reconnect initiated via command event.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -218,6 +218,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\..\common\GPOWrapper\GPOWrapper.vcxproj" />
|
<ProjectReference Include="..\..\..\common\GPOWrapper\GPOWrapper.vcxproj" />
|
||||||
|
<ProjectReference Include="..\..\..\common\interop\PowerToys.Interop.vcxproj" />
|
||||||
<ProjectReference Include="..\..\..\settings-ui\Settings.UI.Library\Settings.UI.Library.csproj" />
|
<ProjectReference Include="..\..\..\settings-ui\Settings.UI.Library\Settings.UI.Library.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
||||||
|
<rect x="2.25" y="4.25" width="19.5" height="12.5" rx="2.5" fill="#5F5F5F"/>
|
||||||
|
<rect x="4.5" y="6.75" width="1.9" height="1.75" rx="0.35" fill="#FFFFFF"/>
|
||||||
|
<rect x="7.1" y="6.75" width="1.9" height="1.75" rx="0.35" fill="#FFFFFF"/>
|
||||||
|
<rect x="9.7" y="6.75" width="1.9" height="1.75" rx="0.35" fill="#FFFFFF"/>
|
||||||
|
<rect x="12.3" y="6.75" width="1.9" height="1.75" rx="0.35" fill="#FFFFFF"/>
|
||||||
|
<rect x="14.9" y="6.75" width="1.9" height="1.75" rx="0.35" fill="#FFFFFF"/>
|
||||||
|
<rect x="17.5" y="6.75" width="1.9" height="1.75" rx="0.35" fill="#FFFFFF"/>
|
||||||
|
<rect x="4.5" y="9.5" width="2.4" height="1.75" rx="0.35" fill="#FFFFFF"/>
|
||||||
|
<rect x="7.6" y="9.5" width="2.4" height="1.75" rx="0.35" fill="#FFFFFF"/>
|
||||||
|
<rect x="10.7" y="9.5" width="2.4" height="1.75" rx="0.35" fill="#FFFFFF"/>
|
||||||
|
<rect x="13.8" y="9.5" width="2.4" height="1.75" rx="0.35" fill="#FFFFFF"/>
|
||||||
|
<rect x="16.9" y="9.5" width="2.4" height="1.75" rx="0.35" fill="#FFFFFF"/>
|
||||||
|
<rect x="4.5" y="12.25" width="10.9" height="1.9" rx="0.4" fill="#FFFFFF"/>
|
||||||
|
<rect x="16.1" y="12.25" width="3.3" height="1.9" rx="0.4" fill="#FFFFFF"/>
|
||||||
|
<circle cx="18.5" cy="18.5" r="4.5" fill="#C50F1F"/>
|
||||||
|
<path d="M16.35 18.5h4.3" fill="none" stroke="#FFFFFF" stroke-linecap="round" stroke-width="1.5"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.3 KiB |
@@ -0,0 +1,18 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
||||||
|
<rect x="2.25" y="4.25" width="19.5" height="12.5" rx="2.5" fill="#0078D4"/>
|
||||||
|
<rect x="4.5" y="6.75" width="1.9" height="1.75" rx="0.35" fill="#FFFFFF"/>
|
||||||
|
<rect x="7.1" y="6.75" width="1.9" height="1.75" rx="0.35" fill="#FFFFFF"/>
|
||||||
|
<rect x="9.7" y="6.75" width="1.9" height="1.75" rx="0.35" fill="#FFFFFF"/>
|
||||||
|
<rect x="12.3" y="6.75" width="1.9" height="1.75" rx="0.35" fill="#FFFFFF"/>
|
||||||
|
<rect x="14.9" y="6.75" width="1.9" height="1.75" rx="0.35" fill="#FFFFFF"/>
|
||||||
|
<rect x="17.5" y="6.75" width="1.9" height="1.75" rx="0.35" fill="#FFFFFF"/>
|
||||||
|
<rect x="4.5" y="9.5" width="2.4" height="1.75" rx="0.35" fill="#FFFFFF"/>
|
||||||
|
<rect x="7.6" y="9.5" width="2.4" height="1.75" rx="0.35" fill="#FFFFFF"/>
|
||||||
|
<rect x="10.7" y="9.5" width="2.4" height="1.75" rx="0.35" fill="#FFFFFF"/>
|
||||||
|
<rect x="13.8" y="9.5" width="2.4" height="1.75" rx="0.35" fill="#FFFFFF"/>
|
||||||
|
<rect x="16.9" y="9.5" width="2.4" height="1.75" rx="0.35" fill="#FFFFFF"/>
|
||||||
|
<rect x="4.5" y="12.25" width="10.9" height="1.9" rx="0.4" fill="#FFFFFF"/>
|
||||||
|
<rect x="16.1" y="12.25" width="3.3" height="1.9" rx="0.4" fill="#FFFFFF"/>
|
||||||
|
<circle cx="18.5" cy="18.5" r="4.5" fill="#107C10"/>
|
||||||
|
<path d="M16.55 18.4l1.35 1.35 2.6-3.05" fill="none" stroke="#FFFFFF" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.45"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.3 KiB |
@@ -0,0 +1,24 @@
|
|||||||
|
// 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 Microsoft.CommandPalette.Extensions.Toolkit;
|
||||||
|
using PowerToysExtension.Helpers;
|
||||||
|
using PowerToysExtension.Properties;
|
||||||
|
|
||||||
|
namespace PowerToysExtension.Commands;
|
||||||
|
|
||||||
|
internal sealed partial class ToggleKeyboardManagerListeningCommand : InvokableCommand
|
||||||
|
{
|
||||||
|
public ToggleKeyboardManagerListeningCommand()
|
||||||
|
{
|
||||||
|
Name = "Toggle Keyboard Manager active state";
|
||||||
|
}
|
||||||
|
|
||||||
|
public override CommandResult Invoke()
|
||||||
|
{
|
||||||
|
return KeyboardManagerStateService.TryToggleListening()
|
||||||
|
? CommandResult.KeepOpen()
|
||||||
|
: CommandResult.ShowToast(Resources.ResourceManager.GetString("KeyboardManager_ToggleListening_Error", Resources.Culture) ?? "Keyboard Manager is unavailable. Try enabling it in PowerToys settings.");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
// 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.Threading;
|
||||||
|
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||||
|
using PowerToys.Interop;
|
||||||
|
|
||||||
|
namespace PowerToysExtension.Commands;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Triggers a reconnection attempt in Mouse Without Borders via the shared event.
|
||||||
|
/// </summary>
|
||||||
|
internal sealed partial class MWBReconnectCommand : InvokableCommand
|
||||||
|
{
|
||||||
|
public MWBReconnectCommand()
|
||||||
|
{
|
||||||
|
Name = "Mouse Without Borders: Reconnect";
|
||||||
|
}
|
||||||
|
|
||||||
|
public override CommandResult Invoke()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var evt = new EventWaitHandle(false, EventResetMode.AutoReset, Constants.MWBReconnectEvent());
|
||||||
|
evt.Set();
|
||||||
|
return CommandResult.Dismiss();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return CommandResult.ShowToast($"Failed to reconnect Mouse Without Borders: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
// 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.Threading;
|
||||||
|
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||||
|
using PowerToys.Interop;
|
||||||
|
|
||||||
|
namespace PowerToysExtension.Commands;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Toggles Easy Mouse feature in Mouse Without Borders via the shared event.
|
||||||
|
/// </summary>
|
||||||
|
internal sealed partial class ToggleMWBEasyMouseCommand : InvokableCommand
|
||||||
|
{
|
||||||
|
public ToggleMWBEasyMouseCommand()
|
||||||
|
{
|
||||||
|
Name = "Mouse Without Borders: Toggle Easy Mouse";
|
||||||
|
}
|
||||||
|
|
||||||
|
public override CommandResult Invoke()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var evt = new EventWaitHandle(false, EventResetMode.AutoReset, Constants.MWBToggleEasyMouseEvent());
|
||||||
|
evt.Set();
|
||||||
|
return CommandResult.Dismiss();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return CommandResult.ShowToast($"Failed to toggle Easy Mouse: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
// 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.Threading;
|
||||||
|
using PowerToys.Interop;
|
||||||
|
|
||||||
|
namespace PowerToysExtension.Helpers;
|
||||||
|
|
||||||
|
internal static class KeyboardManagerStateService
|
||||||
|
{
|
||||||
|
private static readonly object Sync = new();
|
||||||
|
private static readonly Timer PollingTimer;
|
||||||
|
private static bool _lastKnownListeningState = IsListening();
|
||||||
|
|
||||||
|
internal static event Action? StatusChanged;
|
||||||
|
|
||||||
|
static KeyboardManagerStateService()
|
||||||
|
{
|
||||||
|
PollingTimer = new Timer(
|
||||||
|
static _ => PollStatus(),
|
||||||
|
null,
|
||||||
|
TimeSpan.FromMilliseconds(500),
|
||||||
|
TimeSpan.FromMilliseconds(500));
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static bool IsListening()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (Mutex.TryOpenExisting(Constants.KeyboardManagerEngineInstanceMutex(), out var mutex))
|
||||||
|
{
|
||||||
|
mutex.Dispose();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// The engine mutex is best-effort state. Treat failures as not listening.
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static bool TryToggleListening()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var evt = EventWaitHandle.OpenExisting(Constants.ToggleKeyboardManagerActiveEvent());
|
||||||
|
var signaled = evt.Set();
|
||||||
|
PollStatus();
|
||||||
|
return signaled;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void PollStatus()
|
||||||
|
{
|
||||||
|
var isListening = IsListening();
|
||||||
|
var raiseChanged = false;
|
||||||
|
|
||||||
|
lock (Sync)
|
||||||
|
{
|
||||||
|
if (isListening != _lastKnownListeningState)
|
||||||
|
{
|
||||||
|
_lastKnownListeningState = isListening;
|
||||||
|
raiseChanged = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (raiseChanged)
|
||||||
|
{
|
||||||
|
StatusChanged?.Invoke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,11 +9,21 @@ namespace PowerToysExtension.Helpers;
|
|||||||
|
|
||||||
internal static class PowerToysResourcesHelper
|
internal static class PowerToysResourcesHelper
|
||||||
{
|
{
|
||||||
|
private const string AssetsRoot = "Assets\\";
|
||||||
private const string SettingsIconRoot = "WinUI3Apps\\Assets\\Settings\\Icons\\";
|
private const string SettingsIconRoot = "WinUI3Apps\\Assets\\Settings\\Icons\\";
|
||||||
|
|
||||||
internal static IconInfo IconFromSettingsIcon(string fileName) => IconHelpers.FromRelativePath($"{SettingsIconRoot}{fileName}");
|
internal static IconInfo IconFromSettingsIcon(string fileName) => IconHelpers.FromRelativePath($"{SettingsIconRoot}{fileName}");
|
||||||
|
|
||||||
|
internal static IconInfo KeyboardManagerListeningIcon(bool isListening) => IconHelpers.FromRelativePath(
|
||||||
|
isListening
|
||||||
|
? $"{AssetsRoot}KeyboardManager\\KeyboardManagerListeningOn.svg"
|
||||||
|
: $"{AssetsRoot}KeyboardManager\\KeyboardManagerListeningOff.svg");
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
public static IconInfo ProviderIcon() => IconFromSettingsIcon("PowerToys.dark.png");
|
||||||
|
#else
|
||||||
public static IconInfo ProviderIcon() => IconFromSettingsIcon("PowerToys.png");
|
public static IconInfo ProviderIcon() => IconFromSettingsIcon("PowerToys.png");
|
||||||
|
#endif
|
||||||
|
|
||||||
public static IconInfo ModuleIcon(this SettingsWindow module)
|
public static IconInfo ModuleIcon(this SettingsWindow module)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -30,6 +30,10 @@
|
|||||||
<Content Include="..\..\..\..\settings-ui\Settings.UI\Assets\Settings\Icons\*.png" Link="WinUI3Apps\Assets\Settings\Icons\%(Filename)%(Extension)">
|
<Content Include="..\..\..\..\settings-ui\Settings.UI\Assets\Settings\Icons\*.png" Link="WinUI3Apps\Assets\Settings\Icons\%(Filename)%(Extension)">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<!-- Monochrome icons from PowerToys Run Plugin for debug mode differentiation -->
|
||||||
|
<Content Include="..\..\..\launcher\Plugins\Microsoft.PowerToys.Run.Plugin.PowerToys\Images\PowerToys.dark.png" Link="WinUI3Apps\Assets\Settings\Icons\PowerToys.dark.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -77,6 +81,20 @@
|
|||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Remove="Assets\KeyboardManager\KeyboardManagerListeningOn.svg" />
|
||||||
|
<None Remove="Assets\KeyboardManager\KeyboardManagerListeningOff.svg" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Update="Assets\KeyboardManager\KeyboardManagerListeningOn.svg">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Update="Assets\KeyboardManager\KeyboardManagerListeningOff.svg">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<!-- Always build/publish AOT so the extension ships as native code -->
|
<!-- Always build/publish AOT so the extension ships as native code -->
|
||||||
<SelfContained>true</SelfContained>
|
<SelfContained>true</SelfContained>
|
||||||
|
|||||||
@@ -18,8 +18,22 @@ internal sealed class KeyboardManagerModuleCommandProvider : ModuleCommandProvid
|
|||||||
{
|
{
|
||||||
public override IEnumerable<ListItem> BuildCommands()
|
public override IEnumerable<ListItem> BuildCommands()
|
||||||
{
|
{
|
||||||
var title = SettingsWindow.KBM.ModuleDisplayName();
|
var module = SettingsWindow.KBM;
|
||||||
var icon = SettingsWindow.KBM.ModuleIcon();
|
var title = module.ModuleDisplayName();
|
||||||
|
var icon = module.ModuleIcon();
|
||||||
|
|
||||||
|
if (ModuleEnablementService.IsModuleEnabled(module))
|
||||||
|
{
|
||||||
|
var isListening = KeyboardManagerStateService.IsListening();
|
||||||
|
yield return new ListItem(new ToggleKeyboardManagerListeningCommand() { Id = "com.microsoft.powertoys.keyboardManager.toggleListening" })
|
||||||
|
{
|
||||||
|
Title = GetResourceString("KeyboardManager_ToggleListening_Title", "Keyboard Manager: Toggle active state"),
|
||||||
|
Subtitle = isListening
|
||||||
|
? GetResourceString("KeyboardManager_ToggleListening_On_Subtitle", "Keyboard Manager is active. Invoke to stop listening.")
|
||||||
|
: GetResourceString("KeyboardManager_ToggleListening_Off_Subtitle", "Keyboard Manager is paused. Invoke to start listening."),
|
||||||
|
Icon = PowerToysResourcesHelper.KeyboardManagerListeningIcon(isListening),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
if (IsUseNewEditorEnabled())
|
if (IsUseNewEditorEnabled())
|
||||||
{
|
{
|
||||||
@@ -31,7 +45,7 @@ internal sealed class KeyboardManagerModuleCommandProvider : ModuleCommandProvid
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
yield return new ListItem(new OpenInSettingsCommand(SettingsWindow.KBM, title) { Id = "com.microsoft.powertoys.keyboardManager.openSettings" })
|
yield return new ListItem(new OpenInSettingsCommand(module, title) { Id = "com.microsoft.powertoys.keyboardManager.openSettings" })
|
||||||
{
|
{
|
||||||
Title = title,
|
Title = title,
|
||||||
Subtitle = Resources.KeyboardManager_Settings_Subtitle,
|
Subtitle = Resources.KeyboardManager_Settings_Subtitle,
|
||||||
@@ -39,6 +53,11 @@ internal sealed class KeyboardManagerModuleCommandProvider : ModuleCommandProvid
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string GetResourceString(string resourceName, string fallback)
|
||||||
|
{
|
||||||
|
return Resources.ResourceManager.GetString(resourceName, Resources.Culture) ?? fallback;
|
||||||
|
}
|
||||||
|
|
||||||
private static bool IsUseNewEditorEnabled()
|
private static bool IsUseNewEditorEnabled()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ internal sealed class MouseWithoutBordersModuleCommandProvider : ModuleCommandPr
|
|||||||
{
|
{
|
||||||
var title = SettingsWindow.MouseWithoutBorders.ModuleDisplayName();
|
var title = SettingsWindow.MouseWithoutBorders.ModuleDisplayName();
|
||||||
var icon = SettingsWindow.MouseWithoutBorders.ModuleIcon();
|
var icon = SettingsWindow.MouseWithoutBorders.ModuleIcon();
|
||||||
|
var easyMouseIcon = new IconInfo("\uE962");
|
||||||
|
var reconnectIcon = new IconInfo("\uE72C");
|
||||||
|
|
||||||
yield return new ListItem(new OpenInSettingsCommand(SettingsWindow.MouseWithoutBorders, title) { Id = "com.microsoft.powertoys.mouseWithoutBorders.openSettings" })
|
yield return new ListItem(new OpenInSettingsCommand(SettingsWindow.MouseWithoutBorders, title) { Id = "com.microsoft.powertoys.mouseWithoutBorders.openSettings" })
|
||||||
{
|
{
|
||||||
@@ -24,5 +26,19 @@ internal sealed class MouseWithoutBordersModuleCommandProvider : ModuleCommandPr
|
|||||||
Subtitle = Resources.MouseWithoutBorders_Settings_Subtitle,
|
Subtitle = Resources.MouseWithoutBorders_Settings_Subtitle,
|
||||||
Icon = icon,
|
Icon = icon,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
yield return new ListItem(new ToggleMWBEasyMouseCommand())
|
||||||
|
{
|
||||||
|
Title = Resources.MouseWithoutBorders_ToggleEasyMouse_Title,
|
||||||
|
Subtitle = Resources.MouseWithoutBorders_ToggleEasyMouse_Subtitle,
|
||||||
|
Icon = easyMouseIcon,
|
||||||
|
};
|
||||||
|
|
||||||
|
yield return new ListItem(new MWBReconnectCommand())
|
||||||
|
{
|
||||||
|
Title = Resources.MouseWithoutBorders_Reconnect_Title,
|
||||||
|
Subtitle = Resources.MouseWithoutBorders_Reconnect_Subtitle,
|
||||||
|
Icon = reconnectIcon,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ internal sealed partial class PowerToysExtensionPage : ListPage
|
|||||||
{
|
{
|
||||||
public PowerToysExtensionPage()
|
public PowerToysExtensionPage()
|
||||||
{
|
{
|
||||||
Icon = Helpers.PowerToysResourcesHelper.IconFromSettingsIcon("PowerToys.png");
|
Icon = Helpers.PowerToysResourcesHelper.ProviderIcon();
|
||||||
Title = Resources.PowerToys_DisplayName;
|
Title = Resources.PowerToys_DisplayName;
|
||||||
Name = Resources.PowerToysExtension_CommandsName;
|
Name = Resources.PowerToysExtension_CommandsName;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,20 +15,21 @@ internal sealed partial class PowerToysListPage : ListPage
|
|||||||
|
|
||||||
public PowerToysListPage()
|
public PowerToysListPage()
|
||||||
{
|
{
|
||||||
Icon = PowerToysResourcesHelper.IconFromSettingsIcon("PowerToys.png");
|
Icon = PowerToysResourcesHelper.ProviderIcon();
|
||||||
Name = Title = Resources.PowerToys_DisplayName;
|
Name = Title = Resources.PowerToys_DisplayName;
|
||||||
Id = "com.microsoft.cmdpal.powertoys";
|
Id = "com.microsoft.cmdpal.powertoys";
|
||||||
SettingsChangeNotifier.SettingsChanged += OnSettingsChanged;
|
SettingsChangeNotifier.SettingsChanged += OnItemsChanged;
|
||||||
|
KeyboardManagerStateService.StatusChanged += OnItemsChanged;
|
||||||
_empty = new CommandItem()
|
_empty = new CommandItem()
|
||||||
{
|
{
|
||||||
Icon = PowerToysResourcesHelper.IconFromSettingsIcon("PowerToys.png"),
|
Icon = PowerToysResourcesHelper.ProviderIcon(),
|
||||||
Title = Resources.PowerToys_NoMatchingModule,
|
Title = Resources.PowerToys_NoMatchingModule,
|
||||||
Subtitle = SearchText,
|
Subtitle = SearchText,
|
||||||
};
|
};
|
||||||
EmptyContent = _empty;
|
EmptyContent = _empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnSettingsChanged()
|
private void OnItemsChanged()
|
||||||
{
|
{
|
||||||
RaiseItemsChanged(0);
|
RaiseItemsChanged(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public sealed partial class PowerToysCommandsProvider : CommandProvider
|
|||||||
public PowerToysCommandsProvider()
|
public PowerToysCommandsProvider()
|
||||||
{
|
{
|
||||||
DisplayName = Resources.PowerToys_DisplayName;
|
DisplayName = Resources.PowerToys_DisplayName;
|
||||||
Icon = PowerToysResourcesHelper.IconFromSettingsIcon("PowerToys.png");
|
Icon = PowerToysResourcesHelper.ProviderIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ICommandItem[] TopLevelCommands() =>
|
public override ICommandItem[] TopLevelCommands() =>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public partial class PowerToysExtensionCommandsProvider : CommandProvider
|
|||||||
public PowerToysExtensionCommandsProvider()
|
public PowerToysExtensionCommandsProvider()
|
||||||
{
|
{
|
||||||
DisplayName = Resources.PowerToys_DisplayName;
|
DisplayName = Resources.PowerToys_DisplayName;
|
||||||
Icon = PowerToysResourcesHelper.IconFromSettingsIcon("PowerToys.png");
|
Icon = PowerToysResourcesHelper.ProviderIcon();
|
||||||
_commands = [
|
_commands = [
|
||||||
new CommandItem(new Pages.PowerToysListPage())
|
new CommandItem(new Pages.PowerToysListPage())
|
||||||
{
|
{
|
||||||
@@ -25,6 +25,9 @@ public partial class PowerToysExtensionCommandsProvider : CommandProvider
|
|||||||
Subtitle = Resources.PowerToys_Subtitle,
|
Subtitle = Resources.PowerToys_Subtitle,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
SettingsChangeNotifier.SettingsChanged += RaiseModuleItemsChanged;
|
||||||
|
KeyboardManagerStateService.StatusChanged += RaiseModuleItemsChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ICommandItem[] TopLevelCommands()
|
public override ICommandItem[] TopLevelCommands()
|
||||||
@@ -63,4 +66,9 @@ public partial class PowerToysExtensionCommandsProvider : CommandProvider
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void RaiseModuleItemsChanged()
|
||||||
|
{
|
||||||
|
RaiseItemsChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1014,6 +1014,42 @@ namespace PowerToysExtension.Properties {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Toggle Easy Mouse.
|
||||||
|
/// </summary>
|
||||||
|
internal static string MouseWithoutBorders_ToggleEasyMouse_Title {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("MouseWithoutBorders_ToggleEasyMouse_Title", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Toggle easy mouse switching between machines.
|
||||||
|
/// </summary>
|
||||||
|
internal static string MouseWithoutBorders_ToggleEasyMouse_Subtitle {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("MouseWithoutBorders_ToggleEasyMouse_Subtitle", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Reconnect.
|
||||||
|
/// </summary>
|
||||||
|
internal static string MouseWithoutBorders_Reconnect_Title {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("MouseWithoutBorders_Reconnect_Title", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Reconnect to other machines.
|
||||||
|
/// </summary>
|
||||||
|
internal static string MouseWithoutBorders_Reconnect_Subtitle {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("MouseWithoutBorders_Reconnect_Subtitle", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Open New+ settings.
|
/// Looks up a localized string similar to Open New+ settings.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -414,6 +414,18 @@
|
|||||||
<data name="KeyboardManager_OpenNewEditor_Subtitle" xml:space="preserve">
|
<data name="KeyboardManager_OpenNewEditor_Subtitle" xml:space="preserve">
|
||||||
<value>Open the Keyboard Manager remap editor</value>
|
<value>Open the Keyboard Manager remap editor</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="KeyboardManager_ToggleListening_Title" xml:space="preserve">
|
||||||
|
<value>Keyboard Manager: Toggle active state</value>
|
||||||
|
</data>
|
||||||
|
<data name="KeyboardManager_ToggleListening_On_Subtitle" xml:space="preserve">
|
||||||
|
<value>Keyboard Manager is active. Invoke to stop listening.</value>
|
||||||
|
</data>
|
||||||
|
<data name="KeyboardManager_ToggleListening_Off_Subtitle" xml:space="preserve">
|
||||||
|
<value>Keyboard Manager is paused. Invoke to start listening.</value>
|
||||||
|
</data>
|
||||||
|
<data name="KeyboardManager_ToggleListening_Error" xml:space="preserve">
|
||||||
|
<value>Keyboard Manager is unavailable. Try enabling it in PowerToys settings.</value>
|
||||||
|
</data>
|
||||||
<!-- Light Switch Module -->
|
<!-- Light Switch Module -->
|
||||||
<data name="LightSwitch_Toggle_Title" xml:space="preserve">
|
<data name="LightSwitch_Toggle_Title" xml:space="preserve">
|
||||||
<value>Light Switch: Toggle theme</value>
|
<value>Light Switch: Toggle theme</value>
|
||||||
@@ -462,6 +474,18 @@
|
|||||||
<data name="MouseWithoutBorders_Settings_Subtitle" xml:space="preserve">
|
<data name="MouseWithoutBorders_Settings_Subtitle" xml:space="preserve">
|
||||||
<value>Open Mouse Without Borders settings</value>
|
<value>Open Mouse Without Borders settings</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="MouseWithoutBorders_ToggleEasyMouse_Title" xml:space="preserve">
|
||||||
|
<value>Toggle Easy Mouse</value>
|
||||||
|
</data>
|
||||||
|
<data name="MouseWithoutBorders_ToggleEasyMouse_Subtitle" xml:space="preserve">
|
||||||
|
<value>Mouse Without Borders: Toggle Easy Mouse feature on/off</value>
|
||||||
|
</data>
|
||||||
|
<data name="MouseWithoutBorders_Reconnect_Title" xml:space="preserve">
|
||||||
|
<value>Reconnect</value>
|
||||||
|
</data>
|
||||||
|
<data name="MouseWithoutBorders_Reconnect_Subtitle" xml:space="preserve">
|
||||||
|
<value>Mouse Without Borders: Reconnect to all machines</value>
|
||||||
|
</data>
|
||||||
<!-- New+ Module -->
|
<!-- New+ Module -->
|
||||||
<data name="NewPlus_Settings_Subtitle" xml:space="preserve">
|
<data name="NewPlus_Settings_Subtitle" xml:space="preserve">
|
||||||
<value>Open New+ settings</value>
|
<value>Open New+ settings</value>
|
||||||
@@ -640,3 +664,4 @@
|
|||||||
<value>N/A</value>
|
<value>N/A</value>
|
||||||
</data>
|
</data>
|
||||||
</root>
|
</root>
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
#include <keyboardmanager/KeyboardManagerEngineLibrary/trace.h>
|
#include <keyboardmanager/KeyboardManagerEngineLibrary/trace.h>
|
||||||
#include <common/interop/shared_constants.h>
|
#include <common/interop/shared_constants.h>
|
||||||
|
|
||||||
const std::wstring instanceMutexName = L"Local\\PowerToys_KBMEngine_InstanceMutex";
|
const std::wstring instanceMutexName = CommonSharedConstants::KEYBOARD_MANAGER_ENGINE_INSTANCE_MUTEX;
|
||||||
|
|
||||||
int WINAPI wWinMain(_In_ HINSTANCE /*hInstance*/,
|
int WINAPI wWinMain(_In_ HINSTANCE /*hInstance*/,
|
||||||
_In_opt_ HINSTANCE /*hPrevInstance*/,
|
_In_opt_ HINSTANCE /*hPrevInstance*/,
|
||||||
@@ -90,3 +90,4 @@ int WINAPI wWinMain(_In_ HINSTANCE /*hInstance*/,
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ private:
|
|||||||
|
|
||||||
HANDLE m_hTerminateEngineEvent = nullptr;
|
HANDLE m_hTerminateEngineEvent = nullptr;
|
||||||
HANDLE m_open_new_editor_event_handle{ nullptr };
|
HANDLE m_open_new_editor_event_handle{ nullptr };
|
||||||
|
HANDLE m_toggle_active_event_handle{ nullptr };
|
||||||
std::thread m_toggle_thread;
|
std::thread m_toggle_thread;
|
||||||
std::atomic<bool> m_toggle_thread_running{ false };
|
std::atomic<bool> m_toggle_thread_running{ false };
|
||||||
|
|
||||||
@@ -87,6 +88,19 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void toggle_engine()
|
||||||
|
{
|
||||||
|
refresh_process_state();
|
||||||
|
if (m_active)
|
||||||
|
{
|
||||||
|
stop_engine();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
start_engine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool start_engine()
|
bool start_engine()
|
||||||
{
|
{
|
||||||
refresh_process_state();
|
refresh_process_state();
|
||||||
@@ -273,6 +287,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_open_new_editor_event_handle = CreateDefaultEvent(CommonSharedConstants::OPEN_NEW_KEYBOARD_MANAGER_EVENT);
|
m_open_new_editor_event_handle = CreateDefaultEvent(CommonSharedConstants::OPEN_NEW_KEYBOARD_MANAGER_EVENT);
|
||||||
|
m_toggle_active_event_handle = CreateDefaultEvent(CommonSharedConstants::TOGGLE_KEYBOARD_MANAGER_ACTIVE_EVENT);
|
||||||
|
|
||||||
init_settings();
|
init_settings();
|
||||||
};
|
};
|
||||||
@@ -291,6 +306,11 @@ public:
|
|||||||
CloseHandle(m_open_new_editor_event_handle);
|
CloseHandle(m_open_new_editor_event_handle);
|
||||||
m_open_new_editor_event_handle = nullptr;
|
m_open_new_editor_event_handle = nullptr;
|
||||||
}
|
}
|
||||||
|
if (m_toggle_active_event_handle)
|
||||||
|
{
|
||||||
|
CloseHandle(m_toggle_active_event_handle);
|
||||||
|
m_toggle_active_event_handle = nullptr;
|
||||||
|
}
|
||||||
if (m_hEditorProcess)
|
if (m_hEditorProcess)
|
||||||
{
|
{
|
||||||
CloseHandle(m_hEditorProcess);
|
CloseHandle(m_hEditorProcess);
|
||||||
@@ -422,25 +442,45 @@ public:
|
|||||||
|
|
||||||
void StartOpenEditorListener()
|
void StartOpenEditorListener()
|
||||||
{
|
{
|
||||||
if (m_toggle_thread_running || !m_open_new_editor_event_handle)
|
if (m_toggle_thread_running || (!m_open_new_editor_event_handle && !m_toggle_active_event_handle))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_toggle_thread_running = true;
|
m_toggle_thread_running = true;
|
||||||
m_toggle_thread = std::thread([this]() {
|
m_toggle_thread = std::thread([this]() {
|
||||||
|
HANDLE handles[2]{};
|
||||||
|
DWORD handle_count = 0;
|
||||||
|
DWORD open_editor_index = MAXDWORD;
|
||||||
|
DWORD toggle_active_index = MAXDWORD;
|
||||||
|
|
||||||
|
if (m_open_new_editor_event_handle)
|
||||||
|
{
|
||||||
|
open_editor_index = handle_count;
|
||||||
|
handles[handle_count++] = m_open_new_editor_event_handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_toggle_active_event_handle)
|
||||||
|
{
|
||||||
|
toggle_active_index = handle_count;
|
||||||
|
handles[handle_count++] = m_toggle_active_event_handle;
|
||||||
|
}
|
||||||
|
|
||||||
while (m_toggle_thread_running)
|
while (m_toggle_thread_running)
|
||||||
{
|
{
|
||||||
const DWORD wait_result = WaitForSingleObject(m_open_new_editor_event_handle, 500);
|
const DWORD wait_result = WaitForMultipleObjects(handle_count, handles, FALSE, 500);
|
||||||
if (!m_toggle_thread_running)
|
if (!m_toggle_thread_running)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wait_result == WAIT_OBJECT_0)
|
if (open_editor_index != MAXDWORD && wait_result == (WAIT_OBJECT_0 + open_editor_index))
|
||||||
{
|
{
|
||||||
launch_editor();
|
launch_editor();
|
||||||
ResetEvent(m_open_new_editor_event_handle);
|
}
|
||||||
|
else if (toggle_active_index != MAXDWORD && wait_result == (WAIT_OBJECT_0 + toggle_active_index))
|
||||||
|
{
|
||||||
|
toggle_engine();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -458,6 +498,10 @@ public:
|
|||||||
{
|
{
|
||||||
SetEvent(m_open_new_editor_event_handle);
|
SetEvent(m_open_new_editor_event_handle);
|
||||||
}
|
}
|
||||||
|
if (m_toggle_active_event_handle)
|
||||||
|
{
|
||||||
|
SetEvent(m_toggle_active_event_handle);
|
||||||
|
}
|
||||||
if (m_toggle_thread.joinable())
|
if (m_toggle_thread.joinable())
|
||||||
{
|
{
|
||||||
m_toggle_thread.join();
|
m_toggle_thread.join();
|
||||||
@@ -551,15 +595,7 @@ public:
|
|||||||
if (hotkeyId == 0)
|
if (hotkeyId == 0)
|
||||||
{
|
{
|
||||||
// Toggle engine on/off
|
// Toggle engine on/off
|
||||||
refresh_process_state();
|
toggle_engine();
|
||||||
if (m_active)
|
|
||||||
{
|
|
||||||
stop_engine();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
start_engine();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (hotkeyId == 1)
|
else if (hotkeyId == 1)
|
||||||
{
|
{
|
||||||
@@ -575,3 +611,4 @@ extern "C" __declspec(dllexport) PowertoyModuleIface* __cdecl powertoy_create()
|
|||||||
{
|
{
|
||||||
return new KeyboardManager();
|
return new KeyboardManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user