From a9ed2d809d6b90716edec32057c3901122b0abd7 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Sun, 9 Jun 2013 17:06:04 -0700 Subject: [PATCH] Spin the event loop every 50 ms to allow Rust channels to be processed. This is the nail in the coffin for GLUT; we need to fix this. --- src/components/main/platform/common/glut_windowing.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/components/main/platform/common/glut_windowing.rs b/src/components/main/platform/common/glut_windowing.rs index 7e3dfd33044..847c4346c31 100644 --- a/src/components/main/platform/common/glut_windowing.rs +++ b/src/components/main/platform/common/glut_windowing.rs @@ -12,6 +12,7 @@ use windowing::{ResizeCallback, ScrollCallback, WindowMethods, WindowMouseEvent, use windowing::{WindowMouseDownEvent, WindowMouseUpEvent, ZoomCallback}; use alert::{Alert, AlertMethods}; +use core::cell::Cell; use core::libc::c_int; use geom::point::Point2D; use geom::size::Size2D; @@ -71,6 +72,15 @@ impl WindowMethods for Window { mouse_down_point: @mut Point2D(0, 0), }; + // Spin the event loop every 50 ms to allow the Rust channels to be polled. + // + // This requirement is pretty much the nail in the coffin for GLUT's usefulness. + // + // FIXME(pcwalton): What a mess. + let register_timer_callback: @mut @fn() = @mut ||{}; + *register_timer_callback = || { + glut::timer_func(50, *register_timer_callback); + }; // Register event handlers. do glut::reshape_func(window.glut_window) |width, height| { @@ -107,6 +117,7 @@ impl WindowMethods for Window { _ => window.handle_scroll(Point2D(0.0, delta)), } } + (*register_timer_callback)(); machack::perform_scroll_wheel_hack();