Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyboard events incorrectly delivered to Graphics module's polling routines when compiled natively #4485

vicuna opened this Issue Jan 21, 2008 · 1 comment


None yet
1 participant
Copy link

commented Jan 21, 2008

Original bug ID: 4485
Reporter: sharvil
Status: closed (set by @damiendoligez on 2013-07-09T14:06:41Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 3.10.1
Target version: 4.01.0+dev
Fixed in version: 4.01.0+dev
Category: ~DO NOT USE (was: OCaml general)
Monitored by: @Chris00

Bug description

Keyboard events and other X events are delivered only after a mouse click in the sample application below. This behaviour is only observed when compiled natively.

The issue is related to the delivery of signals. When polling, SIGIO is not delivered in a timely fashion to its handler. Adding the following lines to the start of the function otherlibs/graph/events.c#caml_gr_wait_event_poll fixes the issue by forcing signal delivery.


Additional information


OCaml: 3.10.1 (also tested on 3.9.2)
OS: Linux 2.6.16 (Debian Etch)
CPU: Dual-Core AMD Opteron @ 2.6GHz
Command Line: ocamlopt graphics.cmxa -o test; ./test

Steps to reproduce:

  1. Compile code below using ocamlopt
  2. Run application
  3. Type string "abc" with "OCaml graphics" window focused
  4. Click mouse on "OCaml graphics" window

Sample code (

let main () =
Graphics.open_graph " 320x320";

let rec event_loop () =
    if Graphics.key_pressed () then
        Printf.printf "Key = %c\n%!" (Graphics.read_key ())

    if Graphics.button_down () then
        let x, y = Graphics.mouse_pos () in
        Printf.printf "Mouse at %d,%d\n%!" x y

    event_loop ()

event_loop ();
Graphics.close_graph ()


main ();;

Expected output:

Key = a
Key = b
Key = c
Mouse at xxx,yyy

Actual output:

Mouse at xxx,yyy
Key = a
Key = b
Key = c


This comment has been minimized.

Copy link
Collaborator Author

commented Jul 9, 2013

Comment author: @damiendoligez

Fixed in 4.01 branch (rev 13883)

@vicuna vicuna closed this Jul 9, 2013

@vicuna vicuna added this to the 4.01.0 milestone Mar 14, 2019

@vicuna vicuna added the bug label Mar 19, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.