fix for bug #27667: window should be reference to toplevel