Modified constellation key event handler to deal with missing frames

This commit is contained in:
Keith Yeung 2015-02-04 00:04:12 +08:00
parent 2ae7ed327d
commit b262fc16e0

View file

@ -885,11 +885,17 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
}
fn handle_key_msg(&self, key: Key, state: KeyState, mods: KeyModifiers) {
self.current_frame().as_ref().map(|frame| {
let ScriptControlChan(ref chan) = frame.pipeline.borrow().script_chan;
chan.send(ConstellationControlMsg::SendEvent(
frame.pipeline.borrow().id, CompositorEvent::KeyEvent(key, state, mods))).unwrap();
});
match *self.current_frame() {
Some(ref frame) => {
let ScriptControlChan(ref chan) = frame.pipeline.borrow().script_chan;
chan.send(ConstellationControlMsg::SendEvent(
frame.pipeline.borrow().id,
CompositorEvent::KeyEvent(key, state, mods))).unwrap();
},
None => self.compositor_proxy.clone_compositor_proxy()
.send(CompositorMsg::KeyEvent(key, mods))
}
}
fn handle_get_pipeline_title_msg(&mut self, pipeline_id: PipelineId) {