From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id QAA06817; Fri, 6 Sep 2002 16:40:05 +0200 (MET DST) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id QAA07152 for ; Fri, 6 Sep 2002 16:40:04 +0200 (MET DST) Received: from shiva.jussieu.fr (shiva.jussieu.fr [134.157.0.129]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g86Ee4103889 for ; Fri, 6 Sep 2002 16:40:04 +0200 (MET DST) Received: from mail.liafa.jussieu.fr (liafa1.liafa.jussieu.fr [132.227.81.128]) by shiva.jussieu.fr (8.12.5/jtpda-5.4) with ESMTP id g86Ee3jR076463 for ; Fri, 6 Sep 2002 16:40:03 +0200 (CEST) X-Authentication-Warning: shiva.jussieu.fr: Host liafa1.liafa.jussieu.fr [132.227.81.128] claimed to be mail.liafa.jussieu.fr Received: from liafa0p.liafa.jussieu.fr (liafa0p.liafa.jussieu.fr [132.227.81.252]) by mail.liafa.jussieu.fr (8.9.3/jtpda-5.3.2) with ESMTP id QAA15542 for ; Fri, 6 Sep 2002 16:40:03 +0200 (MET DST) Received: from (durak@localhost) by liafa0p.liafa.jussieu.fr (8.11.6/jtpda-5.4) id g86Ee3G22083 for caml-list@inria.fr; Fri, 6 Sep 2002 16:40:03 +0200 Date: Fri, 6 Sep 2002 16:40:03 +0200 From: Berke Durak To: caml-list@inria.fr Subject: [Caml-list] Timeout patch to X11 Graphics module Message-ID: <20020906164003.C21965@liafa.jussieu.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i X-Antivirus: scanned by sophie at shiva.jussieu.fr Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hello, Since I had problems with threads, and since the required feature does not really need threads, I've done a little patch to the Graphics module. Well, in fact, the X11 version of the Graphics module. Someone needs to fix this for Win32. A new Timeout of float constructor is available in the Graphics.event type : type event = Button_down (** A mouse button is pressed *) | Button_up (** A mouse button is released *) | Key_pressed (** A key is pressed *) | Mouse_motion (** The mouse is moved *) | Poll (** Don't wait; return immediately *) | Timeout of float (** No event occurs in the specified number of seconds *) A new timedout field has been added to Graphics.status record type : type status = { mouse_x : int; (** X coordinate of the mouse *) mouse_y : int; (** Y coordinate of the mouse *) button : bool; (** true if a mouse button is pressed *) keypressed : bool; (** true if a key has been pressed *) key : char; (** the character for the key pressed *) timedout : bool; (** true only if no event occured in the given time *) } For example the expression wait_next_event [Key_pressed;Mouse_motion;Timeout 3.0] will return when the mouse is moved, a key is pressed or if 3 seconds pass, whichever comes first. In the first two cases, the timedout field will be false. In the last case, it will be true and other fields will be meaningless (zero or false, actually). The patch is available at http://www.liafa.jussieu.fr/~durak/ocaml-306-graph.patch Apply it by typing (sorry I'm not an expert in making patches, hope this is correct) cd /usr/local/src/ocaml-3.06 && patch -p6