/* Process all pending events from the internal queue. 
This function processes all pending events from the internal queue. In order for the window system to work properly, this function should be called as often as possible, to process new events. In this implementation, whenever a new event is added to the queue, the system automatically adds a work item to the main application work queue. This work item refers to win_event_worker() which in turn will call this function to process all pending events. */
void win_process_events(void)
/* Process all pending events from the internal queue. 
This function processes all pending events from the internal queue. In order for the window system to work properly, this function should be called as often as possible, to process new events. In this implementation, whenever a new event is added to the queue, the system automatically adds a work item to the main application work queue. This work item refers to win_event_worker() which in turn will call this function to process all pending events. */
void win_process_events(void)
{
	while (win_are_events_pending()) {
		struct win_event *event = win_event_queue.front;
		switch (event->type) {
		case WIN_EVENT_POINTER:
			win_process_pointer_event(&event->pointer);
			break;
		case WIN_EVENT_KEYBOARD:
			win_process_keyboard_event(&event->keyboard);
			break;
		case WIN_EVENT_COMMAND:
			win_process_command_event(&event->command);
			break;
		default:
			Assert(event->type);
			break;
		}
		win_pop_front_event();
	}
}