add/remove Title bar at run time

This forum is read only. No new submissions are accepted.

Questions about motif? Contact us

3 posts / 0 new
Last post
add/remove Title bar at run time

Submitted by orank on Thu, 08/01/2002 - 18:59. Developers
Hi ,

I am manipulating the decorations of a window at run time,
I need to add a title bar when the mouse moves over the window and remove the title bar when the mouse leaves the window area.
I am using
XtAddEventHandler(widg,EnterWidnowMask | LeaveWindowMask, False, my_focus_function,NULL);
To register to the needed event.
Here is the focus callback
static void my_focus_function (w, client_data, event)
Widget w;
caddr_t client_data;
XCrossingEvent *event;
{
if ( event->type == EnterNotify ) {
add_title_bar(w);
}
else if ( event->type == LeaveNotify ) {
remove_title_bar(w);
}
}

now the 2 title bar functions
static void add_title_bar(Widget w)
{
/* set the window to have border and title bar (with top left menu) */
XtVaSetValues(w,
XmNmwmDecorations, (MWM_DECOR_BORDER | MWM_DECOR_TITLE | MWM_DECOR_MENU),
NULL);
/* need to refresh the dialog for the change to take effect */
XtUnmapWidget(w);
XtMapWidget(w);
}

static void remove_title_bar(Widget w)
{
/* set the window to have only borders */
XtVaSetValues(w,
XmNmwmDecorations, MWM_DECOR_BORDER,
NULL);
/* need to refresh the dialog for the change to take effect */
XtUnmapWidget(w);
XtMapWidget(w);
}

My problem is that the window starts to jitter like crazy it flickers because the unmap and map cause a endless amount of callbacks.
But if I remove the unmap and map the title bar is not changed.

What can I do ?
How can I make the change to the title bar take effect without the upmap and map, or how can I stop the endless event activation ?

Hope someone can help
Thanks
oran

ICS_support

1) I suspect that this is hard on the user, even if it works the way you want. The window suddenly appears different and possibly in a different location.

2) The effect works only with mwm and derivatives.

3) If it is really necessary to unmap and remap the widget -- and I believe mwm should not need that extra action -- then you are likely to get the same result by unmanaging and remanaging the dialog instead of unmapping it.

4) To avoid the infinite loop, simply save state i.e. in the add_title_bar() function, set globalEnumeration=ADDING_STUFF_NOW and in remove_title_bar(), check for that flag before doing anything.

orank

Thank you DBL ,

You were right , my project manager found this solution ugly and it was canceled.
But it was a good chance for me to learn more about event handling in X.
Thanks.