MCPcopy Create free account
hub / github.com/Kitware/VTK / WaitForEvents

Method WaitForEvents

Rendering/UI/vtkXRenderWindowInteractor.cxx:284–337  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

282
283//------------------------------------------------------------------------------
284void vtkXRenderWindowInteractor::WaitForEvents()
285{
286 bool useTimeout = false;
287 int soonestTimer = 0;
288
289 // check to see how long we wait for the next timer
290 for (auto rwi : vtkXRenderWindowInteractorInternals::Instances)
291 {
292 if (rwi->Done)
293 {
294 continue;
295 }
296
297 int t;
298 bool haveTimer = rwi->Internal->GetTimeToNextTimer(t);
299 if (haveTimer)
300 {
301 if (!useTimeout)
302 {
303 useTimeout = true;
304 soonestTimer = t;
305 }
306 else
307 {
308 soonestTimer = std::min(soonestTimer, t);
309 }
310 }
311 }
312
313 // build the list of unique display connection fds to poll
314 std::vector<pollfd> in_fds;
315 for (auto rwi : vtkXRenderWindowInteractorInternals::Instances)
316 {
317 if (!rwi->Done && rwi->RenderWindow->GetGenericDisplayId() != nullptr)
318 {
319 int rwi_fd = rwi->Internal->DisplayConnection;
320 auto iter = std::lower_bound(in_fds.begin(), in_fds.end(), rwi_fd,
321 [](const pollfd& pfd, const int& fd) { return pfd.fd < fd; });
322
323 if (iter == in_fds.end() || iter->fd != rwi_fd)
324 {
325 in_fds.insert(iter, { rwi_fd, POLLIN, 0 });
326 }
327 }
328 }
329
330 if (!in_fds.empty())
331 {
332 // poll() will wait until timeout elapses or something else wakes us
333 int timeout = useTimeout ? soonestTimer : -1;
334 vtkDebugMacro(<< "X event wait, timeout=" << timeout << "ms");
335 poll(in_fds.data(), static_cast<nfds_t>(in_fds.size()), timeout);
336 }
337}
338
339//------------------------------------------------------------------------------
340// This will start up the X event loop. If you

Callers 1

StartEventLoopMethod · 0.95

Calls 9

GetTimeToNextTimerMethod · 0.80
minFunction · 0.50
GetGenericDisplayIdMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
insertMethod · 0.45
emptyMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected