emitting pointer event

hi,
in my application, i want to send pointer event from ‘A’ application to
‘B’ application.

To try this i created transparant region which is sensitive and opaque to
Ph_EV_BUT_PRESS and Ph_EV_BUT_RELEASE. with this, region is catching all
mouse button press and release event.

now i want to re-emit those same mouse event towards ROOT, so it will be
caught by any application running within event space. That application
should process this event as any normal mouse button press and release
event.

To forward pointer type event, following code is used:

int ForwardPointerEvent (PhPointerEvent_t *PointerEvent, PhEvent_t * event)
{
PhEventRegion_t eventrid;
PhRect_t rect;

// event = event of mouse button press or release event
// PointerEvent = data return by PhGetData(event)

eventrid.rid = rid; // rid of the application
eventrid.handle = 0;
event->emitter = eventrid;
event->collector.rid = 0;
rect.ul.x = rect.ul.y = 0;
rect.lr.x = rect.lr.y = 0;

PhEventEmit (event, &rect, (PhPointerEvent_t *) PointerEvent);

return 0;
}

but this is not working, it is not emitting pointer event. mouse clicks are
not taken by any application running in the system.

what is wrong with this code ?

can anybody help me in this ?

thanks in advance

sameer

sam <seto@vsnl.com> wrote:

in my application, i want to send pointer event from ‘A’ application to
‘B’ application.

To try this i created transparant region which is sensitive and opaque to
Ph_EV_BUT_PRESS and Ph_EV_BUT_RELEASE. with this, region is catching all
mouse button press and release event.

now i want to re-emit those same mouse event towards ROOT, so it will be
caught by any application running within event space. That application
should process this event as any normal mouse button press and release
event.

This can be tricky, and you might need to catch motion events, too.
Otherwise, you have a race condition that could cause events to be seen
by an application in the wrong order (e.g. a MOTION_BUTTON before a
BUT_PRESS).

But in your case, I think the problem is that your event misses the
application because you emit it with the wrong position. If you want to
re-emit the event from the same position where you received it (and from
the same region), you need to set event->translation to zero and use the
received event’s rectangle.

If you wanted to shift the events to a different position, then you
would also need to translate the absolute position in the “pos” field of
PhPointerEvent_t. For most pointer events, this absolute position must
match the absolute position of the event’s rectangle. (The exception is
the “phantom” release, whose rectangle must match where the last press
was sent rather than where the mouse currently points to.)

BTW It’s better not to modify the current event in a callback: the
library might want to look at it after the callback returns. It’s safer
to make a copy.

To forward pointer type event, following code is used:

int ForwardPointerEvent (PhPointerEvent_t *PointerEvent, PhEvent_t * event)
{
PhEventRegion_t eventrid;
PhRect_t rect;

// event = event of mouse button press or release event
// PointerEvent = data return by PhGetData(event)

eventrid.rid = rid; // rid of the application
eventrid.handle = 0;
event->emitter = eventrid;
event->collector.rid = 0;
rect.ul.x = rect.ul.y = 0;
rect.lr.x = rect.lr.y = 0;

PhEventEmit (event, &rect, (PhPointerEvent_t *) PointerEvent);

return 0;
}

but this is not working, it is not emitting pointer event. mouse clicks are
not taken by any application running in the system.

what is wrong with this code ?

can anybody help me in this ?

thanks in advance

sameer


Wojtek Lerch QNX Software Systems Ltd.

hi Wojtek Lerch,
thanks for your reply,

i have found the problem :slight_smile: , but i do not have the solution :frowning:

this is problem
when we release the mouse button, multiple mouse release events get
fired, out of these multipe mouse release events the last mouse release
event is Ph_EV_RELEASE_ENDCLICK.

application call ACTIVATE callback only after this ENDCLICK event is
received. and for mouse release event DISARM callback is called.

so with my transparent region program and my test app. i found that the
test application is receiving the mouse button release event and it is
calling the DISARM callback. but it is not receiving ENDCLICK event, that is
why it is not calling ACTIVATE callback.

now in my region program i have written separate function for
re-emitting the pointer events, which i have given in my earlier post. this
function is getting called for emitting all pointer events.

why only the ENDCLICK event is not re-emitting or not receiving by the other
application ?

how the ENDCLICK event is diffrenet from other mouse button release event ?

please help…

thanks in advance

sameer

sam <seto@vsnl.com> wrote:

hi Wojtek Lerch,
thanks for your reply,

i have found the problem > :slight_smile: > , but i do not have the solution > :frowning:

this is problem
when we release the mouse button, multiple mouse release events get
fired, out of these multipe mouse release events the last mouse release
event is Ph_EV_RELEASE_ENDCLICK.

Yes. Except the Ph_EV_RELEASE_ENDCLICK is generated up to 250ms after
the release, and only if you don’t click again within that time. The
purpose of the ENDCLICK event is to tell you that Photon has decided
that the click you received recently is not going to be considered the
first click of a double-click (or the second click of a triple-click,
and so on) even if the person clicks again very soon. In other words,
it tells you that the click_count has stopped incrementing and will
start counting from one the next time a button is pressed.

application call ACTIVATE callback only after this ENDCLICK event is
received. and for mouse release event DISARM callback is called.

No. The library calls the ACTIVATE callback if it sees a REAL release
while the button is armed.

When you release a button, Photon sends two release events: a REAL one
and a PHANTOM one. The REAL one is sent where the mouse currently
points to, whereas the PHANTOM one goes where the last PRESS was sent
to. The REAL release causes buttons to call the ACTIVATE callback, but
only if the button is still armed; the PHANTOM causes the button to
disarm itself. This way, if you press on one button, then move to
another button, and then release, neither button gets activated.

so with my transparent region program and my test app. i found that the
test application is receiving the mouse button release event and it is
calling the DISARM callback. but it is not receiving ENDCLICK event, that is
why it is not calling ACTIVATE callback.

I think you’re confusing the REAL release with the ENDCLICK.

now in my region program i have written separate function for
re-emitting the pointer events, which i have given in my earlier post. this
function is getting called for emitting all pointer events.

why only the ENDCLICK event is not re-emitting or not receiving by the other
application ?

how the ENDCLICK event is diffrenet from other mouse button release event ?

The ENDCLICK is normally ignored by widgets.

The REAL release is different for the other releases in that it’s
rectangle doesn’t necessarily match the current position of the mouse.
But when it’s an application rather than Photon that emits them, Photon
threats them the same way.

hi Wojtek Lerch,

thank you for quick and valuable information,

it looks like am i am still stuck with mouse pointer event re-emit. where
can i find some examples or code of mouse pointer emitting ?

thank you for your support

sameer

sam <seto@vsnl.com> wrote:

it looks like am i am still stuck with mouse pointer event re-emit. where
can i find some examples or code of mouse pointer emitting ?

I don’t know of anything I could point you at.

But if your code doesn’t work even of you’re just trying to re-emit
those events without modifying them, here’s how you could try to find
out what you’re forgetting to do:

Make your event-catching region transparent to pointer events.

Put up another event-catching region right behind the first one.
Make it big and sensitive to pointer events. In this region’s
callback, just print out all the contents of any received event,
including the emitter region ID. Save this log to a file.

Compare the original events (emitted from region 1) to your
re-emitted ones (emitted from the first region). Check if any are
missing, or have wrong rectangles, pointer positions, etc. Keep in
mind that Photon compresses certain events – a few motion events
can be merged into one if there are no presses or releases between
them.