Skip to content

Commit

Permalink
Fix the problem with context menu not going away.
Browse files Browse the repository at this point in the history
When you right click the notification icon, a context
menu appears, clicking outside of this menu should
cancel this menu. But without this change the menu
would stick around.
From:
https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-trackpopupmenu
"To display a context menu for a notification icon, the current window
must be the foreground window before the application calls
TrackPopupMenu or TrackPopupMenuEx. Otherwise, the menu will not
disappear when the user clicks outside of the menu or the window that
created the menu (if it is visible)."
  • Loading branch information
masoudd committed Jul 30, 2024
1 parent 4e24a42 commit 604cce3
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/irancal.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
case WM_RBUTTONDOWN:
case WM_CONTEXTMENU:
SetForegroundWindow(hwnd);
TrackPopupMenu(menu, TPM_RIGHTBUTTON | TPM_VERNEGANIMATION,
GET_X_LPARAM(wParam), GET_Y_LPARAM(wParam), 0, hwnd, NULL);

Expand Down

0 comments on commit 604cce3

Please sign in to comment.