HavenDV / H.NotifyIcon

TrayIcon for WPF/WinUI/Uno/MAUI
MIT License
563 stars 46 forks source link

ContextMenuMode="SecondWindow" has issue with WinUI when clicking MenuFlyoutSubItem before it displays its children #161

Closed airtaxi closed 2 months ago

airtaxi commented 2 months ago

Describe the bug

Hi, thanks for the great library! But I found a bug with ContextMenuMode for WinUI.

ContextMenuMode="SecondWindow" has issue with WinUI when clicking MenuFlyoutSubItem before it displays its children

Steps to reproduce the bug

Expected behavior

Screenshots

Gif below (might takes some time to load): Honeycam 2024-08-15 09-08-23

NuGet package version

Platform

WinUI

IDE

Visual Studio 2022

Windows Version

Windows 11

WindowsAppSDK Version

Other

WindowsAppSDK Type

Unpackaged

Manifest

If you mean app.manifest, the project has this. But problem also occurs without <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/> statement

<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
    <assemblyIdentity version="1.0.0.0" name="PinStats.app"/>
    <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
        <security>
            <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
                <!-- This process needs to be run as administrator to access the hardware information. -->
                <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
            </requestedPrivileges>
        </security>
    </trustInfo>

    <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
        <application>
            <!--The ID below informs the system that this application is compatible with OS features first introduced in Windows 8. 
      For more info see https://docs.microsoft.com/windows/win32/sysinfo/targeting-your-application-at-windows-8-1 

      It is also necessary to support features in unpackaged applications, for example the custom titlebar implementation.-->
            <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />
        </application>
    </compatibility>

    <application xmlns="urn:schemas-microsoft-com:asm.v3">
        <windowsSettings>
            <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
        </windowsSettings>
    </application>
</assembly>

Additional context

Haven't reviewed source code, but maybe H.NotifyIcon handles MenuFlyoutSubItem as clickable object that makes ContextMenu to dismiss?

HavenDV commented 2 months ago

All the code regarding SecondWindow is located in TaskbarIcon.ContextMenu.WinUI.SecondWindow.cs. There are only 200 lines there. No ideas yet, it could be a bug in WinUI, or some other problems with this code

airtaxi commented 2 months ago

@HavenDV Just reviewed the source code but I think this issue wil be resolved if we add an exception for MenuFlyoutSubItem at line between 119~130 of TaskbarIcon.ContextMenu.WinUI.SecondWindow.cs May I make pull request for that?

HavenDV commented 2 months ago

Yes of course, that would be great.

airtaxi commented 2 months ago

@HavenDV I just made a pull request! feel free to review that :)

HavenDV commented 2 months ago

Available on NuGet as 2.1.2

airtaxi commented 2 months ago

@HavenDV Works like a charm! Thanks for the instant update!