Skip to content

Conversation

@AIG-Livny
Copy link

System clipboard paste functionality. Unfortunately, this is only Linux implementation for now.

I'am going to do Ctrl+V from system clipboard into console.

@Try
Copy link
Owner

Try commented Dec 15, 2025

Hi, @AIG-Livny and thanks for PR!

I've checked breathy, how other UI libraries do handle clipboard. Usually clipboard is 'singleton'-like, and has global get/set function.
Hotkeys, such as ctrl+c/ctrl+v are handled on widget-level. For example: in qt there is QClipboard, on android ClipboardManager, and SDL_GetClipboardText in sdl.

Would it be possible to refactor this PR into :

  • SystemApi::setClipboardData/SystemApi::clipboardData
  • handle hotkeys at Tempest::AbstractTextInput - similar to how ctrl+z implemented

@AIG-Livny
Copy link
Author

AIG-Livny commented Dec 18, 2025

Hi, @Try! Thanks for the review! I tried to follow your advice and would appreciate another look.

The X11 clipboard is isn't trivial, and to paste data from the system, we need to receive the SelectionNotify event. I couldn't find a better solution than waiting for the required event. At the same time, we still need to handle other events, so I've separated the handlers into the dispatchEvent function and called it while waiting for SelectionNotify

@Try
Copy link
Owner

Try commented Dec 18, 2025

I couldn't find a better solution than waiting for the required event.

You already have a storage for pasted data in X11Api:clipboard. Should be fine to store there on receiving SelectionNotify on the main loop - no need to have extra spins in X11Api::implClipboardData.

Also I'm worried that with such event spinning, weird cases of recursion may happen in UI.

@Try
Copy link
Owner

Try commented Jan 15, 2026

Hi, @AIG-Livny !

Just kindly check, if you are still working on this PR. If there is no time or anything - I can take clipboard work from here, its fine

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