ocaml / graphics

The Graphics library from OCaml, in a standalone repository
Other
56 stars 29 forks source link

Handle windows closing gracefully under X11 #42

Closed xavierleroy closed 1 year ago

xavierleroy commented 1 year ago

Request and process WM_DELETE_WINDOW events, so that clicking on the "close" button is equivalent to calling Graphics.close_graph. Subsequent graphical operations will raise the Graphic_failure exception instead of killing the program on an I/O error. (This is more or less the current behavior of the Win32 implementation of Graphics, if I'm not mistaken.)

In passing, use XPending + XNextEvent instead of XCheckMaskEvent(-1), as the latter ignores client events such as WM_DELETE_WINDOW.

Fixes: #41

xavierleroy commented 1 year ago

Thanks a lot for the review!