You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Type string "abc" with "OCaml graphics" window focused
Click mouse on "OCaml graphics" window
Sample code (test.ml):
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 ()
in
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
The text was updated successfully, but these errors were encountered:
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.
enter_blocking_section();
leave_blocking_section();
Additional information
Configuration:
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 test.ml -o test; ./test
Steps to reproduce:
Sample code (test.ml):
let main () =
Graphics.open_graph " 320x320";
;;
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
The text was updated successfully, but these errors were encountered: