From: matt@kvamdata.no (Matthew Kerr)
Subject: Setting window Focus when keyboardFocusPolicy == pointer (?)
Organization: Kvam data as
Date: Mon, 16 Nov 1992 15:13:46 GMT

   (source included below, just add water)

**** Quesion? ****
   What is the trick to have the 'Application's Focus' into it's topmost
   DialogBox?  (when Mwm*keyboardFocusPolicy == pointer)

   (Should be easy, but didn't see this in the FAQ...)

**** Description ****
   I have a _vanilla_ Motif widget hierarchy (see code below):

         -------------------------------
         |AppShell                     |
         |                         X <-------- Mouse Pointer
         |       --------------        |       (outside DialogShell)
         |       |DialogShell |        |
         |       |(w/BBoard)  |        |
         |       |            |        |
         |       --------------        |
         |                             |
         -------------------------------

   If 'Mwm*keyboardFocusPolicy' == 'pointer'
   when my DialogShell is mapped it does not get the WM (mwm) focus...
   (because the Mouse Pointer is outside the DialogShell window?)
   So I have to move my Mouse to give focus to the DBox... :-(

   Focus works fine if 'Mwm*keyboardFocusPolicy' == 'explicit' (no help)

thanks for the help,
matt
==============================================================================
 Matthew Kerr                   Kvam data as
 matt@kvamdata.no               Nikkelveien 14, N-4300 Sandnes, Norway
                                Tel: + 47 4 62 37 66
 (woof)                         Fax: + 47 4 62 39 85
==============================================================================

/*-------------------------8<  Snip, Snip  8<-------------------------------*/
#include <Xm/Xm.h>
#include <Xm/BulletinB.h>
#include <Xm/DialogS.h>
#include <Xm/PushB.h>

/*********************************************************************/
void ButtonCB (NotUsed, Shell)
   Widget NotUsed;
   Widget Shell;
{
   Widget DShell, BBoard, Button;

   DShell = XmCreateDialogShell   (Shell, "DialogShell", NULL, 0);
   BBoard = XmCreateBulletinBoard (DShell, "DialogBox", NULL, 0);
   Button = XmCreatePushButton    (BBoard, "another Button...", NULL, 0);

   XtManageChild (Button);
   XtManageChild (BBoard);
}

/*********************************************************************/
main (argc, argv)
   Cardinal argc;
   char *argv[];
{
   XtAppContext AppContext;
   Display *MyDisp;
   Widget AppShell, Button;
   Arg args[10];
   Cardinal n;

/* Init Stuff... */
           XtToolkitInitialize();
   AppContext = XtCreateApplicationContext();
   MyDisp     = XtOpenDisplay (AppContext, NULL, "AppName", "AppClass",
                               NULL, 0, &argc, argv);

/* Create Shell... */
   n = 0;
   XtSetArg (args[n], XmNwidth,  400); n++;
   XtSetArg (args[n], XmNheight, 400); n++;
   AppShell = XtAppCreateShell("AppName", "AppClass",
                               applicationShellWidgetClass, MyDisp, args, n);
   XtRealizeWidget (AppShell);

/* Create Button... */
   Button = XmCreatePushButton(AppShell, "a Button", NULL, 0);
   XtManageChild (Button);
   XtAddCallback (Button, XmNactivateCallback, ButtonCB, AppShell);

/* Loop... */
   XtAppMainLoop(AppContext);
}
Newsgroups: comp.windows.x.motif