mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
Headless contexts get no desktop services (craft-libs d3a4e159 reports held buttons on Windows)
The new craft-libs pin makes SystemWindows report the physical mouse buttons on Windows. Integration tests build ui-egui without cfg(test), so their scripted presses ended as lost releases. Same change as in #18632. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
c69cd1c320
commit
43afd1d41a
1 file changed
+8
-3
@@ -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<De
|
||||
// PhotoCraft's input always has.
|
||||
let wheel = WheelModifiers::new(egui::Modifiers::NONE, egui::Modifiers::SHIFT | egui::Modifiers::COMMAND);
|
||||
let wake = ctx.clone();
|
||||
let mut spec = InstallSpec::new(ShellInfo::default().backend(Backend::from_env()), Arc::new(Desktop))
|
||||
// Only a window the platform decided a frame for has a desktop behind it. A headless context (integration tests,
|
||||
// benches, the web) gets none: otherwise the held buttons Windows reports (no real button is down) end every
|
||||
// scripted press as a lost release.
|
||||
let desktop: Arc<dyn WindowSystem> = 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()));
|
||||
|
||||
Reference in new issue
Block a user