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

fixup build on windows

and correct the notify same thread optimization on unix
This commit is contained in:
Wez Furlong 2021-05-05 08:28:14 -07:00
parent 0f384b5c06
commit 630d9d215b
3 changed files with 30 additions and 2 deletions

View File

@ -616,7 +616,8 @@ impl WindowOps for WaylandWindow {
Self: Sized,
{
// If we're already on the correct thread, just queue it up
if let Some(handle) = Connection::get().unwrap().wayland().window_by_id(self.0) {
if let Some(conn) = Connection::get() {
let handle = conn.wayland().window_by_id(self.0).unwrap();
let inner = handle.borrow();
inner
.events

View File

@ -11,6 +11,7 @@ use config::ConfigHandle;
use lazy_static::lazy_static;
use promise::{Future, Promise};
use shared_library::shared_library;
use std::any::Any;
use std::cell::RefCell;
use std::collections::HashMap;
use std::convert::TryInto;
@ -552,6 +553,31 @@ impl WindowOps for Window {
.await
}
fn notify<T: Any + Send + Sync>(&self, t: T)
where
Self: Sized,
{
// If we're already on the correct thread, just queue it up
if let Some(conn) = Connection::get() {
let handle = conn.get_window(self.0).unwrap();
let inner = handle.borrow_mut();
inner
.events
.try_send(WindowEvent::Notification(Box::new(t)))
.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())))
.ok();
Ok(())
});
}
}
fn close(&self) -> Future<()> {
Connection::with_window_inner(self.0, |inner| {
inner.close();

View File

@ -906,7 +906,8 @@ impl WindowOps for XWindow {
Self: Sized,
{
// If we're already on the correct thread, just queue it up
if let Some(handle) = Connection::get().unwrap().x11().window_by_id(self.0) {
if let Some(conn) = Connection::get() {
let handle = conn.x11().window_by_id(self.0).unwrap();
let inner = handle.lock().unwrap();
inner
.events