Re: XForms: Problems resizing form containing a gl_canvas

From: spl@ncmir.ucsd.edu
Date: Fri Mar 08 2002 - 17:55:19 EST


# To subscribers of the xforms list from spl@ncmir.ucsd.edu :

> Here is some test code that displays the problem
> I see. I have checked this with both KDE and Gnome
> window managers and it shows up in both - so I wonder
> again if the problem is related to the Linux version
> of the form library.

In this particular case the ConfigureNotify event is getting delivered
but appears that there's an extraneous call to your function
DisplayImage():

        void ChgSize::OnZoom()
        {
            nXSize = nZoom*200;
            nYSize = nZoom*200;
            fprintf( stderr, "Zoom = %d\n", nZoom );
            fl_freeze_form(Form());
            int cx, cy, cw, ch;
            fl_get_wingeometry(window,&cx, &cy, &cw, &ch);
            fprintf( stderr,
                     "Window geometry before Zoom: x = %d, y = %d, w = %d, h = %d\n",
                     cx, cy, cw, ch );
            fl_get_object_geometry(chgsize->canvas,&cx, &cy, &cw, &ch);
            fprintf( stderr,
                     "Canvas geometry before Zoom: x = %d, y = %d, w = %d, h = %d\n",
                     cx, cy, cw, ch);
            fl_set_form_size( Form(), nXSize, nYSize);
            fl_get_wingeometry(window,&cx, &cy, &cw, &ch);
            fl_unfreeze_form(Form());
            bZoom = true;
        // glViewport(0, 0, nXSize -1 , nYSize -1);
        // DisplayImage();
        }

Commenting it out makes the problem go away.

Further investigation shows that while in its guts fl_set_form_size()
calls XResizeWindow() and XFlush(), the window actually is not resized
immediately, so OpenGL and X are probably in disagreement as to the
geometry of the windows.

Adding a little delay allows your original code to work:

            fl_set_form_size( Form(), nXSize, nYSize);
            fl_unfreeze_form(Form());
            do {
        
              fl_check_forms();
              fl_get_wingeometry(window,&cx, &cy, &cw, &ch);
        
            } while ( ( cw != nXSize ) || ( ch != nYSize ) );
            bZoom = true;
            glViewport(0, 0, nXSize -1 , nYSize -1);
            DisplayImage();

However, I think the best tack here is to let the events propagate
"naturally."

                                                        spl
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuhs.mil or see
http://bob.usuhs.mil/mailserv/xforms.html
XForms Home Page: http://world.std.com/~xforms
List Archive: http://bob.usuhs.mil/mailserv/list-archives/



This archive was generated by hypermail 2b29 : Wed May 01 2002 - 13:54:16 EDT