Skip to content

Conversation

@BLM16
Copy link
Contributor

@BLM16 BLM16 commented Jan 9, 2023

Summary of the Pull Request

Adds the ability to toggle the system tray icon through a setting in the General tab.

PR Checklist

Detailed Description of the Pull Request / Additional comments

Closes #9526 by contributing the functionality to hide the tray icon. This does not remove the icon process, which the modules depend on, but rather uses Windows' dwState and dwStateMask and only hides the icon from view. This does not impact the functionality of the modules or settings.

Validation Steps Performed

  • Automated testing succeeds
  • Built and tested the toggle observing the settings file
  • Confirmed the hide icon context menu option exists
  • Confirmed the icon disappears from the system tray when it should
  • Confirmed the exit button in the settings UI kills PowerToys

Todo

  • Ensure/fix running the executable opens the current settings menu
  • Call the icon visibility change function when IPC is notified of a change to the setting
  • Add a context menu option to hide the system tray icon
  • Add a button in settings to exit PowerToys both in the absence of an icon and as an intuitive place for such an option

@BLM16
Copy link
Contributor Author

BLM16 commented Jan 9, 2023 via email

@BLM16 BLM16 changed the title Added option to toggle the system tray icon Option to toggle the system tray icon Jan 9, 2023
@htcfreek
Copy link
Collaborator

htcfreek commented Jan 9, 2023

@crutkas
Can we accept this PR? The issue is closed. And how does someone opens the settings menu without icon?

@BLM16
Copy link
Contributor Author

BLM16 commented Jan 9, 2023

And how does someone opens the settings menu without icon?

If PowerToys is running, launching the shortcut or the executable again finds the running system tray process and calls the settings command bound to it as if you right clicked and pressed it yourself.

This is not working currently with my dev environment so I need to make sure this works before marking this not a draft.

@Jay-o-Way
Copy link
Collaborator

Jay-o-Way commented Jan 9, 2023

If PowerToys is running, launching the shortcut or the executable again finds the running system tray process and calls the settings command bound to it as if you right clicked and pressed it yourself.

Unfortunately, that does not seem to be the case.

P.S. 765 is dup'ed against #9526

Note
Removing the tray icon requires a set of steps that can be implemented ahead of adding the actual option to hide the icon.

@BLM16 Looks like this is much more complicated...

@BLM16
Copy link
Contributor Author

BLM16 commented Jan 10, 2023

If PowerToys is running, launching the shortcut or the executable again finds the running system tray process and calls the settings command bound to it as if you right clicked and pressed it yourself.

Unfortunately, that does not seem to be the case.

I commented on this in #8277 and will be including that fix in my next push. My fix seems to have resolved the issue.

@BLM16 BLM16 closed this Jan 10, 2023
@BLM16 BLM16 reopened this Jan 10, 2023
@BLM16 BLM16 marked this pull request as ready for review January 10, 2023 02:01
@BLM16
Copy link
Contributor Author

BLM16 commented Jan 15, 2023

There are numerous steps under #9526 that I would like to clarify.

  • Creating a new icon for the bug report tool & documentation about the bug tool.
    • Is this necessary? This seems unrelated to hiding the tray icon itself. People accept the loss of functionality such as quick access to the bug report tool by enabling this.
  • Documentation about changes affecting the Exit command.
    • I have not added any option to exit PowerToys when the icon is hidden. When enabled, it would act as a service that would not need to be exited.
    • PowerToys can always be killed via task manager if needed.
    • An exit option at the bottom of general settings could be implemented if desired which would be self explanatory.
    • What sort of documentation needs to be written with regards to closing the application?
  • Specs for changes affecting the tray icon context menu items.
    • What needs to be clarified here? Hiding the icon removes the ability to use the context menu. Is this related to the future flyout window?
  • Documentation for the settings option to hide the tray icon.
    • What needs to be documented here? Toggling the "Hide system tray icon" switch along with the description of how to access settings again seems self explanatory.

What of these needs to be done? It seems to me like the setting itself along with how all other similar tools operate means documentation is self explanatory and theoretically shouldn't be needed.

Does the bug report tool change need to be included in this feature? Should it not be migrated to a separate issue to be included in the roadmap?

@BLM16 BLM16 requested a review from Jay-o-Way January 15, 2023 00:17
@Jay-o-Way
Copy link
Collaborator

Jay-o-Way commented Jan 15, 2023

Thanks for asking me, but those things are beyond me 😇 I would point to @enricogior, but he fell off the grid...
Best I could do try the branch on my computer in the coming days...

@Jay-o-Way Jay-o-Way removed their request for review January 15, 2023 16:57
@jaimecbernardo
Copy link
Contributor

We're currently extending the system tray icon functionalities: #22408

Why is the change in this PR required?
Indeed I don't think it can be accepted right now since the tray icon is the only way (in the UI, not talking about directly terminating the process) to exit PowerToys and creating a Bug Report.

@Jay-o-Way
Copy link
Collaborator

Why is the change in this PR required?

Hundreds of people have been asking for this?

@BLM16
Copy link
Contributor Author

BLM16 commented Jan 16, 2023

We're currently extending the system tray icon functionalities: #22408

Why is the change in this PR required?
Indeed I don't think it can be accepted right now since the tray icon is the only way (in the UI, not talking about directly terminating the process) to exit PowerToys and creating a Bug Report.

If the user wishes to use PowerToys as a service, their choice to remove the UI flyout is their own.

There is already a link at the top of the settings menu (at least general settings) that links to the bug report.

My thought was adding a button to the settings menu (would have to determine an ideal location if you have any ideas) that exits the program.

If any functionality is desired once the icon has been hidden, it is simply a matter of relaunching PowerToys via the executable and disabling the hide icon setting.

@htcfreek
Copy link
Collaborator

Please have in mind that the context menu entry in tray creates a bug report file and the link in settings app opens the GitHub page.

I personally don't like this change because it brings us trouble.

@BLM16
Copy link
Contributor Author

BLM16 commented Jan 16, 2023

Please have in mind that the context menu entry in tray creates a bug report file and the link in settings app opens the GitHub page.

I think this is a product design issue overall actually, as different methods of reporting a bug feels inconsistent. Currently my bug report option from the context menu doesn't work (I am investigating this before creating an issue), however different methods of reporting bugs seems rather unmanageable and confusing.

@Jay-o-Way
Copy link
Collaborator

Oh by the way, is common that the menu itself has a "hide menu" item too 💡

@BLM16
Copy link
Contributor Author

BLM16 commented Jan 16, 2023

Oh by the way, is common that the menu itself has a "hide menu" item too 💡

That is one of the features I plan to implement soon. Which part of the context menu do you think should this go under?

@Jay-o-Way
Copy link
Collaborator

Above exit should be fine if you ask me

@crutkas
Copy link
Member

crutkas commented Jan 19, 2023

As @jaimecbernardo called out, we are in the process of extending the system tray icon functionalities, #22408 to add in a quick launcher and super charge that menu.

I do understand the user ask, but I feel like this is a partial solution to what was called out.

Two big items is I don't think are actually addressed that the root issue did call out as needed implementation

  • How to know PT is running / How do you quit
    • To me, this i think is a larger Q, what is the design here.
  • How to report a bug report
    • I think guidance in the bug report we may be able to solve with direct EXE @jaimecbernardo assuming this would work, a direct exe call

@BLM16
Copy link
Contributor Author

BLM16 commented Jan 19, 2023

As @jaimecbernardo called out, we are in the process of extending the system tray icon functionalities, #22408 to add in a quick launcher and super charge that menu.

Yes, and I think this is a great idea. A Win11 action center style flyout makes total sense for PowerToys. If people wish to run PT as a service (simply using the keyboard shortcuts for a few modules, or setting FancyZones once and leaving them) they can hide the PT icon with no repercussions (once the quit/bug report are fixed). I think giving people the option since they have asked is a good idea, leaving the decision up to them about whether or not they want it.

  • How to know PT is running / How do you quit

I cannot think of any other way to indicate PT is running, but that is the same as tons of other apps and services that are background processes. The icon will be visible by default, and it would only be hidden by people who don't want it. As such, the users who have hidden the icon know that the process is running (unless they quit or don't have run on start enabled). The use case for hiding the icon would be for people who aren't going to be frequently changing anything and simply wish for it to run in the background.

As for quitting, I am going to add the ability to stop PT directly from the settings menu, which I think should be implemented regardless of whether this PR is merged. Add the ability to quit alongside all the other settings options where you would expect.

  • How to report a bug report

I think it is important to determine how bugs are to be reported firstly. There are 2 different methods where the icon shortcut launches the exe, but the link from settings redirects to the github issues. This should be standardized (unless I am unaware of the reason for this). The link from settings would report the bugs fine. In the case of reporting a bug regarding opening the settings window (this was mentioned in one of the related issues), the bug report tool being a standalone process would make more sense, where the user could simply launch the executable themselves as you mentioned.

@Jay-o-Way
Copy link
Collaborator

How to report a bug report

Do #7423

@Jay-o-Way
Copy link
Collaborator

FYI can't seem to build. There's about 238 errors from the ImageResizer project.

@BLM16
Copy link
Contributor Author

BLM16 commented Jan 19, 2023

FYI can't seem to build. There's about 238 errors from the ImageResizer project.

Interesting. That probably happened during my rebase merge to pull main in along with my commit. The build succeeded in CI though... Are you able to build the commit prior to integrating the context menu option?

@BLM16
Copy link
Contributor Author

BLM16 commented Jan 19, 2023

How to report a bug report

Do #7423

This is possible, however I again think this is out of the scope of this PR. Standardizing the bug report and fixing things like this should be integrated through a separate PR.

@cinnamon-msft
Copy link
Collaborator

cinnamon-msft commented May 13, 2025

Chiming in here, looks like the remaining open items were:

  • Where's a good place for adding shut down
  • Where should we put report bug
  • Reverse the logic from hide to show
  • Merging main in to get it up-to-date

I've gone ahead and moved the shut down button to the title bar and out of the navigation view. I also added the report bug package creator to the General settings page under the Diagnostics & feedback section. Lastly, I flipped the logic from hide to show.

All we need now is to get this up-to-date with main and @niels9001 will pop in and fix up the title bar height a bit. After this, let's get this reviewed and merged :)

@BLM16 Thank you for your work here, we greatly appreciate it. This has been quite the popular ask and I'm hoping we can get this in for our next release

Here's a screenshot with my changes:
image

@cinnamon-msft cinnamon-msft requested a review from niels9001 May 13, 2025 23:04
@cinnamon-msft
Copy link
Collaborator

Alrighty got the styling changes in from @niels9001, @vanzue can you get this synced up with main and help review and get this across the finish line?

@vanzue
Copy link
Contributor

vanzue commented May 17, 2025

Sure, Happy to do that

@vanzue vanzue added this to the PowerToys 0.92 milestone May 17, 2025
Copy link
Contributor Author

@BLM16 BLM16 left a comment

Choose a reason for hiding this comment

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

I don't currently have the repo downloaded, so I just added the few minor changes as comments. This is untested, but theoretically this should fix the double-negative logic that arose from this being hide and being inverted to now being show.

}
}

// Gets or sets a value indicating whether the PowerToys icon should be hidden in the system tray.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

// Gets or sets a value indicating whether the PowerToys icon should be shown in the system tray.


// TODO: would be nice to get rid of these globals, since they're basically cached json settings
static std::wstring settings_theme = L"system";
static bool show_tray_icon = false;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

static bool show_tray_icon = true;

Default is to show the icon.

@vanzue
Copy link
Contributor

vanzue commented May 21, 2025

Fix comments and built an installer locally and tested scenarios:

  1. hide/unhide tray icon
  2. shutdown powertoys in settings icon
  3. Open powertoys again brings settings page when there is no icon
  4. Bug generating button work

Looks pretty good from my side
Will work to get it check in.

Only one left is when bug generating, there is no sign that it is generating, the button would not show there is any progress either.
I'm going to open a new issue try to fix that

@vanzue
Copy link
Contributor

vanzue commented May 21, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@vanzue
Copy link
Contributor

vanzue commented May 23, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@vanzue
Copy link
Contributor

vanzue commented May 26, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@vanzue
Copy link
Contributor

vanzue commented May 26, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@vanzue vanzue merged commit 53b9898 into microsoft:main May 26, 2025
10 checks passed
sadirano pushed a commit to sadirano/PowerToys that referenced this pull request Jun 10, 2025
* Added option to toggle the system tray icon

At the moment, this hides the icon making the settings window inaccessible without first modifying the general `settings.json` file.

* Use IPC messages to manage the tray icon settings

* Fix launching second window binds to active settings process

* Added context menu option to hide tray icon

* Added Exit PT button to settings ui NavigationView.PaneFooter

* Moved DllImports to NativeMethods.cs

* Sentence case titles

* Fix whitespace

* Re-add exit icon to NavView

* Re-added toggle switch to new UI

* Fix build

* Fix build after merge main

* Fix the string to display

* add shut down buttons

* finish polish

* fix string

* Styling tweaks to titlebar and settingscards

* fix comment

* fix unit test

* fix ut

---------

Co-authored-by: Jaime Bernardo <jaime@janeasystems.com>
Co-authored-by: vanzue <vanzue@outlook.com>
Co-authored-by: Kayla Cinnamon <cinnamon@microsoft.com>
Co-authored-by: Niels Laute <niels.laute@live.nl>
yeelam-gordon pushed a commit that referenced this pull request Jun 20, 2025
* Added option to toggle the system tray icon

At the moment, this hides the icon making the settings window inaccessible without first modifying the general `settings.json` file.

* Use IPC messages to manage the tray icon settings

* Fix launching second window binds to active settings process

* Added context menu option to hide tray icon

* Added Exit PT button to settings ui NavigationView.PaneFooter

* Moved DllImports to NativeMethods.cs

* Sentence case titles

* Fix whitespace

* Re-add exit icon to NavView

* Re-added toggle switch to new UI

* Fix build

* Fix build after merge main

* Fix the string to display

* add shut down buttons

* finish polish

* fix string

* Styling tweaks to titlebar and settingscards

* fix comment

* fix unit test

* fix ut

---------

Co-authored-by: Jaime Bernardo <jaime@janeasystems.com>
Co-authored-by: vanzue <vanzue@outlook.com>
Co-authored-by: Kayla Cinnamon <cinnamon@microsoft.com>
Co-authored-by: Niels Laute <niels.laute@live.nl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Product-Settings The standalone PowerToys Settings application Status-In progress This issue or work-item is under development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Option to hide the tray icon