[haiku-development] Re: Intercepting messages between the applications and App. Server

Hi,

> On Fri, Mar 20, 2009 at 3:53 PM, Yashasvi A.C. <yashasviac@xxxxxxxxx>
> wrote:
> > I just built Haiku on Ubuntu and am opening Haiku through the VMWare
> virtual
> > machine. I have a few questions that I wanted to ask:
> > (1) How do you intercept messages between the App. Server and the
> > application?
> > (2) How do you intercept messages between and within applications?
> 
> For a given window, view, etc. (actually BHandler), you can attach an
> object called a BMessageFilter. This can look at any message the
> target receives, modify it, prevent it from being passed on to the
> target, etc. In this case you'd mainly just be interested in looking
> at them though. As such you could make a filter that looks for
> B_MOUSE_DOWN messages, checks who the target is, and otherwise doesn't
> interfere with message processing, which should give you the
> information you need (which you can then send to another app or
> wherever you need it to go for your implementation.
> 
> c.f. http://www.haiku-os.org/legacy-docs/bebook/BHandler_Overview.html
> and
> http://www.haiku-os.org/legacy-docs/bebook/BMessageFilter_Overview.html
> .
> 
> BView and BWindow are both BHandler subclasses and as such all the
> message processing described there applies to them as well.

It sounds a bit like you need to intercept all messages that are going to other 
applications/windows/views. This may be better achieved by using a BView and 
using SetEventMask() to configure it to receive all messages. BMessageFilters 
are most useful if you are already the target of the message. But to find out 
more about the original target of the message (you receive copies), you 
probably need to use scripting techniques. In another words, you need to send 
messages to the original target of the message to find out what kind of object 
the target is. So you should look into the scripting sections in the BeBook to 
see what is possible using that API and messaging protocols. There is a command 
line tool called "hey", which does a lot of cool stuff using scripting. It may 
or may not be easy to achieve, I would need to look at this closer to say for 
sure. In any case, it's always an option to just add the feature, if it isn't 
already possible. :-D

Best regards,
-Stephan

P.S. Awesome to see all this activity around Haiku in the University of 
Auckland! I've been to New Zealand a couple of times and love it very much!

Other related posts: