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
pub mod winit;

use crate::{Basalt, Options as BasaltOptions};
use std::sync::Arc;
use vulkano::instance::Instance;
use vulkano::swapchain::Surface;

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 toggle_fullscreen(&self);
	fn request_resize(&self, width: u32, height: u32);
	fn inner_dimensions(&self) -> [u32; 2];
	fn window_type(&self) -> WindowType;
}

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum WindowType {
	UnixXlib,
	UnixXCB,
	UnixWayland,
	Windows,
	Macos,
	NotSupported,
}

pub fn open_surface(
	ops: BasaltOptions,
	instance: Arc<Instance>,
	result_fn: Box<
		dyn Fn(Result<Arc<Surface<Arc<dyn BasaltWindow + Send + Sync>>>, String>) + Send + Sync,
	>,
) {
	winit::open_surface(ops, instance, result_fn)
}