Felix Palmen :freebsd: :c64:<p><span class="h-card" translate="no"><a href="https://bsd.network/@thomasadam" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>thomasadam</span></a></span> Adventures in <a href="https://mastodon.bsd.cafe/tags/X11" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>X11</span></a> <a href="https://mastodon.bsd.cafe/tags/programming" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>programming</span></a> using <a href="https://mastodon.bsd.cafe/tags/xcb" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>xcb</span></a> ... I think I discovered some strange (and, undocumented?) behavior in <a href="https://mastodon.bsd.cafe/tags/Xorg" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Xorg</span></a>.</p><p>Getting more seemingly(!) "stray" Expose events, I finally discovered what's happening. I already decoupled my drawing logic from handling Expose, and instead maintain information in a widget whether it's visible and invalidated (with invalidation triggered by whatever, e.g. an Expose event). Only after processing a batch of input from the X server, I check whether a widget is both visible and invalidated, and if yes, draw it. So far a common pattern to avoid excessive drawing.</p><p>Now, setting the "root" widget (the window) visible as soon as a MapNotify is received, this *could* lead to start drawing before receiving the first Expose. Drawing still works perfectly fine, but this somehow delays the Expose event until something else "happens" to the window (like moving it), then you suddenly receive this Expose ... 🤯</p><p>Solution: Only set the window "visble" after the first Expose event is received...</p><p>I guess it would be impossible to trigger this with <a href="https://mastodon.bsd.cafe/tags/Xlib" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Xlib</span></a> because its API makes you wait for the response to every request... 😉</p>