we have to let the screen code read the quit message before
[nvi.git] / motif / m_cde.c
blob96e135ce12e6e770466adbf59f1f83e87dc2b8e3
1 /*-
2 * Copyright (c) 1996
3 * Rob Zimmermann. All rights reserved.
4 * Copyright (c) 1996
5 * Keith Bostic. All rights reserved.
7 * See the LICENSE file for redistribution information.
8 */
10 #include "config.h"
12 #ifndef lint
13 static const char sccsid[] = "$Id: m_cde.c,v 8.6 1996/12/10 21:04:25 bostic Exp $ (Berkeley) $Date: 1996/12/10 21:04:25 $";
14 #endif /* not lint */
16 #include <X11/X.h>
17 #include <X11/Xlib.h>
18 #include <X11/Xatom.h>
20 #if SelfTest
21 #define TRACE( x ) printf x
22 #else
23 #define TRACE( x )
24 #endif
26 #define Required 10
27 #define Useful 3
28 #define Present (Required+Useful)
30 static struct {
31 char *name;
32 int value;
33 } Atoms[] = {
34 { "_VUE_SM_WINDOW_INFO", Required, /* "vue" */ },
35 { "_DT_SM_WINDOW_INFO", Required, /* "dtwm" */ },
36 { "_SUN_WM_PROTOCOLS", Useful, /* "olwm" */ },
37 { "_MOTIF_WM_INFO", Useful, /* "mwm/dtwm" */ },
41 * __vi_is_cde --
43 * When running under CDE (or VUE on HPUX) applications should not define
44 * fallback colors (or fonts). The only way to tell is to check the atoms
45 * attached to the server. This routine does that.
47 * PUBLIC: int __vi_is_cde __P((Display *));
49 int
50 __vi_is_cde(d)
51 Display *d;
53 int i, r, format;
54 unsigned long nitems, remaining;
55 unsigned char *prop;
56 Window root = DefaultRootWindow( d );
57 Atom atom, type;
58 int retval = 0;
60 TRACE( ( "Root window is 0x%x\n", root ) );
62 /* create our atoms */
63 for (i=0; i< (sizeof(Atoms)/sizeof(Atoms[0])); i++ ) {
65 atom = XInternAtom( d, Atoms[i].name, True );
66 if ( atom == None ) {
67 TRACE( ( "Atom \"%s\" does not exist\n", Atoms[i].name ) );
68 continue;
71 /* what is the value of the atom? */
72 r = XGetWindowProperty( d,
73 root,
74 atom,
76 1024,
77 False, /* do not delete */
78 AnyPropertyType, /* request type */
79 &type, /* actual type */
80 &format, /* byte size */
81 &nitems, /* number of items */
82 &remaining, /* anything left over? */
83 &prop /* the data itself */
85 if ( r != Success ) {
86 TRACE( ( "Atom \"%s\" cannot be converted to string\n", Atoms[i].name ) );
87 continue;
90 retval += Atoms[i].value;
93 #if SelfTest
94 TRACE( ( "Atom \"%s\"\n", Atoms[i].name ) );
96 switch ( type ) {
97 case 0:
98 TRACE( ( "\t does not exist on the root window\n", Atoms[i].name ) );
100 case XA_ATOM:
101 for (j=0; j<nitems; j++) {
102 name = XGetAtomName( d, ((Atom *) prop)[j] );
103 TRACE( ( "\t[%d] = \"%s\"\n", j, name ) );
104 XFree( name );
106 break;
108 case XA_STRING:
109 TRACE( ( "\t is a string\n", Atoms[i].name ) );
110 break;
112 default:
113 TRACE( ( "\tunknown type %s\n", XGetAtomName( d, type ) ) );
114 break;
116 #endif
118 /* done */
119 XFree( (caddr_t) prop );
123 TRACE( ( "retval = %d\n", retval ) );
124 return retval >= Present;
127 #if SelfTest
129 main () {
130 Display *d = XOpenDisplay( 0 );
132 if ( d == 0 )
133 printf ( "Could not open display\n" );
134 else {
135 printf ( "_vi_is_cde() == %d\n", _vi_is_cde( d ) );
136 XCloseDisplay( d );
139 #endif