aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorJoe Wilm <joe@jwilm.com>2016-11-11 17:40:12 -0800
committerJoe Wilm <joe@jwilm.com>2016-11-11 17:40:12 -0800
commit8cbd7680944b8a453f86d6c5e6ba4e8c3aeccb6e (patch)
tree2a412886b3ba9a608124bb1d4c480c610f78efd9 /src/main.rs
parenta652b4a65fc2321bd77407b55a0eb55a4323e034 (diff)
downloadalacritty-8cbd7680944b8a453f86d6c5e6ba4e8c3aeccb6e.tar.gz
alacritty-8cbd7680944b8a453f86d6c5e6ba4e8c3aeccb6e.zip
Fix resize on macOS leaving screen blank
This still has a problem where intermediate sizes are not drawn. Apparently cocoa blocks the event loop during resize. This needs to be fixed in Glutin. Resolves #16.
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/main.rs b/src/main.rs
index 9a4a2cb6..38ecde39 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -75,7 +75,7 @@ use term::Term;
use tty::process_should_exit;
/// Channel used by resize handling on mac
-static mut RESIZE_SENDER: Option<mpsc::Sender<(u32, u32)>> = None;
+static mut RESIZE_CALLBACK: Option<Box<Fn(u32, u32)>> = None;
#[derive(Clone)]
pub struct Flag(Arc<AtomicBool>);
@@ -98,9 +98,7 @@ impl Flag {
/// Resize handling for Mac
fn window_resize_handler(width: u32, height: u32) {
unsafe {
- if let Some(ref tx) = RESIZE_SENDER {
- let _ = tx.send((width, height));
- }
+ RESIZE_CALLBACK.as_ref().map(|func| func(width, height));
}
}
@@ -189,16 +187,29 @@ fn main() {
let pty_io = terminal.tty().reader();
let (tx, rx) = mpsc::channel();
- unsafe {
- RESIZE_SENDER = Some(tx.clone());
- }
let signal_flag = Flag::new(false);
-
let terminal = Arc::new(FairMutex::new(terminal));
let window = Arc::new(window);
+ // Setup the rsize callback for osx
+ let terminal_ref = terminal.clone();
+ let signal_flag_ref = signal_flag.clone();
+ let proxy = window.create_window_proxy();
+ let tx2 = tx.clone();
+ unsafe {
+ RESIZE_CALLBACK = Some(Box::new(move |width: u32, height: u32| {
+ let _ = tx2.send((width, height));
+ if !signal_flag_ref.0.swap(true, Ordering::AcqRel) {
+ // We raised the signal flag
+ let mut terminal = terminal_ref.lock();
+ terminal.dirty = true;
+ proxy.wakeup_event_loop();
+ }
+ }));
+ }
+
let event_loop = EventLoop::new(
terminal.clone(),
window.create_window_proxy(),