diff -r 9bf2ad7af052 lib/irrlicht/include/IrrlichtDevice.h --- a/lib/irrlicht/include/IrrlichtDevice.h Mon Sep 01 23:19:35 2008 +0200 +++ b/lib/irrlicht/include/IrrlichtDevice.h Tue Sep 02 00:37:10 2008 +0200 @@ -207,6 +207,12 @@ mode. \param resize Flag whether the window should be resizeable. */ virtual void setResizeAble(bool resize=false) = 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 9bf2ad7af052 lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp Mon Sep 01 23:19:35 2008 +0200 +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp Tue Sep 02 00:37:10 2008 +0200 @@ -1088,6 +1088,22 @@ } +//! 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_ +} + + //! Return pointer to a list with all video modes supported by the gfx adapter. video::IVideoModeList* CIrrDeviceLinux::getVideoModeList() { diff -r 9bf2ad7af052 lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.h --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.h Mon Sep 01 23:19:35 2008 +0200 +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.h Tue Sep 02 00:37:10 2008 +0200 @@ -89,6 +89,9 @@ //! Sets if the window should be resizeable in windowed mode. virtual void setResizeAble(bool resize=false); + + //! remove all events pending in the message loop + virtual void clearPendingEvents(); private: diff -r 9bf2ad7af052 lib/irrlicht/source/Irrlicht/CIrrDeviceStub.h --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceStub.h Mon Sep 01 23:19:35 2008 +0200 +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceStub.h Tue Sep 02 00:37:10 2008 +0200 @@ -106,6 +106,9 @@ //! get color format of the current window virtual video::ECOLOR_FORMAT getColorFormat() const; + + //! remove all events pending in the message loop + virtual void clearPendingEvents() {} protected: diff -r 9bf2ad7af052 lib/irrlicht/source/Irrlicht/CIrrDeviceWin32.cpp --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceWin32.cpp Mon Sep 01 23:19:35 2008 +0200 +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceWin32.cpp Tue Sep 02 00:37:10 2008 +0200 @@ -442,6 +442,16 @@ } +//! 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)) + {} +} + //! create the driver void CIrrDeviceWin32::createDriver() diff -r 9bf2ad7af052 lib/irrlicht/source/Irrlicht/CIrrDeviceWin32.h --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceWin32.h Mon Sep 01 23:19:35 2008 +0200 +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceWin32.h Tue Sep 02 00:37:10 2008 +0200 @@ -64,6 +64,9 @@ //! Sets if the window should be resizeable in windowed mode. virtual void setResizeAble(bool resize=false); + + //! remove all events pending in the message loop + virtual void clearPendingEvents(); //! Implementation of the win32 cursor control class CCursorControl : public gui::ICursorControl