Skip to content

Commit 83f8db8

Browse files
committed
fix: Windows compatibility/fixes
1 parent 8651bb0 commit 83f8db8

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ async fn capture_display_thumbnail(display: &scap_targets::Display) -> Option<St
635635
use scap_direct3d::{Capturer, Settings};
636636
use std::io::Cursor;
637637

638-
let item = display.raw_handle().get_capture_item().ok()?;
638+
let item = display.raw_handle().try_as_capture_item().ok()?;
639639

640640
let (tx, rx) = std::sync::mpsc::channel();
641641

@@ -645,7 +645,7 @@ async fn capture_display_thumbnail(display: &scap_targets::Display) -> Option<St
645645
..Default::default()
646646
};
647647

648-
let capturer = Capturer::new(
648+
let mut capturer = Capturer::new(
649649
item,
650650
settings.clone(),
651651
move |frame| {
@@ -696,7 +696,7 @@ async fn capture_display_thumbnail(display: &scap_targets::Display) -> Option<St
696696
thumbnail.as_raw(),
697697
thumbnail.width(),
698698
thumbnail.height(),
699-
ColorType::Rgba8,
699+
ColorType::Rgba8.into(),
700700
)
701701
.ok()?;
702702

@@ -719,7 +719,7 @@ async fn capture_window_thumbnail(window: &scap_targets::Window) -> Option<Strin
719719
use scap_direct3d::{Capturer, Settings};
720720
use std::io::Cursor;
721721

722-
let item = window.raw_handle().get_capture_item().ok()?;
722+
let item = window.raw_handle().try_as_capture_item().ok()?;
723723

724724
let (tx, rx) = std::sync::mpsc::channel();
725725

@@ -729,7 +729,7 @@ async fn capture_window_thumbnail(window: &scap_targets::Window) -> Option<Strin
729729
..Default::default()
730730
};
731731

732-
let capturer = Capturer::new(
732+
let mut capturer = Capturer::new(
733733
item,
734734
settings.clone(),
735735
move |frame| {
@@ -780,7 +780,7 @@ async fn capture_window_thumbnail(window: &scap_targets::Window) -> Option<Strin
780780
thumbnail.as_raw(),
781781
thumbnail.width(),
782782
thumbnail.height(),
783-
ColorType::Rgba8,
783+
ColorType::Rgba8.into(),
784784
)
785785
.ok()?;
786786

crates/scap-targets/src/platform/win.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,11 @@ impl WindowImpl {
10261026

10271027
true
10281028
}
1029+
1030+
pub fn try_as_capture_item(&self) -> windows::core::Result<GraphicsCaptureItem> {
1031+
let interop = windows::core::factory::<GraphicsCaptureItem, IGraphicsCaptureItemInterop>()?;
1032+
unsafe { interop.CreateForWindow(self.0) }
1033+
}
10291034
}
10301035

10311036
fn is_window_valid_for_enumeration(hwnd: HWND, current_process_id: u32) -> bool {

0 commit comments

Comments
 (0)