From dd9ad05d5d1157948c93b9ecac84caadaa1ae560 Mon Sep 17 00:00:00 2001 From: David Mann Date: Tue, 1 Dec 2026 10:52:58 +0100 Subject: [PATCH] ui: a headless context gets no desktop services (#18631) storytold/craft-libs@d3a4e159 makes SystemWindows report the held mouse buttons on Windows. An integration test's context runs the library without cfg(test), so it got SystemWindows; no physical button is down there, so the window host ended every scripted press as a lost release and drags in tests/it (layout_perf, free_transform_preview_canvas) stopped after their first move. Only a window the platform decided a frame for (setup_window) gets the desktop now; setup_context (tests, benches, the web) gets NoWindows. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/app/framework.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/app/framework.rs b/crates/ui-egui/src/app/framework.rs index a428e02eac2..744e8358f8a 100644 --- a/crates/ui-egui/src/app/framework.rs +++ b/crates/ui-egui/src/app/framework.rs @@ -30,12 +30,13 @@ use craft::ui::runtime::install::WheelModifiers; use craft::ui::runtime::{InstallError, InstallSpec}; use craft::ui::shell::embed; use craft::window::policy::Decision; -// Tests run headless: the desktop pointer Windows tells is the mouse of the machine running them, not the test's -// pointer, so tests see no desktop services on any platform, as on Linux. +// Tests run headless: the desktop pointer and mouse buttons Windows tells are those of the machine running them, not +// the test's, so tests see no desktop services on any platform, as on Linux. #[cfg(test)] use craft::window::system::NoWindows as Desktop; #[cfg(not(test))] use craft::window::system::SystemWindows as Desktop; +use craft::window::system::{NoWindows, WindowSystem}; use photocraft_engine::Session; use photocraft_engine::prefs::{AppearanceMode, Preferences, UiDensity}; use serde_json::Value; @@ -69,7 +70,11 @@ pub(crate) fn install(ctx: &egui::Context, fonts: &UiFonts<'_>, frame: Option = if frame.is_some() { Arc::new(Desktop) } else { Arc::new(NoWindows) }; + let mut spec = InstallSpec::new(ShellInfo::default().backend(Backend::from_env()), desktop) .wheel(wheel) .app_id(crate::os_window::app_id()) .system(SystemReader::start(move || wake.request_repaint()));