Fix cursor offset when tiling WM resizes window on first tick

This commit is contained in:
Jared Miller 2026-02-12 20:21:26 -05:00
parent d608909b5d
commit c0621ff717
Signed by: shmup
GPG key ID: 22B5C6D66A38B06C

View file

@ -915,6 +915,15 @@ class Application:
self.gw.post_update() self.gw.post_update()
self.last_time += self.timestep self.last_time += self.timestep
self.updates += 1 self.updates += 1
# On the first update, check if a window manager resized us during
# init (e.g. tiling WMs). The SDL_WINDOWEVENT_RESIZED handler skips
# tick 0 to avoid a spurious resize from resolution detection, so
# any real WM resize on that tick gets dropped.
if self.updates == 1:
w, h = ctypes.c_int(0), ctypes.c_int(0)
sdl2.SDL_GetWindowSize(self.window, ctypes.byref(w), ctypes.byref(h))
if w.value != self.window_width or h.value != self.window_height:
self.resize_window(w.value, h.value)
self.frame_update() self.frame_update()
def frame_update(self): def frame_update(self):