-
-
Notifications
You must be signed in to change notification settings - Fork 121
Expand file tree
/
Copy pathmod.rs
More file actions
92 lines (68 loc) · 1.93 KB
/
mod.rs
File metadata and controls
92 lines (68 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#[cfg(target_os = "macos")]
use futures::executor::block_on;
#[cfg(target_os = "macos")]
mod mac;
#[cfg(target_os = "windows")]
mod win;
#[cfg(target_os = "linux")]
mod linux;
#[cfg(target_os = "windows")]
unsafe impl Send for Window {}
#[derive(Debug, Clone)]
pub struct Window {
pub id: u32,
pub title: String,
#[cfg(target_os = "windows")]
pub raw_handle: windows::Win32::Foundation::HWND,
#[cfg(target_os = "macos")]
pub raw_handle: cidre::cg::WindowId,
}
#[cfg(target_os = "windows")]
unsafe impl Send for Display {}
#[derive(Debug, Clone)]
pub struct Display {
pub id: u32,
pub title: String,
#[cfg(target_os = "windows")]
pub raw_handle: windows::Win32::Graphics::Gdi::HMONITOR,
#[cfg(target_os = "macos")]
pub raw_handle: cidre::cg::DirectDisplayId,
}
#[derive(Debug, Clone)]
pub enum Target {
Window(Window),
Display(Display),
}
/// Returns a list of targets that can be captured
pub fn get_all_targets() -> Vec<Target> {
#[cfg(target_os = "macos")]
return mac::get_all_targets();
#[cfg(target_os = "windows")]
return win::get_all_targets();
#[cfg(target_os = "linux")]
return linux::get_all_targets();
}
pub fn get_scale_factor(target: &Target) -> f64 {
#[cfg(target_os = "macos")]
return mac::get_scale_factor(target);
#[cfg(target_os = "windows")]
return win::get_scale_factor(target);
#[cfg(target_os = "linux")]
return 1.0;
}
pub fn get_main_display() -> Display {
#[cfg(target_os = "macos")]
return mac::get_main_display();
#[cfg(target_os = "windows")]
return win::get_main_display();
#[cfg(target_os = "linux")]
unreachable!();
}
pub fn get_target_dimensions(target: &Target) -> (u64, u64) {
#[cfg(target_os = "macos")]
return mac::get_target_dimensions(target);
#[cfg(target_os = "windows")]
return win::get_target_dimensions(target);
#[cfg(target_os = "linux")]
unreachable!();
}