views:

63

answers:

2

Hello,

How to make X11 application to listen to DBus signal. That to listen to Dbus signal gmainloop should be launched, and for X11 app XEvent loop. So is there an elegant way to do this ? Or do I have to run gmainloop in another thread.

Regards, Levon

A: 

Shouldn't you be able to get a file descriptor for the X event loop? Then you should be able to add it to the gobject mainloop.

From what I can see, ConnectionNumber(xdpy) will give the file descriptor, which you can then add to a source, which you can use with g_source_add_poll().

Teddy
deimus
+2  A: 

If you want to block on two or more things (say X and dbus) you need a main loop. You could use GLib's main loop or libev or other libraries.

Here are two examples of using Xlib with GLib's main loop:

  1. http://git.gnome.org/browse/gtk+/tree/gdk/x11/gdkeventsource.c
  2. http://git.gnome.org/browse/metacity/tree/src/core/eventqueue.c
Havoc P