mmeyer@XENURUS.GOULD.COM (Morris Meyer) (11/11/88)
I have hit the proverbial wall with XSendEvent(). I have a widget that I am writing that I would like to receive an aperiodic ClientMessage event from another program. I have the following defaultTranslations[] and actionsList[] at the beginning of my widget: static void ReceiveMessage(); static char defaultTranslations[] = "<ClientMessage>: clientmessage() "; static XtActionsRec actionsList[] = { {"clientmessage", ReceiveMessage}, }; My class record is initialized as follows: GaugeClassRec gaugeClassRec = { { /* core_class fields */ <<< Stuff deleted >>> /* actions */ actionsList, /* num_actions */ XtNumber(actionsList), <<< More stuff deleted >>> /* tm_table */ defaultTranslations, }; And my ReceiveMessage is pretty simple: /* ARGSUSED */ static void ReceiveMessage(w,event,params,num_params) Widget w; XEvent *event; String *params; /* unused */ Cardinal *num_params; /* unused */ { GaugeWidget gw = (GaugeWidget)w; fprintf (stderr, "WIDGET RECEIVED MESSAGE\n"); } I have a client program similar to xwininfo that prints a cursor on the display. I get the Window ID of the widget and fire off a XSendEvent to the Window ID. XSendEvent returns a BadRequest. I make sure the widget is partially obscured and do an XRaiseWindow on the Window ID to make sure I have the correct Window before I do the XSendEvent. XEvent ClientEvent; status = XRaiseWindow (dpy, win); XSync (dpy, False); ClientEvent.type = ClientMessage; ClientEvent.xclient.message_type = NULL; ClientEvent.xclient.format = 32; status = XSendEvent (dpy, win, False, 0, &ClientEvent); Has anyone using the X Window System, Version 11 run into this? Should I be doing something in the Widget's Initialize() or Realize() functions to prepare for this event? Many thanks in advance. --morris Morris Meyer Motorola Microcomputer Division, Champaign-Urbana Development Center (formerly Gould CSD Urbana Software Development Center). 1101 E. University, Urbana, Illinois 61801, USA. mmeyer@gould.com or mmeyerfang.gould.com or ...!uunet!uiucuxc!ccvaxa!mmeyer
rws@EXPO.LCS.MIT.EDU (Bob Scheifler) (11/11/88)
"<ClientMessage>: clientmessage() "; The correct name of the event type is <Message>, not <ClientMessage>. I tried adding such a translation to an xterm, and it seemed to work just fine. I get the Window ID of the widget and fire off a XSendEvent to the Window ID. XSendEvent returns a BadRequest. Nope. XSendEvent returns Status, not a protocol error code. The 1 that is being returned indicates success.