make window.notify more efficient on unix
avoid going through an extra queue if we already are in the right place
This commit is contained in:
1 parent
9fd04f6024
commit
0f384b5c06
2 files changed
+30
-10
No files matched your search
@@ -615,14 +615,24 @@ impl WindowOps for WaylandWindow {
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
let mut t = Some(t);
|
||||
WaylandConnection::with_window_inner(self.0, move |inner| {
|
||||
// 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) {
|
||||
let inner = handle.borrow();
|
||||
inner
|
||||
.events
|
||||
.try_send(WindowEvent::Notification(Box::new(t.take().unwrap())))
|
||||
.try_send(WindowEvent::Notification(Box::new(t)))
|
||||
.ok();
|
||||
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())))
|
||||
.ok();
|
||||
Ok(())
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
fn close(&self) -> Future<()> {
|
||||
|
||||
@@ -905,14 +905,24 @@ impl WindowOps for XWindow {
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
let mut t = Some(t);
|
||||
XConnection::with_window_inner(self.0, move |inner| {
|
||||
// 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) {
|
||||
let inner = handle.lock().unwrap();
|
||||
inner
|
||||
.events
|
||||
.try_send(WindowEvent::Notification(Box::new(t.take().unwrap())))
|
||||
.try_send(WindowEvent::Notification(Box::new(t)))
|
||||
.ok();
|
||||
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())))
|
||||
.ok();
|
||||
Ok(())
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
fn close(&self) -> Future<()> {
|
||||
|
||||
Reference in new issue
Block a user