mirror of
https://github.com/storytold/photocraft.git
synced 2026-10-24 09:57:08 -06:00
On Windows with Windows Ink (WM_POINTER), winit drops penFlags (PEN_FLAG_BARREL) and reports stylus contact as WindowEvent::Touch, which egui-winit maps exclusively to PointerButton::Primary. Additionally, Windows Ink does not update GetAsyncKeyState(VK_RBUTTON) when pressing the pen barrel button. Consequently, Alt + Barrel Button drag was recognized as Alt + Left Drag (triggering the eyedropper and painting strokes instead of brush resize), and right-clicks with the stylus were treated as left-clicks. This commit resolves the issue by: 1. Adding a native Windows message hook (WH_GETMESSAGE) in crates/tablet/src/windows.rs calling GetPointerPenInfo to intercept PEN_FLAG_BARREL (0x00000001) and POINTER_FLAG_SECONDBUTTON. 2. Exposing ight_button_down in Services combining the pointer hook and GetAsyncKeyState(VK_RBUTTON). 3. Updating canvas.rs and paint_mouse.rs to prevent strokes_live and alt_eyedropper from hijacking the stylus gesture when the barrel button is held, and correctly routing resize events. 4. Adding tests asserting that Alt + stylus barrel drag resizes diameter horizontally and adjusts hardness vertically without triggering eyedropper or painting.
39 lines
1.8 KiB
TOML
39 lines
1.8 KiB
TOML
[package]
|
|
name = "photocraft-tablet"
|
|
version.workspace = true
|
|
edition.workspace = true
|
|
license.workspace = true
|
|
description = "Pen tablet pressure, tilt, rotation and eraser end on macOS (AppKit) and Linux X11 (XInput2), and barrel button on Windows"
|
|
|
|
# The one isolated `unsafe` helper crate (craftrules never-crash, AGENTS.md): the AppKit event
|
|
# monitor on macOS and the WH_GETMESSAGE pointer hook on Windows need platform interop. Only
|
|
# `src/macos.rs` and `src/windows.rs` allow `unsafe`; everything else is denied, and every other
|
|
# crate keeps the workspace's `unsafe_code = "forbid"`.
|
|
[lints.rust]
|
|
unsafe_code = "deny"
|
|
|
|
[lints.clippy]
|
|
dbg_macro = "warn"
|
|
todo = "warn"
|
|
|
|
# Already in Cargo.lock (eframe/wgpu/fmv-macos-events and winit pull them in); pinned exactly:
|
|
# review the diff before bumping.
|
|
[target.'cfg(target_os = "macos")'.dependencies]
|
|
objc2 = "=0.6.4"
|
|
block2 = "=0.6.2"
|
|
objc2-foundation = { version = "=0.3.2", default-features = false, features = ["std", "NSGeometry"] }
|
|
objc2-app-kit = { version = "=0.3.2", default-features = false, features = ["std", "block2", "NSEvent"] }
|
|
|
|
# Pure-Rust X11 client (no unsafe in the RustConnection path we use).
|
|
[target.'cfg(target_os = "linux")'.dependencies]
|
|
x11rb = { version = "=0.13.2", default-features = false, features = ["xinput"] }
|
|
|
|
# Tests build real tablet NSEvents (from CGEvents) and read them through the monitor's path.
|
|
[target.'cfg(target_os = "macos")'.dev-dependencies]
|
|
objc2-app-kit = { version = "=0.3.2", default-features = false, features = ["std", "block2", "NSEvent", "NSGraphicsContext", "objc2-core-graphics", "NSApplication", "NSResponder"] }
|
|
objc2-core-graphics = { version = "=0.3.2", default-features = false, features = ["std", "CGEvent", "CGEventTypes"] }
|
|
|
|
[[test]]
|
|
name = "monitor_macos"
|
|
harness = false
|