Trapping Close on App's Main Window - Motif

This is a discussion on Trapping Close on App's Main Window - Motif ; My application traps the WM_DELETE_WINDOW atom since it must do some housekeeping whenever a window is deleted. This works fine for all but the app's main window. Closing that window should cause the app terminate with a confirmation but currently ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Trapping Close on App's Main Window

  1. Trapping Close on App's Main Window


    My application traps the WM_DELETE_WINDOW atom since it must do some
    housekeeping whenever a window is deleted. This works fine for all but the
    app's main window. Closing that window should cause the app terminate with a
    confirmation but currently it simply closes the window - with X errors. How
    do I identify that a window is the app's main window so that my callback can
    deal with it differently?

    --
    Jake Colman

    Principia Partners LLC Phone: (201) 209-2467
    Harborside Financial Center Fax: (201) 946-0320
    902 Plaza Two E-mail: colman@ppllc.com
    Jersey City, NJ 07311 www.principiapartners.com

  2. Re: Trapping Close on App's Main Window



    Jake Colman wrote:
    >
    > My application traps the WM_DELETE_WINDOW atom since it must do some
    > housekeeping whenever a window is deleted. This works fine for all but the
    > app's main window. Closing that window should cause the app terminate with a
    > confirmation but currently it simply closes the window - with X errors. How
    > do I identify that a window is the app's main window so that my callback can
    > deal with it differently?
    >
    > --
    > Jake Colman
    >
    > Principia Partners LLC Phone: (201) 209-2467
    > Harborside Financial Center Fax: (201) 946-0320
    > 902 Plaza Two E-mail: colman@ppllc.com
    > Jersey City, NJ 07311 www.principiapartners.com


    Same way as you trap on other windows.
    When you create app's main window, you use something like:
    toplevel = XtAppInitialize(...);
    Then just add a callback on WM close:
    XtVaSetValues( toplevelw, XmNdeleteResponse, XmDO_NOTHING, NULL ) ;
    XmAddWMProtocolCallback( toplevel,
    XmInternAtom( XtDisplay(toplevel),"WM_DELETE_WINDOW", False),
    your_exit_proc, (XtPointer)your_client_data ) ;

    Then your_exit_proc pops the confirmation dialog (or whatever). The OK
    callback of the confirmation dialog then calls exit(0).
    --
    Fred L. Kleinschmidt
    Boeing Associate Technical Fellow
    Technical Architect, Common User Interface Services
    M/S 2R-94 (206)544-5225

  3. Re: Trapping Close on App's Main Window

    >>>>> "FLK" == Fred L Kleinschmidt
    >>>>> writes:


    FLK> Jake Colman wrote:
    >>
    >> My application traps the WM_DELETE_WINDOW atom since it must do some
    >> housekeeping whenever a window is deleted. This works fine for all but
    >> the app's main window. Closing that window should cause the app
    >> terminate with a confirmation but currently it simply closes the window
    >> - with X errors. How do I identify that a window is the app's main
    >> window so that my callback can deal with it differently?
    >>

    FLK> Same way as you trap on other windows.
    FLK> When you create app's main window, you use something like:
    FLK> toplevel = XtAppInitialize(...);
    FLK> Then just add a callback on WM close:
    FLK> XtVaSetValues( toplevelw, XmNdeleteResponse, XmDO_NOTHING, NULL ) ;
    FLK> XmAddWMProtocolCallback( toplevel,
    FLK> XmInternAtom( XtDisplay(toplevel),"WM_DELETE_WINDOW", False),
    FLK> your_exit_proc, (XtPointer)your_client_data ) ;

    FLK> Then your_exit_proc pops the confirmation dialog (or whatever). The OK
    FLK> callback of the confirmation dialog then calls exit(0).

    Perfect! Worked like a charm. Thanks!

    --
    Jake Colman

    Principia Partners LLC Phone: (201) 209-2467
    Harborside Financial Center Fax: (201) 946-0320
    902 Plaza Two E-mail: colman@ppllc.com
    Jersey City, NJ 07311 www.principiapartners.com

+ Reply to Thread