From: envbvs@epb9.lbl.gov (Brian V. Smith)
Newsgroups: comp.windows.x
Subject: command button stays in reverse video after popping up widget
Keywords: X11R5
Date: 9 Apr 92 18:44:45 GMT
Article-I.D.: dog.22606
Organization: lbl
NNTP-Posting-Host: 128.3.12.98

I have a box widget that contains several command widgets, each of which
can popup a widget.  When the command widget was clicked upon, it would
go to reverse video to show that it was selected, but then go
back to normal video, after which the  was popped up.
This worked fine under R4.

However, when I compile it against the R5 libraries and you click
on the command widget it STAYS in reverse video forever.  Even after
the popup menu is dismissed.

Another user has noticed this problem.
Here is the (greatly reduced) code. 
Has anyone else seen this problem?
By the way,  if I don't have the command widget popup the popup then
it doesn't say in reverse video.

-- 
Brian V. Smith    (bvsmith@lbl.gov)
Lawrence Berkeley Laboratory
I don't speak for LBL; they don't pay me enough for that.

stand-alone code follows:

#include <stdio.h>
#include <sys/types.h>
#include <ctype.h>
#include <errno.h>
#include <X11/Xlib.h>
#include <X11/cursorfont.h>
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/Shell.h>
#include <X11/Xatom.h>
#include <X11/Xaw/Command.h>
#include <X11/Xaw/Label.h>
#include <X11/Xaw/Box.h>
#include <X11/Xaw/Form.h>
#include <X11/Xaw/Toggle.h>

#include "assert.h"

#define ArgCount	_fooArgCount
#define Args		_fooArgList
#define ArgCountMax	_fooArgCountMax

#define DeclareArgs(n)	Arg Args[n]; int ArgCountMax = n; int ArgCount

#define DeclareStaticArgs(n)  static Arg Args[n]; static int ArgCountMax = n; static int ArgCount

#define FirstArg(name, val) \
	{ XtSetArg(Args[0], (name), (val)); ArgCount=1;}
#define NextArg(name, val) \
	{ assert(ArgCount < ArgCountMax); \
	  XtSetArg(Args[ArgCount], (name), (val)); ArgCount++;}
#define GetValues(n)	XtGetValues(n, Args, ArgCount)
#define SetValues(n)	XtSetValues(n, Args, ArgCount)

XtAppContext tool_app;
Widget	tool,
	ind_panel,
	updbut,
	choice_popup,
	button;

/* button selection event handler */
static void     sel_ind_but();

DeclareArgs(10);

static void
note_state(w, sw, event)
    Widget	    w;
    caddr_t	   *sw;
    XButtonEvent   *event;
{
    if (event->button != Button1)
	return;
    fprintf(stderr,"Update button pressed\n");
}

main(argc,argv)
int	argc;
char	*argv[];
	{
	tool = XtAppInitialize(&tool_app, (String) "Hello", (XrmOptionDescList) NULL,
		(Cardinal) 0,&argc,argv,
		(String *) NULL,(ArgList) NULL,(Cardinal) 0);

	FirstArg(XtNwidth, 300);
	NextArg(XtNheight, 100);
	ind_panel = XtCreateManagedWidget("ind_panel", boxWidgetClass, tool,
					   Args, ArgCount);

	FirstArg(XtNwidth, 50);
	NextArg(XtNheight, 20);
	updbut = XtCreateManagedWidget("update", toggleWidgetClass,
			     ind_panel, Args, ArgCount);
	XtAddEventHandler(updbut, ButtonReleaseMask, (Boolean) 0,
			     note_state, (caddr_t) NULL);
	/* now create the command button */
	FirstArg(XtNwidth, 100);
	NextArg(XtNheight, 50);
	button = XtCreateManagedWidget("button", commandWidgetClass,
			     ind_panel, Args, ArgCount);

	/* allow left & right buttons */
	/* (callbacks pass same data for ANY button) */
	XtAddEventHandler(button, ButtonReleaseMask, (Boolean) 0,
			  sel_ind_but, (caddr_t) NULL);
	XtRealizeWidget(tool);
	XtAppMainLoop(tool_app);
	}

static void popup_choice_panel();

/* come here when a button is pressed in the indicator panel */

static void
sel_ind_but(widget, isw, event)
    Widget	    widget;
    caddr_t	   *isw;
    XButtonEvent   *event;
{
    if (event->button == Button3) {	/* right button */
	fprintf(stderr,"Increment\n");
    } else if (event->button == Button2) {	/* middle button */
	fprintf(stderr,"Decrement\n");
    } else {			/* left button */
	fprintf(stderr,"Popup\n");
	popup_choice_panel();
    }
}

static void
choice_panel_dismiss()
{
    XtDestroyWidget(choice_popup);
    XtSetSensitive(ind_panel, True);
}

static void
choice_panel_cancel(w, ev)
    Widget	    w;
    XButtonEvent   *ev;
{
    choice_panel_dismiss();
}

static void
popup_choice_panel()
{
    Widget	label,form,cancel,beside;

    XtSetSensitive(ind_panel, False);

    FirstArg(XtNx, 400);
    NextArg(XtNy, 200);
    NextArg(XtNresize, False);
    NextArg(XtNresizable, False);
    NextArg(XtNtitle, "Xfig: Set indicator panel");

    choice_popup = XtCreatePopupShell("xfig_set_indicator_panel",
				      transientShellWidgetClass, tool,
				      Args, ArgCount);

    form = XtCreateManagedWidget("form", formWidgetClass, choice_popup, NULL, 0);

    FirstArg(XtNborderWidth, 0);
    label = XtCreateManagedWidget("Menu choices", labelWidgetClass, form, Args, ArgCount);

    FirstArg(XtNlabel, "cancel");
    NextArg(XtNfromVert, label);
    NextArg(XtNresize, False);
    NextArg(XtNresizable, False);
    NextArg(XtNheight, 20);
    NextArg(XtNborderWidth, 3);
    cancel = XtCreateManagedWidget("cancel", commandWidgetClass,
				   form, Args, ArgCount);
    XtAddEventHandler(cancel, ButtonReleaseMask, (Boolean) 0,
		      (XtEventHandler)choice_panel_cancel, (XtPointer) NULL);

    XtPopup(choice_popup, XtGrabExclusive);
}
Newsgroups: comp.windows.x