Skip to content

Conversation

pegvin
Copy link

@pegvin pegvin commented Jun 3, 2025

Clipboard functionality on X11 is absolute TRASH & Way more complicated than it's Windows counterparts.

The complication comes from the fact that clipboard is maintained by the person who sets it. Thus when you set clipboard, You simply notify everyone that you have the latest clipboard data (XSetSelectionOwner).

Now for other window to read to clipboard (or even ours), We need to get who owns the window (XGetSelectionOwner) & Request the clipboard data (XConvertSelection).

Also other than textual data, X11 supports clipboard for much more complicated types like images & much more, This is why we our clipboard data request function is named XConvertSelection, Because we are requesting the own to convert it to the type we want.

I am still new to working with X11, So please do a thorough scrutiny. I tested it on my system & it works fine.

Note: The only issue I was facing was that when doing Ctrl + X or Ctrl + C in the Open Popup (File -> Open), The behavior was weird. Doing Ctrl + C just copied the whole string instead of selection & Ctrl + X did remove the selection text from input box but it didn't seem to send appropriate data to set clipboard function.

@pegvin pegvin changed the title Implement Clipboard Functionality For Linux (X11) X11: Implement Clipboard Functionality Jun 4, 2025
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