diff -r 1787be3cd037 lib/irrlicht/include/IrrlichtDevice.h --- a/lib/irrlicht/include/IrrlichtDevice.h Wed Jun 03 08:04:42 2009 +0200 +++ b/lib/irrlicht/include/IrrlichtDevice.h Wed Jun 03 19:49:33 2009 +0200 @@ -229,6 +229,10 @@ virtual bool getGammaRamp(f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast) =0; + //! remove all events pending in the message loop + //! NOTE: Only supported for the Win32 and the Linux device so far + //! NOTE: This will not remove the WM_QUIT on windows you have to call run() once more to consume that one + virtual void clearPendingEvents() = 0; }; } // end namespace irr diff -r 1787be3cd037 lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp Wed Jun 03 08:04:42 2009 +0200 +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp Wed Jun 03 19:49:33 2009 +0200 @@ -718,6 +718,20 @@ } } +//! remove all events pending in the message loop +void CIrrDeviceLinux::clearPendingEvents() +{ +#ifdef _IRR_COMPILE_WITH_X11_ + if (CreationParams.DriverType != video::EDT_NULL) + { + XEvent event; + while (XPending(display) > 0 ) + { + XNextEvent(display, &event); + } + } +#endif //_IRR_COMPILE_WITH_X11_ +} //! runs the device. Returns false if device wants to be deleted bool CIrrDeviceLinux::run() diff -r 1787be3cd037 lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.h --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.h Wed Jun 03 08:04:42 2009 +0200 +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.h Wed Jun 03 19:49:33 2009 +0200 @@ -96,6 +96,9 @@ //! Activate any joysticks, and generate events for them. virtual bool activateJoysticks(core::array & joystickInfo); + //! remove all events pending in the message loop + virtual void clearPendingEvents(); + private: //! create the driver diff -r 1787be3cd037 lib/irrlicht/source/Irrlicht/CIrrDeviceStub.h --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceStub.h Wed Jun 03 08:04:42 2009 +0200 +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceStub.h Wed Jun 03 19:49:33 2009 +0200 @@ -116,6 +116,9 @@ //! Get the current Gamma Value for the Display virtual bool getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast ); + //! remove all events pending in the message loop + virtual void clearPendingEvents() {} + protected: void createGUIAndScene(); diff -r 1787be3cd037 lib/irrlicht/source/Irrlicht/CIrrDeviceWin32.cpp --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceWin32.cpp Wed Jun 03 08:04:42 2009 +0200 +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceWin32.cpp Wed Jun 03 19:49:33 2009 +0200 @@ -67,6 +67,16 @@ return (*it).irrDev; return 0; +} + +//! remove all events pending in the message loop +void CIrrDeviceWin32::clearPendingEvents() +{ + MSG msg; + while (PeekMessage(&msg, NULL, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE)) + {} + while (PeekMessage(&msg, NULL, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE)) + {} } diff -r 1787be3cd037 lib/irrlicht/source/Irrlicht/CIrrDeviceWin32.h --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceWin32.h Wed Jun 03 08:04:42 2009 +0200 +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceWin32.h Wed Jun 03 19:49:33 2009 +0200 @@ -81,6 +81,9 @@ //! Get the current Gamma Value for the Display virtual bool getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast ); + //! remove all events pending in the message loop + virtual void clearPendingEvents(); + //! Implementation of the win32 cursor control class CCursorControl : public gui::ICursorControl { e() const