window: add the initial workings of the communicative main loop

See issues #39 and #40.