2021-03-04 09:47:31 +03:00
|
|
|
use crate::WindowDecorations;
|
2020-12-28 08:51:56 +03:00
|
|
|
use std::sync::{Arc, Mutex};
|
|
|
|
|
|
|
|
pub trait WindowConfiguration {
|
|
|
|
fn use_ime(&self) -> bool {
|
|
|
|
false
|
|
|
|
}
|
2020-12-28 08:56:16 +03:00
|
|
|
|
2021-02-01 04:06:30 +03:00
|
|
|
fn send_composed_key_when_left_alt_is_pressed(&self) -> bool {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
|
|
|
|
fn send_composed_key_when_right_alt_is_pressed(&self) -> bool {
|
|
|
|
true
|
|
|
|
}
|
|
|
|
|
2021-03-07 17:51:01 +03:00
|
|
|
fn treat_left_ctrlalt_as_altgr(&self) -> bool {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
|
2021-02-01 04:06:30 +03:00
|
|
|
// Applies to Windows only.
|
|
|
|
// For macos, see send_composed_key_when_XXX_alt_is_pressed
|
2020-12-28 08:56:16 +03:00
|
|
|
fn use_dead_keys(&self) -> bool {
|
|
|
|
true
|
|
|
|
}
|
2020-12-28 09:00:51 +03:00
|
|
|
|
|
|
|
fn enable_wayland(&self) -> bool {
|
|
|
|
true
|
|
|
|
}
|
2020-12-28 09:06:04 +03:00
|
|
|
|
|
|
|
fn prefer_egl(&self) -> bool {
|
|
|
|
true
|
|
|
|
}
|
2020-12-28 09:34:31 +03:00
|
|
|
|
2021-02-28 10:59:04 +03:00
|
|
|
fn prefer_swrast(&self) -> bool {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
|
2020-12-28 09:34:31 +03:00
|
|
|
fn native_macos_fullscreen_mode(&self) -> bool {
|
|
|
|
false
|
|
|
|
}
|
2021-01-30 18:58:53 +03:00
|
|
|
|
2021-01-30 19:08:11 +03:00
|
|
|
/// Retrieves the opacity configuration from the host application.
|
|
|
|
/// Note that this value doesn't directly control the opacity of
|
|
|
|
/// the window from the perspective of this window crate; the application
|
|
|
|
/// must set the alpha level of the pixels when it renders the window.
|
|
|
|
/// This method is used by the macOS impl to adjust other window settings
|
|
|
|
/// when the window is transparent.
|
2021-01-30 18:58:53 +03:00
|
|
|
fn window_background_opacity(&self) -> f32 {
|
|
|
|
1.0
|
|
|
|
}
|
2021-03-04 09:47:31 +03:00
|
|
|
|
|
|
|
fn decorations(&self) -> WindowDecorations {
|
|
|
|
WindowDecorations::default()
|
|
|
|
}
|
2020-12-28 08:51:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
lazy_static::lazy_static! {
|
|
|
|
static ref CONFIG: Mutex<Arc<dyn WindowConfiguration + Send + Sync>> = default_config();
|
|
|
|
}
|
|
|
|
|
2021-03-05 10:05:44 +03:00
|
|
|
pub type WindowConfigHandle = Arc<dyn WindowConfiguration + Send + Sync>;
|
|
|
|
|
|
|
|
pub(crate) fn config() -> WindowConfigHandle {
|
2020-12-28 08:51:56 +03:00
|
|
|
Arc::clone(&CONFIG.lock().unwrap())
|
|
|
|
}
|
|
|
|
|
2021-03-05 10:05:44 +03:00
|
|
|
fn default_config() -> Mutex<WindowConfigHandle> {
|
2020-12-28 08:51:56 +03:00
|
|
|
struct DefConfig;
|
|
|
|
impl WindowConfiguration for DefConfig {}
|
|
|
|
Mutex::new(Arc::new(DefConfig))
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn set_configuration<C: WindowConfiguration + Send + Sync + 'static>(c: C) {
|
|
|
|
let mut global_config = CONFIG.lock().unwrap();
|
|
|
|
*global_config = Arc::new(c);
|
|
|
|
}
|