Axel Dörfler wrote: > Adi Oanca <adioanca@xxxxxxxxxxxxxx> wrote: > >> First of all, we need to make sure we are BWindow thread. Second >>thing, take all message from BWindow's port and put them in the >>MessageQueue(). >> Then search for B_MOUSE_UP and B_MOUSE_MOVED messages, and >>while doing so, take the _UPDATE_ message that you may find and >>dispatch >>it. Calling DispatchMessage(updateMsg, window) is OK - I don't see >>any >>problem by doing so. > > I'm pretty sure that calling DispatchMessage() from GetMouse() is a bad > idea. The first question to ask for me would be: why are you doing > this? Yes, agreed! But if we _know_ the message and we know we have a case for it, as we have for _UPDATE_, then it's perfectly safe. I suggested that because I don't want to take the code from case_UPDATE_ and copy it in GetMouse(). > DispatchMessage() will a) process the messages, and b) call the > handler's MessageReceived() hooks (hello stack eating recursion, btw). Not in this case. > That's not what you want in GetMouse() - if checkQueue is true, it > should just peek at the queue, and remove the oldest message there is. Just had a look at BeBook. Stefano it's not like you said in a previous mail... Look: ============= GetMouse(): If checkQueue is true, as it is by default, this function first looks in the message queue for any pending reports of mouse-moved or mouse-up events. If it finds any, it takes the one that has been in the queue the longest (the oldest message), removes it from the queue, and reports the cursor location and button states that were recorded in the message. Each GetMouse() call removes another message from the queue. If the queue doesn't hold any B_MOUSE_MOVED or B_MOUSE_UP messages, GetMouse() reports the current state of the mouse and cursor, just as if checkQueue were false ============= > The idea behind this is (AFAICT) that the Mouse*() hooks are *not* > called again for these events. Nobody said they would. > _UPDATE_ messages don't need to go through DispatchMessage() either, we > just need to make sure they are processed. I explained above. >> One thing I don't understand from the current implementation is why >>*location is not updated with the coordinates found in up or moved >>messages? > > You are supposed to call GetMouse() more than once to get the latest > event. When do you know you have the latest event? When can you stop calling GetMouse()? This method is confusing... bye, Adi.