Since the keyboard filter compared targets by their pointers, it could happen
that it didn't reset the EventDispatcher's focus target even though the object underneath that same pointer had change, which caused the EventDispatcher to drop the event. This fixes bug #416, and should fix bug #409, too. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17141 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -60,6 +60,7 @@ class KeyboardFilter : public EventFilter {
|
||||
|
||||
virtual filter_result Filter(BMessage* message, EventTarget** _target,
|
||||
int32* _viewToken, BMessage* latestMouseMoved);
|
||||
virtual void RemoveTarget(EventTarget* target);
|
||||
|
||||
private:
|
||||
void _UpdateFocus(int32 key, EventTarget** _target);
|
||||
@@ -112,7 +113,7 @@ KeyboardFilter::_UpdateFocus(int32 key, EventTarget** _target)
|
||||
// be done differently, though (using something like B_LOCK_WINDOW_FOCUS)
|
||||
// (at least B_WINDOW_ACTIVATED must be postponed)
|
||||
|
||||
if (focus != fLastFocus && now - fTimestamp > 100000) {
|
||||
if (fLastFocus == NULL || (focus != fLastFocus && now - fTimestamp > 100000)) {
|
||||
// if the time span between the key presses is very short
|
||||
// we keep our previous focus alive - this is save even
|
||||
// if the target doesn't exist anymore, as we don't reset
|
||||
@@ -200,6 +201,14 @@ KeyboardFilter::Filter(BMessage* message, EventTarget** _target,
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
KeyboardFilter::RemoveTarget(EventTarget* target)
|
||||
{
|
||||
if (target == fLastFocus)
|
||||
fLastFocus = NULL;
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
|
||||
@@ -214,6 +214,15 @@ EventTarget::AddListener(int32 token, uint32 eventMask,
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
void
|
||||
EventFilter::RemoveTarget(EventTarget* target)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
EventDispatcher::EventDispatcher()
|
||||
: BLocker("event dispatcher"),
|
||||
fStream(NULL),
|
||||
@@ -321,6 +330,11 @@ EventDispatcher::RemoveTarget(EventTarget& target)
|
||||
if (fPreviousMouseTarget == &target)
|
||||
fPreviousMouseTarget = NULL;
|
||||
|
||||
if (fKeyboardFilter != NULL)
|
||||
fKeyboardFilter->RemoveTarget(&target);
|
||||
if (fMouseFilter != NULL)
|
||||
fMouseFilter->RemoveTarget(&target);
|
||||
|
||||
fTargets.RemoveItem(&target);
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@ class EventFilter {
|
||||
public:
|
||||
virtual filter_result Filter(BMessage* event, EventTarget** _target,
|
||||
int32* _viewToken = NULL, BMessage* latestMouseMoved = NULL) = 0;
|
||||
virtual void RemoveTarget(EventTarget* target);
|
||||
};
|
||||
|
||||
class EventDispatcher : public BLocker {
|
||||
|
||||
Reference in New Issue
Block a user