1
1
mirror of https://github.com/wez/wezterm.git synced 2024-09-20 11:17:15 +03:00

window: don't propagate errors from close notif channel

When a window is being destroyed we expect the receiver end
to be disconnected, so we don't want to break out of the
message loop if a couple of residual windows fail to notify.
This commit is contained in:
Wez Furlong 2021-05-08 10:20:26 -07:00
parent 453cfc1813
commit 325e755216
3 changed files with 26 additions and 20 deletions

View File

@ -478,15 +478,19 @@ impl Window {
// Synthesize a resize event immediately; this allows
// the embedding application an opportunity to discover
// the dpi and adjust for display scaling
inner.borrow_mut().events.try_send(WindowEvent::Resized {
dimensions: Dimensions {
pixel_width: width as usize,
pixel_height: height as usize,
dpi: (crate::DEFAULT_DPI * (backing_frame.size.width / frame.size.width))
as usize,
},
is_full_screen: false,
})?;
inner
.borrow_mut()
.events
.try_send(WindowEvent::Resized {
dimensions: Dimensions {
pixel_width: width as usize,
pixel_height: height as usize,
dpi: (crate::DEFAULT_DPI * (backing_frame.size.width / frame.size.width))
as usize,
},
is_full_screen: false,
})
.ok();
Ok((window, receiver))
}

View File

@ -596,7 +596,7 @@ impl WaylandWindowInner {
}
fn do_paint(&mut self) -> anyhow::Result<()> {
self.events.try_send(WindowEvent::NeedRepaint)?;
self.events.try_send(WindowEvent::NeedRepaint).ok();
Ok(())
}
}

View File

@ -137,7 +137,7 @@ impl XWindowInner {
}
self.paint_all = false;
self.expose.clear();
self.events.try_send(WindowEvent::NeedRepaint)?;
self.events.try_send(WindowEvent::NeedRepaint).ok();
Ok(())
}
@ -161,7 +161,7 @@ impl XWindowInner {
}
fn do_mouse_event(&mut self, event: MouseEvent) -> anyhow::Result<()> {
self.events.try_send(WindowEvent::MouseEvent(event))?;
self.events.try_send(WindowEvent::MouseEvent(event)).ok();
Ok(())
}
@ -213,17 +213,19 @@ impl XWindowInner {
self.resize_promises.remove(0).ok(dimensions);
}
self.events.try_send(WindowEvent::Resized {
dimensions,
is_full_screen: self.is_fullscreen().unwrap_or(false),
})?;
self.events
.try_send(WindowEvent::Resized {
dimensions,
is_full_screen: self.is_fullscreen().unwrap_or(false),
})
.ok();
}
xcb::KEY_PRESS | xcb::KEY_RELEASE => {
let key_press: &xcb::KeyPressEvent = unsafe { xcb::cast_event(event) };
self.copy_and_paste.time = key_press.time();
if let Some(key) = conn.keyboard.process_key_event(key_press) {
let key = key.normalize_shift();
self.events.try_send(WindowEvent::KeyEvent(key))?;
self.events.try_send(WindowEvent::KeyEvent(key)).ok();
}
}
@ -310,7 +312,7 @@ impl XWindowInner {
}
}
xcb::DESTROY_NOTIFY => {
self.events.try_send(WindowEvent::Destroyed)?;
self.events.try_send(WindowEvent::Destroyed).ok();
conn.windows.borrow_mut().remove(&self.window_id);
}
xcb::SELECTION_CLEAR => {
@ -353,11 +355,11 @@ impl XWindowInner {
}
xcb::FOCUS_IN => {
log::trace!("Calling focus_change(true)");
self.events.try_send(WindowEvent::FocusChanged(true))?;
self.events.try_send(WindowEvent::FocusChanged(true)).ok();
}
xcb::FOCUS_OUT => {
log::trace!("Calling focus_change(false)");
self.events.try_send(WindowEvent::FocusChanged(false))?;
self.events.try_send(WindowEvent::FocusChanged(false)).ok();
}
_ => {
eprintln!("unhandled: {:x}", r);