Skip to content

win32: let the application cancel a window close - #58

Closed
grzybr1 wants to merge 1 commit into
samangh:masterfrom
grzybr1:win32-veto-close
Closed

grzybr1 wants to merge 1 commit into
samangh:masterfrom
grzybr1:win32-veto-close

Conversation

@grzybr1

@grzybr1 grzybr1 commented Oct 19, 2026 •

Copy link
Copy Markdown

On Windows, closing the window lets DefWindowProc destroy it, and the main loop then ends on WM_QUIT before iterate() is called, so an application can't ask anything (e.g. about unsaved changes). The SDL2 backend instead sets done = true before iterate(done), which the application can reset.

This handles WM_CLOSE in WndProc (sets a flag instead of destroying the window) and passes it to the application as done = true before iterate(done), matching SDL2. A minimised window is restored first so the frame actually runs. The window is still destroyed in the existing cleanup after the loop.

For applications that ignore done, closing behaves as before, except that iterate() runs one more frame with done == true (as with SDL2).

Please note that I have neither built or tested this myself.

@grzybr1

grzybr1 commented Oct 19, 2026

Copy link
Copy Markdown
Author

I have now tested this on Windows against af507cc (the commit that libtem is pointing at today).

Closing with unsaved changes asks, without them it closes immediately, minimised-and-closed restores the window first.

@samangh samangh closed this in 2c72bc2 Oct 19, 2026
@grzybr1
grzybr1 deleted the win32-veto-close branch October 20, 2026 06:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant