X11: Implement Clipboard Functionality #518
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.