Skip to content

surface UAC consent prompt in the foreground#5154

Merged
Gabriel Dufresne (GabrielDuf) merged 2 commits into
mainfrom
fix/5146-uac-prompt-foreground
Jul 20, 2026
Merged

surface UAC consent prompt in the foreground#5154
Gabriel Dufresne (GabrielDuf) merged 2 commits into
mainfrom
fix/5146-uac-prompt-foreground

Conversation

@GabrielDuf

Copy link
Copy Markdown
Contributor

This pull request improves how the application handles User Account Control (UAC) consent prompts on Windows, ensuring that the consent dialog appears in the foreground and is not hidden behind other windows. The main changes introduce a mechanism for the UI layer to bring the main window forward before a UAC prompt is shown, and update the elevation logic to support this behavior.

Foreground window activation for UAC prompts:

  • Added a BringMainWindowToForegroundAsync delegate to CoreData, allowing the UI layer to expose a method for bringing the main window to the foreground before a UAC prompt is triggered. This ensures the consent prompt is not hidden behind other windows, especially when secure desktop is off.
  • In MainWindow.axaml.cs, set CoreData.BringMainWindowToForegroundAsync to a method that brings the window forward only if it is currently visible, preventing the window from being shown unexpectedly if it's hidden in the tray.
  • Updated the UAC elevation logic in Tools.cs to call BringMainWindowToForegroundAsync (if set) and then invoke the Windows API AllowSetForegroundWindow, ensuring the consent dialog can take focus.
  • Added P/Invoke definitions for AllowSetForegroundWindow and related constants to support the above logic.

Code organization:

  • Added a missing import for UniGetUI.Core.Data in MainWindow.axaml.cs to support the new delegate.

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

Improves Windows UAC prompt foreground activation by coordinating the UI and elevation layers.

Changes:

  • Adds a main-window activation delegate.
  • Activates visible windows before cached elevation.
  • Adds Windows foreground permission interop.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/UniGetUI.Core.Tools/Tools.cs Prepares foreground access before cached elevation.
src/UniGetUI.Core.Data/CoreData.cs Exposes the UI activation delegate.
src/UniGetUI.Avalonia/Views/MainWindow.axaml.cs Registers visible-window activation behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/UniGetUI.Core.Tools/Tools.cs Outdated
Comment thread src/UniGetUI.Core.Tools/Tools.cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Les alertes de demande d'autorisation d'exécution en mode admnistrateur ne passent pas au 1er plan de l'écran

3 participants