Skip to content

Add clipboard and TARGETS selection support#4

Merged
jserv merged 1 commit into
mainfrom
clipboard
Jun 2, 2026
Merged

Add clipboard and TARGETS selection support#4
jserv merged 1 commit into
mainfrom
clipboard

Conversation

@jserv
Copy link
Copy Markdown
Contributor

@jserv jserv commented Jun 2, 2026

XConvertSelection now synthesizes a TARGETS reply when SDL holds the clipboard, advertising TARGETS/UTF8_STRING/STRING so requestors can discover the supported text types before asking for the data. Guard the synthesized reply on SDL_GetClipboardText() succeeding so we don't lie when SDL_HasClipboardText() and the follow-up read disagree (race, OOM).

examples/clipboard.c is a small interactive Xlib client that drives XConvertSelection through the new path. --once prints the TARGETS list headlessly under SDL_VIDEODRIVER=dummy and is exercised by the selection regression test (atoms[0]==TARGETS, [1]==UTF8_STRING, [2]==XA_STRING).


Summary by cubic

Add TARGETS support to the SDL-backed clipboard path so X11 clients can discover supported formats before requesting data. Includes a small Xlib example and tests.

  • New Features

    • XConvertSelection now synthesizes a TARGETS reply when SDL has clipboard text, advertising TARGETS, UTF8_STRING, and STRING (only if SDL_GetClipboardText() succeeds).
    • Added examples/clipboard.c: interactive probe (C/T/V keys); --once prints the TARGETS list headlessly. Wired into the build and docs.
    • Implemented XIfEvent to block until a predicate matches (used by the example).
  • Bug Fixes

    • Reset selection atom cache on XCloseDisplay to avoid stale atom IDs across display reopen.
    • Validate the type atom in XChangeProperty and remove the strict type-match check on replace to prevent spurious errors with selection properties.

Written for commit f163ed6. Summary will update on new commits.

Review in cubic

cubic-dev-ai[bot]

This comment was marked as resolved.

XConvertSelection now synthesizes a TARGETS reply when SDL holds the
clipboard, advertising TARGETS/UTF8_STRING/STRING so requestors can
discover the supported text types before asking for the data. Guard the
synthesized reply on SDL_GetClipboardText() succeeding so we don't lie
when SDL_HasClipboardText() and the follow-up read disagree (race, OOM).

examples/clipboard.c is a small interactive Xlib client that drives
XConvertSelection through the new path. `--once` prints the TARGETS list
headlessly under SDL_VIDEODRIVER=dummy and is exercised by the selection
regression test (atoms[0]==TARGETS, [1]==UTF8_STRING, [2]==XA_STRING).
@jserv jserv merged commit 893ac11 into main Jun 2, 2026
3 checks passed
@jserv jserv deleted the clipboard branch June 2, 2026 04:14
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.

1 participant