orlp
orlp

Reputation: 117846

Get current X11 server time

Using Xlib, can we query the current X server time? With that I mean the value that would be returned in the time field of an XEvent if we were to receive an event right now.

Preferably without opening any windows.

Upvotes: 7

Views: 1188

Answers (2)

Vladimir Panteleev
Vladimir Panteleev

Reputation: 25197

The approach suggested by Andreas is also recommended by the ICCCM specification:

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. A zero-length append to a property is a way to obtain a timestamp for this purpose; the timestamp is in the corresponding PropertyNotify event.

Upvotes: 1

Domenico Shura
Domenico Shura

Reputation: 31

Maybe this is what you was searching for:

The only system counter that is guaranteed to be present is called SERVERTIME, which counts milliseconds from some arbitrary starting point. The least significant 32 bits of this counter track the value of Time used by the server in Events and Requests. Other system counters may be provided by different implementations of the extension. The X Consortium will maintain a registry of system counter names to avoid collisions in the name space.

Upvotes: 1

Related Questions