mirror of
https://github.com/wez/wezterm.git
synced 2024-11-10 06:34:17 +03:00
with_window inner from FnMut -> FnOnce
Not sure why it was FnMut, but this tidies up an awkward option/take/unwrap thing in notify().
This commit is contained in:
parent
fb72338689
commit
a44607fb3f
@ -51,10 +51,10 @@ impl Connection {
|
||||
|
||||
pub(crate) fn with_window_inner<
|
||||
R,
|
||||
F: FnMut(&mut WindowInner) -> anyhow::Result<R> + Send + 'static,
|
||||
F: FnOnce(&mut WindowInner) -> anyhow::Result<R> + Send + 'static,
|
||||
>(
|
||||
window_id: usize,
|
||||
mut f: F,
|
||||
f: F,
|
||||
) -> promise::Future<R>
|
||||
where
|
||||
R: Send + 'static,
|
||||
|
@ -511,14 +511,13 @@ impl WindowOps for Window {
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
let mut t = Some(t);
|
||||
Connection::with_window_inner(self.0, move |inner| {
|
||||
if let Some(window_view) = WindowView::get_this(unsafe { &**inner.view }) {
|
||||
window_view
|
||||
.inner
|
||||
.borrow()
|
||||
.events
|
||||
.try_send(WindowEvent::Notification(Box::new(t.take().unwrap())))
|
||||
.try_send(WindowEvent::Notification(Box::new(t)))
|
||||
.ok();
|
||||
}
|
||||
Ok(())
|
||||
|
@ -146,10 +146,10 @@ impl WaylandConnection {
|
||||
|
||||
pub(crate) fn with_window_inner<
|
||||
R,
|
||||
F: FnMut(&mut WaylandWindowInner) -> anyhow::Result<R> + Send + 'static,
|
||||
F: FnOnce(&mut WaylandWindowInner) -> anyhow::Result<R> + Send + 'static,
|
||||
>(
|
||||
window: usize,
|
||||
mut f: F,
|
||||
f: F,
|
||||
) -> promise::Future<R>
|
||||
where
|
||||
R: Send + 'static,
|
||||
|
@ -625,11 +625,10 @@ impl WindowOps for WaylandWindow {
|
||||
.ok();
|
||||
} else {
|
||||
// Otherwise, get into that thread and write to the queue
|
||||
let mut t = Some(t);
|
||||
WaylandConnection::with_window_inner(self.0, move |inner| {
|
||||
inner
|
||||
.events
|
||||
.try_send(WindowEvent::Notification(Box::new(t.take().unwrap())))
|
||||
.try_send(WindowEvent::Notification(Box::new(t)))
|
||||
.ok();
|
||||
Ok(())
|
||||
});
|
||||
|
@ -114,10 +114,10 @@ impl Connection {
|
||||
|
||||
pub(crate) fn with_window_inner<
|
||||
R,
|
||||
F: FnMut(&mut WindowInner) -> anyhow::Result<R> + Send + 'static,
|
||||
F: FnOnce(&mut WindowInner) -> anyhow::Result<R> + Send + 'static,
|
||||
>(
|
||||
window: HWindow,
|
||||
mut f: F,
|
||||
f: F,
|
||||
) -> promise::Future<R>
|
||||
where
|
||||
R: Send + 'static,
|
||||
|
@ -567,11 +567,10 @@ impl WindowOps for Window {
|
||||
.ok();
|
||||
} else {
|
||||
// Otherwise, get into that thread and write to the queue
|
||||
let mut t = Some(t);
|
||||
Connection::with_window_inner(self.0, move |inner| {
|
||||
inner
|
||||
.events
|
||||
.try_send(WindowEvent::Notification(Box::new(t.take().unwrap())))
|
||||
.try_send(WindowEvent::Notification(Box::new(t)))
|
||||
.ok();
|
||||
Ok(())
|
||||
});
|
||||
|
@ -452,10 +452,10 @@ impl XConnection {
|
||||
|
||||
pub(crate) fn with_window_inner<
|
||||
R,
|
||||
F: FnMut(&mut XWindowInner) -> anyhow::Result<R> + Send + 'static,
|
||||
F: FnOnce(&mut XWindowInner) -> anyhow::Result<R> + Send + 'static,
|
||||
>(
|
||||
window: xcb::xproto::Window,
|
||||
mut f: F,
|
||||
f: F,
|
||||
) -> promise::Future<R>
|
||||
where
|
||||
R: Send + 'static,
|
||||
|
@ -915,11 +915,10 @@ impl WindowOps for XWindow {
|
||||
.ok();
|
||||
} else {
|
||||
// Otherwise, get into that thread and write to the queue
|
||||
let mut t = Some(t);
|
||||
XConnection::with_window_inner(self.0, move |inner| {
|
||||
inner
|
||||
.events
|
||||
.try_send(WindowEvent::Notification(Box::new(t.take().unwrap())))
|
||||
.try_send(WindowEvent::Notification(Box::new(t)))
|
||||
.ok();
|
||||
Ok(())
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user