thor@thor.atd.ucar.edu (Richard Neitzel) (04/09/91)
I am trying to write an application that needs to send text strings to an xterm. The most obvious method to me is to use selections and mimic the button2 actions by sending events to the target xterm. However, the xterm does not respond by getting the selection. I've tested the events sent with xev, so I am certain that xterm is getting them - so why isn't it getting the selection. Here's the effected part of the code: XEvent ev; ev.type = ButtonPress; ev.xbutton.type = ButtonPress; ev.xbutton.display = disp; ev.xbutton.window = wdw; ev.xbutton.root = root; ev.xbutton.subwindow = 0; ev.xbutton.time = CurrentTime; ev.xbutton.x = 10; ev.xbutton.y = 50; ev.xbutton.x_root = rx; ev.xbutton.y_root = ry; ev.xbutton.state = 0; ev.xbutton.button = Button2; ev.xbutton.same_screen = True; if (!XSendEvent(disp,wdw,True,ButtonPressMask,&ev)) cerr << "XSendEvent failed.\n"; ev.type = ButtonRelease; ev.xbutton.type = ButtonRelease; ev.xbutton.time = CurrentTime; ev.xbutton.state = Button2Mask; if (!XSendEvent(disp,wdw,True,ButtonReleaseMask,&ev)) cerr << "XSendEvent failed.\n"; -- Richard Neitzel thor@thor.atd.ucar.edu Torren med sitt skjegg National Center For Atmospheric Research lokkar borni under sole-vegg Box 3000 Boulder, CO 80307-3000 Gjo'i med sitt shinn 303-497-2057 jagar borni inn.
cjmchale@cs.tcd.ie (Ciaran McHale) (04/09/91)
In <10961@ncar.ucar.edu> thor@thor.atd.ucar.edu (Richard Neitzel) writes: > I am trying to write an application that needs to send text >strings to an xterm. [...] However, the xterm does not respond by >getting the selection. I've tested the events sent with xev, so I am >certain that xterm is getting them - so why isn't it getting the >selection. An important point to note about sending events is that the X server will force the send_event field to True. Xterm examines this field and if set will (by default) discard the event rather than process it. This is to prevent people from "sending" harmful key sequences to an xterm. For example, sending the string "rm -f *\n" to somebody else's xterm is not a nice thing to do. You can tell xterm to process events which have been sent by setting one of its resources (called "allowSendEvents") to True. This can be done in a resources file or can be toggled on/off by choosing the appropriate option in the menu displayed by pressing the <control> key and the 1st mouse button. Ciaran. -- Ciaran McHale "There's a lot to be said for verbosity." ---- Department of Computer Science, Trinity College, Dublin 2, Ireland. \ / Telephone: +353-1-772941 ext 1538 FAX: +353-1-772204 \/ Telex: 93782 TCD EI email: cjmchale@cs.tcd.ie
fgreco@govt.shearson.COM (Frank Greco) (04/09/91)
> I am trying to write an application that needs to send text > strings to an xterm. The most obvious method to me is to use > selections and mimic the button2 actions by sending events to the > target xterm. However, the xterm does not respond by getting the > selection. I've tested the events sent with xev, so I am certain that > xterm is getting them - so why isn't it getting the selection. Here's > the effected part of the code: Have you specified the Xterm resource "allowSendEvents" to be true? That's usually the source of the consternation... Frank G.