Skip to content

Commit

Permalink
stormlicht: Repaint after events if necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
simonwuelker committed Sep 21, 2023
1 parent 25dad16 commit 847f3d8
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions stormlicht/src/browser_application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ impl glazier::WinHandler for BrowserApplication {
kind: event::MouseEventKind::Down(button),
};

self.browsing_context
.handle_event(event::Event::Mouse(mouse_event));
self.dispatch_event(event::Event::Mouse(mouse_event));
}

fn pointer_move(&mut self, glazier_event: &glazier::PointerEvent) {
Expand All @@ -132,8 +131,8 @@ impl glazier::WinHandler for BrowserApplication {
position,
kind: event::MouseEventKind::Move,
};
self.browsing_context
.handle_event(event::Event::Mouse(mouse_event))

self.dispatch_event(event::Event::Mouse(mouse_event));
}

fn pointer_up(&mut self, glazier_event: &glazier::PointerEvent) {
Expand All @@ -155,8 +154,7 @@ impl glazier::WinHandler for BrowserApplication {
kind: event::MouseEventKind::Up(button),
};

self.browsing_context
.handle_event(event::Event::Mouse(mouse_event));
self.dispatch_event(event::Event::Mouse(mouse_event));
}
}

Expand Down Expand Up @@ -220,4 +218,13 @@ impl BrowserApplication {
},
}
}

/// Forwards an event to the browsing context and repaints if necessary
pub fn dispatch_event(&mut self, event: event::Event) {
let needs_repaint = self.browsing_context.handle_event(event);

if needs_repaint {
self.window_handle.invalidate();
}
}
}

0 comments on commit 847f3d8

Please sign in to comment.