From a33659c8c59445418086ace2ce8466d8dd759ca5 Mon Sep 17 00:00:00 2001 From: Ivan Li Date: Thu, 26 Jan 2023 23:30:28 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=88=87=E6=8D=A2=E5=88=B0=E5=90=8E?= =?UTF-8?q?=E5=8F=B0=E5=90=8E=E4=B8=80=E5=88=86=E9=92=9F=E5=86=85=EF=BC=8C?= =?UTF-8?q?=E6=88=AA=E5=9B=BE=E6=95=88=E7=8E=87=E9=99=8D=E4=BD=8E=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-tauri/Cargo.lock | 12 ++++++++++++ src-tauri/Cargo.toml | 1 + src-tauri/src/core/core.rs | 3 ++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index f1ca52b..7ba06ec 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -779,6 +779,7 @@ dependencies = [ "futures", "hex", "image", + "macos-app-nap", "mdns", "once_cell", "paris", @@ -1771,6 +1772,17 @@ dependencies = [ "time", ] +[[package]] +name = "macos-app-nap" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9701bd74bcff7fb5f9bff8ff4930a889a55f9cccc8a0dfc4c51ea08b786f0c6a" +dependencies = [ + "cc", + "cocoa-foundation", + "objc", +] + [[package]] name = "malloc_buf" version = "0.0.6" diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 69a62c8..0321989 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -35,6 +35,7 @@ futures = "0.3.25" either = "1.8.0" image = "0.24.5" mdns = "3.0.0" +macos-app-nap = "0.0.1" [features] # by default Tauri runs in production mode diff --git a/src-tauri/src/core/core.rs b/src-tauri/src/core/core.rs index 028bde3..4817fea 100644 --- a/src-tauri/src/core/core.rs +++ b/src-tauri/src/core/core.rs @@ -92,6 +92,7 @@ impl CoreManager { } pub async fn play_follow(&self) -> anyhow::Result<()> { + macos_app_nap::prevent(); let mut futs = vec![]; let configs = picker::config::Manager::global().reload_config().await; let configs = match configs { @@ -220,7 +221,7 @@ impl CoreManager { if let AmbientLightMode::Follow = *lock { drop(lock); let screenshot = picker.take_screenshot()?; - // info!("Take Screenshot Spend: {:?}", start.elapsed()); + info!("Take Screenshot Spend: {:?}", start.elapsed()); match tx.send(screenshot).await { Ok(_) => {} Err(err) => {