Commit 17cee03c authored by cutealien's avatar cutealien

ClearSystemMessages does now also just remove keyboard/mouse events on Linux....

ClearSystemMessages does now also just remove keyboard/mouse events on Linux. Should probably be parametrized in the long run.


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3057 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 74b0345a
...@@ -237,13 +237,13 @@ namespace irr ...@@ -237,13 +237,13 @@ 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 //! Remove messages pending in the system message loop
/** This function is usually used after messages have been buffered for a longer time, for example /** 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 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> have pressed in the meantime will now trigger unexpected actions in the gui. <br>
So far the following messages are cleared:<br> So far the following messages are cleared:<br>
Win32: All keyboard and mouse messages<br> Win32: All keyboard and mouse messages<br>
Linux: All messages<br> Linux: All keyboard and mouse messages<br>
All other devices are not yet supported here.<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. 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. */ If you think further messages should be cleared, or some messages should not be cleared here, then please tell us. */
......
...@@ -1814,6 +1814,19 @@ void CIrrDeviceLinux::copyToClipboard(const c8* text) const ...@@ -1814,6 +1814,19 @@ void CIrrDeviceLinux::copyToClipboard(const c8* text) const
#endif #endif
} }
#ifdef _IRR_COMPILE_WITH_X11_
// return true if the passed event has the type passed in parameter arg
Bool PredicateIsEventType(Display *display, XEvent *event, XPointer arg)
{
if ( event && event->type == (int)arg )
{
// os::Printer::log("remove event:", core::stringc((int)arg).c_str(), ELL_INFORMATION);
return True;
}
return False;
}
#endif //_IRR_COMPILE_WITH_X11_
//! Remove all messages pending in the system message loop //! Remove all messages pending in the system message loop
void CIrrDeviceLinux::clearSystemMessages() void CIrrDeviceLinux::clearSystemMessages()
{ {
...@@ -1821,10 +1834,11 @@ void CIrrDeviceLinux::clearSystemMessages() ...@@ -1821,10 +1834,11 @@ void CIrrDeviceLinux::clearSystemMessages()
if (CreationParams.DriverType != video::EDT_NULL) if (CreationParams.DriverType != video::EDT_NULL)
{ {
XEvent event; XEvent event;
while (XPending(display) > 0 ) while ( XCheckIfEvent(display, &event, PredicateIsEventType, (XPointer)ButtonPress) == True ) {}
{ while ( XCheckIfEvent(display, &event, PredicateIsEventType, (XPointer)ButtonRelease) == True ) {}
XNextEvent(display, &event); while ( XCheckIfEvent(display, &event, PredicateIsEventType, (XPointer)MotionNotify) == True ) {}
} while ( XCheckIfEvent(display, &event, PredicateIsEventType, (XPointer)KeyRelease) == True ) {}
while ( XCheckIfEvent(display, &event, PredicateIsEventType, (XPointer)KeyPress) == True ) {}
} }
#endif //_IRR_COMPILE_WITH_X11_ #endif //_IRR_COMPILE_WITH_X11_
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment