mirror of
https://github.com/wez/wezterm.git
synced 2024-12-23 13:21:38 +03:00
refactor: new_window is now async
This doesn't really change anything, but it makes it a little simpler to integrate wgpu in a later commit.
This commit is contained in:
parent
e210cdf8ea
commit
6919630810
@ -28,11 +28,15 @@ impl GuiFrontEnd {
|
||||
if let Some(_fe) = fe.upgrade() {
|
||||
match n {
|
||||
MuxNotification::WindowCreated(mux_window_id) => {
|
||||
if let Err(err) = TermWindow::new_window(mux_window_id) {
|
||||
log::error!("Failed to create window: {:#}", err);
|
||||
let mux = Mux::get().expect("subscribe to trigger on main thread");
|
||||
mux.kill_window(mux_window_id);
|
||||
}
|
||||
promise::spawn::spawn(async move {
|
||||
if let Err(err) = TermWindow::new_window(mux_window_id).await {
|
||||
log::error!("Failed to create window: {:#}", err);
|
||||
let mux = Mux::get().expect("subscribe to trigger on main thread");
|
||||
mux.kill_window(mux_window_id);
|
||||
}
|
||||
anyhow::Result::<()>::Ok(())
|
||||
})
|
||||
.detach();
|
||||
}
|
||||
MuxNotification::PaneOutput(_) => {}
|
||||
MuxNotification::Alert {
|
||||
|
@ -350,7 +350,8 @@ impl WindowCallbacks for TermWindow {
|
||||
dimensions.pixel_height,
|
||||
guts,
|
||||
Some(&config),
|
||||
)?;
|
||||
)
|
||||
.await?;
|
||||
|
||||
Self::apply_icon(&window)?;
|
||||
Self::start_periodic_maintenance(window.clone());
|
||||
@ -465,7 +466,7 @@ fn reload_background_image(
|
||||
}
|
||||
|
||||
impl TermWindow {
|
||||
pub fn new_window(mux_window_id: MuxWindowId) -> anyhow::Result<()> {
|
||||
pub async fn new_window(mux_window_id: MuxWindowId) -> anyhow::Result<()> {
|
||||
let config = configuration();
|
||||
|
||||
let window_background = load_background_image(&config);
|
||||
@ -566,7 +567,8 @@ impl TermWindow {
|
||||
has_animation: RefCell::new(None),
|
||||
}),
|
||||
Some(&config),
|
||||
)?;
|
||||
)
|
||||
.await?;
|
||||
|
||||
Self::apply_icon(&window)?;
|
||||
Self::setup_clipboard(&window, mux_window_id, clipboard_contents);
|
||||
|
@ -354,7 +354,7 @@ fn function_key_to_keycode(function_key: char) -> KeyCode {
|
||||
pub struct Window(usize);
|
||||
|
||||
impl Window {
|
||||
pub fn new_window(
|
||||
pub async fn new_window(
|
||||
_class_name: &str,
|
||||
name: &str,
|
||||
width: usize,
|
||||
|
@ -161,7 +161,7 @@ impl PendingEvent {
|
||||
pub struct WaylandWindow(usize);
|
||||
|
||||
impl WaylandWindow {
|
||||
pub fn new_window(
|
||||
pub async fn new_window(
|
||||
class_name: &str,
|
||||
name: &str,
|
||||
width: usize,
|
||||
|
@ -367,7 +367,7 @@ impl Window {
|
||||
Ok(hwnd)
|
||||
}
|
||||
|
||||
pub fn new_window(
|
||||
pub async fn new_window(
|
||||
class_name: &str,
|
||||
name: &str,
|
||||
width: usize,
|
||||
|
@ -674,7 +674,7 @@ impl XWindow {
|
||||
|
||||
/// Create a new window on the specified screen with the specified
|
||||
/// dimensions
|
||||
pub fn new_window(
|
||||
pub async fn new_window(
|
||||
class_name: &str,
|
||||
name: &str,
|
||||
width: usize,
|
||||
|
@ -45,7 +45,7 @@ impl Connection {
|
||||
Ok(Connection::X11(Rc::new(XConnection::create_new()?)))
|
||||
}
|
||||
|
||||
pub fn new_window(
|
||||
pub async fn new_window(
|
||||
&self,
|
||||
class_name: &str,
|
||||
name: &str,
|
||||
@ -55,10 +55,12 @@ impl Connection {
|
||||
config: Option<&ConfigHandle>,
|
||||
) -> anyhow::Result<Window> {
|
||||
match self {
|
||||
Self::X11(_) => XWindow::new_window(class_name, name, width, height, callbacks, config),
|
||||
Self::X11(_) => {
|
||||
XWindow::new_window(class_name, name, width, height, callbacks, config).await
|
||||
}
|
||||
#[cfg(feature = "wayland")]
|
||||
Self::Wayland(_) => {
|
||||
WaylandWindow::new_window(class_name, name, width, height, callbacks, config)
|
||||
WaylandWindow::new_window(class_name, name, width, height, callbacks, config).await
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -106,7 +108,7 @@ impl ConnectionOps for Connection {
|
||||
}
|
||||
|
||||
impl Window {
|
||||
pub fn new_window(
|
||||
pub async fn new_window(
|
||||
class_name: &str,
|
||||
name: &str,
|
||||
width: usize,
|
||||
@ -117,6 +119,7 @@ impl Window {
|
||||
Connection::get()
|
||||
.unwrap()
|
||||
.new_window(class_name, name, width, height, callbacks, config)
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user