What we think is going on
The dog just appreciates the beauty of the outside world. Like how we might relax on the beach or in a conservatory. Or he is "keeping guard" in his mind.
What's actually happening
The dog is waiting for its next kick of endorphins, when a dog or cat walks by and he gets excited and barks. In that sense, the dog at the window is more like you or me refreshing the page on Facebook to see if anyone has liked our post.
Conclusion: For your pet, the window is literally Facebook