FAQ Index - Search - Recent Changes - Everything - Add entry

<< Previous Entry | FAQ Entry 23.24 | Next Entry >>

23.24. Can GTK know the mouse position outside of GTK Application?

To get the position relative to a given window

  gdkwindow.get_pointer() 
If you need the absolute position, call get_pointer on the root window of the current screen:

  rootwin = widget.get_screen().get_root_window()
  x, y, mods = rootwin.get_pointer()
If you call get_pointer() on some other GdkWindow, the result will be relative to the position of that window (so you can get negative coordinates)

(James Henstridge)

PyGTK FAQ Wizard | PyGTK Homepage | Feedback to faq at pygtk.org