[Xcb] sending a custom event

Jamey Sharp jamey at minilop.net
Tue Mar 27 14:03:10 PDT 2007


On Tue, Mar 27, 2007 at 03:51:02PM -0400, Jim Crafton wrote:
> No timers, no easy way to send messages to yourself, etc. It would be
> nice if a lot of this had a default implementation, so that
> app/toolkit developers didn't have to re-implement and worry about
> whether or not they did it correctly.

GLib (used by Gtk+) has all this, though implemented with callbacks
rather than as an application event loop. You should check out the GLib
event loop and GObject signal mechanisms:

http://developer.gnome.org/doc/API/2.0/glib/glib-The-Main-Event-Loop.html
http://developer.gnome.org/doc/API/2.0/gobject/signal.html

I expect Qt has similar functionality; I know it at least supports the
signals concept. However, I assume you'd pull in all of Qt if you wanted
to use these features, which is probably silly if you're trying to write
your own toolkit. Plus you'd have to use C++. *sigh*

> Well what I'd like is what I can do in Win32, that is send custom
> events/messages to the event loop running in the current thread, and
> then just respond to these messages.

Wow, I never thought anybody would propose a feature for XCB with a
rationale worse than "because Xlib does it". ;-)

Check out the shatter attack for an example of why Win32's
implementation of this idea is frightening. The Wikipedia article gives
a reasonable overview:
	http://en.wikipedia.org/wiki/Shatter_attack

> While I understand the reasons for this feature not being there, it's
> absence, IMHO, does make it (programming on X and xcb specifically)
> harder to use.

Frankly, XCB's job is not to be easy to use. Don't get me wrong: for
what it does, we believe it has a very simple and easy interface, even
for things that are currently impossible with other tools. But the scope
of XCB is intentionally very limited to exposing only what the X
protocol provides.

Making it easy to write applications is the job of a toolkit; making it
easy to write a toolkit is the job of utility libraries built on XCB.

If you want Win32-style message loops, I encourage you to design and
build a library that provides Win32-style message loops on top of XCB.
If XCB's interface makes writing such a library difficult, then we can
chat about how to implement what you want.

--Jamey
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.freedesktop.org/archives/xcb/attachments/20070327/74fb9b4e/attachment.pgp


More information about the Xcb mailing list