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

Feature: Improved (but hacky) context menu loading #11966

Merged
merged 3 commits into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Files.App/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Files.App.ServicesImplementation;
using Files.App.ServicesImplementation.DateTimeFormatter;
using Files.App.ServicesImplementation.Settings;
using Files.App.Shell;
using Files.App.Storage.NativeStorage;
using Files.App.UserControls.MultitaskingControl;
using Files.App.ViewModels;
Expand Down Expand Up @@ -139,7 +140,8 @@ await Task.WhenAll(

await Task.WhenAll(
JumpListHelper.InitializeUpdatesAsync(),
addItemService.GetNewEntriesAsync()
addItemService.GetNewEntriesAsync(),
ContextMenu.WarmUpQueryContextMenuAsync()
);

FileTagsHelper.UpdateTagsDb();
Expand Down
13 changes: 13 additions & 0 deletions src/Files.App/Shell/ContextMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,19 @@ public async Task InvokeItem(int itemID)
}
}

public static async Task WarmUpQueryContextMenuAsync()
{
var thread = new ThreadWithMessageQueue();
await thread.PostMethod(() =>
{
// Create a dummy context menu for warming up
var shellItem = ShellFolderExtensions.GetShellItemFromPathOrPidl("C:\\");
Shell32.IContextMenu menu = shellItem.Parent.GetChildrenUIObjects<Shell32.IContextMenu>(default, shellItem);
menu.QueryContextMenu(User32.CreatePopupMenu(), 0, 1, 0x7FFF, Shell32.CMF.CMF_NORMAL);
});
thread.Dispose();
}

#endregion FactoryMethods

private void EnumMenuItems(
Expand Down