[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bulova::decw_jan-89_to_nov-90

Title:DECWINDOWS 26-JAN-89 to 29-NOV-90
Notice:See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit
Moderator:STAR::VATNE
Created:Mon Oct 30 1989
Last Modified:Mon Dec 31 1990
Last Successful Update:Fri Jun 06 1997
Number of topics:3726
Total number of notes:19516

647.0. "Stack Order Problem" by DLOACT::SCOTTK () Thu Apr 20 1989 16:14

    I have a customer that is trying to get a dialogue box to remain
    on top of the stacking order.  Following is a short program that
    demonstrates the problem.  I would appreciate any help, especially
    as related to the XtMakeGeometryRequest call.  Also, if there is
    a better way to accomplish this functionality, please let me know.
    
    Thanks,
    Kevin Scott
    
    
#include <stdlib.h>
#include <stdio.h>
#include <decwdwtwidgetprog.h>

int go_on = 1;

btn1(w,tag,reason)
Widget w;
char *tag;
int reason;
{
   printf("Button 1 pressed\n");
}

btn2(w,tag,reason)
Widget w;
char *tag;
int reason;
{
   printf("Button 2 pressed\n");
}

selection(w,tag,reason)
Widget w;
char *tag;
int reason;
{
   go_on = 0;
}

main()
{
   char **argv;
   int argc,id,x,y,w,h,bcol,i=0;
   XEvent event;
   Widget toplevel, mainwindow, win1, win2, diag1, diag2, pb1, pb2;
   Arg args[10];
   XtWidgetGeometry *vals;

   DwtCallback selectionptr[]=
      { {(VoidProc) selection, NULL}, {NULL, NULL} };
   DwtCallback btn1ptr[]=
      { {(VoidProc) btn1, NULL}, {NULL, NULL} };
   DwtCallback btn2ptr[]=
      { {(VoidProc) btn2, NULL}, {NULL, NULL} };

   argc = 0;
   argv = NULL;

   toplevel = XtInitialize("EASE1", "EASE2", NULL, 0, &argc, argv);
   XtSetArg(args[0], XtNx, 50);
   XtSetArg(args[1], XtNy, 50);
   argc = 2;
   XtSetValues(toplevel, args, argc);

   XtSetArg(args[0], XtNwidth, 500);
   XtSetArg(args[1], XtNheight, 500);
   argc = 2;
   mainwindow = XtCreateManagedWidget("EASE Application Window",
                      mainwindowwidgetclass, toplevel, args, argc);

   XtSetArg(args[0], DwtNstyle, DwtModeless);
   XtSetArg(args[1], DwtNunits, DwtPixelUnits);
   XtSetArg(args[2], DwtNautoUnmanage, 0);
   XtSetArg(args[3], DwtNtakeFocus, 1);
   XtSetArg(args[4], DwtNx, 100);
   XtSetArg(args[5], DwtNy, 100);
   XtSetArg(args[6], DwtNwidth, 200);
   XtSetArg(args[7], DwtNheight, 200);
   diag1 = DwtDialogBoxPopupCreate(mainwindow, "Dbox Title", args, 8);

   XtSetArg(args[0], DwtNx, 0);
   XtSetArg(args[1], DwtNy, 0);
   XtSetArg(args[2], DwtNwidth, 150);
   XtSetArg(args[3], DwtNheight, 50);
   XtSetArg(args[4], DwtNlabel, DwtLatin1String("number 1 text label"));
   XtSetArg(args[5], DwtNactivateCallback, btn1ptr);
   pb1 = XtCreateManagedWidget("pbless", pushbuttonwidgetclass,
               diag1, args, 6);

   XtSetArg(args[0], DwtNstyle, DwtModeless);
   XtSetArg(args[1], DwtNunits, DwtPixelUnits);
   XtSetArg(args[2], DwtNautoUnmanage, 0);
   XtSetArg(args[3], DwtNtakeFocus, 1);
   XtSetArg(args[4], DwtNx, 200);
   XtSetArg(args[5], DwtNy, 200);
   XtSetArg(args[6], DwtNwidth, 200);
   XtSetArg(args[7], DwtNheight, 200);
   diag2 = DwtDialogBoxPopupCreate(mainwindow, "Dbox Title", args, 8);

   XtSetArg(args[0], DwtNx, 0);
   XtSetArg(args[1], DwtNy, 0);
   XtSetArg(args[2], DwtNwidth, 150);
   XtSetArg(args[3], DwtNheight, 50);
   XtSetArg(args[4], DwtNlabel, DwtLatin1String("number 2 text label"));
   XtSetArg(args[5], DwtNactivateCallback, btn2ptr);
   pb2 = XtCreateManagedWidget("pbless", pushbuttonwidgetclass,
               diag2, args, 6);

   XtRealizeWidget(toplevel);
   XtManageChild(diag1);
   XtManageChild(diag2);

   vals = (XtWidgetGeometry *) XtMalloc(sizeof(XtWidgetGeometry));
   vals->request_mode = CWStackMode;
   vals->sibling = diag1;
   vals->stack_mode = Above;
   XtMakeGeometryRequest(diag2, vals, NULL);

   while (go_on)
   {
      XtNextEvent(&event);
      XtDispatchEvent(&event);
   }
}
    

T.RTitleUserPersonal
Name
DateLines
647.1Diag2STAR::CYPRYCHThu Apr 20 1989 16:3710
    I just tried your program. 
    
    I could use a little bit of clarification on the
    problem.  Diag2 is on top of its sibling (Diag1), just
    like its specified in the stack_mode.
    
    What am I missing here?  Is it what happens later that
    you are referring to?
    

647.2XRaiseWindowSTAR::CYPRYCHThu Apr 20 1989 16:4411
    re: .0
    
    Sorry, I just re-read the first message-- you
    want to keep it on top at all times.
    
    You may consider doing an XRaiseWindow on DIAG2
    when a button down even occurs on any of your
    windows.
    
    Nancy

647.3More on the stacking order problemDLOACT::SCOTTKThu Apr 20 1989 17:0915
    I apologize for the brevity (or lack) of information as to the problem.
    
    The customer would like the "diag2" box to remain on top no matter
    what actions occur.  If you focus on "diag1" it pops to the top.
    The result desired is accomplished if you hit the panel button while
    holding the shift key on each window in this order, EASE1, diag2,
    then diag1 (then push EASE1 to the back).  This seems to "lock" the
    stacking order.  If you then drag "diag1" over "diag2," "diag2"
    will remain on top.  This is the desired effect, which indicates
    that "some" attribute should be set in order to accomplish this.
    I just don't know what attribute...
    
    Thanks again,
    Kevin Scott

647.4stickySTAR::CYPRYCHFri Apr 21 1989 10:4214
    Assuming that "diag2" should remain on top,  and it
    isn't critical what the stacking order is for the
    remaining widgets,  then perhaps you ought to set
    everything to sticky except for diag2.
    
    Basically you need to do an XChangeProperty on the
    DECWmHints property,  such that sticky is set to True.
                                                       
    The atom is "DEC_WM_HINTS",
    the value_mask in DECWmHints should be DECWmStickyMask.
    and sticky in DECWmHints should be set to True.
    
    Nancy

647.5more on stickySTAR::CYPRYCHFri Apr 21 1989 10:4911
    RE: .3 and .4
    
    I forgot to mention,  it sounds like from your
    description in .3,  that you are looking to
    set windows "sticky".  The panel button
    you are referring to I assume is the "push to
    back" button (second one from the right hand side).
    Push to back and making it "stick" is "sticky windows". 
    
    hence,  the value "sticky" in the DECWmHints property.