logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

common - common functions used in other examples libAfterImage/tutorials/common.h

Description

       User action requesting window to be closed is generally received first by Window Manager. Window  Manager
       is  then  handles  it down to the window by sending it ClientMessage event with first 32 bit word of data
       set to the value of WM_DELETE_WINDOW Atom.  Accordingly, all client has to do is wait for such event from
       X server and, when received, it should destroy its window and generally exit.

Inputs

       w      - ID of the window from which to wait for events.

Name

common - common functions used in other examples libAfterImage/tutorials/common.h

Name_Xa_Wm_Delete_Window

Namecreate_Top_Level_Window()

Nameset_Window_Background_And_Free()

Namewait_Closedown()

Notes

       It is recommended that XFlush() is issued right after  XDestroyWindow()  as  Window  Manager  itself  may
       attempt to do something with the window until it receives DestroyNotify event.

Return Value

       None on success. Pixmap ID of original Pixmap on failure.

See Also

       ICCCM, Window

Source

           void wait_closedown( Window w ) { #ifndef X_DISPLAY_MISSING
               Display *dpy = get_default_asvisual()->dpy;

               if(dpy)
               {
                   if (w)
                   {
                       XSelectInput (dpy, w, ( StructureNotifyMask |
                                               ButtonPressMask|
                                               ButtonReleaseMask));

                       while(w != None)
                       {
                           XEvent event ;

                           XNextEvent (dpy, &event);
                           switch(event.type)
                           {
                               case ClientMessage:
                                   if ((event.xclient.format != 32) ||
                                       (event.xclient.data.l[0] != _XA_WM_DELETE_WINDOW))
                                       break ;
                               case ButtonPress:
                                   XDestroyWindow( dpy, w );
                                   XFlush( dpy );
                                   w = None ;
                                   break ;
                           }
                       }
                   }
                   XCloseDisplay (dpy);
               } #endif }

3rd Berkeley Distribution                      AfterStep v.2.2.12                                     common(3x)

Synopsis

       void wait_closedown( Window w );

See Also