From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: To: 9fans@cse.psu.edu From: Gorka Guardiola Date: Thu, 13 Jan 2005 17:30:45 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: [9fans] cooked mouse mode. Topicbox-Message-UUID: 2dee7024-eace-11e9-9e20-41e7f4b1d025 We have written and submitted a cooked-mouse mode patch. It means that while using mouse(2), setmousemode can be called in order to stop getting raw mouse events and start getting them cooked so the state machine for proccessing single clicks, double clicks, slides, chords and so on (which is difficult to get right) isn't rewritten for every application and has a clear boundary. The state machine is implemented as an interpreter for a minilanguage with the program hardcoded in it, but all that is isolated from the user of the library. A typical use for this would be: 1) call setmousemode setmousemode(mousectl, MCOOKED); 2) receive events from the channel already processed: for (;;) { switch(alt(alts)) { case Akeyboard: if(r==DELETEKEY) threadexitsall(nil); break; case Areshape: resized(1); break; case Amouse: if (button==(MCLICK|MEND|2)){ //single click with the 2 button } if (button==(MCLICK||MDOUBLE|MEND|1)) { //double click with the 1 button } if ((button&(MFLAGS|7)) == (MEND|MCHORD|MCLICK|4|1)){ if (MCHORDB(m->buttons,0) == 1){ //chord with buttons 1 and 3, the first being 1. } } } } We are finding it very useful in Plan B. Oppinions, ideas, suggestions?. The genealogy of this is funny: squeak (language for the mouse) ->aleph->libthread->cooked mouse G.