Skip to content

Commit

Permalink
split window code and browser code in two different files
Browse files Browse the repository at this point in the history
  • Loading branch information
paulrouget committed Mar 22, 2018
1 parent 34c2150 commit 1cdba88
Show file tree
Hide file tree
Showing 9 changed files with 478 additions and 417 deletions.
2 changes: 0 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions components/compositing/compositor_thread.rs
Expand Up @@ -141,6 +141,8 @@ pub enum EmbedderMsg {
LoadComplete(TopLevelBrowsingContextId),
/// A pipeline panicked. First string is the reason, second one is the backtrace.
Panic(TopLevelBrowsingContextId, String, Option<String>),
/// Servo has shut down
Shutdown,
}

/// Messages from the painting thread and the constellation thread to the compositor thread.
Expand Down Expand Up @@ -239,6 +241,7 @@ impl Debug for EmbedderMsg {
EmbedderMsg::LoadStart(..) => write!(f, "LoadStart"),
EmbedderMsg::LoadComplete(..) => write!(f, "LoadComplete"),
EmbedderMsg::Panic(..) => write!(f, "Panic"),
EmbedderMsg::Shutdown => write!(f, "Shutdown"),
}
}
}
Expand Down
15 changes: 12 additions & 3 deletions components/servo/lib.rs
Expand Up @@ -107,7 +107,7 @@ use webvr::{WebVRThread, WebVRCompositorHandler};
pub use gleam::gl;
pub use servo_config as config;
pub use servo_url as url;
pub use msg::constellation_msg::TopLevelBrowsingContextId as BrowserId;
pub use msg::constellation_msg::{KeyState, TopLevelBrowsingContextId as BrowserId};

/// The in-process interface to Servo.
///
Expand Down Expand Up @@ -372,6 +372,14 @@ impl<Window> Servo<Window> where Window: WindowMethods + 'static {

(_, ShutdownState::ShuttingDown) => {},

(EmbedderMsg::KeyEvent(top_level_browsing_context, ch, key, state, modified),
ShutdownState::NotShuttingDown) => {
if state == KeyState::Pressed {
let msg = EmbedderMsg::KeyEvent(top_level_browsing_context, ch, key, state, modified);
self.embedder_events.push(msg);
}
},

(msg, ShutdownState::NotShuttingDown) => {
self.embedder_events.push(msg);
},
Expand All @@ -383,7 +391,7 @@ impl<Window> Servo<Window> where Window: WindowMethods + 'static {
::std::mem::replace(&mut self.embedder_events, Vec::new())
}

pub fn handle_events(&mut self, events: Vec<WindowEvent>) -> bool {
pub fn handle_events(&mut self, events: Vec<WindowEvent>) {
if self.compositor.receive_messages() {
self.receive_messages();
}
Expand All @@ -392,8 +400,9 @@ impl<Window> Servo<Window> where Window: WindowMethods + 'static {
}
if self.compositor.shutdown_state != ShutdownState::FinishedShuttingDown {
self.compositor.perform_updates();
} else {
self.embedder_events.push(EmbedderMsg::Shutdown);
}
self.compositor.shutdown_state != ShutdownState::FinishedShuttingDown
}

pub fn repaint_synchronously(&mut self) {
Expand Down
2 changes: 0 additions & 2 deletions ports/servo/Cargo.toml
Expand Up @@ -43,11 +43,9 @@ glutin = "0.13"
libservo = {path = "../../components/servo"}
log = "0.3.5"
msg = {path = "../../components/msg"}
net_traits = {path = "../../components/net_traits"}
script_traits = {path = "../../components/script_traits"}
servo_geometry = {path = "../../components/geometry"}
servo_config = {path = "../../components/config"}
servo_url = {path = "../../components/url"}
style_traits = {path = "../../components/style_traits"}
tinyfiledialogs = "3.0"
webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]}
Expand Down

0 comments on commit 1cdba88

Please sign in to comment.