Bug in geometry management?

Hello,
I am a beginner in motif but I have noticed a strange behaviour with a widget manager and I would like to know if somebody has already noticed it.
So I would like to control the visibility of some widget by using buttons. The idea is the following one: three forms which contain label widget (labels 1, 2 and 3), and two buttons which control the visibility of labels 1 and 2. The button 1 toggles the visibility of label 1, and so on.
The visibility is controlled by managing or unmanaging the forms.

So I create a top level shell which contains one form widget (called the_form in the code below). This form contains two forms, main_form and buttons_form. The widget buttons_form contains the two buttons.
The form main_form contains three forms which are attached together (form1, form2 and form3). The main_form is not resizable. Each of the three forms contains another form (text_form1, text_form2 and text_form3) which contains a label (label1, label2 and label3). If I want to hide the label1, I unmanage the text_form1. The main_form is not resizable so the forms which remain visible are resized in order to take the free space left by invisible forms.

The problem appears when we do the following sequence: click button1 (the text_form1 disappears, text_form2 and text_form3 are resized correctly), click button2 (text_form2 disappears, test_form3 is resized correctly) and then click button 1. Normally the text_form1 should appear and text_form3 should resize to let enough space to text_form1. But text_form3 does not resize and text_form1 has not enough space to be visible.

I would like to know if it is a true bug or a mistake in the code.
Any idea? Do I make any error in my code?

Thank you very much

This is my piece of code:

#include
#include
#include

#include
#include
#include

int main(argc, argv)
char *argv[];
{
Widget toplevel, the_form;
Widget main_form, buttons_form;
Widget form1, form2, form3;
Widget text_form1, text_form2, text_form3;
Widget label1, label2, label3;
Widget button1, button2;

XmString str1 = XmStringCreateLocalized ("Form 1");
XmString str2 = XmStringCreateLocalized ("Form 2");
XmString str3 = XmStringCreateLocalized ("Form 3");

void button1_callback(w, client_data, call_data)
Widget w;
XtPointer client_data;
XtPointer call_data;
{
if (XtIsManaged(text_form1) == True)
XtUnmanageChild(text_form1);
else
XtManageChild(text_form1);
}

void button2_callback(w, client_data, call_data)
Widget w;
XtPointer client_data;
XtPointer call_data;
{
if (XtIsManaged(text_form2) == True)
XtUnmanageChild(text_form2);
else
XtManageChild(text_form2);
}

XtAppContext app;

XtSetLanguageProc (NULL, NULL, NULL);

toplevel = XtVaAppInitialize (&app, "TestForm", NULL, 0, &argc, argv, NULL, NULL);

XtVaSetValues (toplevel,
XmNwidth, 200,
XmNheight, 100,
NULL);

the_form = XtVaCreateManagedWidget ("the_form", xmFormWidgetClass, toplevel,
XmNtopAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_FORM,
NULL);

main_form = XtVaCreateManagedWidget ("main_form", xmFormWidgetClass, the_form,
XmNtopAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM,
NULL);

buttons_form = XtVaCreateManagedWidget ("buttons_form", xmFormWidgetClass, the_form,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, main_form,
XmNleftAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_FORM,
NULL);

form1 = XtVaCreateManagedWidget ("form1", xmFormWidgetClass, main_form,
XmNtopAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM,
NULL);

form2 = XtVaCreateManagedWidget ("form2", xmFormWidgetClass, main_form,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, form1,
XmNleftAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_FORM,
NULL);

form3 = XtVaCreateManagedWidget ("form3", xmFormWidgetClass, main_form,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, form1,
XmNleftAttachment, XmATTACH_WIDGET,
XmNleftWidget, form2,
XmNrightAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_FORM,
NULL);

text_form1 = XtVaCreateManagedWidget ("text_form1", xmFormWidgetClass, form1,
XmNtopAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_FORM,
NULL);

text_form2 = XtVaCreateManagedWidget ("text_form2", xmFormWidgetClass, form2,
XmNtopAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_FORM,
NULL);

text_form3 = XtVaCreateManagedWidget ("text_form3", xmFormWidgetClass, form3,
XmNtopAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_FORM,
NULL);

label1 = XtVaCreateManagedWidget ("label1", xmLabelWidgetClass, text_form1,
XmNlabelString, str1,
XmNtopAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_FORM,
NULL);

label2 = XtVaCreateManagedWidget ("label2", xmLabelWidgetClass, text_form2,
XmNlabelString, str2,
XmNtopAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_FORM,
NULL);

label3 = XtVaCreateManagedWidget ("label3", xmLabelWidgetClass, text_form3,
XmNlabelString, str3,
XmNtopAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_FORM,
NULL);

button1 = XtVaCreateManagedWidget ("button1", xmPushButtonWidgetClass, buttons_form,
XmNlabelString, str1,
XmNtopAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_FORM,
NULL);

XtVaSetValues (button1,
XmNwidth, 100,
NULL);

XtAddCallback (button1, XmNactivateCallback, button1_callback, NULL);

button2 = XtVaCreateManagedWidget ("button2", xmPushButtonWidgetClass, buttons_form,
XmNlabelString, str2,
XmNtopAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_WIDGET,
XmNleftWidget, button1,
XmNrightAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_FORM,
NULL);

XtAddCallback (button2, XmNactivateCallback, button2_callback, NULL);

XtRealizeWidget (toplevel);

XtVaSetValues (main_form,
XmNresizable, False,
NULL );

XtAppMainLoop (app);
return(0);
}