ocaml / graphics

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

Question: how to handle close of window? #41

Closed anentropic closed 1 year ago

anentropic commented 1 year ago

I'm on macos

I opened a window from ocaml shell, the XQuartz window opens. If I then close the window from the 'x' button on the window controls I get this error and the ocaml shell crashes:

# Fatal error: exception Graphics.Graphic_failure("fatal I/O error")

(closing from code Graphics.close_graph ();; works fine)

Is there a way to handle the close button so it doesn't cause an error?

nojb commented 1 year ago

I don't know the answer to your question, but I recommend you ask it over at https://discuss.ocaml.org, where it is more likely to receive an answer.

xavierleroy commented 1 year ago

Looks like the X11 implementation of Graphics doesn't handle "close window" events, unlike the Win32 implementation. This should not be hard to handle. See e.g. https://www.lemoda.net/c/xlib-wmclose/