Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0004485OCamlOCaml generalpublic2008-01-21 20:322013-07-09 16:09
Reportersharvil 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version3.10.1 
Target Version4.01.0+devFixed in Version4.01.0+dev 
Summary0004485: Keyboard events incorrectly delivered to Graphics module's polling routines when compiled natively
DescriptionKeyboard 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 InformationConfiguration:
--------------
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:
-------------------
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 (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
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0009733)
doligez (administrator)
2013-07-09 16:06

Fixed in 4.01 branch (rev 13883)

- Issue History
Date Modified Username Field Change
2008-01-21 20:32 sharvil New Issue
2008-01-22 13:14 doligez Status new => confirmed
2012-07-11 15:59 doligez Target Version => 4.01.0+dev
2012-07-31 13:37 doligez Target Version 4.01.0+dev => 4.00.1+dev
2012-09-15 11:48 doligez Target Version 4.00.1+dev => 4.00.2+dev
2013-07-09 16:06 doligez Note Added: 0009733
2013-07-09 16:06 doligez Status confirmed => closed
2013-07-09 16:06 doligez Resolution open => fixed
2013-07-09 16:06 doligez Target Version 4.00.2+dev => 4.01.0+dev
2013-07-09 16:09 doligez Fixed in Version => 4.01.0+dev


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker