Clipboard modification Event
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 9.7k
- Forks
- 565
- PR merge metrics
- No merged PRs in 30d
Description
Hi!
I am new to druid, so forgive me if I missed something here.
Tell me if not, but it may be interesting to have a kind of "event" which reflects the clipboard modifications, in the same way key_down does for example.
As it's seems to be linked to the window system events (for Windows and x11 at least), it may fall in the Druid net.
Don't get me wrong here: I saw that there are existing API that allow us to set or get clipboard. I am talking here about the "clipboard modification event".
After some researches, it seems to be achievable on windows platform, with something like this to register the event:
WM_CREATE => {
let ret = unsafe {AddClipboardFormatListener(hwnd)};
println!("add clipbardlistener: {:?}", ret);
and the event can be retrieved with:
match msg {
WM_CLIPBOARDUPDATE => {
println!("Clipboard has changed!");
Some(0)
}
On x11, this kind be done using the "Xfixes" extension, for example, to register the event::
conn.xfixes_select_selection_input(
screen.root,
AtomEnum::PRIMARY.into(),
xfixes::SelectionEventMask::SET_SELECTION_OWNER,
)?
.check()?;
and to retrieve the event:
while let Some(event) = conn.poll_for_event()? {
match event {
Event::XfixesSelectionNotify(event) => {
(I am afraid my knowledge is limited here, and I don't have a clue for now for both platforms gtk & mac)
But it may imply a modification in the trait WinHandler to add something like:
fn clipboard(&mut self, event: ClipBoardEvent)
So my questions is: is it interesting from your point of view?
If yes and if you are agree, I may try to do a pull request for this, for the Windows and x11 platforms.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the WinHandler trait and the proposed Windows AddClipboardFormatListener and X11 Xfixes event paths described in the issue. Done would require a decided clipboard-event API and an agreed platform support scope; the issue names no files or tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- desktop, operating-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100