XForms: Synthetic X events

AMIT BHATNAGAR (amit@cs.dal.ca)
Mon, 23 Feb 1998 15:07:34 -0400 (AST)

# To subscribers of the xforms list from AMIT BHATNAGAR <amit@cs.dal.ca> :

I have a canvs with an installed handler which uses fl_get_win_mouse()
to draw. I have a text interface as well which currently has to duplicate
all of my draw functions. I would like to constuct a synthetic X event and
send it to my handler so that I don't have redundant code (ie: different
code for mouse/text interaction)

My problem is the synthetic X event gets to the handler but
fl_get_win_mouse() does not pick up the proper co-ordinates (?)

Heres my synthetic X code.

XEvent *
construct (XEvent * synthetic, int x, int y, int Button)
{

printf ("Synthetic!\n");
synthetic->type = 4;
synthetic->xbutton.type = 4;
synthetic->xbutton.x = x;
synthetic->xbutton.y = y;
synthetic->xbutton.send_event = 0;
synthetic->xbutton.display = fl_get_display ();
synthetic->xbutton.window = FL_ObjWin (fdui->ViewPort);
synthetic->xbutton.root = RootWindow (fl_get_display (), 0);
synthetic->xbutton.subwindow = 0;
fl_get_winorigin(fl_get_canvas_id(fdui->ViewPort),
&synthetic->xbutton.x_root, &synthetic->xbutton.y_root);

synthetic->xbutton.x_root+=x;
synthetic->xbutton.y_root+=y;

synthetic->xbutton.state = 0;
synthetic->xbutton.button = Button;
synthetic->xbutton.same_screen = 1;
XSendEvent (fl_get_display (), fl_get_canvas_id (fdui->ViewPort), 0,
ButtonPress, synthetic);

Sorry for posting code....

_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html
XForms Home Page: http://bloch.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/