notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

commit cf2a832a5e740116b4dc3444409499441109cb2d
parent 3a891a982c5982cb54f62280b93e6eee4d5f406d
Author: William Casarin <jb55@jb55.com>
Date:   Fri, 17 May 2024 19:27:57 -0500

input: switch to scanning over raw input events

Calling key_pressed invokes a filter over the entire event list every
time, this is much more efficient, which is important when we are
handling many key events.

Diffstat:
Msrc/app.rs | 23+++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/src/app.rs b/src/app.rs @@ -107,10 +107,25 @@ fn send_initial_filters(damus: &mut Damus, relay_url: &str) { fn try_process_event(damus: &mut Damus, ctx: &egui::Context) -> Result<()> { ctx.input(|i| { let amount = 0.2; - if i.key_pressed(egui::Key::Equals) { - ctx.set_pixels_per_point(ctx.pixels_per_point() + amount); - } else if i.key_pressed(egui::Key::Minus) { - ctx.set_pixels_per_point(ctx.pixels_per_point() - amount); + + for event in &i.raw.events { + match event { + egui::Event::Key { + key, pressed: true, .. + } => match key { + egui::Key::Equals => { + ctx.set_pixels_per_point(ctx.pixels_per_point() + amount); + } + + egui::Key::Minus => { + ctx.set_pixels_per_point(ctx.pixels_per_point() - amount); + } + + _ => {} + }, + + _ => {} + } } });