mirror of
https://github.com/wez/wezterm.git
synced 2024-09-20 11:17:15 +03:00
simplify middle mouse button paste logic
Now that we can tell whether the mouse is grabbed, we can safely process the paste in the same way that we use for keyboard initiated pasting.
This commit is contained in:
parent
5f5113ce50
commit
bafa36b8ca
@ -373,51 +373,34 @@ impl WindowCallbacks for TermWindow {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if let WMEK::Press(MousePress::Middle) = event.kind {
|
if let WMEK::Press(MousePress::Middle) = event.kind {
|
||||||
// The middle button will typically want to paste the clipboard but
|
if !tab.is_mouse_grabbed() {
|
||||||
// obtaining the contents is an async operation that requires the
|
// Middle mouse button is Paste
|
||||||
// event loop to pump.
|
|
||||||
// So we schedule that work and continue with dispatching the middle
|
|
||||||
// button once we have it.
|
|
||||||
// want to paste the clipboard,
|
|
||||||
|
|
||||||
let tab_id = tab.tab_id();
|
let tab_id = tab.tab_id();
|
||||||
let window_clone = self.window.as_ref().cloned().unwrap();
|
let future = self.window.as_ref().unwrap().get_clipboard();
|
||||||
let future = self.window.as_ref().unwrap().get_clipboard();
|
Connection::get().unwrap().spawn_task(async move {
|
||||||
Connection::get().unwrap().spawn_task(async move {
|
if let Ok(clip) = future.await {
|
||||||
if let Ok(clip) = future.await {
|
promise::Future::with_executor(executor(), move || {
|
||||||
window_clone.apply(move |myself, context| {
|
|
||||||
if let Some(myself) = myself.downcast_mut::<Self>() {
|
|
||||||
myself
|
|
||||||
.clipboard_contents
|
|
||||||
.lock()
|
|
||||||
.unwrap()
|
|
||||||
.replace(clip.clone());
|
|
||||||
let mux = Mux::get().unwrap();
|
let mux = Mux::get().unwrap();
|
||||||
if let Some(tab) = mux.get_tab(tab_id) {
|
if let Some(tab) = mux.get_tab(tab_id) {
|
||||||
tab.mouse_event(
|
tab.trickle_paste(clip)?;
|
||||||
mouse_event,
|
|
||||||
&mut Host {
|
|
||||||
writer: &mut *tab.writer(),
|
|
||||||
context,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.ok();
|
|
||||||
}
|
}
|
||||||
}
|
Ok(())
|
||||||
Ok(())
|
});
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
});
|
return;
|
||||||
} else {
|
}
|
||||||
tab.mouse_event(
|
|
||||||
mouse_event,
|
|
||||||
&mut Host {
|
|
||||||
writer: &mut *tab.writer(),
|
|
||||||
context,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tab.mouse_event(
|
||||||
|
mouse_event,
|
||||||
|
&mut Host {
|
||||||
|
writer: &mut *tab.writer(),
|
||||||
|
context,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
match event.kind {
|
match event.kind {
|
||||||
|
Loading…
Reference in New Issue
Block a user