8000 Fix: clipboard on linux by fmotalleb · Pull Request #10 · jooaf/thoth · GitHub
[go: up one dir, main page]

Skip to content

Fix: clipboard on linux - #10

Closed
fmotalleb wants to merge 3 commits into
jooaf:mainfrom
fmotalleb:fix/clipboard-on-linux
Closed

fmotalleb wants to merge 3 commits into
jooaf:mainfrom
fmotalleb:fix/clipboard-on-linux

Conversation

@fmotalleb
@fmotalleb fmotalleb commented Sep 18, 2024 •
Copy link
Copy Markdown
Contributor

This PR introduces a possible fix for clipboard handling on simpler desktop environments. The implementation leverages multithreading to avoid blocking the main thread when interacting with the clipboard, improving responsiveness and compatibility with certain desktop environments.

  • The EditorClipboard struct wraps the arboard::Clipboard functionality in a thread-safe Arc<Mutex<Clipboard>> to ensure safe concurrent access.
  • Clipboard contents are set directly within the current thread for non-Linux platforms.
  • For Linux platforms, clipboard contents are set asynchronously using a new thread to prevent blocking.

Known Limitation

While this solution handles clipboard interaction in simpler DEs, there is a limitation. If the main program exits, the clipboard thread will also terminate (have not tested this but it is expected), meaning the clipboard contents may be lost. To allow clipboard contents to persist beyond the life of the program, a longer-lasting solution would be to spawn a daemon process. An example of how to implement this can be found in the arboard daemonize example.

@fmotalleb
fmotalleb requested a review from jooaf as a code owner September 18, 2024 18:58
@fmotalleb fmotalleb changed the title Fix/clipboard on linux Fix: clipboard on linux Sep 18, 2024
@fmotalleb
Copy link
Copy Markdown
Contributor Author

Tests are failing due to clipboard not being mocked, I'll try fixing this

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

0