| 226 | } |
| 227 | |
| 228 | void vtkXRenderWindowInteractor::ProcessEvents() |
| 229 | { |
| 230 | auto& internals = (*this->Internal); |
| 231 | auto& done = internals.LoopDone; |
| 232 | |
| 233 | std::map<Window, vtkXRenderWindowInteractor*> windowmap; |
| 234 | std::set<Display*> dpys; |
| 235 | // Make a copy of Instances, the original set might change during loop |
| 236 | std::vector<vtkXRenderWindowInteractor*> instances( |
| 237 | vtkXRenderWindowInteractorInternals::Instances.begin(), |
| 238 | vtkXRenderWindowInteractorInternals::Instances.end()); |
| 239 | for (auto rwi : instances) |
| 240 | { |
| 241 | if (rwi->RenderWindow->GetGenericDisplayId() == nullptr) |
| 242 | { |
| 243 | // The window has closed the display connection |
| 244 | rwi->Finalize(); |
| 245 | continue; |
| 246 | } |
| 247 | windowmap.insert({ rwi->WindowId, rwi }); |
| 248 | dpys.insert(rwi->DisplayId); |
| 249 | } |
| 250 | |
| 251 | for (Display* dpy : dpys) |
| 252 | { |
| 253 | XEvent event; |
| 254 | while (this->CheckDisplayId(dpy) && vtkXPending(dpy) != 0) |
| 255 | { |
| 256 | // If events are pending, dispatch them to the right RenderWindowInteractor |
| 257 | vtkXNextEvent(dpy, &event); |
| 258 | Window w = event.xany.window; |
| 259 | auto iter = windowmap.find(w); |
| 260 | if (iter != windowmap.end() && !iter->second->Done) |
| 261 | { |
| 262 | iter->second->DispatchEvent(&event); |
| 263 | iter->second->FireTimers(); |
| 264 | } |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | // Set event loop to terminate if there were no displays to check for events |
| 269 | done = dpys.empty(); |
| 270 | |
| 271 | for (auto rwi : vtkXRenderWindowInteractorInternals::Instances) |
| 272 | { |
| 273 | if (!rwi->Done) |
| 274 | { |
| 275 | rwi->FireTimers(); |
| 276 | } |
| 277 | // Set event loop to terminate if SetDone(true) or TerminateApp() was |
| 278 | // called on any of the interactors |
| 279 | done = done || rwi->Done; |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | //------------------------------------------------------------------------------ |
| 284 | void vtkXRenderWindowInteractor::WaitForEvents() |
no test coverage detected