fix focus related issues

@lennartcl please test if contextmenu on mac works.