Cache source measurements and propagate native viewport inputs
Verify Tessera GUI / verify (push) Failing after 7m29s

This commit is contained in:
2026-10-21 16:33:35 +08:00
parent 1b5fe1069f
commit 3ea4bac48c
12 changed files with 744 additions and 37 deletions
+31 -1
View File
@@ -75,6 +75,26 @@ impl TesseraApp {
})
}
fn publish_viewport(&self) {
let Some(window) = &self.window else {
return;
};
let size = window.inner_size().to_logical::<f32>(window.scale_factor());
if size.width <= 0.0
|| size.height <= 0.0
|| !size.width.is_finite()
|| !size.height.is_finite()
{
return;
}
if let Ok(mut namespace) = self.namespace.write() {
namespace.viewport = Some(crate::layout::Size {
width: size.width.min(crate::ui_bridge::MAX_DIMENSION as f32),
height: size.height.min(crate::ui_bridge::MAX_DIMENSION as f32),
});
}
}
fn request_redraw(&self) {
if let Some(window) = &self.window {
window.request_redraw();
@@ -197,6 +217,14 @@ impl TesseraApp {
return None;
}
let current = self.namespace.read().ok()?;
if current.viewport.is_some_and(|size| {
self.pointer.x < 0.0
|| self.pointer.y < 0.0
|| self.pointer.x >= size.width
|| self.pointer.y >= size.height
}) {
return None;
}
let frame = &current.document.frame;
if frame.session == 0 {
return None;
@@ -359,6 +387,7 @@ impl ApplicationHandler<AppEvent> for TesseraApp {
self.window = Some(window.clone());
self.context = Some(context);
self.surface = Some(surface);
self.publish_viewport();
window.request_redraw();
}
@@ -400,7 +429,8 @@ impl ApplicationHandler<AppEvent> for TesseraApp {
match event {
WindowEvent::CloseRequested => event_loop.exit(),
WindowEvent::Resized(_) | WindowEvent::ScaleFactorChanged { .. } => {
window.request_redraw()
self.publish_viewport();
window.request_redraw();
}
WindowEvent::CursorMoved {
position: PhysicalPosition { x, y },