Get an X window ID
Carsten Haitzler (The Rasterman)
raster at rasterman.com
Fri May 18 17:02:03 PDT 2007
On Fri, 18 May 2007 22:11:51 +0200 (CEST) eberrocal at laurel.datsi.fi.upm.es
babbled:
> > Have you thought about opening a pipe before you fork/exec
> > so that the child can simply send the desired information
> > back to the parent?
>
> I can not do that because the applications that The son are going to exec
> will be anyone. Applications that I can not modify to do something with a
> pipe.
>
> The principal problem is to discover a window ID (or windows Ids maybe) of
> an X application that is running and I know his PID.
>
> I need do that because I need to send "artificial" X events to this window.
>
> It is possible?.
sometimes it might be. follow the thread of replies to your question for
information. it is not guaranteed to know - and there is not "get" function
call. you will need to walk the x window tree and/or listen for window create
events and get properties of possible targets to check.
> Edu
>
> >
> > Dan
> >
> >>
> >> Hi all.
> >>
> >> First, Thanks for your requests.
> >>
> >> Second, I am going to put a code where you can see what I am pretending.
> >>
> >> ----------------------------
> >> pid = fork();
> >>
> >> switch(pid)
> >> {
> >> case 0:
> >> if (execl
> >> ("./myXapplication","./myXapplication","param",NULL) < 0) perror("execl");
> >> break;
> >> case -1:
> >> fprintf(stderr,"Error during the process of fork()\n");
> >> break;
> >> default:
> >> // I am going to listen for the event number 16 (CreateNotify)
> >>
> >> while (!XCheckTypedEvent(display,16,&event));
> >>
> >> anyevent = event.xany;
> >> win_id = anyevent.window;
> >> fprintf(stdout, "The window have this ID: %x\n",win_id);
> >>
> >> // wait for the son
> >> while (pid != wait(NULL));
> >> fprintf(stdout, "Execution finished\n");
> >> }
> >>
> >> ----------------------------
> >>
> >> The problem is that XCheckTypedEvent() can not capture the event
> >> CreateNotify for the window that create myXapplication.
> >>
> >> Really, XCheckTypedEvent() can not capture any CreateNotify event. When
> >> this program is running I open windows but the function do not capture
> >> nothing.
> >>
> >> Any Idea?.
> >>
> >> Thanks.
> >>
> >> Edu.
> >>
> >> _______________________________________________
> >> xorg mailing list
> >> xorg at lists.freedesktop.org
> >> http://lists.freedesktop.org/mailman/listinfo/xorg
> >
>
>
> _______________________________________________
> xorg mailing list
> xorg at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/xorg
>
--
------------- Codito, ergo sum - "I code, therefore I am" --------------
The Rasterman (Carsten Haitzler) raster at rasterman.com
裸好多
Tokyo, Japan (東京 日本)
More information about the xorg
mailing list