Repository navigation
Expand file tree
/
Copy pathnative.rs
More file actions
128 lines (107 loc) · 3.32 KB
/
Copy pathnative.rs
File metadata and controls
128 lines (107 loc) · 3.32 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// Origine : miniquad 0.4.8 (crates.io, git cc6f8d1f), fork pour PS Vita.
// Modifications pour PS Vita : module `vita` sous `cfg(target_os = "vita")`.
// Voir VITA-CHANGES.md.
#![allow(dead_code)]
use std::sync::mpsc;
#[derive(Default)]
pub(crate) struct DroppedFiles {
pub paths: Vec<std::path::PathBuf>,
pub bytes: Vec<Vec<u8>>,
}
pub(crate) struct NativeDisplayData {
pub screen_width: i32,
pub screen_height: i32,
pub screen_position: (u32, u32),
pub dpi_scale: f32,
pub high_dpi: bool,
pub quit_requested: bool,
pub quit_ordered: bool,
pub native_requests: mpsc::Sender<Request>,
pub clipboard: Box<dyn Clipboard>,
pub dropped_files: DroppedFiles,
pub blocking_event_loop: bool,
#[cfg(target_vendor = "apple")]
pub view: crate::native::apple::frameworks::ObjcId,
#[cfg(target_os = "ios")]
pub view_ctrl: crate::native::apple::frameworks::ObjcId,
#[cfg(target_vendor = "apple")]
pub gfx_api: crate::conf::AppleGfxApi,
}
#[cfg(target_vendor = "apple")]
unsafe impl Send for NativeDisplayData {}
#[cfg(target_vendor = "apple")]
unsafe impl Sync for NativeDisplayData {}
impl NativeDisplayData {
pub fn new(
screen_width: i32,
screen_height: i32,
native_requests: mpsc::Sender<Request>,
clipboard: Box<dyn Clipboard>,
) -> NativeDisplayData {
NativeDisplayData {
screen_width,
screen_height,
screen_position: (0, 0),
dpi_scale: 1.,
high_dpi: false,
quit_requested: false,
quit_ordered: false,
native_requests,
clipboard,
dropped_files: Default::default(),
blocking_event_loop: false,
#[cfg(target_vendor = "apple")]
gfx_api: crate::conf::AppleGfxApi::OpenGl,
#[cfg(target_vendor = "apple")]
view: std::ptr::null_mut(),
#[cfg(target_os = "ios")]
view_ctrl: std::ptr::null_mut(),
}
}
}
#[derive(Debug)]
pub(crate) enum Request {
ScheduleUpdate,
SetCursorGrab(bool),
ShowMouse(bool),
SetMouseCursor(crate::CursorIcon),
SetWindowSize { new_width: u32, new_height: u32 },
SetWindowPosition { new_x: u32, new_y: u32 },
SetFullscreen(bool),
ShowKeyboard(bool),
}
pub trait Clipboard: Send + Sync {
fn get(&mut self) -> Option<String>;
fn set(&mut self, string: &str);
}
pub mod module;
#[cfg(target_os = "linux")]
pub mod linux_x11;
#[cfg(target_os = "linux")]
pub mod linux_wayland;
#[cfg(target_os = "android")]
pub mod android;
#[cfg(target_os = "windows")]
pub mod windows;
// PS Vita (armv7-sony-vita-newlibeabihf) : vitaGL + SceCtrl/SceTouch. Ajout spike A.
#[cfg(target_os = "vita")]
pub mod vita;
#[cfg(target_os = "android")]
pub use android::*;
#[cfg(target_arch = "wasm32")]
pub mod wasm;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub mod apple;
#[cfg(target_os = "macos")]
pub mod macos;
#[cfg(target_os = "ios")]
pub mod ios;
#[cfg(any(target_os = "android", target_os = "linux"))]
pub mod egl;
// there is no glGetProcAddr on webgl, so its impossible to make "gl" module work
// on macos.. well, there is, but way easier to just statically link to gl
#[cfg(not(target_arch = "wasm32"))]
pub mod gl;
#[cfg(target_arch = "wasm32")]
pub use wasm::webgl as gl;
pub mod query_stab;