Skip to content

[Feature] PowerToys hotkey conflict detection - #41029

Merged
Shawn Yuan (shuaiyuanxx) merged 63 commits into
microsoft:mainfrom
shuaiyuanxx:shawn/hotkeyConflictDetectionBase
Aug 20, 2025
Merged

Shawn Yuan (shuaiyuanxx) merged 63 commits into
microsoft:mainfrom
shuaiyuanxx:shawn/hotkeyConflictDetectionBase

Conversation

@shuaiyuanxx

@shuaiyuanxx Shawn Yuan (shuaiyuanxx) commented Aug 7, 2025 •

Copy link
Copy Markdown
Contributor

Summary of the Pull Request

Implements comprehensive hotkey conflict detection and resolution system for PowerToys, providing real-time conflict checking and centralized management interface.

PR Checklist

TODO Lists

  • Add real-time hotkey validation functionality to the hotkey dialog
  • Immediately detect conflicts and update shortcut conflict status after applying new shortcuts
  • Return conflict list from runner hotkey conflict detector for conflict checking.
  • Implement the Tooltip for every shortcut control
  • Add dialog UI for showing all the shortcut conflicts
  • Support changing shortcut directly inside the shortcut conflict window/dialog, no need to nav to the settings page.
  • Redesign the ShortcutConflictDialogContentControl to align with the spec
  • Add navigating and changing hotkey auctionability to the ShortcutConflictDialogContentControl
  • Add telemetry. Impemented in another PR

Shortcut Conflict Support Modules

image

Demo videos
demo1.mp4
demo2.1.mp4
demo3.1.mp4
demo6.mp4

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

Manually validation performed.

Shawn Yuan (shuaiyuanxx) and others added 28 commits August 11, 2025 10:03
remove the ui for shortcut conflicts
and prepair for rebase to the new ui design.

Signed-off-by: Shawn Yuan <shuaiyuan@microsoft.com>
Signed-off-by: Shawn Yuan <shuaiyuan@microsoft.com>
Signed-off-by: Shuai Yuan <shuai.yuan.zju@gmail.com>
Signed-off-by: Shuai Yuan <shuai.yuan.zju@gmail.com>
Update Shortcut control.
Update UI for hotkey conflict in AdvancedPaste module.

Signed-off-by: Shuai Yuan <shuai.yuan.zju@gmail.com>
Signed-off-by: Shuai Yuan <shuai.yuan.zju@gmail.com>
Signed-off-by: Shuai Yuan <shuai.yuan.zju@gmail.com>
Signed-off-by: Shuai Yuan <shuai.yuan.zju@gmail.com>
Signed-off-by: Shuai Yuan <shuai.yuan.zju@gmail.com>
Signed-off-by: Shuai Yuan <shuai.yuan.zju@gmail.com>
Signed-off-by: Shuai Yuan <shuai.yuan.zju@gmail.com>
Signed-off-by: Shuai Yuan <shuai.yuan.zju@gmail.com>
Signed-off-by: Shuai Yuan <shuai.yuan.zju@gmail.com>
Signed-off-by: Shuai Yuan <shuai.yuan.zju@gmail.com>
Signed-off-by: Shuai Yuan <shuai.yuan.zju@gmail.com>
Signed-off-by: Shuai Yuan <shuai.yuan.zju@gmail.com>
Signed-off-by: Shuai Yuan <shuai.yuan.zju@gmail.com>
Signed-off-by: Shuai Yuan <shuai.yuan.zju@gmail.com>
Added navigation to hotkey conflict detection dialog card.

