Implemented private function BWindow::DequeueAll() which reads all pending

messages from the port.
BView::GetMouse() now calls this function if it was called from the window's
thread and thus blocking the message loop.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12716 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-05-18 16:54:56 +00:00
parent 25b0ec461d
commit 3405fff2a9
2 changed files with 24 additions and 7 deletions
+7 -6
View File
@@ -1172,19 +1172,20 @@ BView::GetMouse(BPoint *location, uint32 *buttons, bool checkMessageQueue)
{
do_owner_check();
// ToDo: We should check if we are calling this from the BWindow's thread or not.
// But why exactly do we have to do this? If the looper is locked, it
// shouldn't do too much harm, besides, who would do this, anyway :) -- axeld.
if (checkMessageQueue) {
BMessageQueue *queue = Window()->MessageQueue();
BMessage *msg;
if (find_thread(NULL) == Window()->Thread()) {
// If the event loop is not running right now (we're blocking it),
// we need to retrieve all messages that are pending on the port.
Window()->DequeueAll();
}
BMessageQueue *queue = Window()->MessageQueue();
queue->Lock();
// First process and remove all _UPDATE_ messages
// ToDo: it would be great to join them together to one big update message!
BMessage *msg;
for (int32 i = 0; (msg = queue->FindMessage(i)) != NULL; ) {
if (msg->what == _UPDATE_) {
Window()->BWindow::DispatchMessage(msg, Window());