Skip to content

blitz-shell: CursorMoved doesn't request_redraw, so DOM-driven drags lag behind the cursor #480

Description

@postadelmaga

In blitz-shell/src/window.rs, the WindowEvent::CursorMoved handler forwards the move to the DOM but — unlike every other event handler in the file — never calls self.request_redraw():

WindowEvent::CursorMoved { position, .. } => {
    let LogicalPosition::<f32> { x, y } = position.to_logical(self.window.scale_factor());
    self.mouse_pos = (x, y);
    let event = UiEvent::MouseMove(BlitzMouseButtonEvent { x, y, /* … */ });
    self.doc.handle_ui_event(event);
    // no request_redraw() here
}

(observed in blitz-shell 0.2.3)

Impact

Any app that implements dragging purely in the DOM — onmousedown starts a drag, onmousemove updates a signal, the element re-renders at the new position — sees the dragged element trail behind the cursor. Because the move doesn't request a repaint, the new frame only shows up on the next event that does request one (mouse-up, wheel, etc.), so the element catches up only when you pause or release. Same effect for DOM-driven panning.

Expectation

A mouse-move that changes the DOM should repaint promptly, like in a browser.

Suggested fix

Keeps idle hover cheap by only repainting while a button is held (self.buttons is already in scope):

self.doc.handle_ui_event(event);
if !self.buttons.is_empty() {
    self.request_redraw();
}

Alternatively, unconditionally request_redraw() on CursorMoved if the idle-hover cost is acceptable. Happy to open a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions