Article View: ba.windows.x
Article #54Re: editres protocol
From: Kouji Washio
Date: Thu, 16 Jul 1992 15:13
Date: Thu, 16 Jul 1992 15:13
81 lines
3726 bytes
3726 bytes
In article <l68q9vINNnsf@smli.Eng.Sun.COM>
kedwards@dufus.Eng.Sun.COM (Keith Edwards) writes:
| >I want to send an event to a certain widget in another client. But
| >how do I get a *child or a grandchild* widget/window value from the
| >widget name?
|
| Once you've initiated the editres protocol with a client you can use the
| SendWidgetTree command to retrieve the entire widget hierarchy of the
| application. The reply that you get back contains the window id of any
| widgets that have been realized, along with each widget's name and class.
| The main hassle is that dealing with the data structures that editres uses
| can be a drag...
Thanx, Keith. Your advice is great help for me.
But,
- How I initiate the editres protocol with a client?
- How I use the SendWidgetTree command?
- How I get the reply?
- How I find the window id in the reply?
The codes below is an attempt. It doesn't work. Would you correct?
BEGIN----------------------------------------
Window xGetWindow(Display *dpy, Window win, char *name)
{
char *window_name_ret;
Window root, parent, *children, window = 0;
unsigned int nchildren;
int i;
XFetchName(dpy, win, &window_name_ret);
if ((window_name_ret) && (strcmp(window_name_ret, name) == 0))
return win;
if (XQueryTree(dpy, win, &root, &parent, &children, &nchildren) == 0)
return NULL;
for (i = 0; i < nchildren; i++) {
window = xGetWindow(dpy, children[i], name);
if (window) break;
}
return window;
}
void xSendMsgEvent(Display *dpy, Window win)
{
static XClientMessageEvent xcme;
xcme.type = ClientMessage;
xcme.window = win;
xcme.message_type = XInternAtom(dpy, EDITRES_NAME, False);
xcme.format = EDITRES_SEND_EVENT_FORMAT;
xcme.data.l[0] = XtLastTimestampProcessed(dpy);
xcme.data.l[1] = XInternAtom(dpy, EDITRES_COMM_ATOM, False);
xcme.data.l[2] = 0; /* ? */
xcme.data.l[3] = 4; /* ? */
XSendEvent(dpy, win, False, (long)0, (XEvent *)&xcme);
}
void xReceiveEvent(){ /* ? */ }
void main(int argc, char *argv[]) /* argv[1]: window name */
{
Widget toplevel_widget;
XtAppContext app_context_return;
Window root_win, target_win;
toplevel_widget = XtAppInitialize(&app_context_return,
"TEst", NULL, ZERO,
&argc, argv, NULL, NULL, ZERO);
root_win = XDefaultRootWindow(XtDisplay(toplevel_widget));
target_win = xGetWindow(XtDisplay(toplevel_widget), root_win, argv[1]);
if (target_win == (Window)NULL) exit(1);
xSendMsgEvent(XtDisplay(toplevel_widget), target_win);
xReceiveEvent();
exit(0);
}
END----------------------------------------
--
Kouji Washio @ NEC Microcomputer Technorogy Ltd., Tokyo, Japan.
k-wasio@ccs.mt.nec.co.jp
Technical Details
Message-ID:
<K-WASIO.92Jul16151302@nmite17.ccs.mt.nec.co.jp>Path:
arc1-ca.pugleaf.net!sparky!uunet!sun-barr!sh.wide!wnoc-tyo-news!nec-tyo!necspl!ccsnews!ccsnews!k-wasioReferences:
<K-WASIO.92Jul15133104@nmite17.ccs.mt.nec.co.jp> <l68q9vINNnsf@smli.Eng.Sun.COM>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103734,4ec398fca4f841b1 X-Google-Attributes: gid103734,public X-Google-Thread: 10e286,4ec398fca4f841b1 X-Google-Attributes: gid10e286,public X-Google-ArrivalTime: 1992-07-15 18:33:08 PST Newsgroups: ba.windows.x,comp.windows.x Path: arc1-ca.pugleaf.net!sparky!uunet!sun-barr!sh.wide!wnoc-tyo-news!nec-tyo!necspl!ccsnews!ccsnews!k-wasio From: k-wasio@ccs.mt.nec.co.jp (Kouji Washio) Subject: Re: editres protocol Sender: news@ccsnews.ccs.mt.nec.co.jp ( News server) Message-ID: <K-WASIO.92Jul16151302@nmite17.ccs.mt.nec.co.jp> In-Reply-To: kedwards@dufus.Eng.Sun.COM's message of 15 Jul 92 18:06:55 GMT Date: Thu, 16 Jul 1992 15:13:02 GMT References: <K-WASIO.92Jul15133104@nmite17.ccs.mt.nec.co.jp> <l68q9vINNnsf@smli.Eng.Sun.COM> Organization: Nec MIcrocomputer Technology, ltd. Lines: 81