ocaml / graphics

The Graphics library from OCaml, in a standalone repository
Other
58 stars 30 forks source link

Replace call to caml_process_pending_signals by explicit processing of events #15

Closed xavierleroy closed 4 years ago

xavierleroy commented 4 years ago

This is a tentative fix for issue #14 .

caml_process_pending_signals is a function from OCaml's runtime system that disappeared in version 4.10.

The reason this function was called in caml_gr_wait_event_poll was to process pending X events and merge them in our event queue before the results of the poll are determined.

It should be just as good to explicitly purge pending X events instead.

jhjourdan commented 4 years ago

I don't know whether this PR is the right fix for this code, but I know that the function which is intended to be used for polling signals is caml_process_pending_actions. Of course, the issue is that it is not backward compatible, so this require some configure hacking.

xavierleroy commented 4 years ago

Thanks for the tip. We could #if OCAML_VERSION >= 41000 and select the new signal-polling function. But I'd rather avoid to depend on the precise implementation of signal handling in the OCaml runtime system.

ghost commented 4 years ago

LGTM. Just to make sure I understand the logic correctly here, the graphics library handles X events in the signal handler for SIGIO.

ghost commented 4 years ago

Thanks for the patch!

xavierleroy commented 4 years ago

Just to make sure I understand the logic correctly here, the graphics library handles X events in the signal handler for SIGIO.

That's correct. I'm not sure how long this approach will keep working, but if it breaks there's a "plan B" using threads.