Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] The WAM Popup Windows Are Sometimes Not on the Top When Launch from VSCode #4887

Open
msJinLei opened this issue Aug 12, 2024 · 1 comment

Comments

@msJinLei
Copy link

msJinLei commented Aug 12, 2024

Library version used

N/A

.NET version

.net standard 2.0

Scenario

PublicClient - desktop app

Is this a new or an existing app?

The app is in production, and I have upgraded to a new version of MSAL

Issue description and reproduction steps

The customer reports that WAM window sometimes popup behind and they cannot see it initially.

Originally posted by @JeremyTBradshaw in Azure/azure-powershell#25120 (comment)

Originally posted by @peter-bertok in Azure/azure-powershell#24989

PowerShell console in Visual Studio Code is a case to reproduce the issue.

Relevant code snippets

enum GetAncestorFlags
{   
    GetParent = 1,
    GetRoot = 2,
    /// <summary>
    /// Retrieves the owned root window by walking the chain of parent and owner windows returned by GetParent.
    /// </summary>
    GetRootOwner = 3
}

/// <summary>
/// Retrieves the handle to the ancestor of the specified window.
/// </summary>
/// <param name="hwnd">A handle to the window whose ancestor is to be retrieved.
/// If this parameter is the desktop window, the function returns NULL. </param>
/// <param name="flags">The ancestor to be retrieved.</param>
/// <returns>The return value is the handle to the ancestor window.</returns>
[DllImport("user32.dll", ExactSpelling = true)]
static extern IntPtr GetAncestor(IntPtr hwnd, GetAncestorFlags flags);

[DllImport("kernel32.dll")]
static extern IntPtr GetConsoleWindow();

// This is your window handle!
public IntPtr GetConsoleOrTerminalWindow()
{
    IntPtr consoleHandle = GetConsoleWindow();
    IntPtr handle = GetAncestor(consoleHandle, GetAncestorFlags.GetRootOwner );
    
    return handle;
}

Expected behavior

WAM windows always popup on the front

Identity provider

Microsoft Entra ID (Work and School accounts and Personal Microsoft accounts)

Regression

No response

Solution and workarounds

The customers should look for the WAM popup very hard

@msJinLei msJinLei added needs attention Delete label after triage untriaged Do not delete. Needed for Automation labels Aug 12, 2024
@msJinLei msJinLei changed the title [Bug] The WAM Popup Windows are Sometimes on the Front [Bug] The WAM Popup Windows Are Sometimes Not on the Front Aug 12, 2024
@bgavrilMS bgavrilMS added bug P2 WAM and removed untriaged Do not delete. Needed for Automation needs attention Delete label after triage labels Aug 12, 2024
@bgavrilMS bgavrilMS changed the title [Bug] The WAM Popup Windows Are Sometimes Not on the Front [Bug] The WAM Popup Windows Are Sometimes Not on the top Aug 12, 2024
@bgavrilMS
Copy link
Member

The key point here is that the terminal window is hosted in VS Code.

@msJinLei msJinLei changed the title [Bug] The WAM Popup Windows Are Sometimes Not on the top [Bug] The WAM Popup Windows Are Sometimes Not on the Top When Launch from VSCode Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants