Skip to content

Modern standard window context menu - #19075

Closed
hoshiizumiya wants to merge 2 commits into
files-community:mainfrom
hoshiizumiya:ModernStandardWindowContextMenu
Closed

hoshiizumiya wants to merge 2 commits into
files-community:mainfrom
hoshiizumiya:ModernStandardWindowContextMenu

Conversation

@hoshiizumiya

Copy link
Copy Markdown
Contributor

Resolved / Related Issues

To prevent extra work, all changes to the Files codebase must link to an approved issue marked as Ready to build. Please insert the issue number following the hashtag with the issue number that this Pull Request resolves.

  • Closes None

Steps used to test these changes

Stability is a top priority for Files and all changes are required to go through testing before being merged into the repo. Please include a list of steps that you used to test this PR.
Previously:
image
After:
image

@0x5bfa 0x5bfa left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Recommend reading our contribution guidelines and follow the PR template.

In my opinion, this is more code little gain.


// These declarations are local to the port; the app already uses user32.dll.
[DllImport("user32.dll", ExactSpelling = true)]
private static extern nint GetSystemMenu(nint hWnd, [MarshalAs(UnmanagedType.Bool)] bool revert);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Use CsWin32 instead of manually writing interop code, including DllImport, constants, structs, enums, etc.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Refactored

MinWidth="200"
Style="{StaticResource WindowExModernSystemMenuItemStyle}">
<MenuFlyoutItem.Icon>
<PathIcon Data="M921.5,303.5C921.5,275.833 916,249.75 905,225.25C894,200.75 879.083,179.417 860.25,161.25C841.417,143.083 819.583,128.75 794.75,118.25C769.917,107.75 743.833,102.5 716.5,102.5L213.5,102.5C218.833,87.1667 226.333,73.1667 236,60.5C245.667,47.8334 256.833,37.0001 269.5,28C282.167,19.0001 296.083,12.0834 311.25,7.25C326.417,2.41669 342.167,0 358.5,0L716.5,0C758.833,0 798.667,8.08337 836,24.25C873.333,40.4167 905.917,62.3334 933.75,90C961.583,117.667 983.583,150.167 999.75,187.5C1015.92,224.833 1024,264.667 1024,307L1024,665.5C1024,681.833 1021.58,697.583 1016.75,712.75C1011.92,727.917 1005,741.833 996,754.5C987,767.167 976.167,778.333 963.5,788C950.833,797.667 936.833,805.167 921.5,810.5ZM151,1024C131,1024 111.833,1019.92 93.5,1011.75C75.1667,1003.58 59.0833,992.583 45.25,978.75C31.4167,964.917 20.4167,948.833 12.25,930.5C4.08333,912.167 0,893 0,873L0,356C0,335.667 4.08333,316.417 12.25,298.25C20.4167,280.083 31.4167,264.083 45.25,250.25C59.0833,236.417 75.0833,225.417 93.25,217.25C111.417,209.083 130.667,205 151,205L668,205C688.333,205 707.667,209.083 726,217.25C744.333,225.417 760.333,236.333 774,250C787.667,263.667 798.583,279.667 806.75,298C814.917,316.333 819,335.667 819,356L819,873C819,893.333 814.917,912.583 806.75,930.75C798.583,948.917 787.583,964.917 773.75,978.75C759.917,992.583 743.917,1003.58 725.75,1011.75C707.583,1019.92 688.333,1024 668,1024ZM665.5,921.5C672.5,921.5 679.083,920.167 685.25,917.5C691.417,914.833 696.917,911.167 701.75,906.5C706.583,901.833 710.333,896.417 713,890.25C715.667,884.083 717,877.5 717,870.5L717,358.5C717,351.5 715.667,344.833 713,338.5C710.333,332.167 706.667,326.667 702,322C697.333,317.333 691.833,313.667 685.5,311C679.167,308.333 672.5,307 665.5,307L153.5,307C146.5,307 139.917,308.333 133.75,311C127.583,313.667 122.167,317.417 117.5,322.25C112.833,327.083 109.167,332.583 106.5,338.75C103.833,344.917 102.5,351.5 102.5,358.5L102.5,870.5C102.5,877.5 103.833,884.083 106.5,890.25C109.167,896.417 112.833,901.833 117.5,906.5C122.167,911.167 127.583,914.833 133.75,917.5C139.917,920.167 146.5,921.5 153.5,921.5Z" />

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Use &#xE923;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

As far as I know, the windows10 will display unexpectable if we don't use PathIcon here.

x:Name="MinimizeItem"
Style="{StaticResource WindowExModernSystemMenuItemStyle}">
<MenuFlyoutItem.Icon>
<PathIcon Data="M51,512C44,512 37.4167,510.667 31.25,508C25.0833,505.333 19.6667,501.667 15,497C10.3333,492.333 6.66667,486.917 4,480.75C1.33333,474.583 0,468 0,461C0,454 1.33333,447.417 4,441.25C6.66667,435.083 10.3333,429.583 15,424.75C19.6667,419.917 25.0833,416.167 31.25,413.5C37.4167,410.833 44,409.5 51,409.5L973,409.5C980,409.5 986.583,410.833 992.75,413.5C998.917,416.167 1004.33,419.917 1009,424.75C1013.67,429.583 1017.33,435.083 1020,441.25C1022.67,447.417 1024,454 1024,461C1024,468 1022.67,474.583 1020,480.75C1017.33,486.917 1013.67,492.333 1009,497C1004.33,501.667 998.917,505.333 992.75,508C986.583,510.667 980,512 973,512Z" />

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Use &#xE921;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I believe it will display abnormally if the user lacks of related font family.

x:Name="MaximizeItem"
Style="{StaticResource WindowExModernSystemMenuItemStyle}">
<MenuFlyoutItem.Icon>
<PathIcon Data="M151,1024C131,1024 111.833,1019.92 93.5,1011.75C75.1667,1003.58 59.0833,992.583 45.25,978.75C31.4167,964.917 20.4167,948.833 12.25,930.5C4.08333,912.167 0,893 0,873L0,151C0,131 4.08333,111.833 12.25,93.5C20.4167,75.1667 31.4167,59.0834 45.25,45.25C59.0833,31.4167 75.1667,20.4167 93.5,12.25C111.833,4.08337 131,0 151,0L873,0C893,0 912.167,4.08337 930.5,12.25C948.833,20.4167 964.917,31.4167 978.75,45.25C992.583,59.0834 1003.58,75.1667 1011.75,93.5C1019.92,111.833 1024,131 1024,151L1024,873C1024,893 1019.92,912.167 1011.75,930.5C1003.58,948.833 992.583,964.917 978.75,978.75C964.917,992.583 948.833,1003.58 930.5,1011.75C912.167,1019.92 893,1024 873,1024ZM870.5,921.5C877.5,921.5 884.083,920.167 890.25,917.5C896.417,914.833 901.833,911.167 906.5,906.5C911.167,901.833 914.833,896.417 917.5,890.25C920.167,884.083 921.5,877.5 921.5,870.5L921.5,153.5C921.5,146.5 920.167,139.917 917.5,133.75C914.833,127.583 911.167,122.167 906.5,117.5C901.833,112.833 896.417,109.167 890.25,106.5C884.083,103.833 877.5,102.5 870.5,102.5L153.5,102.5C146.5,102.5 139.917,103.833 133.75,106.5C127.583,109.167 122.167,112.833 117.5,117.5C112.833,122.167 109.167,127.583 106.5,133.75C103.833,139.917 102.5,146.5 102.5,153.5L102.5,870.5C102.5,877.5 103.833,884.083 106.5,890.25C109.167,896.417 112.833,901.833 117.5,906.5C122.167,911.167 127.583,914.833 133.75,917.5C139.917,920.167 146.5,921.5 153.5,921.5Z" />

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Use &#xE922;

FontWeight="Bold"
Style="{StaticResource WindowExModernSystemMenuItemStyle}">
<MenuFlyoutItem.Icon>
<PathIcon Data="M512,584.5L87.5,1009C77.5,1019 65.5,1024 51.5,1024C36.8333,1024 24.5833,1019.08 14.75,1009.25C4.91667,999.417 0,987.167 0,972.5C0,958.5 5,946.5 15,936.5L439.5,512L15,87.5C5,77.5 0,65.3334 0,51C0,44 1.33333,37.3334 4,31C6.66667,24.6667 10.3333,19.25 15,14.75C19.6667,10.25 25.1667,6.66669 31.5,4C37.8333,1.33337 44.5,0 51.5,0C65.5,0 77.5,5 87.5,15L512,439.5L936.5,15C946.5,5 958.667,0 973,0C980,0 986.583,1.33337 992.75,4C998.917,6.66669 1004.33,10.3334 1009,15C1013.67,19.6667 1017.33,25.0834 1020,31.25C1022.67,37.4167 1024,44 1024,51C1024,65.3334 1019,77.5 1009,87.5L584.5,512L1009,936.5C1019,946.5 1024,958.5 1024,972.5C1024,979.5 1022.67,986.167 1020,992.5C1017.33,998.833 1013.75,1004.33 1009.25,1009C1004.75,1013.67 999.333,1017.33 993,1020C986.667,1022.67 980,1024 973,1024C958.667,1024 946.5,1019 936.5,1009Z" />

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Use &#xE8BB;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is this necessary?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Of course we need the xaml file to display it like we want.

@yair100

yair100 commented Oct 28, 2026

Copy link
Copy Markdown
Member

@hoshiizumiya we don't mind if contributors use AI in their work, but only if they already have a solid understanding of the codebase. Considering this is your first PR, it would be advisable to first learn your way around the codebase.

@yair100 yair100 closed this Oct 28, 2026
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@hoshiizumiya

Copy link
Copy Markdown
Contributor Author

Recommend reading our contribution guidelines and follow the PR template.

In my opinion, this is more code little gain.

I believe all of us want to have a morden menu style and unify with already exiting file's titlebar operation. So it's worth easily. Why not?

@0x5bfa

0x5bfa commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Have we said so? We should first discuss this change, filing an issue. Plus, as Yair told, please read our contribution guidelines before opening any PR, so that both sides won't waste time.

DO create one pull request per Issue, and ensure that the Issue is linked in the pull request.

DO NOT submit a PR unless the connected issue is marked as ready to build or approved by an org member. This enables us to have a discussion on the idea before anyone invests time on the implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants