Skip to content

Commit 70e0a32

Browse files
author
not-elm
committed
update: event reader
1 parent d105dd0 commit 70e0a32

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

crates/bevy_flurx_ipc/src/ipc_trigger.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ impl IpcTriggerExt for App {
5050
P: DeserializeOwned + Event + Send + Sync + 'static,
5151
{
5252
let event_id = event_id.into();
53+
self.add_event::<P>();
5354
self.add_systems(PreUpdate, read_receive_ipc_event_from_webview::<P>(event_id).before(cleanup_ipc_trigger_sender));
5455
self
5556
}
@@ -78,13 +79,17 @@ where
7879
return;
7980
};
8081
for message in messages.iter().filter(|m| m.event_id == event_id) {
81-
let Ok(payload) = serde_json::from_str::<Payload>(&message.payload) else {
82+
let Ok(p1) = serde_json::from_str::<Payload>(&message.payload) else {
8283
continue;
8384
};
85+
let Ok(p2) = serde_json::from_str::<Payload>(&message.payload) else {
86+
continue;
87+
};
88+
commands.send_event(p1);
8489
if let Some(target) = message.target {
85-
commands.entity(target).trigger(payload);
90+
commands.entity(target).trigger(p2);
8691
} else {
87-
commands.trigger(payload);
92+
commands.trigger(p2);
8893
}
8994
}
9095
}

crates/bevy_webview_wry/src/embedding/grip_zone.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl Plugin for GripZonePlugin {
3333
.add_observer(apply_drag_end);
3434

3535
#[cfg(target_os = "linux")]
36-
app.add_ipc_event::<OnGribDrag>("FLURX|grip::drag");
36+
app.add_ipc_trigger::<OnGribDrag>("FLURX|grip::drag");
3737
}
3838
}
3939

@@ -57,7 +57,7 @@ struct MouseDelta<'w, 's> {
5757
/// I was testing on Ubuntu 24.04 ARM64 in Parallels, but `MouseMotion` was getting clearly abnormal coordinates,
5858
/// so I switched to getting delta from webview.
5959
#[cfg(target_os = "linux")]
60-
er: EventReader<'w, 's, IpcEvent<OnGribDrag>>,
60+
er: EventReader<'w, 's, OnGribDrag>,
6161
}
6262

6363
impl MouseDelta<'_, '_> {
@@ -76,7 +76,7 @@ impl MouseDelta<'_, '_> {
7676
.er
7777
.read()
7878
.map(|event| {
79-
Vec2::new(event.payload.x, event.payload.y)
79+
Vec2::new(event.x, event.y)
8080
})
8181
.reduce(|d1, d2| d1 + d2)
8282
}
@@ -132,7 +132,7 @@ struct OnGripGrab {
132132
}
133133

134134
#[cfg(target_os = "linux")]
135-
#[derive(Deserialize)]
135+
#[derive(Deserialize, Event)]
136136
struct OnGribDrag {
137137
x: f32,
138138
y: f32,

0 commit comments

Comments
 (0)