From 6a6a1baa28af9da0e9e2aee406c99c4bb4eb2b35 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 12 Nov 2026 02:21:22 -0800 Subject: [PATCH] Color: the screen color sampler names its Wayland parent on its own thread Exporting the window for the portal waits for the compositor to answer. The sampler now does it on its worker thread, as the portal's save dialog does, so a slow compositor does not hold up the UI. --- apps/vectorcraft/src/linux_screen_color.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/vectorcraft/src/linux_screen_color.rs b/apps/vectorcraft/src/linux_screen_color.rs index 0a07f2053c..0f46af19d8 100644 --- a/apps/vectorcraft/src/linux_screen_color.rs +++ b/apps/vectorcraft/src/linux_screen_color.rs @@ -1,7 +1,7 @@ //! Linux: Sample Color from Screen (`vectorcraft_ui_egui::screen_color`) through the XDG desktop //! portal's color sampler ([`portal`]). A thread of its own asks the portal and waits for the //! person, so the UI keeps drawing; it sends the color to the UI and wakes the window. The dialog's -//! parent is the window, named on the UI thread as for the portal's save dialog (`portal_save`). +//! parent is the window, named on that thread as for the portal's save dialog (`portal_save`). mod portal; mod request; @@ -11,17 +11,17 @@ pub fn sampler(ui: egui::Context, parent: super::host_services::Parent) -> vecto Box::new(move || { let (tx, rx) = std::sync::mpsc::channel(); let (ui, window) = (ui.clone(), parent.clone()); - // The thread holds the window until the export that names it is dropped. - let (handle, export) = match window.as_deref() { - Some(window) => { - let (handle, export) = super::portal_save::exported_parent(window); - (handle, Some(export)) - } - None => (String::new(), None), - }; std::thread::Builder::new() .name("screen-color".into()) .spawn(move || { + // The thread names the window and holds it until the export that names it is dropped. + let (handle, export) = match window.as_deref() { + Some(window) => { + let (handle, export) = super::portal_save::exported_parent(window); + (handle, Some(export)) + } + None => (String::new(), None), + }; let picked = portal::connect(zbus::blocking::connection::Builder::session()).and_then(|conn| portal::pick(&conn, &handle)); drop(export); drop(window);