Where to get timestamp for selection?

Yann Droneaud ydroneaud at mandriva.com
Fri Feb 26 01:06:41 PST 2010

Le vendredi 26 février 2010 à 13:39 +0800, Zhang, Xing Z a écrit :
> Hello experts:
>          ICCCM said “Clients attempting to acquire a selection must
> set the time value of the SetSelectionOwner 
> request to the timestamp of the event triggering the acquisition
> attempt, not to CurrentTime”. In my simple
> code, there is no event happen before SetSelectionOwner, how can I get
> the timestamp? I didn’t see a function
> used to require timestamp in Xlib, so I have to trigger an event just
> for getting timestamp?
>          I see in MetaCity, there is a PropModeReplace event prior to
> SetSelectionOwner. If I have to produce an event
> by myself, what’s event usually used?

The timestamp usually come from a ButtonEvent or KeyPressEvent, any
event linked to the user's action which creates the selection.
Selection shouldn't come from the ether, and that's why ICCCM forbid
CurrentTime usage.

For a test, you could could use the trick, from gtk,

  XChangeProperty (xdisplay, xwindow, timestamp_prop_atom,
                   8, PropModeReplace, &c, 1);

  XIfEvent (xdisplay, &xevent,
            timestamp_predicate, GUINT_TO_POINTER(xwindow));

That should be the trick used by Metacity.

>          I am not sure if there is a maillist for X newbie, if I post
> to wrong place, pls kindly direct me to right room.

In the future, you should ask on xorg at freedesktop.org instead of
xorg-devel at lists.x.org.


Yann Droneaud

More information about the xorg mailing list