SDL2 has a structure for handling window events such as moving a window or resizing a window.
This structure, SDL_WindowEvent
, is useful because Windows's event loop for a window blocks the thread of execution that created the window when the window is being moved or resized. Many SDL2 application developers find such behaviour undesirable, so they poll SDL2 for SDL_WindowEvent
s with SDL_WindowEventID
s of SDL_WINDOW_MOVED
or SDL_WINDOW_RESIZED
in order to handle the thread block. For example, physics engines with variable timesteps may potentially receive a dt
of several seconds as a result of the user moving the window, and the engine will probably want to discard this time to avoid physics errors.
However, in my experience, SDL_WindowEvent
s cannot recognize when a window's title bar is "grabbed" by the mouse but not moved, or when a window's resize handles are "grabbed" but the window size does not change. In these cases, Windows blocks the thread of execution owning the window, but neither SDL_WINDOW_MOVED
nor SDL_WINDOW_RESIZED
are present in any SDL_WindowEvent
s.
In the example case given, these two cases make no difference, as the physics engine will merely discard the dt
or clamp it, but this kind of workaround is not always possible.
Is there a way to detect these cases in which a window move or resize event has occurred that did not affect the location or size of the window?