mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Change the way the keyboard event is handled
This commit is contained in:
parent
9a5f88d380
commit
f98c4ff1ad
3 changed files with 18 additions and 31 deletions
|
@ -1,26 +0,0 @@
|
|||
fn input(
|
||||
osmain_ch: comm::chan<osmain::msg>,
|
||||
draw_ch: comm::chan<gfx::renderer::msg>,
|
||||
model_ch: comm::chan<layout::lister::msg>,
|
||||
layout_ch: comm::chan<layout::layout::msg>
|
||||
) {
|
||||
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(layout_ch, layout::layout::exit);
|
||||
comm::send(model_ch, layout::lister::exit);
|
||||
|
||||
let draw_exit_confirm_po = comm::port();
|
||||
comm::send(draw_ch, gfx::renderer::exit(comm::chan(draw_exit_confirm_po)));
|
||||
|
||||
comm::recv(draw_exit_confirm_po);
|
||||
comm::send(osmain_ch, osmain::exit);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -43,4 +43,3 @@ mod util {
|
|||
}
|
||||
|
||||
mod osmain;
|
||||
mod input;
|
|
@ -7,10 +7,10 @@ import azure::cairo::bindgen::*;
|
|||
|
||||
fn main() {
|
||||
// The platform event handler thread
|
||||
let osmain_ch = osmain::osmain();
|
||||
let osmain = osmain::osmain();
|
||||
|
||||
// The compositor
|
||||
let renderer = gfx::renderer::renderer(osmain_ch);
|
||||
let renderer = gfx::renderer::renderer(osmain);
|
||||
|
||||
// The display list builder
|
||||
let lister = layout::lister::lister(renderer);
|
||||
|
@ -19,10 +19,24 @@ fn main() {
|
|||
let layout = layout::layout::layout(lister);
|
||||
|
||||
// The keyboard handler
|
||||
input::input(osmain_ch, renderer, lister, layout);
|
||||
let key_po = port();
|
||||
send(osmain, osmain::add_key_handler(chan(key_po)));
|
||||
|
||||
loop {
|
||||
std::timer::sleep(10u);
|
||||
send(layout, layout::layout::do_layout);
|
||||
|
||||
std::timer::sleep(10u);
|
||||
|
||||
if peek(key_po) {
|
||||
comm::send(layout, layout::layout::exit);
|
||||
comm::send(lister, layout::lister::exit);
|
||||
|
||||
let draw_exit_confirm_po = comm::port();
|
||||
comm::send(renderer, gfx::renderer::exit(comm::chan(draw_exit_confirm_po)));
|
||||
|
||||
comm::recv(draw_exit_confirm_po);
|
||||
comm::send(osmain, osmain::exit);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue