Skip to content

[CmdPal] Add system tray menu #39155

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

Merged
merged 4 commits into from
Jun 5, 2025

Conversation

davidegiacometti
Copy link
Collaborator

@davidegiacometti davidegiacometti commented Apr 29, 2025

Summary of the Pull Request

image

PR Checklist

Detailed Description of the Pull Request / Additional comments

  • Move all system tray related code from main window code behind to a dedicated service
  • Add system tray menu

Validation Steps Performed

Manually tested:

  • Started CmdPal with tray icon enabled
  • Started CmdPal with tray icon disabled
  • Enabled/Disabled tray icon
  • Tested tray menu commands
  • Verified that the tray icon is visible after restarting explorer.exe

@davidegiacometti davidegiacometti added the Product-Command Palette Refers to the Command Palette utility label Apr 29, 2025
@davidegiacometti davidegiacometti self-assigned this Apr 29, 2025
{
PInvoke.GetCursorPos(out var cursorPos);
PInvoke.SetForegroundWindow(_hwnd);
PInvoke.TrackPopupMenuEx(_popupMenu, (uint)TRACK_POPUP_MENU_FLAGS.TPM_LEFTALIGN | (uint)TRACK_POPUP_MENU_FLAGS.TPM_BOTTOMALIGN, cursorPos.X, cursorPos.Y, _hwnd, null);

Check failure

Code scanning / check-spelling

Unrecognized Spelling

[LEFTALIGN](#security-tab) is not a recognized word. \(unrecognized-spelling\)
@davidegiacometti davidegiacometti marked this pull request as draft April 29, 2025 19:52
@davidegiacometti davidegiacometti changed the title [CmdPal] Add system tray menu 🚧 [CmdPal] Add system tray menu Apr 29, 2025
@@ -216,7 +196,7 @@ private static DesktopAcrylicController GetAcrylicConfig(UIElement content)

private void ShowHwnd(IntPtr hwndValue, MonitorBehavior target)
{
var hwnd = new HWND(hwndValue);
var hwnd = new HWND(hwndValue != 0 ? hwndValue : _hwnd);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't like this.. 😒
Do we really need to propagate CmdPal window HWND from various messages? Isn't the HWND fixed?

@crutkas
Copy link
Member

crutkas commented Apr 29, 2025

i like it but i feel like we're in a mode where we need to really dark mode enable / unify the context menus :(

@davidegiacometti
Copy link
Collaborator Author

davidegiacometti commented Apr 30, 2025

I agree that dark mode would be nice but I also like the native approach (Runner and Awake tray icon menus also use native API).
I would love to see dark theme implemented at OS level at some point and get this for all PowerToys tray icon menus 😍

EDIT: otherwise we could explore another solution.. https://github.com/HavenDV/H.NotifyIcon comes to mind 🤔

@zadjii-msft
Copy link
Member

Is there any reason that this is still in draft? Seems like we can ship it.

(I'd probably also just leave the "exit" item there always, but that's just me)

@davidegiacometti
Copy link
Collaborator Author

davidegiacometti commented May 15, 2025

No reason. I just wanted to do more testing, which I did, but forgot to mark as ready.

As the PT arg has been removed I would love get a feedback on the Exit menu. Does it make sense to add Exit only when NOT started from the URI?

Then I will merge latest main and mark as ready.

@zadjii-msft
Copy link
Member

I frankly would just leave the exit item in the menu always. I still get a pretty decent number of cases where something goes sideways and I need to quit out of the palette, and being able to do that even when started from PT seems useful to me

(even if that's a little weird for how it integrates with PT)

@davidegiacometti davidegiacometti changed the title 🚧 [CmdPal] Add system tray menu [CmdPal] Add system tray menu May 15, 2025
@davidegiacometti davidegiacometti marked this pull request as ready for review May 15, 2025 19:40
@davidegiacometti davidegiacometti added the Needs-Review This Pull Request awaits the review of a maintainer. label May 23, 2025
Copy link
Contributor

@michaeljolley michaeljolley left a comment

Choose a reason for hiding this comment

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

LGTM :shipit:

@michaeljolley michaeljolley merged commit 3095827 into main Jun 5, 2025
16 checks passed
@michaeljolley michaeljolley deleted the users/davidegiacometti/cmdpal-tray-menu branch June 5, 2025 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs-Review This Pull Request awaits the review of a maintainer. Product-Command Palette Refers to the Command Palette utility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants