Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get current X11 server time

Tags:

c

time

x11

xlib

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.

like image 709
orlp Avatar asked May 17 '20 09:05

orlp


2 Answers

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.

like image 181
Domenico Shura Avatar answered Nov 06 '22 10:11

Domenico Shura


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.

like image 26
Vladimir Panteleev Avatar answered Nov 06 '22 11:11

Vladimir Panteleev