Get an X window ID

Pat Kane pekane52 at gmail.com
Sat May 19 20:40:13 PDT 2007


You could enumerate  the window tree before and after the "exec", and
then look for changes -- that would give you a very good starting point (hint).
That method might not scale very well...

My PID hack would allow you to create a list of possible
window ID  which would help you correlate with the above "enum" idea

Pat
---
>
> 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?.
>
> 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
>



More information about the xorg mailing list