Changed Msg::KeyEvent to take in KeyState and moved the checks in CompositorTask::send_key_event to Compositor::handle_browser_message

This commit is contained in:
Keith Yeung 2015-02-04 10:30:23 +08:00
parent b262fc16e0
commit 37cb876f4e
3 changed files with 7 additions and 7 deletions

View file

@ -358,9 +358,11 @@ impl<Window: WindowMethods> IOCompositor<Window> {
}
}
(Msg::KeyEvent(key, modified), ShutdownState::NotShuttingDown) => {
(Msg::KeyEvent(key, state, modified), ShutdownState::NotShuttingDown) => {
if state == KeyState::Pressed {
self.window.handle_key(key, modified);
}
}
(Msg::SetCursor(cursor), ShutdownState::NotShuttingDown) => {
self.window.set_cursor(cursor)

View file

@ -91,9 +91,7 @@ impl ScriptListener for Box<CompositorProxy+'static+Send> {
}
fn send_key_event(&mut self, key: Key, state: KeyState, modifiers: KeyModifiers) {
if state == KeyState::Pressed {
self.send(Msg::KeyEvent(key, modifiers));
}
self.send(Msg::KeyEvent(key, state, modifiers));
}
}
@ -218,7 +216,7 @@ pub enum Msg {
/// composite should happen. (See the `scrolling` module.)
ScrollTimeout(u64),
/// Sends an unconsumed key event back to the compositor.
KeyEvent(Key, KeyModifiers),
KeyEvent(Key, KeyState, KeyModifiers),
/// Changes the cursor.
SetCursor(Cursor),
/// Informs the compositor that the paint task for the given pipeline has exited.

View file

@ -893,7 +893,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
CompositorEvent::KeyEvent(key, state, mods))).unwrap();
},
None => self.compositor_proxy.clone_compositor_proxy()
.send(CompositorMsg::KeyEvent(key, mods))
.send(CompositorMsg::KeyEvent(key, state, mods))
}
}