Repository: libsdl-org/SDL
File: src/tray/windows/SDL_tray.c (C)

Code before:

    return NULL;
}

static SDL_TrayEntry *find_entry_with_id(SDL_Tray *tray, UINT_PTR id)
{
    if (!tray->menu) {
        return NULL;
    }

    return find_entry_in_menu(tray->menu, id);
}

LRESULT CALLBACK TrayWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
    SDL_Tray *tray = (SDL_Tray *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
    SDL_TrayEntry *entry = NULL;

    if (!tray) {
        return DefWindowProc(hwnd, uMsg, wParam, lParam);
    }

    static UINT s_taskbarRestart = 0;
    if (s_taskbarRestart == 0) {
        s_taskbarRestart = RegisterWindowMessage(TEXT("TaskbarCreated"));
    }
    if(uMsg == s_taskbarRestart) {
        Shell_NotifyIconW(NIM_ADD, &tray->nid);
        Shell_NotifyIconW(NIM_SETVERSION, &tray->nid);
    }

    switch (uMsg) {
        case WM_TRAYICON:
            if (LOWORD(lParam) == WM_CONTEXTMENU || LOWORD(lParam) == WM_LBUTTONUP) {
                SetForegroundWindow(hwnd);

                if (tray->menu) {
                    TrackPopupMenu(tray->menu->hMenu, TPM_BOTTOMALIGN | TPM_RIGHTALIGN, GET_X_LPARAM(wParam), GET_Y_LPARAM(wParam), 0, hwnd, NULL);
                }
            }
            break;

        case WM_COMMAND:
            entry = find_entry_with_id(tray, LOWORD(wParam));

            if (entry && (entry->flags & SDL_TRAYENTRY_CHECKBOX)) {
                SDL_SetTrayEntryChecked(entry, !SDL_GetTrayEntryChecked(entry));
            }

            if (entry && entry->callback) {
                entry->callback(entry->userdata, entry);
            }

Review comment (suggestion):
```suggestion
    if (uMsg == s_taskbarRestart) {
```

Code after:

    return NULL;
}

static SDL_TrayEntry *find_entry_with_id(SDL_Tray *tray, UINT_PTR id)
{
    if (!tray->menu) {
        return NULL;
    }

    return find_entry_in_menu(tray->menu, id);
}

LRESULT CALLBACK TrayWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
    SDL_Tray *tray = (SDL_Tray *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
    SDL_TrayEntry *entry = NULL;

    if (!tray) {
        return DefWindowProc(hwnd, uMsg, wParam, lParam);
    }

    static UINT s_taskbarRestart = 0;
    if (s_taskbarRestart == 0) {
        s_taskbarRestart = RegisterWindowMessage(TEXT("TaskbarCreated"));
    }
    if (uMsg == s_taskbarRestart) {
        Shell_NotifyIconW(NIM_ADD, &tray->nid);
        Shell_NotifyIconW(NIM_SETVERSION, &tray->nid);
    }

    switch (uMsg) {
        case WM_TRAYICON:
            if (LOWORD(lParam) == WM_CONTEXTMENU || LOWORD(lParam) == WM_LBUTTONUP) {
                SetForegroundWindow(hwnd);

                if (tray->menu) {
                    TrackPopupMenu(tray->menu->hMenu, TPM_BOTTOMALIGN | TPM_RIGHTALIGN, GET_X_LPARAM(wParam), GET_Y_LPARAM(wParam), 0, hwnd, NULL);
                }
            }
            break;

        case WM_COMMAND:
            entry = find_entry_with_id(tray, LOWORD(wParam));

            if (entry && (entry->flags & SDL_TRAYENTRY_CHECKBOX)) {
                SDL_SetTrayEntryChecked(entry, !SDL_GetTrayEntryChecked(entry));
            }

            if (entry && entry->callback) {
                entry->callback(entry->userdata, entry);
            }