fix issue where focusing the window would clear the clipboard

This was particularly noticable on windows.
This commit is contained in:
Wez Furlong committed 2019-07-17 08:58:45 -07:00
1 parent 7e50c4db68
commit 3d8e4f8b0e
1 file changed
+19 -1
+19 -1
View File
@@ -16,6 +16,7 @@ use glium::glutin::{self, ElementState, MouseCursor};
use log::{debug, error};
use std::rc::Rc;
use std::sync::Arc;
use std::time::{Duration, Instant};
use term;
use term::KeyCode;
use term::KeyModifiers;
@@ -83,6 +84,7 @@ pub struct GliumTerminalWindow {
allow_received_character: bool,
mux_window_id: WindowId,
have_pending_resize_check: bool,
focus_instant: Instant,
}
impl TerminalWindow for GliumTerminalWindow {
@@ -257,6 +259,7 @@ impl GliumTerminalWindow {
allow_received_character: false,
mux_window_id,
have_pending_resize_check: false,
focus_instant: Instant::now(),
})
}
@@ -670,6 +673,14 @@ impl GliumTerminalWindow {
self.host.with_window(|win| win.check_for_resize());
}
}
Event::WindowEvent {
event: WindowEvent::Focused(focus),
..
} => {
if focus {
self.focus_instant = Instant::now();
}
}
Event::WindowEvent {
event: WindowEvent::Moved(position),
..
@@ -723,7 +734,14 @@ impl GliumTerminalWindow {
},
..
} => {
self.mouse_click(state, button, modifiers)?;
// When focusing the window, allow a brief grace period and ignore
// clicks within that interval. If we don't do this, the click will
// clear the current selection which is super annoying if you just
// copied some text in another app, and then clicked on the terminal
// to paste it.
if Instant::now() - self.focus_instant > Duration::from_millis(200) {
self.mouse_click(state, button, modifiers)?;
}
}
Event::WindowEvent {
event: