writing.exchange is one of the many independent Mastodon servers you can use to participate in the fediverse.
A small, intentional community for poets, authors, and every kind of writer.

Administered by:

Server stats:

334
active users

#select

1 post1 participant0 posts today

Integrating #xcb in a #select / #poll based #event loop, next chapter 🤯

Testing in a remote session with xrdp, I observed the first tooltip rendering only the frame → obviously an unnoticed (queued by xcb) expose event.

Tried to add code checking after xcb_flush() whether more bytes were read, and, indeed, this fixed it. Oh my. 🤪

github.com/Zirias/xmoji/commit

I really like xcb so far, but this eagerness to read and queue stuff without a way to disable that behavior is more or less braindead and should really be fixed. Any real-life application will do other things than just interacting with #X11, so running your own event loop *is* a common scenario. And I refuse to do the stupid workaround seen a lot which dedicates a thread to xcb_wait_for_events() and friends.

GitHubX11Adapter: Add another check for queued events · Zirias/xmoji@e7044fbIt seems in rare cases, even xcb_flush() can trigger reads, catch this as well.
Replied in thread

Adventures with #X11 #programming using #xcb: I now have to admit it's *really* hard to *correctly* integrate xcb with a typical generic event loop working on file descriptors (e.g. with #select or #poll). My issue of an occassionally undrawn window was probably caused by not getting that correct.

Xcb more or less enforces its own asynchronous model, getting a "cookie" for each request and using that later to check for the reply. This works great if talking to the X server is all you do, but otherwise, it's a pain. Xcb also demuxes events from replies, and while there's a function to check only for *queued* events, there's no such function for replies, so checking for them could always trigger another read from the socket, possibly queueing new events. 🤯

Many projects resort to dedicating a thread to xcb and using its blocking API from there to solve this issue. I think integrating into a generic event loop is still *possible* though, and this is what I finally came up with (commented implementation because it's just too complex):
github.com/Zirias/xmoji/blob/d

If you're an xcb expert and spot an error there, please let me know 😂

This code requires two things to work reliably:

- Never ever use one of xcb's reply functions, instead use the AWAIT() macro to get a callback when the reply arrives
- Never use an xcb wait_for or poll_for function, if error-handling for a request is needed, use one of the overloads of CHECK()

GitHubxmoji/src/bin/xmoji/x11adapter.c at d5fcf301c0cb65b5a33e1310b298c01bcd682f47 · Zirias/xmojiContribute to Zirias/xmoji development by creating an account on GitHub.
Replied in thread

@jwz @rodgerd

What is it with graphics software, in particular, that makes open source coders go #insane?

One of my pet peeves is one very tiny stupidity (of many) in Gnu Imp - many years ago, you opened an image, clicked the rectangular #select #tool, and selected a box with the left mouse button. Fine.

Then at some point years ago, this changed. You can't do this selection; you get a "bzzt, dumb user" pointer. You have to shift and select, then click.

Must make sense to someone...

#NASA #SpaceX Crew-6 #launch 🚀 (Bowen, Hoburg, Alneyadi, Fedyaev) to the #ISS scheduled at 🕜 2:07 a.m. EST on 📆 Sunday, Feb. 26 nasa.gov/nasalive

#Starliner is on track for launch in the second half of 📆 April 🥱

#Boeing also said that it has been talking 🗨️ with multiple companies about what #launch vehicles the Starliner capsule will use after its run of eight launches atop #Atlas V rockets is done. It plans to #select 💵 launch providers next year bizjournals.com/denver/news/20