Detecting the start of window resize

Is there a way to detect when the user clicks on a Window’s border to begin resizing it?

On MacOS it seems that beginning a resize operation halts the main thread until it’s done (i.e mouse released). This causes me problems because timers still fire as normal during this time and things go out of sync.
(this doesn’t seem to happen on Linux, I haven’t tried Windows)
Ideally I’d be able to pause or otherwise tell my timer callbacks to stop doing things until the main thread is resumed.

If the main thread is suspended while the window’s being resized, and your event loop is running inside the main thread, then by definition there’s no way to detect this.

Instead of using system timers, keep track of how much time has elapsed yourself and fire off your own timers that way. Gives you more control (like easily pausing timers when the game is paused by just not increasing game world time), and has the added benefit that if the main thread is paused then none of your timers will fire until the main thread resumes.

Thanks both. Changing the timers will require a bit of a re-think but I’ll see how I get on.

In direct response to my question though - there is no way to detect the start of a resize operation, is that correct?

Not that is currently provided by SDL, no.

1 Like