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
pub mod winit;
#[cfg(target_os = "linux")]
pub mod x11;
use Basalt;

use std::sync::Arc;
use vulkano::swapchain::Surface;
use vulkano::instance::Instance;
use ::InputSource;
use ::Options as BasaltOptions;

pub trait BasaltWindow {
	fn capture_cursor(&self);
	fn release_cursor(&self);
	fn cursor_captured(&self) -> bool;
	fn attach_basalt(&self, basalt: Arc<Basalt>);
	fn enable_fullscreen(&self);
	fn disable_fullscreen(&self);
	fn request_resize(&self, width: u32, height: u32);
}

#[allow(unused_assignments)]
pub fn open_surface(ops: BasaltOptions, instance: Arc<Instance>) -> Result<Arc<Surface<Arc<dyn BasaltWindow + Send + Sync>>>, String> {
	#[cfg(target_os = "linux")]
	{
		match ops.input_src {
			InputSource::Native => x11::open_surface(ops, instance),
			InputSource::Winit => winit::open_surface(ops, instance)
		}
	}
	#[cfg(target_os = "windows")]
	{
		winit::open_surface(ops, instance)
	}
	#[cfg(all(not(target_os = "linux"), not(target_os = "windows")))]
	{
		winit::open_surface(ops, instance)
	}
}