Add adaptive/high-contrast text rendering for transparent panels

xfce4-panel supports transparent/semi-transparent backgrounds, but text readability can become extremely poor depending on the wallpaper or windows visible underneath the panel.

This is especially noticeable with plugins that use colored or relatively low-contrast text. A foreground color that looks fine against one part of the desktop may become nearly invisible against another.

A possible improvement would be an optional foreground rendering mode intended specifically for transparent panels.

Potential approaches, from simplest to more ambitious:

  1. Text outline / shadow

    • Preserve the plugin-selected foreground color.
    • Add a contrasting outline or shadow around text.
    • Probably the easiest option and may already solve most cases.
  2. Adaptive black/white foreground

    • Determine the luminance of the background underneath the panel/text.
    • Render text as black or white, depending on which provides higher contrast.
    • This intentionally sacrifices plugin-defined foreground colors in exchange for readability.
  3. Difference / inverse blending

    • Render foreground text using a difference-style blend against the actual pixels underneath the panel.
    • Conceptually, white text rendered with difference blending would invert the background beneath each glyph.
    • This would allow individual glyphs, or even parts of glyphs, to remain distinguishable across backgrounds with strongly varying brightness.

The third option is probably significantly harder and may require compositor cooperation, especially under Wayland. Under X11 it may be possible to implement using background capture/XComposite/XRender/Cairo, while a proper Wayland implementation would likely need compositor-side support or an appropriate protocol.

The feature does not necessarily need to preserve the original foreground color. For users choosing this mode, readability would be the priority.

An example use case is a nearly or fully transparent panel placed over a photographic wallpaper: text can range from perfectly readable to almost invisible merely depending on which portion of the wallpaper happens to be underneath it.

Possible UI, for example:

Appearance → Foreground rendering

(•) Theme/default
( ) High contrast
( ) Difference/invert

Even a simpler configurable text-shadow/outline option would be useful if adaptive rendering is considered out of scope.

xfce_panel