window size and client size are two different things. The difference is the frame border size. Frame buffer size is what you set it to be, hopefully the client dimensions.
https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-getwindowrect
https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-getclientrect
apologies if that was trivial. I'd look also at the window space the mouse is pulling from and check for expected results. Usually when window size is chosen during creation, the actual client size given back is smaller depending on the window style and (os). You carry on not noticing the handful of pixel and just give your frame buffer the window size. All seems fine until we dial into something accurate. Or is it the other way around... I'd have to check.
Nice looking project.