diff --git a/crates/gpui/src/platform/linux/wayland/client.rs b/crates/gpui/src/platform/linux/wayland/client.rs index 2dfd878755..3e82d32c02 100644 --- a/crates/gpui/src/platform/linux/wayland/client.rs +++ b/crates/gpui/src/platform/linux/wayland/client.rs @@ -403,9 +403,14 @@ impl WaylandClient { let handle = event_loop.handle(); handle - .insert_source(main_receiver, |event, _, _: &mut WaylandClientStatePtr| { - if let calloop::channel::Event::Msg(runnable) = event { - runnable.run(); + .insert_source(main_receiver, { + let handle = handle.clone(); + move |event, _, _: &mut WaylandClientStatePtr| { + if let calloop::channel::Event::Msg(runnable) = event { + handle.insert_idle(|_| { + runnable.run(); + }); + } } }) .unwrap(); diff --git a/crates/gpui/src/platform/linux/x11/client.rs b/crates/gpui/src/platform/linux/x11/client.rs index 36d1129574..57295ee772 100644 --- a/crates/gpui/src/platform/linux/x11/client.rs +++ b/crates/gpui/src/platform/linux/x11/client.rs @@ -165,9 +165,17 @@ impl X11Client { let handle = event_loop.handle(); handle - .insert_source(main_receiver, |event, _, _: &mut X11Client| { - if let calloop::channel::Event::Msg(runnable) = event { - runnable.run(); + .insert_source(main_receiver, { + let handle = handle.clone(); + move |event, _, _: &mut X11Client| { + if let calloop::channel::Event::Msg(runnable) = event { + // Insert the runnables as idle callbacks, so we make sure that user-input and X11 + // events have higher priority and runnables are only worked off after the event + // callbacks. + handle.insert_idle(|_| { + runnable.run(); + }); + } } }) .unwrap();