Move WR profiler keybindings to glutin window, where the other keybindings

are located
This commit is contained in:
Tremoneck 2017-07-10 12:43:01 +02:00
parent 95a85a301f
commit e5e3748a46
3 changed files with 12 additions and 13 deletions

View file

@ -11,7 +11,7 @@ use gfx_traits::Epoch;
use gleam::gl; use gleam::gl;
use image::{DynamicImage, ImageFormat, RgbImage}; use image::{DynamicImage, ImageFormat, RgbImage};
use ipc_channel::ipc::{self, IpcSharedMemory}; use ipc_channel::ipc::{self, IpcSharedMemory};
use msg::constellation_msg::{Key, KeyModifiers, KeyState, CONTROL}; use msg::constellation_msg::{Key, KeyModifiers, KeyState};
use msg::constellation_msg::{PipelineId, PipelineIndex, PipelineNamespaceId, TraversalDirection}; use msg::constellation_msg::{PipelineId, PipelineIndex, PipelineNamespaceId, TraversalDirection};
use net_traits::image::base::{Image, PixelFormat}; use net_traits::image::base::{Image, PixelFormat};
use profile_traits::time::{self, ProfilerCategory, profile}; use profile_traits::time::{self, ProfilerCategory, profile};
@ -825,6 +825,11 @@ impl<Window: WindowMethods> IOCompositor<Window> {
warn!("Sending reload to constellation failed ({}).", e); warn!("Sending reload to constellation failed ({}).", e);
} }
} }
WindowEvent::ToggleWebRenderProfiler => {
let profiler_enabled = self.webrender.get_profiler_enabled();
self.set_webrender_profiler_enabled(!profiler_enabled);
}
} }
} }
@ -1313,18 +1318,6 @@ impl<Window: WindowMethods> IOCompositor<Window> {
key: Key, key: Key,
state: KeyState, state: KeyState,
modifiers: KeyModifiers) { modifiers: KeyModifiers) {
// Steal a few key events for webrender debug options.
if modifiers.contains(CONTROL) && state == KeyState::Pressed {
match key {
Key::F12 => {
let profiler_enabled = self.webrender.get_profiler_enabled();
self.webrender.set_profiler_enabled(!profiler_enabled);
return;
}
_ => {}
}
}
let msg = ConstellationMsg::KeyEvent(ch, key, state, modifiers); let msg = ConstellationMsg::KeyEvent(ch, key, state, modifiers);
if let Err(e) = self.constellation_chan.send(msg) { if let Err(e) = self.constellation_chan.send(msg) {
warn!("Sending key event to constellation failed ({}).", e); warn!("Sending key event to constellation failed ({}).", e);

View file

@ -76,6 +76,8 @@ pub enum WindowEvent {
KeyEvent(Option<char>, Key, KeyState, KeyModifiers), KeyEvent(Option<char>, Key, KeyState, KeyModifiers),
/// Sent when Ctr+R/Apple+R is called to reload the current page. /// Sent when Ctr+R/Apple+R is called to reload the current page.
Reload, Reload,
/// Toggles the Web renderer profiler on and off
ToggleWebRenderProfiler,
} }
impl Debug for WindowEvent { impl Debug for WindowEvent {
@ -98,6 +100,7 @@ impl Debug for WindowEvent {
WindowEvent::Navigation(..) => write!(f, "Navigation"), WindowEvent::Navigation(..) => write!(f, "Navigation"),
WindowEvent::Quit => write!(f, "Quit"), WindowEvent::Quit => write!(f, "Quit"),
WindowEvent::Reload => write!(f, "Reload"), WindowEvent::Reload => write!(f, "Reload"),
WindowEvent::ToggleWebRenderProfiler => write!(f, "ToggleWebRenderProfiler"),
} }
} }
} }

View file

@ -1290,6 +1290,9 @@ impl WindowMethods for Window {
self.event_queue.borrow_mut().push(WindowEvent::Quit); self.event_queue.borrow_mut().push(WindowEvent::Quit);
} }
} }
(CONTROL, None, Key::F12) => {
self.event_queue.borrow_mut().push(WindowEvent::ToggleWebRenderProfiler);
}
_ => { _ => {
self.platform_handle_key(key, mods); self.platform_handle_key(key, mods);