REBOL [ Title: "Event Filtering patch to wake-event" Purpose: { To speed up View by filtering useless events. } Author: "Gabriele Santilli" EMail: giesse@rebol.it File: %wake-event.r License: { Copyright (c) 2003, Gabriele Santilli All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * The name of Gabriele Santilli may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. } Date: 26-Mar-2004 Version: 1.1.0 ; majorv.minorv.status ; status: 0: unfinished; 1: testing; 2: stable History: [ 26-Mar-2004 1.1.0 "History start" ] ] ; comment the following line if you are using autodoc.r ;#do [document: func [text] [none]] #do [document { ===Event Filtering Patch to wake-event (wake-event.r) This patch changes the awake function of the event port. The new function filters queued events so that "useless" events are not propagated to the event system. (For example, queued mouse events are usually useless, unless you are writing a freehand paint program.) It is possible to customize the function by changing the kind of events that are filtered when queued. The NO-QUEUE object is used for this; an event of a type that matches a word in the object, is never queued. }] ; Event filtering --- speeds up view! context [ no-queue: context [move: offset: none] wake-event: func [event /local no-btn] bind [ either not pop-face [ do event empty? screen-face/pane ] [ either any [pop-face = event/face within? event/offset win-offset? pop-face pop-face/size] [ no-btn: false if block? get in pop-face 'pane [ no-btn: foreach item pop-face/pane [if get in item 'action [break/return false] true] ] if any [all [event/type = 'up no-btn] event/type = 'close] [hide-popup] do event ] [ if pop-face/action [ if not find [move time] event/type [hide-popup] do event ] ] none? find pop-list pop-face ] ] in system/view 'self system/ports/wait-list/1/awake: func [port /local event events lasttype] [ events: clear [] while [event: pick port 1] [ either all [in no-queue event/type lasttype = event/type] [ change back tail events event ] [ lasttype: event/type insert tail events event ] ] foreach event events [ if wake-event event [return true] ] false ] ]