Glue code now knows the state of the main window. Fixes #3