MCPcopy Create free account
hub / github.com/deskflow/deskflow / getCurrentTime

Method getCurrentTime

src/lib/platform/XWindowsUtil.cpp:148–180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

146}
147
148Time XWindowsUtil::getCurrentTime(Display *display, Window window)
149{
150 XLockDisplay(display);
151 // select property events on window
152 XWindowAttributes attr;
153 XGetWindowAttributes(display, window, &attr);
154 XSelectInput(display, window, attr.your_event_mask | PropertyChangeMask);
155
156 // make a property name to receive dummy change
157 Atom atom = XInternAtom(display, "TIMESTAMP", False);
158
159 // do a zero-length append to get the current time
160 unsigned char dummy;
161 XChangeProperty(display, window, atom, XA_INTEGER, 8, PropModeAppend, &dummy, 0);
162
163 // look for property notify events with the following
164 PropertyNotifyPredicateInfo filter;
165 filter.m_window = window;
166 filter.m_property = atom;
167
168 // wait for reply
169 XEvent xevent;
170 XIfEvent(display, &xevent, &XWindowsUtil::propertyNotifyPredicate, (XPointer)&filter);
171 assert(xevent.type == PropertyNotify);
172 assert(xevent.xproperty.window == window);
173 assert(xevent.xproperty.atom == atom);
174
175 // restore event mask
176 XSelectInput(display, window, attr.your_event_mask);
177 XUnlockDisplay(display);
178
179 return xevent.xproperty.time;
180}
181
182std::string XWindowsUtil::atomToString(Display *display, Atom atom)
183{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected