diff -r 98f69ec30cad lib/irrlicht/include/IrrlichtDevice.h --- a/lib/irrlicht/include/IrrlichtDevice.h Wed Sep 23 00:22:01 2009 +0200 +++ b/lib/irrlicht/include/IrrlichtDevice.h Wed Sep 23 00:26:51 2009 +0200 @@ -236,6 +236,11 @@ namespace irr //! Get the current Gamma Value for the Display 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; //! Get the type of the device. /** This allows the user to check which windowing system is currently being diff -r 98f69ec30cad lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp Wed Sep 23 00:22:01 2009 +0200 +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp Wed Sep 23 00:26:51 2009 +0200 @@ -770,6 +770,20 @@ void CIrrDeviceLinux::createDriver() } } +//! 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 98f69ec30cad lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.h --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.h Wed Sep 23 00:22:01 2009 +0200 +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.h Wed Sep 23 00:26:51 2009 +0200 @@ -101,6 +101,9 @@ namespace irr //! 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(); //! Set the current Gamma Value for the Display virtual bool setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast ); diff -r 98f69ec30cad lib/irrlicht/source/Irrlicht/CIrrDeviceStub.h --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceStub.h Wed Sep 23 00:22:01 2009 +0200 +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceStub.h Wed Sep 23 00:26:51 2009 +0200 @@ -116,6 +116,9 @@ namespace irr //! 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() {} + //! Set the maximal elapsed time between 2 clicks to generate doubleclicks for the mouse. It also affects tripleclick behaviour. //! When set to 0 no double- and tripleclicks will be generated. virtual void setDoubleClickTime( u32 timeMs ); diff -r 98f69ec30cad lib/irrlicht/source/Irrlicht/CIrrDeviceWin32.cpp --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceWin32.cpp Wed Sep 23 00:22:01 2009 +0200 +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceWin32.cpp Wed Sep 23 00:26:51 2009 +0200 @@ -70,6 +70,15 @@ irr::CIrrDeviceWin32* getDeviceFromHWnd( 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)) + {} +} LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { diff -r 98f69ec30cad lib/irrlicht/source/Irrlicht/CIrrDeviceWin32.h --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceWin32.h Wed Sep 23 00:22:01 2009 +0200 +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceWin32.h Wed Sep 23 00:26:51 2009 +0200 @@ -86,6 +86,9 @@ namespace irr //! 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(); //! Get the device type virtual E_DEVICE_TYPE getType() const