Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions desktop/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::ui::{MULTICLICK_ALLOWED_TRAVEL, MULTICLICK_TIMEOUT, PINCH_ZOOM_SPEED,
use crate::wrapper::messages::{DesktopWrapperMessage, InputMessage, ModifierKeys, MouseKeys, PointerState, ScrollDelta};

pub(crate) struct InputState {
start: Instant,
viewport_info: Option<ViewportInfo>,
pointer_lock_position: Option<PhysicalPosition<f64>>,
modifier_keys: ModifierKeys,
Expand All @@ -29,6 +30,7 @@ impl InputAction {
impl InputState {
pub(crate) fn new() -> Self {
Self {
start: Instant::now(),
viewport_info: None,
pointer_lock_position: None,
modifier_keys: ModifierKeys::empty(),
Expand Down Expand Up @@ -189,6 +191,7 @@ impl InputState {
PointerState {
editor_position: (self.pointer_position.x / self.scale(), self.pointer_position.y / self.scale()).into(),
mouse_keys: self.pointer_keys,
time: Some(self.start.elapsed().as_secs_f64() * 1000.),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: time stores an undocumented unit and epoch: self.start.elapsed().as_secs_f64() * 1000. yields milliseconds since app startup, and the field is never populated on the web/editor path (it stays Default/None there). Since this will later drive time-varying brushes, the magnitude and unit should be explicit and the desktop/web inconsistency documented, per the team's preference for precise, consistent naming. Add a doc comment stating the value is milliseconds since app start (or rename to time_ms), and note that it is currently desktop-only.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At desktop/src/input.rs, line 194:

<comment>`time` stores an undocumented unit and epoch: `self.start.elapsed().as_secs_f64() * 1000.` yields milliseconds since app startup, and the field is never populated on the web/editor path (it stays `Default`/`None` there). Since this will later drive time-varying brushes, the magnitude and unit should be explicit and the desktop/web inconsistency documented, per the team's preference for precise, consistent naming. Add a doc comment stating the value is milliseconds since app start (or rename to `time_ms`), and note that it is currently desktop-only.</comment>

<file context>
@@ -189,6 +191,7 @@ impl InputState {
 		PointerState {
 			editor_position: (self.pointer_position.x / self.scale(), self.pointer_position.y / self.scale()).into(),
 			mouse_keys: self.pointer_keys,
+			time: Some(self.start.elapsed().as_secs_f64() * 1000.),
 			..Default::default()
 		}
</file context>

..Default::default()
}
}
Expand Down
3 changes: 3 additions & 0 deletions editor/src/messages/input_mapper/utility_types/pointer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ pub struct PointerState {
pub position: ViewportPosition,
pub mouse_keys: MouseKeys,
pub scroll_delta: ScrollDelta,
pub time: Option<f64>,
pub pressure: Option<f64>,
pub tilt: Option<DVec2>,
pub twist: Option<f64>,
Expand All @@ -77,6 +78,7 @@ pub struct EditorPointerState {
pub editor_position: EditorPosition,
pub mouse_keys: MouseKeys,
pub scroll_delta: ScrollDelta,
pub time: Option<f64>,
pub pressure: Option<f64>,
pub tilt: Option<DVec2>,
pub twist: Option<f64>,
Expand All @@ -101,6 +103,7 @@ impl EditorPointerState {
position: (viewport.logical(self.editor_position) - viewport.offset()).into(),
mouse_keys: self.mouse_keys,
scroll_delta: self.scroll_delta,
time: self.time,
pressure: self.pressure,
tilt: self.tilt,
twist: self.twist,
Expand Down
Loading