Signed-off-by: Shuai Yuan <shuai.yuan.zju@gmail.com>
Signed-off-by: Shuai Yuan <shuai.yuan.zju@gmail.com>
Signed-off-by: Shuai Yuan <shuai.yuan.zju@gmail.com>
Signed-off-by: Shuai Yuan <shuai.yuan.zju@gmail.com>
Signed-off-by: Shuai Yuan <shuai.yuan.zju@gmail.com>
Signed-off-by: Shuai Yuan <shuai.yuan.zju@gmail.com>
Signed-off-by: Shuai Yuan <shuai.yuan.zju@gmail.com>
Signed-off-by: Shuai Yuan <shuai.yuan.zju@gmail.com>
Signed-off-by: Shuai Yuan <shuai.yuan.zju@gmail.com>
Signed-off-by: Shuai Yuan <shuai.yuan.zju@gmail.com>
{
private static IPCResponseService _instance;

public static IPCResponseService Instance => _instance ??= new IPCResponseService();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now, you cannot do unittest easily for the core logic here, given it has strong binding with Shell related implementation.

Consider to make IPCResponseService, and use DI to inject the right implementation accordingly.

For DI, you can refer to CommandPalette, you can see in its App.xaml.cs, it will register the singleton creation for instance.
As the result, you can inject different implementation during unittest.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if this Service can be replacing implementation, probably GlobalHotKeyConfictManager as well as PageViewModelBase.cs (or just pick one ViewModel) can be do unittest.


namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
public class ShortcutConflictViewModel : PageViewModelBase, IDisposable

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe both this ViewModel (or you can pick anyone inherit it) and the SettingsFactory can do unittest.

Especially if you already want to see if there is anything "you worry" people doesn't implement correctly, instead of failing during runtime, you can fail at unittest instead of just write debug information.

Signed-off-by: Shawn Yuan <shuaiyuan@microsoft.com>
@github-actions

This comment has been minimized.

This guidance is intended to help developers understand
how to add conflict detection support when introducing new hotkeys.

Signed-off-by: Shawn Yuan <shuaiyuan@microsoft.com>
@shuaiyuanxx
Shawn Yuan (shuaiyuanxx) marked this pull request as ready for review August 19, 2025 02:52
Signed-off-by: Shawn Yuan <shuaiyuan@microsoft.com>
Signed-off-by: Shawn Yuan <shuaiyuan@microsoft.com>
@shuaiyuanxx Shawn Yuan (shuaiyuanxx) added the Product-Settings The standalone PowerToys Settings application label Aug 19, 2025
Signed-off-by: Shawn Yuan <shuaiyuan@microsoft.com>
Signed-off-by: Shawn Yuan <shuaiyuan@microsoft.com>
Signed-off-by: Shawn Yuan <shuaiyuan@microsoft.com>
Signed-off-by: Shawn Yuan <shuaiyuan@microsoft.com>

This comment was marked as outdated.

@shuaiyuanxx
Shawn Yuan (shuaiyuanxx) merged commit 75526b9 into microsoft:main Aug 20, 2025

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements comprehensive hotkey conflict detection and resolution for PowerToys, adding real-time conflict checking and a centralized management interface. The implementation provides visual indicators for hotkey conflicts, a dedicated conflict resolution dialog, and integration throughout the Settings UI.

Key changes include:

  • Implementation of global hotkey conflict management with IPC communication for real-time updates
  • Creation of a new PageViewModelBase class that standardizes conflict handling across all module ViewModels
  • Addition of hotkey conflict detection infrastructure with visual feedback in hotkey controls

Reviewed Changes

Copilot reviewed 102 out of 104 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/settings-ui/Settings.UI/ViewModels/PageViewModelBase.cs New base class providing conflict management functionality for all module ViewModels
src/settings-ui/Settings.UI/Services/GlobalHotkeyConflictManager.cs Central service for managing hotkey conflicts with IPC communication
src/settings-ui/Settings.UI/SettingsXAML/Controls/Dashboard/ShortcutConflictWindow.xaml New dedicated window for viewing and resolving hotkey conflicts
src/settings-ui/Settings.UI/Library/HotkeySettings.cs Enhanced with conflict detection properties and change notifications
Multiple ViewModels (*ViewModel.cs) Updated to inherit from PageViewModelBase and implement hotkey conflict detection

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

{
Settings.Properties.ToggleEasyMouseShortcut = value ?? MouseWithoutBordersProperties.DefaultHotKeyToggleEasyMouse;
NotifyPropertyChanged();
NotifyModuleUpdatedSettings();

Copilot AI Aug 27, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method NotifyModuleUpdatedSettings() is being called but is not defined in this class or its base class. This will cause a compilation error.

Copilot uses AI. Check for mistakes.
Settings.Properties.LockMachineShortcut = value;
Settings.Properties.LockMachineShortcut = value ?? MouseWithoutBordersProperties.DefaultHotKeyLockMachine;
NotifyPropertyChanged();
NotifyModuleUpdatedSettings();

Copilot AI Aug 27, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method NotifyModuleUpdatedSettings() is being called but is not defined in this class or its base class. This will cause a compilation error.

Copilot uses AI. Check for mistakes.
Settings.Properties.ReconnectShortcut = value;
Settings.Properties.ReconnectShortcut = value ?? MouseWithoutBordersProperties.DefaultHotKeyReconnect;
NotifyPropertyChanged();
NotifyModuleUpdatedSettings();

Copilot AI Aug 27, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method NotifyModuleUpdatedSettings() is being called but is not defined in this class or its base class. This will cause a compilation error.

Copilot uses AI. Check for mistakes.
Settings.Properties.Switch2AllPCShortcut = value;
Settings.Properties.Switch2AllPCShortcut = value ?? MouseWithoutBordersProperties.DefaultHotKeySwitch2AllPC;
NotifyPropertyChanged();
NotifyModuleUpdatedSettings();

Copilot AI Aug 27, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method NotifyModuleUpdatedSettings() is being called but is not defined in this class or its base class. This will cause a compilation error.

Copilot uses AI. Check for mistakes.
int isEnabled = 0;
NativeMethods.SystemParametersInfo(NativeMethods.SPI_GETCLIENTAREAANIMATION, 0, ref isEnabled, 0);

Utilities.NativeMethods.SystemParametersInfo(Utilities.NativeMethods.SPI_GETCLIENTAREAANIMATION, 0, ref isEnabled, 0);

Copilot AI Aug 27, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The namespace Utilities.NativeMethods appears to be incorrect. Based on the original code pattern, this should likely be NativeMethods.SystemParametersInfo without the Utilities prefix.

Suggested change
Utilities.NativeMethods.SystemParametersInfo(Utilities.NativeMethods.SPI_GETCLIENTAREAANIMATION, 0, ref isEnabled, 0);
NativeMethods.SystemParametersInfo(NativeMethods.SPI_GETCLIENTAREAANIMATION, 0, ref isEnabled, 0);

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Product-Settings The standalone PowerToys Settings application

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants