The bird you saw attacking the glass is full of raging breeding hormones, and most likely a male. He is seeing his reflection in the glass and, not knowing what a reflection is, believes it to be a rival male that has dared to trespass on his territory. What’s worse, rather than fly away, the interloper seems to fight back with equal ferocity, which the bird sees as a serious threat. In addition, the rival never leaves: whenever the bird goes looking for him in that same part of his territory, there he is, waiting to fight.
During the breeding season, when hormones make them very aggressive, male birds can waste hours doing this, neglecting to feed or to look after their mate and their chicks. The most effective way to stop it is to take some cling-film, scrunch it up as much as possible so that it is very wrinkled, then place it over the outside (not the inside) of the glass. The wrinkles will break the bird’s reflection up enough so that it no longer recognises it, and light can still pass through the window as normal. You would only need to do this for a week or two: after that, the bird will forget all about it and will be in a less aggressive mood.