mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Merge pull request #569 from metajack/glfw-close
Add support for closing the window with window chrome or escape key.
This commit is contained in:
commit
c82be59a4b
4 changed files with 9 additions and 5 deletions
|
@ -548,7 +548,9 @@ impl CompositorTask {
|
|||
check_for_messages(&self.port);
|
||||
|
||||
// Check for messages coming from the windowing system.
|
||||
window.check_loop();
|
||||
if window.check_loop() {
|
||||
*done = true;
|
||||
}
|
||||
|
||||
if *recomposite {
|
||||
*recomposite = false;
|
||||
|
|
|
@ -154,10 +154,11 @@ impl WindowMethods<Application> for Window {
|
|||
}
|
||||
|
||||
/// Spins the event loop.
|
||||
pub fn check_loop(@mut self) {
|
||||
pub fn check_loop(@mut self) -> bool {
|
||||
glfw::poll_events();
|
||||
self.throbber_frame = (self.throbber_frame + 1) % (THROBBER.len() as u8);
|
||||
self.update_window_title();
|
||||
self.glfw_window.should_close()
|
||||
}
|
||||
|
||||
/// Sets the ready state.
|
||||
|
@ -198,6 +199,7 @@ impl Window {
|
|||
/// Helper function to handle keyboard events.
|
||||
fn handle_key(&self, key: c_int, mods: c_int) {
|
||||
match key {
|
||||
glfw::KEY_ESCAPE => self.glfw_window.set_should_close(true),
|
||||
glfw::KEY_L if mods & glfw::MOD_CONTROL != 0 => self.load_url(), // Ctrl+L
|
||||
glfw::KEY_EQUAL if mods & glfw::MOD_CONTROL != 0 => { // Ctrl-+
|
||||
for self.zoom_callback.iter().advance |&callback| {
|
||||
|
|
|
@ -54,6 +54,6 @@ impl WindowingMethods<Application> for Window {
|
|||
pub fn set_load_url_callback(&mut self, _: LoadUrlCallback) {}
|
||||
|
||||
/// Returns the next event.
|
||||
pub fn check_loop(@mut self) {}
|
||||
pub fn check_loop(@mut self) -> bool { false }
|
||||
}
|
||||
|
||||
|
|
|
@ -63,8 +63,8 @@ pub trait WindowMethods<A> {
|
|||
/// Registers a callback to run when the user presses backspace or shift-backspace.
|
||||
pub fn set_navigation_callback(&mut self, new_navigation_callback: NavigationCallback);
|
||||
|
||||
/// Spins the event loop.
|
||||
pub fn check_loop(@mut self);
|
||||
/// Spins the event loop. Returns whether the window should close.
|
||||
pub fn check_loop(@mut self) -> bool;
|
||||
/// Sets the ready state of the current page.
|
||||
pub fn set_ready_state(@mut self, ready_state: ReadyState);
|
||||
/// Sets the render state of the current page.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue