public void poll(int width, int height) {
		// add any listeners requested since last time
		for (int i=0;i<keyListenersToAdd.size();i++) {
			addKeyListenerImpl((KeyListener) keyListenersToAdd.get(i));
		}
		keyListenersToAdd.clear();
		for (int i=0;i<mouseListenersToAdd.size();i++) {
			addMouseListenerImpl((MouseListener) mouseListenersToAdd.get(i));
		}
		mouseListenersToAdd.clear();
		
		if (doubleClickTimeout != 0) {
			if (System.currentTimeMillis() > doubleClickTimeout) {
				doubleClickTimeout = 0;
			}
		}
		
		this.height = height;

		Iterator allStarts = allListeners.iterator();
		while (allStarts.hasNext()) {
			ControlledInputReciever listener = (ControlledInputReciever) allStarts.next();
			listener.inputStarted();
		}
		
		ArrayList localEvents = null;
		
		synchronized (inputEvents) {
			if (inputEvents.size() > 0) {
				localEvents = new ArrayList(inputEvents);
				inputEvents.clear();
			}
		}
		
		if (localEvents != null) {
			for (int i=0;i<localEvents.size();i++) {
				((InputEvent) localEvents.get(i)).invoke();
			}
		}
		Iterator all = allListeners.iterator();
		while (all.hasNext()) {
			ControlledInputReciever listener = (ControlledInputReciever) all.next();
			listener.inputEnded();
		}
	}