This is a common problem. The bird sees its reflection in the window and thinks another bird is encroaching on his territory. One solution is to put a silhouette of a hawk in the window. That scares them off. Birding and nature stores sell paper cutouts that you can tape to the window.