Updated window handler to process mouse movements and stick to window center