From bb73c05fd78548cff26204255950b22682101cf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Wed, 9 Jul 2008 14:13:03 +0000 Subject: [PATCH] * Introduced a new view event mask flag: B_FULL_POINTER_HISTORY which, when set, prevents any old mouse moved message discarding. * BWindow::DispatchMessage(B_MOUSE_MOVED) checks the event time of the message and discards too old events, but only if there is another event in the queue and the view does not specify B_FULL_POINTER_HISTORY. * BView::GetMouse() ignores the checkHistory flag passed to the function in case the event mask specifies B_NO_POINTER_HISTORY. B_FULL_POINTER_HISTORY on the other hand prevents the dropping of old messages. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26341 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/interface/View.h | 6 +++++- src/kits/interface/View.cpp | 8 ++++++-- src/kits/interface/Window.cpp | 27 +++++++++++++++++---------- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/headers/os/interface/View.h b/headers/os/interface/View.h index fa9a56a3c5..ceb839fbe9 100644 --- a/headers/os/interface/View.h +++ b/headers/os/interface/View.h @@ -43,7 +43,11 @@ enum { enum { B_LOCK_WINDOW_FOCUS = 0x00000001, B_SUSPEND_VIEW_FOCUS = 0x00000002, - B_NO_POINTER_HISTORY = 0x00000004 + B_NO_POINTER_HISTORY = 0x00000004, + // new in Haiku (unless this flag is + // specified, both BWindow and BView::GetMouse() + // will filter out older mouse moved messages) + B_FULL_POINTER_HISTORY = 0x00000008 }; enum { diff --git a/src/kits/interface/View.cpp b/src/kits/interface/View.cpp index afc79cdf85..4a0fbf8f23 100644 --- a/src/kits/interface/View.cpp +++ b/src/kits/interface/View.cpp @@ -1393,7 +1393,11 @@ BView::GetMouse(BPoint *location, uint32 *buttons, bool checkMessageQueue) { _CheckOwnerLockAndSwitchCurrent(); - if (checkMessageQueue) { + uint32 eventOptions = fEventOptions | fMouseEventOptions; + bool noHistory = eventOptions & B_NO_POINTER_HISTORY; + bool fullHistory = eventOptions & B_FULL_POINTER_HISTORY; + + if (checkMessageQueue && !noHistory) { Window()->UpdateIfNeeded(); BMessageQueue *queue = Window()->MessageQueue(); queue->Lock(); @@ -1410,7 +1414,7 @@ BView::GetMouse(BPoint *location, uint32 *buttons, bool checkMessageQueue) if (!Window()->_StealMouseMessage(message, deleteMessage)) continue; - if (message->what == B_MOUSE_MOVED) { + if (!fullHistory && message->what == B_MOUSE_MOVED) { // Check if the message is too old. Some applications // check the message queue in such a way that mouse // messages *must* pile up. This check makes them work diff --git a/src/kits/interface/Window.cpp b/src/kits/interface/Window.cpp index bc335308d3..9171636a43 100644 --- a/src/kits/interface/Window.cpp +++ b/src/kits/interface/Window.cpp @@ -1092,8 +1092,20 @@ FrameMoved(origin); case B_MOUSE_MOVED: { if (BView *view = dynamic_cast(target)) { - if (((view->fEventOptions | view->fMouseEventOptions) - & B_NO_POINTER_HISTORY) != 0) { + + uint32 eventOptions = view->fEventOptions + | view->fMouseEventOptions; + bool noHistory = eventOptions & B_NO_POINTER_HISTORY; + bool fullHistory = eventOptions & B_FULL_POINTER_HISTORY; + + bigtime_t eventTime; + if (noHistory + || msg->FindInt64("when", (int64*)&eventTime) < B_OK) { + eventTime = system_time(); + } + + if (noHistory || (!fullHistory + && (system_time() - eventTime > 20000))) { // filter out older mouse moved messages in the queue _DequeueAll(); BMessageQueue *queue = MessageQueue(); @@ -1102,6 +1114,9 @@ FrameMoved(origin); BMessage *moved; for (int32 i = 0; (moved = queue->FindMessage(i)) != NULL; i++) { if (moved != msg && moved->what == B_MOUSE_MOVED) { + // there is a newer mouse moved message in the + // queue, just ignore the current one, the newer one + // will be handled here eventually queue->Unlock(); return; } @@ -1116,14 +1131,6 @@ FrameMoved(origin); msg->FindInt32("buttons", (int32*)&buttons); msg->FindInt32("be:transit", (int32*)&transit); -#if 0 - bigtime_t when; - if (msg->FindInt64("when", (int64*)&when) < B_OK) - printf("BWindow B_MOUSE_MOVED no when\n"); - else if (system_time() - when > 5000) - printf("BWindow B_MOUSE_MOVED lagging behind\n"); -#endif - BMessage* dragMessage = NULL; if (msg->HasMessage("be:drag_message")) { dragMessage = new BMessage();