Skip to content

PoC: feat(platform): add system clipboard integration - #88

Draft
kakra wants to merge 1 commit into
ralgar:mainfrom
kakra:feat/system-clipboard
Draft

PoC: feat(platform): add system clipboard integration#88
kakra wants to merge 1 commit into
ralgar:mainfrom
kakra:feat/system-clipboard

Conversation

@kakra

@kakra kakra commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add a platform clipboard abstraction
  • implement X11/Xwayland clipboard ownership through an isolated XCB connection
  • connect the provider to ImGui's platform clipboard callback
  • retain ImGui's private fallback when no system provider is available

Motivation

ImGui's default Linux fallback only stores clipboard contents inside the current process. Consequently, GUI Copy controls cannot place text in the desktop clipboard.

X11 clipboard ownership also requires the owner to keep responding to selection requests. The implementation therefore uses a private XCB connection and a bounded background event loop, avoiding interference with application-owned displays and event queues.

This provides the infrastructure needed by follow-up Copy controls for the live log and developer diagnostics.

Scope

This PR implements setting clipboard text on X11 and Xwayland. It does not add any Copy buttons itself.

Native Wayland sessions without an Xwayland DISPLAY remain unsupported and will require a separate wl_data_device provider.

Verification

  • release build
  • full exhaustive cppcheck invocation used by CI
  • all six unit tests
  • runtime smoke test using an independent xclip client:
    • TARGETS, UTF8_STRING, TEXT, and STRING were advertised
    • UTF-8 clipboard contents were transferred successfully

Provide an isolated XCB clipboard owner that serves UTF-8 text without
consuming application events. Connect it to ImGui's platform clipboard
callback and leave the private fallback in place when no X11 or
Xwayland display is available.
@Jahfry

Jahfry commented Sep 4, 2026

Copy link
Copy Markdown

Sorry to post here but don't know if there's a better place.

I'm curious if this will in some form give a game running in gamescope with vkShade running access to/from the system clipboard?

I currently run a hack in Faugus to allow copy/paste (pre-launch: sh -c 'while true; do wl-paste --no-newline | DISPLAY=:1 xclip -selection clipboard 2>/dev/null; sleep 1; done' & && post-launch: killall xclip 2>/dev/null || true).

I could see a lot of value add if vkShade were the solution to that? Maybe using vkShade as a bridge between clipboards in Gamescope and Linux. Since it's already running (even if effects are toggled off, vkShade would need to be running to check for toggles). Might be considered scope creep but if it's doable without massive extra effort I really see it being useful. Maybe a setting in the .ini to enable it and have it off by default.

@kakra

kakra commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

I'm curious if this will in some form give a game running in gamescope with vkShade running access to/from the system clipboard?

Most likely not, I think rather gamescope would need to bridge the clipboard between the system and its nested compositor. So maybe you should report an issue in the gamescope project?

Also, vkShade has no business in creating such workarounds. If even possible, it would be very hacky, not just scope creep.

Your hack already shows that it is a problem bridging different compositor technologies (Xorg and Wayland) for the clipboard, and it's probably just a missing implementation in gamescope.

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.

2 participants