After you create your window, do gtk_grab_add(my_window). And after closing the window do gtk_grab_remove(my_window).