This commit is contained in:
open-trade
2021-12-23 17:44:44 +08:00
parent 252d3cb797
commit a30aaebc72
5 changed files with 79 additions and 48 deletions

View File

@@ -97,8 +97,12 @@ mod listen {
fn trigger(ctx: &mut ClipboardContext) {
let _ = match ctx.get_text() {
Ok(text) => ctx.set_text(text),
Err(_) => ctx.set_text(Default::default()),
Ok(text) => {
if !text.is_empty() {
ctx.set_text(text).ok();
}
}
Err(_) => {}
};
}
}

View File

@@ -220,7 +220,7 @@ fn run(sp: GenericService) -> ResultType<()> {
let start = time::Instant::now();
let mut last_check_displays = time::Instant::now();
#[cfg(windows)]
let mut try_gdi = true;
let mut try_gdi = 1;
#[cfg(windows)]
log::info!("gdi: {}", c.is_gdi());
while sp.ok() {
@@ -261,7 +261,7 @@ fn run(sp: GenericService) -> ResultType<()> {
frame_controller.set_send(now, send_conn_ids);
#[cfg(windows)]
{
try_gdi = false;
try_gdi = 0;
}
}
Err(ref e) if e.kind() == WouldBlock => {
@@ -271,10 +271,13 @@ fn run(sp: GenericService) -> ResultType<()> {
wait = 0
}
#[cfg(windows)]
if try_gdi && !c.is_gdi() {
c.set_gdi();
try_gdi = false;
log::info!("No image, fall back to gdi");
if try_gdi > 0 && !c.is_gdi() {
if try_gdi > 3 {
c.set_gdi();
try_gdi = 0;
log::info!("No image, fall back to gdi");
}
try_gdi += 1;
}
continue;
}