如何将 X11 应用程序附加到 Dbus

发布于 2024-09-19 19:42:15 字数 139 浏览 2 评论 0原文

如何让X11应用程序监听DBus信号。 应该启动监听 Dbus 信号的 gmainloop,以及 X11 应用程序的 XEvent 循环。 那么有没有一种优雅的方法来做到这一点呢?或者我必须在另一个线程中运行 gmainloop 吗?

问候, 莱文

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

深海蓝天 2024-09-26 19:43:07

难道您不应该能够获取 X 事件循环的文件描述符吗?然后您应该能够将其添加到 gobject 主循环中。

据我所见, ConnectionNumber(xdpy) 将给出文件
描述符,然后您可以将其添加到源中,您可以将其与
g_source_add_poll()

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().

也只是曾经 2024-09-26 19:42:57

如果你想阻塞两个或更多的东西(比如 X 和 dbus),你需要一个主循环。
您可以使用 GLib 的主循环或 libev 或其他库。

以下是将 Xlib 与 GLib 主循环结合使用的两个示例:

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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文