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
use crate::{
api, consts,
types::{self, Uid},
};
#[derive(
Clone,
Debug,
PartialEq,
PartialOrd,
serde::Serialize,
serde::Deserialize,
)]
pub enum Value {
WebContents(types::OVRWebContents),
I32(i32),
}
impl From<&WindowTypeValue> for Value {
fn from(valued: &WindowTypeValue) -> Value {
use WindowTypeValue::*;
match valued {
WebPage(v) => Value::WebContents(v.clone()),
DesktopCapture(v) => Value::I32(*v),
WindowCapture(v) => Value::I32(*v),
}
}
}
#[derive(
Clone,
Debug,
PartialEq,
PartialOrd,
serde::Serialize,
serde::Deserialize,
)]
pub enum WindowTypeValue {
WebPage(types::OVRWebContents),
DesktopCapture(i32),
WindowCapture(i32),
}
impl WindowTypeValue {
pub fn compose(
kind: consts::WindowType,
value: Value,
) -> Option<Self> {
kind.with(value)
}
pub fn decompose(&self) -> (consts::WindowType, Value) {
(consts::WindowType::from(self), Value::from(self))
}
pub fn set_in_overlay(&self, uid: Uid) {
use WindowTypeValue::*;
unsafe {
match self {
WebPage(v) => api::set_contents_website(uid, v),
DesktopCapture(v) => {
api::set_contents_desktop(uid, *v)
}
WindowCapture(v) => {
api::set_contents_window(uid, *v)
}
}
}
}
}