mirror of
https://github.com/0PandaDEV/Qopy.git
synced 2025-04-21 21:24:05 +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);
|
||||
|
||||
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::time::sleep(tokio::time::Duration::from_millis(500)).await;
|
||||
|
@ -72,22 +93,6 @@ pub async fn write_and_paste<R: Runtime>(
|
|||
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]
|
||||
pub fn get_image_path(app_handle: tauri::AppHandle, filename: String) -> String {
|
||||
let app_data_dir = app_handle
|
||||
|
@ -246,6 +251,8 @@ async fn insert_content_if_not_exists<R: Runtime>(
|
|||
.bind(favicon_base64)
|
||||
.execute(&pool)
|
||||
.await;
|
||||
|
||||
let _ = app_handle.emit("clipboard-content-updated", ());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -302,4 +309,4 @@ pub fn start_monitor(app_handle: AppHandle) -> Result<(), String> {
|
|||
.emit("plugin:clipboard://clipboard-monitor/status", true)
|
||||
.map_err(|e| e.to_string())?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue