[PR #10980] [MERGED] Create a window process for the tray icon #28335

Open
opened 2026-01-31 09:27:52 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/10980
Author: @leonMSFT
Created: 8/18/2021
Status: Merged
Merged: 8/21/2021
Merged by: @undefined

Base: mainHead: dev/lelian/notifyicon/withwindowproc


📝 Commits (7)

  • 1a4e782 add window proc functions
  • 7e1e60d maybe use parent hwnd?
  • d621e11 weirdly it turns out I don't even need to give the window proc to the tray icon, I just need to set it as foreground
  • 4cd113a ok turns out i do need to give it a windowproc
  • 0ffdcf4 maybe I should do this as well?
  • 59d15d6 unique_hwnd, wil helpers
  • 0e162d8 enhance!

📊 Changes

2 files changed (+38 additions, -1 deletions)

View changed files

📝 src/cascadia/WindowsTerminal/TrayIcon.cpp (+36 -1)
📝 src/cascadia/WindowsTerminal/TrayIcon.h (+2 -0)

📄 Description

Currently, the monarch window will show itself when opening the tray icon context menu. This is because a window must be set as the foreground window when the context menu opens, otherwise the menu won't be able to be dismissed when clicking outside of the context menu.

This PR makes the tray icon create a non visible/interactable window for the sole purpose of being set as the foreground window when the tray icon's context menu is opened. Then none of the terminal windows should be set as the foreground window when opening the context menu.

Closes #10936


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/10980 **Author:** [@leonMSFT](https://github.com/leonMSFT) **Created:** 8/18/2021 **Status:** ✅ Merged **Merged:** 8/21/2021 **Merged by:** [@undefined](undefined) **Base:** `main` ← **Head:** `dev/lelian/notifyicon/withwindowproc` --- ### 📝 Commits (7) - [`1a4e782`](https://github.com/microsoft/terminal/commit/1a4e782b269b3a8a7183927a81f980fd9edd1520) add window proc functions - [`7e1e60d`](https://github.com/microsoft/terminal/commit/7e1e60dd9454afb1a5b17f2435753dc5ae545295) maybe use parent hwnd? - [`d621e11`](https://github.com/microsoft/terminal/commit/d621e1103cd53bd15f9c3e54c53ecc8706202988) weirdly it turns out I don't even need to give the window proc to the tray icon, I just need to set it as foreground - [`4cd113a`](https://github.com/microsoft/terminal/commit/4cd113a886b551e552f329e2d52d98f34a7b783f) ok turns out i do need to give it a windowproc - [`0ffdcf4`](https://github.com/microsoft/terminal/commit/0ffdcf4461f9ccf32f7846b5eb763c16d1e4683f) maybe I should do this as well? - [`59d15d6`](https://github.com/microsoft/terminal/commit/59d15d66a2116516414c358ed9c0a5ebbf1a9c23) unique_hwnd, wil helpers - [`0e162d8`](https://github.com/microsoft/terminal/commit/0e162d82166a087450159a4c7aa20fc22781ba69) enhance! ### 📊 Changes **2 files changed** (+38 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/WindowsTerminal/TrayIcon.cpp` (+36 -1) 📝 `src/cascadia/WindowsTerminal/TrayIcon.h` (+2 -0) </details> ### 📄 Description Currently, the monarch window will show itself when opening the tray icon context menu. This is because a window must be set as the foreground window when the context menu opens, otherwise the menu won't be able to be dismissed when clicking outside of the context menu. This PR makes the tray icon create a non visible/interactable window for the sole purpose of being set as the foreground window when the tray icon's context menu is opened. Then none of the terminal windows should be set as the foreground window when opening the context menu. Closes #10936 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:27:52 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#28335