Add clearSystemMessages to IrrlichtDevices (implemented only for Win32 and Linux so far).

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3051 dfc29bdd-3216-0410-991c-e03cc46cb475
master
cutealien 2009-12-13 10:39:29 +00:00
parent dae1088202
commit 9b50b09ea3
8 changed files with 73 additions and 18 deletions

View File

@ -1,5 +1,7 @@
Changes in 1.7 Changes in 1.7
- Add clearSystemMessages to devices (implemented only for Linux and Win32 so far).
- Fix incorrect cursorpos for resizable windows on Windows Vista (found and patched by buffer) - Fix incorrect cursorpos for resizable windows on Windows Vista (found and patched by buffer)
- Change the beginScene window parameter from void* to SExposedVideoData&. This will allow to manage contexts for OpenGL at some point. - Change the beginScene window parameter from void* to SExposedVideoData&. This will allow to manage contexts for OpenGL at some point.

View File

@ -237,6 +237,18 @@ namespace irr
virtual bool getGammaRamp(f32 &red, f32 &green, f32 &blue, virtual bool getGammaRamp(f32 &red, f32 &green, f32 &blue,
f32 &brightness, f32 &contrast) =0; f32 &brightness, f32 &contrast) =0;
//! Remove all messages pending in the system message loop
/** This function is usually used after messages have been buffered for a longer time, for example
when loading a large scene. Clearing the message loop prevents that mouse- or buttonclicks which users
have pressed in the meantime will now trigger unexpected actions in the gui. <br>
So far the following messages are cleared:<br>
Win32: All keyboard and mouse messages<br>
Linux: All messages<br>
All other devices are not yet supported here.<br>
The function is still somewhat experimental, as the kind of messages we clear is based on just a few use-cases.
If you think further messages should be cleared, or some messages should not be cleared here, then please tell us. */
virtual void clearSystemMessages() = 0;
//! Get the type of the device. //! Get the type of the device.
/** This allows the user to check which windowing system is currently being /** This allows the user to check which windowing system is currently being
used. */ used. */

View File

@ -1814,6 +1814,21 @@ void CIrrDeviceLinux::copyToClipboard(const c8* text) const
#endif #endif
} }
//! Remove all messages pending in the system message loop
void CIrrDeviceLinux::clearSystemMessages()
{
#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_
}
void CIrrDeviceLinux::initXAtoms() void CIrrDeviceLinux::initXAtoms()
{ {
#ifdef _IRR_COMPILE_WITH_X11_ #ifdef _IRR_COMPILE_WITH_X11_

View File

@ -116,6 +116,9 @@ namespace irr
//! This sets the clipboard selection and _not_ the primary selection which you have on X on the middle mouse button. //! This sets the clipboard selection and _not_ the primary selection which you have on X on the middle mouse button.
virtual void copyToClipboard(const c8* text) const; virtual void copyToClipboard(const c8* text) const;
//! Remove all messages pending in the system message loop
virtual void clearSystemMessages();
//! Get the device type //! Get the device type
virtual E_DEVICE_TYPE getType() const virtual E_DEVICE_TYPE getType() const
{ {

View File

@ -352,6 +352,12 @@ u32 CIrrDeviceStub::getDoubleClickTime() const
return MouseMultiClicks.DoubleClickTime; return MouseMultiClicks.DoubleClickTime;
} }
//! Remove all messages pending in the system message loop
void CIrrDeviceStub::clearSystemMessages()
{
}
} // end namespace irr } // end namespace irr

View File

@ -123,6 +123,10 @@ namespace irr
//! Get the maximal elapsed time between 2 clicks to generate double- and tripleclicks for the mouse. //! Get the maximal elapsed time between 2 clicks to generate double- and tripleclicks for the mouse.
virtual u32 getDoubleClickTime() const; virtual u32 getDoubleClickTime() const;
//! Remove all messages pending in the system message loop
virtual void clearSystemMessages();
protected: protected:
void createGUIAndScene(); void createGUIAndScene();

View File

@ -1185,6 +1185,16 @@ bool CIrrDeviceWin32::getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &bright
} }
//! Remove all messages pending in the system message loop
void CIrrDeviceWin32::clearSystemMessages()
{
MSG msg;
while (PeekMessage(&msg, NULL, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE))
{}
while (PeekMessage(&msg, NULL, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE))
{}
}
// shows last error in a messagebox to help internal debugging. // shows last error in a messagebox to help internal debugging.
void CIrrDeviceWin32::ReportLastWinApiError() void CIrrDeviceWin32::ReportLastWinApiError()
{ {

View File

@ -87,6 +87,9 @@ namespace irr
//! Get the current Gamma Value for the Display //! Get the current Gamma Value for the Display
virtual bool getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast ); virtual bool getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast );
//! Remove all messages pending in the system message loop
virtual void clearSystemMessages();
//! Get the device type //! Get the device type
virtual E_DEVICE_TYPE getType() const virtual E_DEVICE_TYPE getType() const
{ {