Commit 4ebafa92 authored by Chris Harris's avatar Chris Harris Committed by Code Review
Browse files

Merge topic 'xresize-notify' into master

39fedcd6 Wait for resize notification in SetSize(...)
parents 86a5dad4 39fedcd6
......@@ -496,6 +496,16 @@ extern "C"
}
}
static int XResizeWindowFailed = 0;
extern "C"
{
int vtkXResizeWindowErrorHandler(Display*, XErrorEvent*)
{
XResizeWindowFailed = 1;
return 1;
}
}
void vtkXOpenGLRenderWindow::CreateAWindow()
{
XVisualInfo *v, matcher;
......@@ -1189,6 +1199,10 @@ void vtkXOpenGLRenderWindow::SetSize(int width,int height)
{
if ((this->Size[0] != width)||(this->Size[1] != height))
{
int previousWidth = this->Size[0];
int previousHeight = this->Size[1];
this->Size[0] = width;
this->Size[1] = height;
......@@ -1203,10 +1217,33 @@ void vtkXOpenGLRenderWindow::SetSize(int width,int height)
}
else if(this->WindowId && this->Mapped)
{
// First set error handler so we can tell if the resize failed
XErrorHandler previousHandler = XSetErrorHandler(vtkXResizeWindowErrorHandler);
XResizeWindow(this->DisplayId,this->WindowId,
static_cast<unsigned int>(width),
static_cast<unsigned int>(height));
XSync(this->DisplayId,False);
// XSync is not enough we need to wait for notification that a resize
// has occurred.
while (!XResizeWindowFailed)
{
XEvent e;
XMaskEvent(this->DisplayId, StructureNotifyMask, &e);
if(e.type == ConfigureNotify)
{
XConfigureEvent xce = e.xconfigure;
if (xce.width != previousWidth || xce.height != previousHeight)
{
break;
}
}
}
XSetErrorHandler(previousHandler);
XResizeWindowFailed = 0;
}
this->Modified();
......
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