mirror of
https://github.com/0PandaDEV/Qopy.git
synced 2025-04-21 13:14:04 +02:00
fix: pasting not working on mac
This commit is contained in:
parent
042d708c4b
commit
3ae0313975
1 changed files with 25 additions and 18 deletions
|
@ -62,7 +62,28 @@ pub async fn write_and_paste<R: Runtime>(
|
||||||
|
|
||||||
IS_PROGRAMMATIC_PASTE.store(true, Ordering::SeqCst);
|
IS_PROGRAMMATIC_PASTE.store(true, Ordering::SeqCst);
|
||||||
|
|
||||||
simulate_paste();
|
thread::spawn(|| {
|
||||||
|
thread::sleep(Duration::from_millis(100));
|
||||||
|
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
let modifier_key = Key::MetaLeft;
|
||||||
|
#[cfg(not(target_os = "macos"))]
|
||||||
|
let modifier_key = Key::ControlLeft;
|
||||||
|
|
||||||
|
let events = vec![
|
||||||
|
EventType::KeyPress(modifier_key),
|
||||||
|
EventType::KeyPress(Key::KeyV),
|
||||||
|
EventType::KeyRelease(Key::KeyV),
|
||||||
|
EventType::KeyRelease(modifier_key),
|
||||||
|
];
|
||||||
|
|
||||||
|
for event in events {
|
||||||
|
if let Err(e) = simulate(&event) {
|
||||||
|
println!("Simulation error: {:?}", e);
|
||||||
|
}
|
||||||
|
thread::sleep(Duration::from_millis(20));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
tokio::spawn(async {
|
tokio::spawn(async {
|
||||||
tokio::time::sleep(tokio::time::Duration::from_millis(500)).await;
|
tokio::time::sleep(tokio::time::Duration::from_millis(500)).await;
|
||||||
|
@ -72,22 +93,6 @@ pub async fn write_and_paste<R: Runtime>(
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn simulate_paste() {
|
|
||||||
let mut events = vec![
|
|
||||||
EventType::KeyPress(Key::ControlLeft),
|
|
||||||
EventType::KeyPress(Key::KeyV),
|
|
||||||
EventType::KeyRelease(Key::KeyV),
|
|
||||||
EventType::KeyRelease(Key::ControlLeft),
|
|
||||||
];
|
|
||||||
|
|
||||||
thread::sleep(Duration::from_millis(100));
|
|
||||||
|
|
||||||
for event in events.drain(..) {
|
|
||||||
simulate(&event).unwrap();
|
|
||||||
thread::sleep(Duration::from_millis(20));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn get_image_path(app_handle: tauri::AppHandle, filename: String) -> String {
|
pub fn get_image_path(app_handle: tauri::AppHandle, filename: String) -> String {
|
||||||
let app_data_dir = app_handle
|
let app_data_dir = app_handle
|
||||||
|
@ -246,6 +251,8 @@ async fn insert_content_if_not_exists<R: Runtime>(
|
||||||
.bind(favicon_base64)
|
.bind(favicon_base64)
|
||||||
.execute(&pool)
|
.execute(&pool)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
let _ = app_handle.emit("clipboard-content-updated", ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue