simpler in-window checking

Signed-off-by: Tomas Neme <lacrymology@gmail.com>
fix milliseconds delay

Signed-off-by: Tomas Neme <lacrymology@gmail.com>
comments and whitespace

Signed-off-by: Tomas Neme <lacrymology@gmail.com>