#3724·SFML

Win32: SetCapture/ReleaseCapture Stale State

Author: jkeller51Created Jun 4, 2026Updated Jul 19, 2026
Labelsbugm:sfml-windowp:windows

Prerequisite Checklist

Describe your issue here

See: https://github.com/SFML/SFML/blob/a91a7f6a888a4636493107c33d4faec96bdc1509/src/SFML/Window/Win32/WindowImplWin32.cpp#L1065-L1076

When the mouse is clicked in a window, it receives, among other things, a WM_MOUSEMOVE with some mouse key flags indicating the mouse buttons held. This causes SetCapture() to be called.

Capture is only released when the mouse is moved without a button held. This is not the same as releasing capture when the button is released! If the mouse does not move while the button is released, the window retains capture until the mouse moves. This seems to be a bug. If you are in an environment where someone else is waiting for capture to release on your window, the user has to physically move the mouse after releasing the button before the state is updated.

It seems the capture should actually be released in the LBUTTONUP, RBUTTONUP, ... handlers.

Your Environment

Steps to reproduce

In any SFML-managed Win32 window, put logging breakpoints in the handler for WM_MOUSEMOVE, on SetCapture() and ReleaseCapture(). You will see that ReleaseCapture() is not called until the mouse moves.

Expected behavior

ReleaseCapture() should happen as soon as the mouse button is released, regardless of moving.

Actual behavior

ReleaseCapture() only happens when the mouse moves after the button is released.