What do you need the functionality for? If you want to do it on Linux, you have to have superuser privileges, otherwise forget it, it won't work. I don't know why it doesn't work when you grab the mouse, maybe it grabs the pointer only within the current application and your GTK widget is another application. In that case you need an appropriate Xlib call to grab the mouse for the whole desktop or filter out mouse events that are received by the server.
Bookmarks