W dniu 02.01.2011 21:36, Henry Vermaak pisze:
On 2 January 2011 19:42,<dib...@wp.pl>  wrote:
You may already know this, but it may help to point out that the
OnIdle event won't fire if there are no other events.  For example,
you'll have to move your mouse or hit the keyboard for the OnIdle
event to be called.  I don't know if this will affect talking to dbus
(does it queue up the signals?).

Henry
Yes, but I noticed that when there are no events, OnIdle is fired even so
(at 5 seconds cycle). I thought it was enough to catch signal, but maybe
it's too long and signals may have short live. C example uses glib main loop
to check signals. I see that free pascal have some glib librarys. Can I
somehow use it (I do not know what it is)? I need this solution only for
linux
I had a quick look at the dbus functions.  Perhaps you can use
dbus_connection_set_wakeup_main_function to set up a function that
wakes up your main loop (containing something like:
g_main_context_wakeup(g_main_context_default) for gtk+).  This will
fire the OnIdle event where you can read the message.

Another solution can be to launch a thread that executes a loop of
dbus reads.  You can then communicate back to the main thread.

Henry
Wow, thanks! I read few examples in different programing languages, but nowhere was no mention of this procedure. Although this example doesn't work (or I am doing something wrong): dbus_connection_set_wakeup_main_function(conn, @g_main_context_wakeup, g_main_context_default, nil);
But I declared my own procedure where I call checking for signals:

procedure TestTest(data: Pointer); cdecl;
begin
  Form1.CheckForMessage;
end;

dbus_connection_set_wakeup_main_function(conn, @TestTest, nil, nil);

And it works perfect! :) . Thanks again.

BTW: About your suggestion to use threads. I used threads before and it worked very long on my application. But it stopped after upgrade d-bus interface. That is why I post this problem

Regards.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to