/* call-seq:
 *   window.getEvent()  -> event or nil
 *
 * Pop the event on top of events stack, if any, and return it.
 *
 * This function is not blocking: if there's no pending event then it will return nil. Note that more than the returned
 * event may be present in the events stack, thus you should always call this function in a loop to make sure that you
 * process every pending event. 
 */
static VALUE Window_GetEvent( VALUE self )
{
        sf::Event event;
        sf::Window *window = NULL;
        Data_Get_Struct( self, sf::Window, window );
        if( window->GetEvent( event ) == true )
        {
                VALUE rbObject = rb_funcall( globalEventClass, rb_intern( "new" ), 1, INT2FIX( event.Type ) );
                sf::Event *rubyRawEvent = NULL;
                Data_Get_Struct( rbObject, sf::Event, rubyRawEvent );
                *rubyRawEvent = event;
                return rbObject;
        }
        else
        {
                return Qnil;
        }      
}