I can reproduce the bug. Adding gtk_widget_realize(win); in the middle of grab_keyboard() doesn't change anything.
pgpaXTezIG2wB.pgp
Description: PGP signature
I can reproduce the bug. Adding gtk_widget_realize(win); in the middle of grab_keyboard() doesn't change anything.
pgpaXTezIG2wB.pgp
Description: PGP signature