Commit 3a982ec8 authored by Dan Lipsa's avatar Dan Lipsa

Replace busy waiting.

parent c9fa0226
......@@ -425,16 +425,16 @@ void vtkXOpenGLRenderWindow::SetShowWindow(bool val)
vtkDebugMacro(" Mapping the xwindow\n");
XMapWindow(this->DisplayId, this->WindowId);
XSync(this->DisplayId,False);
XWindowAttributes winattr;
XGetWindowAttributes(this->DisplayId,
this->WindowId,&winattr);
// guarantee that the window is mapped before the program continues
// on to do the OpenGL rendering.
while (winattr.map_state == IsUnmapped)
while(true)
{
XGetWindowAttributes(this->DisplayId,
this->WindowId,&winattr);
XSync(this->DisplayId,False);
XEvent e;
XNextEvent(this->DisplayId, &e);
if (e.type == MapNotify)
{
break;
}
}
this->Mapped = 1;
}
......@@ -443,16 +443,14 @@ void vtkXOpenGLRenderWindow::SetShowWindow(bool val)
vtkDebugMacro(" UnMapping the xwindow\n");
XUnmapWindow(this->DisplayId, this->WindowId);
XSync(this->DisplayId,False);
XWindowAttributes winattr;
XGetWindowAttributes(this->DisplayId,
this->WindowId,&winattr);
// guarantee that the window is mapped before the program continues
// on to do the OpenGL rendering.
while (winattr.map_state != IsUnmapped)
while(true)
{
XGetWindowAttributes(this->DisplayId,
this->WindowId,&winattr);
XSync(this->DisplayId,False);
XEvent e;
XNextEvent(this->DisplayId, &e);
if (e.type == UnmapNotify)
{
break;
}
}
this->Mapped = 0;
}
......@@ -1004,23 +1002,15 @@ void vtkXOpenGLRenderWindow::SetSize(int width,int height)
static_cast<unsigned int>(width),
static_cast<unsigned int>(height));
// this is an async call so we wait until we
// know it has been resized. To avoid infinite
// loops we put in a count limit just to be safe
XWindowAttributes attribs;
int count = 20000;
do
// know it has been resized.
while(true)
{
XSync(this->DisplayId,False);
// Find the current window size
XGetWindowAttributes(this->DisplayId,
this->WindowId, &attribs);
count--;
}
while (count && (attribs.width != width || attribs.height != height));
if (!count)
{
vtkWarningMacro("warning window did not resize in the allotted time");
XEvent e;
XNextEvent(this->DisplayId, &e);
if (e.type == ConfigureNotify)
{
break;
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment