Files
LLeMbas-TTY/window/src/connection.rs
T
Wez Furlong 72cb110b65 add audible_bell config option
This allows using the system beep sound, currently only on macos.

refs: #3
2021-09-26 12:55:19 -07:00

52 lines
1.3 KiB
Rust

use crate::{Appearance, Connection};
use anyhow::Result as Fallible;
use std::cell::RefCell;
use std::rc::Rc;
thread_local! {
static CONN: RefCell<Option<Rc<Connection>>> = RefCell::new(None);
}
pub fn shutdown() {
CONN.with(|m| drop(m.borrow_mut().take()));
}
pub trait ConnectionOps {
fn get() -> Option<Rc<Connection>> {
let mut res = None;
CONN.with(|m| {
if let Some(mux) = &*m.borrow() {
res = Some(Rc::clone(mux));
}
});
res
}
fn default_dpi(&self) -> f64 {
crate::DEFAULT_DPI
}
fn init() -> Fallible<Rc<Connection>> {
let conn = Rc::new(Connection::create_new()?);
CONN.with(|m| *m.borrow_mut() = Some(Rc::clone(&conn)));
crate::spawn::SPAWN_QUEUE.register_promise_schedulers();
Ok(conn)
}
fn terminate_message_loop(&self);
fn run_message_loop(&self) -> Fallible<()>;
/// Retrieve the current appearance for the application.
fn get_appearance(&self) -> Appearance {
Appearance::Light
}
/// Hide the application.
/// This actions hides all of the windows of the application and switches
/// focus away from it.
fn hide_application(&self) {}
/// Perform the system beep/notification sound
fn beep(&self) {}
}