Skip to content

Pick only clipboard image types the decoder can read on Linux [patch] - #655

Merged
matt-edmondson merged 1 commit into
mainfrom
claude/imguiapp-651-clipboard-decodable-types
Oct 18, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
claude/imguiapp-651-clipboard-decodable-types

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #651

What was wrong

LinuxImageClipboard.PickType took image/png if the clipboard offered it. Otherwise it took whichever of image/jpeg, image/bmp and image/webp came first in the clipboard's own order. That caused two problems:

  • ImageDecoder cannot read WebP. A clipboard listing image/webp before image/bmp failed to paste, even though a readable BMP was on offer.
  • A JPEG listed first was chosen over a lossless BMP of the same image.

Change

  • PickType now walks a fixed list of decodable types: image/png, image/bmp, image/x-bmp, image/jpeg. It returns the first one on offer, spelled as the clipboard lists it. WebP is never chosen.
  • When nothing readable is on offer, it returns null. The user then sees the existing no-image message instead of a decode failure.

Tests

The three cases from the issue are added to ImageClipboardTests:

  • webp then bmp → bmp
  • webp alone → null
  • jpeg then bmp → bmp

There are also cases for image/x-bmp and for PNG still winning when it is listed last.

With the fix reverted, both new test methods fail. With it, the full ImGui.App.Tests run passes (608 total, 0 failed).


Generated by Claude Code

LinuxImageClipboard.PickType took PNG if offered, otherwise the first of
image/jpeg, image/bmp and image/webp in the clipboard's own order.
ImageDecoder cannot read WebP, so a clipboard listing image/webp before a
BMP failed to paste even though a readable image was on offer, and a
JPEG listed first won over a lossless BMP of the same image.

PickType now walks a fixed preference list of decodable types (PNG, BMP,
x-BMP, JPEG) and never chooses WebP. With nothing readable on offer it
returns null, so the user sees the no-image message rather than a
decode failure.

Fixes #651

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T3apQEs8uq9BSQJ2j8Z8mr
@sonarqubecloud

Copy link
Copy Markdown

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Linux image paste fails when the clipboard lists image/webp before a BMP or JPEG: PickType chooses a format ImageDecoder can't read

2 participants