Motif/Xt: Trigger reconfiguration of a widget

Holger Sebert holger.sebert at
Thu Oct 28 22:07:54 UTC 2021

On 10/28/21 09:09, Marc Balmer wrote:
>> I am working on Motif code, so please excuse if this mailing list is
>> not the right place for asking my question, but since Motif is based on
>> libXt, I thought I'll give it a try. --
>> I would like to add and remove CascadeButtons dynamically to and from
>> a menubar (a.k.a RowColumn widget).
>> For each addition of a button I create a completely new menubar
>> containing the button(s) to be added and set it in the MainWindow via:
>>     XtVaSetValues(main_window, XmNmenuBar, new_menubar, NULL);
>> The good news is that the program does not crash :) but the menubar is
>> not updated either. Only when I resize the application window does the
>> menubar get updated and displays the new button(s).
>> So my question is: How can I trigger the reconfiguration of a widget's
>> geometry without having to resize the main window?
> The XmUpdateDisplay() function does exactly this.  Call it with the top level widget as parameter.

Thanks for the hint! Calling XmUpdateDisplay() did not have the desired
effect, however.

It turned out that I have to explicitly do an XtDestroyWidget() on the
old menubar before setting the new one (which I had not yet done). It
seems like -- if you don't do this -- the MainWindow widget keeps a
reference of the old menubar somehow still around, even though it should
have been overwritten by XtVaSetValues(XmNmenuBar).


More information about the xorg mailing list