Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,4 @@ objc = { package = "objc-rs", version = "0.2" }

[dev-dependencies]
glam = { version = "0.24", features = ["scalar-math"] }
quad-rand = "0.1"

[profile.release]
lto = true
panic = 'abort'
opt-level = "s"
overflow-checks = false
debug-assertions = false
incremental = false
rpath = false
codegen-units = 1
strip = true
quad-rand = "0.1"
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/native/apple.rs → src/native/apple/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pub mod apple_util;
pub mod frameworks;
pub mod apple_util;
pub mod frameworks;
File renamed without changes.
File renamed without changes.
242 changes: 121 additions & 121 deletions src/native.rs → src/native/mod.rs
Original file line number Diff line number Diff line change
@@ -1,121 +1,121 @@
#![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;

#[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;
#![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;
#[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;
File renamed without changes.
File renamed without changes.
Loading