[haiku-3rdparty-dev] Dispatch messages

  • From: Carlo Lanzotti <clanzotti@xxxxxxxxxxxxx>
  • To: Haiku developers mailing list <haiku-development@xxxxxxxxxxxxx>
  • Date: Sun, 13 Nov 2022 17:57:15 +0100

Hi all,

I’m the developer of a multiplatform system/GUI toolkit. I’ve ported my engine 
to haiku years ago, but now I’m facing a problem that maybe some of you can 
help me figure out how to solve it.

The system rely only on one OS main window that simply intercepts events and 
send it to my own event handler.

In my system I’ve implemented a way to run modal windows that can be called and 
block until a return value is returned, e.g.:

Int val = run_modal_window();

(waiting for the function to return, like when the user clicked an Ok button or 
something)

When the function get called I start running a local loop that will block the 
function from returning and inside this loop I call the OS’s specific message 
dispatching allowing the OS to continue handling events for it’s window and 
send them to my event handler (and avoid ui lock). For example, in Windows I 
use the usual way to do it:

    while(PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE))
    {
        if(GetMessage(&msg, NULL, 0, 0))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }

As well as on the other OS (Linux, iOS, macOS etc… with their counterpart).

The problem is that in Haiku I can’t find a way to do the same due to the 
different (and multi threaded) way things are done, or at least I didn’t find 
something that satisfy my need. Is there a way to tell the system to continue 
intercept/send events to a windows/view (app?) like things are done in other 
OSs?

Thanks in advance.

P.S. I already sent this mail to the haiku developer list due to a mistake 
caused by the corrector, sorry.

Best Regards,

Carlo Lanzotti

Other related posts: