🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.x
Article #36783

Re: ICCCM compliance questions

#36783
From: Jim Becker
Date: Wed, 14 Feb 1990 01:31
132 lines
3808 bytes
baur@venice.SEDD.TRW.COM (Steven L. Baur) writes:


   I have noticed that certain clients generate output on the  console
   when  'Quit'ing  out  of  them  via olwm (broken pipe from server).
   XView-based clients do not (and certain other well-behaved  clients
   do not).  I suspect the error message is due to non-ICCCM compliant
   clients.  What kind of  changes  should  be  made  to  clients  who
   exhibit this problem?


One  has to tell the window manager that the application is interested
in  understanding  when  olwm  wants  it  to go away.  This is done by
`interning  the  atoms' (X-Speak) that are needed for this information
to be passed to the application.

Once  the  application  has interned the atoms a ClientMessage will be
sent  when  olwm  wants  to  tell you something. There are a number of
different things that can be told to you, and I don't know  what  they
all are. However, following is some code that will get you out of  the
application correctly when the wm_delete_window message comes.

I'm not an ICCCM expert, but since there hadn't been a  response  from
one  thought  that this would help. I assume that an ICCCM expert will
correct anything missing.


-Jim Becker


~~~ initialization ~~~

#define	NUM_ATOMS	3

static	short		atomic_world_initialized= FALSE;
static	Atom		atom_wm_protocols, 	atom_wm_delete_window,
			atom_wm_save_yourself, 	atom_wm_take_focus;
static	short		debug;

initialize_atoms()
{
	Atom 		atomic_interest[NUM_ATOMS];

	atom_wm_protocols		= XInternAtom( display, 
						      "WM_PROTOCOLS",   FALSE );
	if( atom_wm_protocols != None ) {
	
		atomic_world_initialized= TRUE;

		atom_wm_delete_window	= XInternAtom( display, 
						      "WM_DELETE_WINDOW", FALSE );
		atom_wm_take_focus	= XInternAtom( display, 
						      "WM_TAKE_FOCUS",    FALSE );
		atom_wm_save_yourself	= XInternAtom( display, 
						      "WM_SAVE_YOURSELF", FALSE );
		
		atomic_interest[0]	= atom_wm_delete_window;
		atomic_interest[1]	= atom_wm_take_focus;
		atomic_interest[2]	= atom_wm_save_yourself;
		
		XChangeProperty( display, mwindow, atom_wm_protocols, XA_ATOM, 32,
				PropModeReplace, (unsigned char*)atomic_interest, 
				NUM_ATOMS);
	}
}

~~~ event loop ~~~

main()
{
	initialize_atoms();

	while( !done ) { 
		XNextEvent( display, &xevent );

		switch( xevent.type ) {

			. . .
	
		case ClientMessage:
			done	= process_client_message( xevent );
			break;

			. . .
		}
	}

	exit(0);
}

~~~ de-compose routine ~~~

static	int
process_client_message( xevent )
XEvent		*xevent;
{
	XClientMessageEvent	*xclient	= xevent->xclient;
	Atom		 	protocol;
	char			*p;	
	short			retval	= FALSE;

	if( atomic_world_initialized 
	    && xclient->message_type == atom_wm_protocols ) {
		
		protocol 	= xevent.xclient.data.l[0];
		
		if( protocol == atom_wm_delete_window ) {
			p		= "WM_DELETE_WINDOW";
			retval 	= TRUE;
		}
		else if( protocol == atom_wm_save_yourself ) {
			p		= "WM_SAVE_YOURSELF";
		}
		else if( protocol == atom_wm_take_focus ) {
			p		= "WM_TAKE_FOCUS";
			
			XSetInputFocus( display, mwindow, RevertToParent,
				       xevent.xclient.data.l[1] );
		}
		else {
			p 		= "*Not Understood Atomically*";
		}
		
		if( debug )
			printf("atom of type %s came by..\n", p);
	}
	
	return retval;
}

--    
	 Jim Becker / jcb%frisbee@sun.com  / Sun Microsystems
Technical Details
Message-ID: <131787@sun.Eng.Sun.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!sun-barr!newstop!sun!frisbee!jcb
References: <295@venice.SEDD.TRW.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!sun-barr!newstop!sun!frisbee!jcb
From: jcb@frisbee.Sun.COM (Jim Becker)
Newsgroups: comp.windows.x
Subject: Re: ICCCM compliance questions
Message-ID: <131787@sun.Eng.Sun.COM>
Date: 14 Feb 90 01:31:17 GMT
References: <295@venice.SEDD.TRW.COM>
Sender: news@sun.Eng.Sun.COM
Lines: 132