Get an X window ID

eberrocal at laurel.datsi.fi.upm.es eberrocal at laurel.datsi.fi.upm.es
Fri May 18 13:11:51 PDT 2007


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

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
>





More information about the xorg mailing list