mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Move keyboard handling to input module
This commit is contained in:
parent
1a0389b70f
commit
ec046a1160
3 changed files with 24 additions and 16 deletions
22
src/servo/input.rs
Normal file
22
src/servo/input.rs
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
fn input(
|
||||||
|
osmain_ch: comm::chan<osmain::msg>,
|
||||||
|
draw_ch: comm::chan<gfx::compositor::msg>,
|
||||||
|
model_ch: comm::chan<()>
|
||||||
|
) {
|
||||||
|
task::spawn {||
|
||||||
|
let key_po = comm::port();
|
||||||
|
comm::send(osmain_ch, osmain::add_key_handler(comm::chan(key_po)));
|
||||||
|
loop {
|
||||||
|
alt comm::recv(key_po) {
|
||||||
|
_ {
|
||||||
|
comm::send(model_ch, ());
|
||||||
|
let draw_exit_confirm_po = comm::port();
|
||||||
|
comm::send(draw_ch, gfx::compositor::exit(comm::chan(draw_exit_confirm_po)));
|
||||||
|
comm::recv(draw_exit_confirm_po);
|
||||||
|
comm::send(osmain_ch, osmain::exit);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -40,3 +40,4 @@ mod util {
|
||||||
}
|
}
|
||||||
|
|
||||||
mod osmain;
|
mod osmain;
|
||||||
|
mod input;
|
|
@ -50,20 +50,5 @@ fn main() {
|
||||||
};
|
};
|
||||||
|
|
||||||
// The keyboard handler
|
// The keyboard handler
|
||||||
task::spawn {||
|
input::input(osmain_ch, draw_ch, model_ch);
|
||||||
let key_po = comm::port();
|
|
||||||
comm::send(osmain_ch, osmain::add_key_handler(comm::chan(key_po)));
|
|
||||||
loop {
|
|
||||||
alt comm::recv(key_po) {
|
|
||||||
_ {
|
|
||||||
comm::send(model_ch, ());
|
|
||||||
let draw_exit_confirm_po = comm::port();
|
|
||||||
comm::send(draw_ch, gfx::compositor::exit(comm::chan(draw_exit_confirm_po)));
|
|
||||||
comm::recv(draw_exit_confirm_po);
|
|
||||||
comm::send(osmain_ch, osmain::exit);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue