feat(wayland): composite imlib2 images (${image}) onto the Wayland surface by ditronicos · Pull Request #2499 · brndnmtthws/conky · GitHub
Skip to content

feat(wayland): composite imlib2 images (${image}) onto the Wayland surface - #2499

Closed
ditronicos wants to merge 1 commit into
brndnmtthws:mainfrom
ditronicos:wayland-imlib2-images
Closed

ditronicos wants to merge 1 commit into
brndnmtthws:mainfrom
ditronicos:wayland-imlib2-images

Conversation

@ditronicos

Copy link
Copy Markdown

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:

***** Imlib2 Developer Warning ***** :
	This program is calling the Imlib call:
		imlib_image_clear();
	With the parameter:
		image
	being NULL. Please fix your program.

Cause

cimlib_render() renders through imlib2, which can only paint into an X11 drawable, and it sizes its temporary buffer from window.geometry / window.drawable — both are populated by the X11 output only. On Wayland they are still empty, so imlib_create_image(0, 0) returns NULL, 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, or nullptr for outputs that keep drawing to an X11 drawable.
  • display_output_wayland implements 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 premultiplied ARGB32 (respecting draw_blended, which now means "composite as opaque") and paints each image at text_start + (cur->x, cur->y) scaled to the -WxH size — 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 calling cimlib_render() because drawing_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 with cairo_surface_write_to_png() from a debugger (no screenshot tool needed on GNOME):

conky.config = {
  background = false,
  output_backend = 'wayland',
  own_window = true,
  minimum_width = 420, minimum_height = 300,
  update_interval = 2,
}
conky.text = [[
WAYLAND IMLIB2 PATCH
${image /path/to/temperature.png -p 330,10 -s 64x64}
${image /path/to/humidity.png    -p 10,80 -s 64x64}
${image /path/to/frame-01.png    -p 90,80 -s 320x180}
]]
  • unpatched: text only, no icons, imlib2 null-image warnings every frame
  • patched: text and the three images; zero imlib2 warnings, zero unable to load image
  • the composited result was compared against an independent reference composite built with ImageMagick: compare -metric AE → 0.99 % differing pixels, i.e. only resampling-filter noise (cairo FILTER_GOOD vs 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

  • Like the X11 path, images are re-loaded and re-composited every update. The conversion is O(w*h) per image per frame; if that matters it could cache the converted cairo_surface_t per image_list_s.
  • ${image ... -i}/-p/-s/-f/-h all work since they share image_list_s.

…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
@netlify

netlify Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

@github-actions github-actions Bot added sources PR modifies project sources display: wayland related to Wayland backend labels Oct 15, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-15T05:05:18.372144Z 8c0cfd9 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/conky.cc
Comment thread src/conky-imlib2.cc
Comment thread src/output/display-wayland.cc
Comment thread src/conky-imlib2.cc
brndnmtthws added a commit that referenced this pull request Oct 23, 2026
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>

Copy link
Copy Markdown
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

display: wayland related to Wayland backend sources PR modifies project sources

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: image variable doesn't work on wayland

3 participants