mirror of
https://github.com/icewind1991/clipboard-sync
synced 2026-06-03 10:24:06 +02:00
don't set clipboard to same value
this breaks copy paste of files on linux
This commit is contained in:
parent
ca1c2d0d88
commit
979348d931
1 changed files with 12 additions and 5 deletions
|
|
@ -18,8 +18,11 @@ mod common;
|
||||||
fn handle_command(command: ClipboardCommand, ctx: &mut ClipboardContext) {
|
fn handle_command(command: ClipboardCommand, ctx: &mut ClipboardContext) {
|
||||||
match command {
|
match command {
|
||||||
ClipboardCommand::Set { value, session: _ } => {
|
ClipboardCommand::Set { value, session: _ } => {
|
||||||
|
let old_clipboard = ctx.get_contents().unwrap_or_default();
|
||||||
|
if value != old_clipboard {
|
||||||
let _ = ctx.set_contents(value);
|
let _ = ctx.set_contents(value);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ClipboardCommand::Listen { session: _ } => {}
|
ClipboardCommand::Listen { session: _ } => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -40,10 +43,6 @@ fn main() {
|
||||||
println!("connecting to {} on channel {}", url, session);
|
println!("connecting to {} on channel {}", url, session);
|
||||||
|
|
||||||
connect(url, |out| {
|
connect(url, |out| {
|
||||||
send_to_server(&out, &ClipboardCommand::Listen {
|
|
||||||
session: session.clone()
|
|
||||||
});
|
|
||||||
|
|
||||||
let (tx, rx) = mpsc::channel();
|
let (tx, rx) = mpsc::channel();
|
||||||
|
|
||||||
clipboard_thread(session.clone(), rx);
|
clipboard_thread(session.clone(), rx);
|
||||||
|
|
@ -67,7 +66,15 @@ fn clipboard_thread(session: String, rx: mpsc::Receiver<Sender>) -> JoinHandle<(
|
||||||
let hunderd_millis = time::Duration::from_millis(100);
|
let hunderd_millis = time::Duration::from_millis(100);
|
||||||
let mut old_clipboard = ctx.get_contents().unwrap_or_default();
|
let mut old_clipboard = ctx.get_contents().unwrap_or_default();
|
||||||
|
|
||||||
|
thread::sleep(hunderd_millis);
|
||||||
|
|
||||||
let out = rx.recv().unwrap();
|
let out = rx.recv().unwrap();
|
||||||
|
|
||||||
|
// we need to do the listen after returning the closure for the websocket
|
||||||
|
// thus we can't send this message in the factory
|
||||||
|
send_to_server(&out, &ClipboardCommand::Listen {
|
||||||
|
session: session.clone()
|
||||||
|
});
|
||||||
loop {
|
loop {
|
||||||
thread::sleep(hunderd_millis);
|
thread::sleep(hunderd_millis);
|
||||||
let new_clipbaord = ctx.get_contents().unwrap_or_default();
|
let new_clipbaord = ctx.get_contents().unwrap_or_default();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue