Skip to content

Commit

Permalink
Merge pull request zserge#11 from cgutman/explorer-restart
Browse files Browse the repository at this point in the history
[Windows] Re-add the tray icon if Explorer restarts
  • Loading branch information
dmikushin authored May 25, 2023
2 parents 1c2fd28 + 14b7797 commit 7510696
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tray_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ static WNDCLASSEX wc;
static NOTIFYICONDATA nid;
static HWND hwnd;
static HMENU hmenu = NULL;
static UINT wm_taskbarcreated;

static LRESULT CALLBACK _tray_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam,
LPARAM lparam) {
Expand Down Expand Up @@ -47,6 +48,12 @@ static LRESULT CALLBACK _tray_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam,
}
break;
}

if (msg == wm_taskbarcreated) {
Shell_NotifyIcon(NIM_ADD, &nid);
return 0;
}

return DefWindowProc(hwnd, msg, wparam, lparam);
}

Expand Down Expand Up @@ -83,6 +90,8 @@ static HMENU _tray_menu(struct tray_menu *m, UINT *id) {
}

int tray_init(struct tray *tray) {
wm_taskbarcreated = RegisterWindowMessage("TaskbarCreated");

memset(&wc, 0, sizeof(wc));
wc.cbSize = sizeof(WNDCLASSEX);
wc.lpfnWndProc = _tray_wnd_proc;
Expand Down

0 comments on commit 7510696

Please sign in to comment.