Yo tomas! > OK, here is a rough sketch (tested). As soon as the pointer crosses the > window boundary (inward), it is grabbed (the app changes the cursor's > appearance to show it). WARNING! IT IS A TRAP! Once your pointer is > inside, you won't be let out. See to it that you have a console around > (a virtual console wth ctrl-alt-Fn will do) to kill the app. Keep out of > reach of children ;-)
You're great. This at least solve the problem that the pointer cannot leave the application window. One step further. But the main problem remains: Once the pointer (Pirate!!) touch the border or the window, the mouse coordinate don't change anymore. Remember: I need to get the relative mouse movement independend of the absolute cursor position. Maybe there is a function to place the cursor in the middle of the window? I've tested your application and rewrote it in PyGTK. (This one you can even give to children, the pointer is released after 15 seconds ;-) ) Thank you. Cheers, Andy import pygtk pygtk.require("2.0") import gobject, gtk def release_me(): gtk.main_quit() return True def on_destroy(widget): gtk.main_quit() def on_enter(widget, event): if event.type == gtk.gdk.ENTER_NOTIFY: cursor = gtk.gdk.Cursor(gtk.gdk.PIRATE) # Pirates!! gtk.gdk.pointer_grab(widget.window, False, gtk.gdk.POINTER_MOTION_MASK, widget.window, cursor, long(event.time)) gobject.timeout_add(15000, release_me) else: # leaving: won't happen gtk.gdk.pointer_ungrab(long(event.time)) return False def on_move(widget, event): print "move to:", event.x, event.y def main(): w = gtk.Window() w.set_title("Grabby") w.connect('destroy', on_destroy) w.connect('enter-notify-event', on_enter) w.connect('motion-notify-event', on_move) w.show_all() gtk.main() gdk.pointer_ungrab(long(event.time)) if __name__ == '__main__': main() _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list