Repository: microsoft/PowerToys
File: src/modules/alwaysontop/AlwaysOnTop/AlwaysOnTop.h (C/C++)

Code before:
            thisRef = reinterpret_cast<AlwaysOnTop*>(createStruct->lpCreateParams);
            SetWindowLongPtr(window, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(thisRef));
        }

        return thisRef ? thisRef->WndProc(window, message, wparam, lparam) :
                         DefWindowProc(window, message, wparam, lparam);
    }

private:
    // IDs used to register hot keys (keyboard shortcuts).
    enum class HotkeyId : int
    {
        Pin = 1,
    };

    static inline AlwaysOnTop* s_instance = nullptr;
    std::vector<HWINEVENTHOOK> m_staticWinEventHooks{};
    Sound m_sound;
    VirtualDesktopUtils m_virtualDesktopUtils;

    HWND m_window{ nullptr };
    HINSTANCE m_hinstance;
    std::map<HWND, std::unique_ptr<WindowBorder>> m_topmostWindows{};
    HANDLE m_hPinEvent;
    std::thread m_thread;
    bool m_powerToysPid;

    LRESULT WndProc(HWND, UINT, WPARAM, LPARAM) noexcept;
    void HandleWinHookEvent(WinHookEvent* data) noexcept;
    
    bool InitMainWindow();
    void RegisterHotkey() const;
    void SubscribeToEvents();

    void ProcessCommand(HWND window);
    void StartTrackingTopmostWindows();
    void UnpinAll();
    void CleanUp();

    void VirtualDesktopSwitchedHandle();

    bool IsTracked(HWND window) const noexcept;
    bool IsTopmost(HWND window) const noexcept;
    bool IsPinned(HWND window) const noexcept;

    bool PinTopmostWindow(HWND window) const noexcept;
    bool UnpinTopmostWindow(HWND window) const noexcept;
    bool AssignBorder(HWND window);

    virtual void SettingsUpdate(SettingId type) override;


Review comment (suggestion):
Let's rename it since it doesn't store pid, only a flag if we use llkh.
And it won't be changed later, so const.

```suggestion
    const bool m_useCentralizedLLKH;
```

Code after:
            thisRef = reinterpret_cast<AlwaysOnTop*>(createStruct->lpCreateParams);
            SetWindowLongPtr(window, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(thisRef));
        }

        return thisRef ? thisRef->WndProc(window, message, wparam, lparam) :
                         DefWindowProc(window, message, wparam, lparam);
    }

private:
    // IDs used to register hot keys (keyboard shortcuts).
    enum class HotkeyId : int
    {
        Pin = 1,
    };

    static inline AlwaysOnTop* s_instance = nullptr;
    std::vector<HWINEVENTHOOK> m_staticWinEventHooks{};
    Sound m_sound;
    VirtualDesktopUtils m_virtualDesktopUtils;

    HWND m_window{ nullptr };
    HINSTANCE m_hinstance;
    std::map<HWND, std::unique_ptr<WindowBorder>> m_topmostWindows{};
    HANDLE m_hPinEvent;
    std::thread m_thread;
    const bool m_useCentralizedLLKH;

    LRESULT WndProc(HWND, UINT, WPARAM, LPARAM) noexcept;
    void HandleWinHookEvent(WinHookEvent* data) noexcept;
    
    bool InitMainWindow();
    void RegisterHotkey() const;
    void RegisterLLKH();
    void SubscribeToEvents();

    void ProcessCommand(HWND window);
    void StartTrackingTopmostWindows();
    void UnpinAll();
    void CleanUp();

    void VirtualDesktopSwitchedHandle();

    bool IsTracked(HWND window) const noexcept;
    bool IsTopmost(HWND window) const noexcept;
    bool IsPinned(HWND window) const noexcept;

    bool PinTopmostWindow(HWND window) const noexcept;
    bool UnpinTopmostWindow(HWND window) const noexcept;
    bool AssignBorder(HWND window);

    virtual void SettingsUpdate(SettingId type) override;