About PtForwardWindowTaskEvent()

Hello,

I’ve already read the article that the GUI Group posted before about
PtForwardWindowTaskEvent().
I really want the phplay application to be front most whenever I need .
So I also used PtForwardWindowTaskEvent() in my photon application to bring
the app to front.
But the my PtForwardWindowTaskEvent() may be not working well.

My function code is following as;

What’s wrong ?

Thanks,
Sangwoon
swchung@rtsolutions.co.kr
http://www.rtsolutions.co.kr

\

void activate_proc( pid_t pid) // pid is the process id of phplay
{
PhWindowEvent_t w_event;
int ret;

memset(&w_event,0,sizeof(w_event));
w_event.event_f= Ph_WM_TOFRONT;
w_event.event_state= Ph_WM_EVSTATE_FFRONT;
ret= PtForwardWindowTaskEvent((PhConnectId_t)pid, &w_event);

printf(“activate %ld, ret= %d …\n”, pid, ret);
}

Sangwoon Chung <swchung@rtsolutions.co.kr> wrote:
: My function code is following as;

: What’s wrong ?

: --------------------------------------
: void activate_proc( pid_t pid) // pid is the process id of phplay
: {
: PhWindowEvent_t w_event;
: int ret;

: memset(&w_event,0,sizeof(w_event));
: w_event.event_f= Ph_WM_TOFRONT;
: w_event.event_state= Ph_WM_EVSTATE_FFRONT;
: ret= PtForwardWindowTaskEvent((PhConnectId_t)pid, &w_event);

The connection ID isn’t the same as the process ID, so you can’t just
cast it. I’m told that there is a way to find the connection ID if you
have the pid, but I’m afraid I don’t know it. Perhaps someone else knows
(in which case, I 'll mention it in the docs).

: printf(“activate %ld, ret= %d …\n”, pid, ret);
: }


Steve Reid stever@qnx.com
TechPubs (Technical Publications)
QNX Software Systems

Steve Reid <stever@qnx.com> wrote:

Sangwoon Chung <> swchung@rtsolutions.co.kr> > wrote:

: ret= PtForwardWindowTaskEvent((PhConnectId_t)pid, &w_event);

The connection ID isn’t the same as the process ID, so you can’t just
cast it. I’m told that there is a way to find the connection ID if you
have the pid, but I’m afraid I don’t know it. Perhaps someone else knows
(in which case, I 'll mention it in the docs).

The easiest way is when you know the rid of a region that the app owns:
just give it to PhRegionQuery(), and you’ll get the connection ID in the
“owner” field of the PhRegion_t.

If all you know is the pid, you’ll have to search for it in a loop.
Something like this:

PhConnectId_t get_connect_id( pid_t pid ) {
ConnectInfo_t buf;
PhConnectId_t id = 0;
while ( ( id = PhGetConnectInfo( id, &buf ) ) != -1
&& ( buf.pid != pid || ND_NODE_CMP( buf.nid, ND_LOCAL_NODE ) )
)
++id;
return id;
}


Wojtek Lerch QNX Software Systems Ltd.

The easiest way is when you know the rid of a region that the app owns:
just give it to PhRegionQuery(), and you’ll get the connection ID in the
“owner” field of the PhRegion_t.

If all you know is the pid, you’ll have to search for it in a loop.
Something like this:

PhConnectId_t get_connect_id( pid_t pid ) {
ConnectInfo_t buf;
PhConnectId_t id = 0;
while ( ( id = PhGetConnectInfo( id, &buf ) ) != -1
&& ( buf.pid != pid || ND_NODE_CMP( buf.nid,
ND_LOCAL_NODE ) )
)
++id;
return id;
}


Wojtek Lerch QNX Software Systems Ltd.

Thank you all,
And the comment Wojtek Lerch gave is very helpful to me.

Thanks so much again,
Regard
Sangwoon