How to stop the user from moving the game window

Is this possible to stop the user from moving the game window? when the game window is moved, my game still keeps track of deltatime and thus when the window is “dropped” the player teleports based on their last velocity. Is there a good solution for this? Thanks!

So, there are a few ways this can be handled:

  1. Cap the time delta.
  2. Detect the window movement and pause the game.
  3. Detect the window movement and when it’s done do a frame with zero delta time. Essentially a new frame where nothing new has happened and nothing has moved. Then everything continues from there as normal.
  4. Do a combination of 1 and 3, so that long frame times for other reasons don’t effect things too much.

For SDL 2 there’s the SDL_WINDOWEVENT_MOVED event, for SDL 3 there’s SDL_EVENT_WINDOW_MOVED

1 Like

I think this is the most robust solution because moving the window is not the only thing that could cause large delta times.