Simulating mouse input with gdk_event_put()?



I have figured out how to inject synthetic, or fake, keyboard events
using gdk_event_put(), but I'm having trouble generating mock
mouse events.  The function I'm trying to implement should take
the X and Y coordinates of the click relative to the app's window,
and generate a click sufficient to activate a button.

I know about
http://library.gnome.org/devel/gdk/stable/gdk-Testing.html#gdk-test-simulate-button
but the app I'm injecting events into doesn't use the gdk test suite,
so that's not appropriate.

I could probably inject events using X, but I'd like to try doing it
using gdk_event_put().

http://k3d.svn.sourceforge.net/viewvc/k3d/tags/k3d-0.7.0.0/k3dsdk/ngui/interactive.cpp
seems to do this.  I've tried to boil this technique down to a trivial
example derived from the gtk button tutorial; all my example
does is put up the button, then when the user presses any key,
it tries to simulate a mouse click on the button.
For debugging purposes, I also warp the pointer to the
location of the click, but that's just so you can see where the click
ought to occur.

My example is at http://kegel.com/gtk/button.c
I can probably figure this out on my own, and will keep trying,
but if anyone feels like having a look and pointing out
what's wrong, I'd appreciate it.
Thanks!
- Dan



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]