diff --git a/crates/gpui/src/platform/linux/wayland/client.rs b/crates/gpui/src/platform/linux/wayland/client.rs index 2dfd878755f1a9b9f6f0df317bbf45247f2916bb..3e82d32c029a80e0829c8aadb74276b471fadda1 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 36d1129574535c425b82779df9c1bc2add483266..57295ee77261b7502b6e305c3e3ee47e7001ce74 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();