Repository navigation
feat(wayland): composite imlib2 images (${image}) onto the Wayland surface - #2499
ditronicos wants to merge 1 commit into
Conversation
…rface
`${image}` silently did nothing on the Wayland backend: imlib2 can only
render into an X11 drawable, and `window.geometry`/`window.drawable` are
populated by the X11 output only. On a Wayland session every queued image
was therefore dropped (and imlib2 complained about a NULL image), so configs
that rely on icons, panels or backgrounds lost all of their graphics.
Ask the active output for a cairo context instead of assuming a drawable:
* display_output_base::drawing_context() returns the cairo context the output
draws into, or null for outputs that keep using an X11 drawable.
* display_output_wayland implements it with its own surface context, and
creates an unbound imlib2 context (cimlib_init_cpu()) since there is no
drawable to bind.
* cimlib_render_cairo() loads each queued image, converts imlib2's
unpremultiplied ARGB data to cairo's premultiplied ARGB32 (honouring
`draw_blended`) and paints it, scaled to the `-WxH' size, before the text
pass -- the same stacking order as the X11 path.
X11 keeps the existing path: drawing_context() is null there, so
draw_stuff() still calls cimlib_render().
Fixes brndnmtthws#2158
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8c0cfd9cba
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Complete the Wayland image support from #2499, correct backend guards and surface coordinates, preserve the Imlib decode cache, and add generated-fixture regression tests for rendering, clipping, alpha, cache, and lifecycle behavior. Fixes #2158. Co-authored-by: Diego Lora <diego@users.noreply.github.com>

Problem
${image}does nothing on the Wayland backend (fixes #2158). Configs that use images for panels, frames or weather icons silently lose all graphics on a Wayland session, and imlib2 floods stderr:Cause
cimlib_render()renders through imlib2, which can only paint into an X11 drawable, and it sizes its temporary buffer fromwindow.geometry/window.drawable— both are populated by the X11 output only. On Wayland they are still empty, soimlib_create_image(0, 0)returnsNULL, every queued image is dropped, and the calls above run against a null image.Approach
Ask the active output what it draws into instead of assuming a drawable:
display_output_base::drawing_context()returns the cairo context the output composites into, ornullptrfor outputs that keep drawing to an X11 drawable.display_output_waylandimplements it with the context of its own surface, and creates an imlib2 context that is not bound to a drawable (cimlib_init_cpu()), since it has none.cimlib_render_cairo()walks the same image list, converts imlib2's unpremultiplied ARGB data into cairo's premultipliedARGB32(respectingdraw_blended, which now means "composite as opaque") and paints each image attext_start + (cur->x, cur->y)scaled to the-WxHsize — i.e. the same position and the same stacking order (images behind text) as the X11 path. Cache flushing (imlib_cache_flush_interval,-f,-h) is unchanged.draw_stuff()only dispatches: X11 keeps callingcimlib_render()becausedrawing_context()is null there. No config settings were added, and the X11 path is untouched.Verification
GNOME 46 / mutter (Wayland), conky at
319260b7, built with-DBUILD_WAYLAND=ON -DBUILD_IMLIB2=ON.Because mutter has no
wlr-layer-shell, conky falls back to an xdg-toplevel, which is enough to render. Both binaries were run against the same config and the surface was dumped withcairo_surface_write_to_png()from a debugger (no screenshot tool needed on GNOME):unable to load imagecompare -metric AE→ 0.99 % differing pixels, i.e. only resampling-filter noise (cairoFILTER_GOODvs ImageMagick's default), so colours, alpha and scaling line up.Happy to attach the before/after screenshot (I could not upload it from the CLI).
Notes / limits
cairo_surface_tperimage_list_s.${image ... -i}/-p/-s/-f/-hall work since they shareimage_list_s.