[Xcb] XCB naming conventions
iano at quirkster.com
Sat Sep 16 15:14:45 PDT 2006
On Sep 16, 2006, at 1:47 PM, Bernardo Innocenti wrote:
> Jeremy A. Kolb wrote:
>> For functions:
>> xcb_ followed by the extension and function name all in lowercase,
>> words separated by underscores.
> I know I'm late to suggest this, but wouldn't it be better if we
> functions with "x_" instead of "xcb_"?
> XConnection connection = x_connect(NULL, NULL);
> XWindow window = x_window_new(connection);
> The advantage is that it shifts focus from libary name (XCB) to
> being used (X). Someone reading the code will be less likely to say
> "what's this xcb thing?". Besides it's shorter and easier to type :-)
Works for me. In fact, you could argue that the XCB library is more
X than Xlib.
One minor problem; discussing the API verbally might lead to
confusion with the old Xlib API.
> And as we're breaking source level compatibility, I'd like to ask for
> another change: could we re-order the fields in XCB*Event
> structures so
> that it could be dispatched in a more polymorphic fashion? The
> scheme requires lots of pointer casting and is very unsafe.
No, because those structures also mirror the X wire protocol, which
is set in stone.
Perhaps what you would rather have is an xcb::Event base class, a
tree of subclasses for the specific events, and a factory for
producing them given an XCBGenericEvent. Then you could have an
Event::window() method that really could be polymorphic, regardless
of the internal structure of the event on the wire.
(BTW, you mean e->window below, right? Only the Graphics/No exposure
events have drawables.)
> An application event loop will usually want to delegate handling some
> events such as XCBExposeEvent or XCBResizeRequestEvent to the
> object associated with the drawable or with the window:
> void Screen::exec()
> while (XCBGenericEvent *e = XCBPollForEvent(connection, 0))
> switch (e->response_type & ~0x80)
> // Dispatch all window-related events to windows
> case XCBExposeEvent:
> case XCBResizeRequestEvent:
> MyFancyWindowClass *w;
> if (w = find_Window(e->drawable))
> By the way, has anybody written a C++ wrapper for XCB? I felt the
> need for some wrapper classes when I wrote some XCB code in C++.
The core XCB devs all seem to be allergic to C++. Taking the "XCB"
off of every identifier and putting it in a namespace would be nice,
On a related note, one of the Google Summer of Code projects was to
develop XCB Objective-C bindings. How did that turn out?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Xcb