Bug type: Visual

machine: x386 running redhat 6.2
LessTif 0.91.4, Xm-2.0 widgets

The problem is described in the comment of the example.

This is a bit of a problem for the application I've developed, as this
has a lot of TextF widgets, it creates a lot of windows that people
bring
to the foreground and background all the time. They quickly end up with
a lot of blinking cursors in several TextF widgets, even though they
don't have focus.

This problem doesn't show up in OpenMotif.

Mogens
-- 
Mogens Kjaer, Carlsberg Laboratory, Dept. of Chemistry
Gamle Carlsberg Vej 10, DK-2500 Valby, Denmark
Phone: +45 33 27 53 25, Fax: +45 33 27 47 08
Email: [EMAIL PROTECTED] Homepage: http://www.crc.dk
/*

        This demonstrates a focus problem in LessTif 0.91.4

        Start the application, put another window on top of it (e.g. an xterm).

        Send this other window in the background using Alt-F3 (depends
        upon your WM) so that your mouse cursor appears on one of
        the TextF widgets. FocusIn gets called, but the window doesn't have focus!

        Move the mousecursor to the other TextF widget, press Alt-F3 twice so that
        the other window gets on top and behind again. Now you have TWO TextF widgets
        with blinking cursors - but none of them have focus!

        [EMAIL PROTECTED]
*/

#include <stdio.h>

#include <Xm/Xm.h>
#include <Xm/TextF.h>
#include <Xm/Form.h>
#include <Xm/PushB.h>

static int n;
static Arg wargs[1000];
static Widget toplevel, form, editor1, editor2, quit;

void quit_callback(Widget w, caddr_t client_data, caddr_t user_data)
{
  exit(0);
}

void activate_callback(Widget w, char *name, XmAnyCallbackStruct *reason)
{
  printf("XmNactivateCallback called for %s.\n", name);
  printf("  editor contains: '%s'\n", XmTextFieldGetString(w));
}

void focus_callback(Widget w, char *name, XmAnyCallbackStruct *reason)
{
  printf("XmNfocusCallback called for %s.\n", name);
  printf("  editor contains: '%s'\n", XmTextFieldGetString(w));
}

void losingfocus_callback(Widget w, char *name, XmAnyCallbackStruct *reason)
{
  printf("XmNlosingfocusCallback called for %s.\n", name);
  printf("  editor contains: '%s'\n", XmTextFieldGetString(w));
}

void valuechanged_callback(Widget w, char *name, XmAnyCallbackStruct *reason)
{
  printf("XmNvalueChangedCallback called for %s.\n", name);
  printf("  editor contains: '%s'\n", XmTextFieldGetString(w));
}

main(int argc, char *argv[])
{
  n=0;
  toplevel=XtInitialize("e12", "E12", (XrmOptionDescRec *) wargs, n, &argc, argv);

  n=0;
  form=XtCreateManagedWidget("form", xmFormWidgetClass, toplevel, wargs, n);

  n=0;
  XtSetArg(wargs[n], XmNtopAttachment, XmATTACH_FORM); n++;
  XtSetArg(wargs[n], XmNleftAttachment, XmATTACH_FORM); n++;
  XtSetArg(wargs[n], XmNlabelString, XmStringCreateSimple("Quit")); n++;
  quit=XtCreateManagedWidget("quit", xmPushButtonWidgetClass, form, wargs, n);
  XtAddCallback(quit, XmNactivateCallback, (XtCallbackProc) quit_callback, NULL);

  n=0;
  XtSetArg(wargs[n], XmNleftAttachment, XmATTACH_FORM); n++;
  XtSetArg(wargs[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  XtSetArg(wargs[n], XmNtopWidget, quit); n++;
  XtSetArg(wargs[n], XmNcolumns, 10); n++;
  XtSetArg(wargs[n], XmNvalue, "0"); n++;
  editor1=XtCreateManagedWidget("editor1", xmTextFieldWidgetClass, form, wargs, n);
  XtAddCallback(editor1, XmNactivateCallback, (XtCallbackProc) activate_callback, 
(XtPointer) "editor1");
  XtAddCallback(editor1, XmNfocusCallback, (XtCallbackProc) focus_callback, 
(XtPointer) "editor1");
  XtAddCallback(editor1, XmNlosingFocusCallback, (XtCallbackProc) 
losingfocus_callback, (XtPointer) "editor1");
  XtAddCallback(editor1, XmNvalueChangedCallback, (XtCallbackProc) 
valuechanged_callback, (XtPointer) "editor1");

  n=0;
  XtSetArg(wargs[n], XmNleftAttachment, XmATTACH_FORM); n++;
  XtSetArg(wargs[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  XtSetArg(wargs[n], XmNtopWidget, editor1); n++;
  XtSetArg(wargs[n], XmNcolumns, 10); n++;
  XtSetArg(wargs[n], XmNvalue, "0"); n++;
  editor2=XtCreateManagedWidget("editor2", xmTextFieldWidgetClass, form, wargs, n);
  XtAddCallback(editor2, XmNactivateCallback, (XtCallbackProc) activate_callback, 
(XtPointer) "editor2");
  XtAddCallback(editor2, XmNfocusCallback, (XtCallbackProc) focus_callback, 
(XtPointer) "editor2");
  XtAddCallback(editor2, XmNlosingFocusCallback, (XtCallbackProc) 
losingfocus_callback, (XtPointer) "editor2");
  XtAddCallback(editor2, XmNvalueChangedCallback, (XtCallbackProc) 
valuechanged_callback, (XtPointer) "editor2");

  XtRealizeWidget(toplevel);
  XtMainLoop();
}

Reply via email to