Skip to content

Commit 2874ffd

Browse files
committed
Limit window variable scope in screenshot handler
1 parent efe8674 commit 2874ffd

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

apps/desktop/src-tauri/src/hotkeys.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,11 @@ async fn handle_hotkey(app: AppHandle, action: HotkeyAction) -> Result<(), Strin
221221
HotkeyAction::ScreenshotWindow => {
222222
use scap_targets::Window;
223223

224-
let window = Window::get_topmost_at_cursor()
225-
.ok_or_else(|| "No window found under cursor".to_string())?;
226-
let target = ScreenCaptureTarget::Window { id: window.id() };
224+
let target = {
225+
let window = Window::get_topmost_at_cursor()
226+
.ok_or_else(|| "No window found under cursor".to_string())?;
227+
ScreenCaptureTarget::Window { id: window.id() }
228+
};
227229

228230
match recording::take_screenshot(app.clone(), target).await {
229231
Ok(path) => {

0 commit comments

Comments
 (0)