[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] NSScroller some event handling cleanups.
From: |
Alexander Malmberg |
Subject: |
Re: [PATCH] NSScroller some event handling cleanups. |
Date: |
Wed, 02 Apr 2003 21:44:33 +0200 |
Benhur Stein wrote:
> > * Source/NSScroller.m (trackKnob:): stop slogging through mounds of
> > mouse motion events and use periodic events.
> I think that this kind of code exists in more than one place in
> GNUstep (and probably in some applications, like in mine), because
> there are too many mouse moved events that are generated by X.
> Wouldn't it be a better idea to change the backend to filter out
> some of those events and not have to have this solution
> reimplemented many times in many places?
It (-x11, at least) already does.
However, I'm not sure the backend should be filtering user input events.
Either way, the whole mess with periodic events and such is just silly,
so I've finally took some time to write a proper solution:
do
{
/* Inner loop that gets and (quickly) handles all events that have
already arrived. */
while (theEvent && [theEvent type]!=NSLeftMouseUp)
{
/* Note the event here. Don't do any expensive handling. */
theEvent = [app nextEventMatchingMask: eventMask
untilDate: [NSDate distantPast] /* Only get events that have
already arrived. */
inMode: NSEventTrackingRunLoopMode
dequeue: YES];
}
if ([theEvent type]==NSLeftMouseUp)
break;
/* No more events right now. Do expensive handling, like drawing,
here. */
/* Get the next event, blocking if necessary. */
theEvent = [app nextEventMatchingMask: eventMask
untilDate: nil /* No limit, block until we get an event. */
inMode: NSEventTrackingRunLoopMode
dequeue: YES];
} while ([theEvent type] != NSLeftMouseUp);
/* Clean up. */
- Alexander Malmberg