PowerToys icon indicating copy to clipboard operation
PowerToys copied to clipboard

[Settings] Implement singleton pattern for ShortcutConflictWindow

Open Copilot opened this issue 4 months ago • 1 comments

Summary

Fixes issue where multiple ShortcutConflictWindow instances could be opened simultaneously. The window now follows the same singleton pattern as OobeWindow - only one instance can exist at a time, and attempting to open another brings the existing window to the foreground.

Changes

Implemented singleton management for ShortcutConflictWindow following the established pattern used by OobeWindow:

App.xaml.cs

  • Added static field to store the singleton window instance
  • Added GetShortcutConflictWindow(), SetShortcutConflictWindow(), and ClearShortcutConflictWindow() methods for lifecycle management

ShortcutConflictWindow.xaml.cs

  • Updated WindowEx_Closed event handler to call App.ClearShortcutConflictWindow() to properly clean up the singleton reference when the window is closed

Updated all three entry points that create ShortcutConflictWindow:

  • ShortcutConflictControl.xaml.cs (Dashboard conflict warning)
  • ShortcutControl.xaml.cs (Settings page shortcut controls)
  • OobeOverview.xaml.cs (OOBE overview page)

Each location now checks if a window already exists using App.GetShortcutConflictWindow():

  • If no window exists, creates a new one and registers it via App.SetShortcutConflictWindow()
  • If a window already exists, simply calls Activate() to bring it to the foreground

Testing

The fix ensures that:

  • ✅ Only one ShortcutConflictWindow can be open at a time
  • ✅ Clicking the shortcut conflict button when a window is already open activates the existing window instead of creating a duplicate
  • ✅ The window reference is properly cleared when closed, allowing a new instance to be created in future interactions

Fixes #[issue_number]

[!WARNING]

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • i1qvsblobprodcus353.vsblob.vsassets.io
    • Triggering command: dotnet build PowerToys.Settings.csproj --configuration Release (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>[Settings] Single Shortcuts Conflicts window</issue_title> <issue_description>### Microsoft PowerToys version

0.95.0

Installation method

GitHub

Area(s) with issue?

Settings

Steps to reproduce

Multiple shortcut conflicts window can be launched. Should have the same behavior of OOBE window. If shortcut conflicts window is already opened, pressing the button should bring the window in foreground.

✔️ Expected Behavior

Single shortcuts conflicts window

❌ Actual Behavior

Multiple shortcut conflicts window can be launched

Additional Information

No response

Other Software

No response</issue_description>

<agent_instructions>Settings ShortcutConflictWindow should have the same behavior of OobeWindow. When ShortcutConflictWindow is already opened, activate that window instead of opening another one. </agent_instructions>

Comments on the Issue (you are @copilot in this section)

Fixes microsoft/PowerToys#42437


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot avatar Oct 16 '25 18:10 Copilot

@check-spelling-bot Report

:red_circle: Please review

See the :open_file_folder: files view, the :scroll:action log, or :memo: job summary for details.

:x: Errors Count
:x: forbidden-pattern 3

See :x: Event descriptions for more information.

Forbidden patterns :no_good: (1)

In order to address this, you could change the content to not match the forbidden patterns (comments before forbidden patterns may help explain why they're forbidden), add patterns for acceptable instances, or adjust the forbidden patterns themselves.

These forbidden patterns matched content:

Should be ; otherwise or . Otherwise

https://study.com/learn/lesson/otherwise-in-a-sentence.html

, [Oo]therwise\b
If the flagged items are :exploding_head: false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it, try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

github-actions[bot] avatar Oct 16 '25 19:10 github-actions[bot]