Isolate rendering state per window presentation
Verify Tessera GUI / verify (push) Failing after 7m26s
Verify Tessera GUI / verify (push) Failing after 7m26s
This commit is contained in:
@@ -12,6 +12,8 @@ use winit::event_loop::EventLoopProxy;
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct Input {
|
||||
#[serde(default = "default_window")]
|
||||
pub window: u64,
|
||||
pub session: u64,
|
||||
pub layout_version: u64,
|
||||
pub mount: u64,
|
||||
@@ -22,8 +24,15 @@ pub struct Input {
|
||||
pub press_point: Option<[f32; 2]>,
|
||||
}
|
||||
|
||||
fn default_window() -> u64 {
|
||||
crate::window::MAIN_WINDOW
|
||||
}
|
||||
|
||||
impl Input {
|
||||
pub fn validate(&self) -> Result<(), &'static str> {
|
||||
if self.window == 0 {
|
||||
return Err("window identity must be nonzero");
|
||||
}
|
||||
match (self.point, self.press_point) {
|
||||
(None, None) => Ok(()),
|
||||
(Some(point), Some(press))
|
||||
@@ -93,3 +102,18 @@ fn send(input: &Input) -> anyhow::Result<()> {
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
#[test]
|
||||
fn legacy_event_window_defaults_but_zero_is_never_a_resource() {
|
||||
let mut input: Input =
|
||||
serde_json::from_str(r#"{"session":1,"layout_version":2,"mount":3,"kind":"focus"}"#)
|
||||
.unwrap();
|
||||
assert_eq!(input.window, crate::window::MAIN_WINDOW);
|
||||
assert!(input.validate().is_ok());
|
||||
input.window = 0;
|
||||
assert!(input.validate().is_err());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user