void DisplayMessageQueue_X11::process_message()
{
	 std::shared_ptr<ThreadData> data = get_thread_data();

	XEvent event;
	while(XPending(display) > 0)
	{
		XNextEvent(display, &event);

		for (std::vector<X11Window *>::size_type i = 0; i < data->windows.size(); i++)
		{
			X11Window *window = data->windows[i];
			if (window->get_window() == event.xany.window)
			{
				X11Window *mouse_capture_window = current_mouse_capture_window;
				if (mouse_capture_window == NULL)
					mouse_capture_window = window;

				window->process_message(event, mouse_capture_window);
			}
		}
	}

	for (std::vector<X11Window *>::size_type i = 0; i < data->windows.size(); i++)
	{
		data->windows[i]->process_message_complete();
	}

	// Process all input context messages (done seperately, because of the mouse_capture hack)
	for (std::vector<X11Window *>::size_type i = 0; i < data->windows.size(); i++)
	{
		InputContext context = data->windows[i]->get_ic();
		context.process_messages();
	}
}
	void DisplayMessageQueue_X11::process_message()
	{
		std::shared_ptr<ThreadData> data = get_thread_data();
		::Display *display = get_display();
		XEvent event;
		while (XPending(display) > 0)
		{
			XNextEvent(display, &event);

			for (auto & elem : data->windows)
			{
				X11Window *window = elem;
				if (window->get_window() == event.xany.window)
				{
					X11Window *mouse_capture_window = current_mouse_capture_window;
					if (mouse_capture_window == nullptr)
						mouse_capture_window = window;

					window->process_message(event, mouse_capture_window);
				}
			}
		}

		for (auto & elem : data->windows)
		{
			elem->process_message_complete();
		}

		// Process all input context messages (done seperately, because of the mouse_capture hack)
		for (auto & elem : data->windows)
		{
			InputContext context = elem->get_ic();
			context.process_messages();
		}
	}
	void DisplayMessageQueue_Win32::process_input_contexts()
	{
		std::shared_ptr<ThreadData> data = get_thread_data();
		for (std::vector<Win32Window *>::size_type i = 0; i < data->windows.size(); i++)
		{
			InputContext context = data->windows[i]->get_ic();
			context.process_messages();
		}
	}