mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Auto merge of #17652 - Tremoneck:debug_key_mover, r=paulrouget
Move Ctrl-F12 keybindings outside of libservo <!-- Please describe your changes on the following line: --> Creates a new WindowEvent called ToggleProfiller, when this Event is queued the profiler is toggled. When Crtl + F12 are pressed the Event is queued. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #17647 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17652) <!-- Reviewable:end -->
This commit is contained in:
commit
ee95bda3bf
4 changed files with 13 additions and 22 deletions
|
@ -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,12 @@ 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.webrender.set_profiler_enabled(!profiler_enabled);
|
||||||
|
self.webrender_api.generate_frame(None);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1313,18 +1319,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);
|
||||||
|
@ -1639,11 +1633,6 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
self.shutdown_state != ShutdownState::FinishedShuttingDown
|
self.shutdown_state != ShutdownState::FinishedShuttingDown
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_webrender_profiler_enabled(&mut self, enabled: bool) {
|
|
||||||
self.webrender.set_profiler_enabled(enabled);
|
|
||||||
self.webrender_api.generate_frame(None);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Repaints and recomposites synchronously. You must be careful when calling this, as if a
|
/// Repaints and recomposites synchronously. You must be careful when calling this, as if a
|
||||||
/// paint is not scheduled the compositor will hang forever.
|
/// paint is not scheduled the compositor will hang forever.
|
||||||
///
|
///
|
||||||
|
|
|
@ -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"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -244,10 +244,6 @@ impl<Window> Browser<Window> where Window: WindowMethods + 'static {
|
||||||
self.compositor.handle_events(events)
|
self.compositor.handle_events(events)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_webrender_profiler_enabled(&mut self, enabled: bool) {
|
|
||||||
self.compositor.set_webrender_profiler_enabled(enabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn repaint_synchronously(&mut self) {
|
pub fn repaint_synchronously(&mut self) {
|
||||||
self.compositor.repaint_synchronously()
|
self.compositor.repaint_synchronously()
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue