Automatically focus the dialogs when they show up

This commit fixes the automatic focusing for arbitrary dialogs and
enables the focusing for advanced message dialogs.

We also enable the focus border for the dialog buttons so the currently
focused button is actually indicated.

Fixes #1679