typo
[nvi.git] / motif / m_cde.c
blobde08276e874f12d36708ef47e675f31ec6437c11
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.10 2001/06/25 15:19:26 skimo Exp $ (Berkeley) $Date: 2001/06/25 15:19:26 $";
14 #endif /* not lint */
16 #include <sys/types.h>
17 #include <sys/queue.h>
19 #include <X11/X.h>
20 #include <X11/Xlib.h>
21 #include <X11/Xatom.h>
23 #include <bitstring.h>
24 #include <stdio.h>
26 #include "../common/common.h"
27 #include "extern.h"
29 #if SelfTest
30 #define _TRACE( x ) printf x
31 #else
32 #define _TRACE( x )
33 #endif
35 #define Required 10
36 #define Useful 3
37 #define Present (Required+Useful)
39 static struct {
40 char *name;
41 int value;
42 } Atoms[] = {
43 { "_VUE_SM_WINDOW_INFO", Required, /* "vue" */ },
44 { "_DT_SM_WINDOW_INFO", Required, /* "dtwm" */ },
45 { "_SUN_WM_PROTOCOLS", Useful, /* "olwm" */ },
46 { "_MOTIF_WM_INFO", Useful, /* "mwm/dtwm" */ },
50 * is_cde --
52 * When running under CDE (or VUE on HPUX) applications should not define
53 * fallback colors (or fonts). The only way to tell is to check the atoms
54 * attached to the server. This routine does that.
56 * PUBLIC: int is_cde __P((Display *));
58 int
59 is_cde(Display *d)
61 int i, r, format;
62 unsigned long nitems, remaining;
63 unsigned char *prop;
64 Window root = DefaultRootWindow( d );
65 Atom atom, type;
66 int retval = 0;
68 _TRACE( ( "Root window is 0x%x\n", root ) );
70 /* create our atoms */
71 for (i=0; i< (sizeof(Atoms)/sizeof(Atoms[0])); i++ ) {
73 atom = XInternAtom( d, Atoms[i].name, True );
74 if ( atom == None ) {
75 _TRACE( ( "Atom \"%s\" does not exist\n", Atoms[i].name ) );
76 continue;
79 /* what is the value of the atom? */
80 r = XGetWindowProperty( d,
81 root,
82 atom,
84 1024,
85 False, /* do not delete */
86 AnyPropertyType, /* request type */
87 &type, /* actual type */
88 &format, /* byte size */
89 &nitems, /* number of items */
90 &remaining, /* anything left over? */
91 &prop /* the data itself */
93 if ( r != Success ) {
94 _TRACE( ( "Atom \"%s\" cannot be converted to string\n", Atoms[i].name ) );
95 continue;
98 retval += Atoms[i].value;
101 #if SelfTest
102 _TRACE( ( "Atom \"%s\"\n", Atoms[i].name ) );
104 switch ( type ) {
105 case 0:
106 _TRACE( ( "\t does not exist on the root window\n", Atoms[i].name ) );
108 case XA_ATOM:
109 for (j=0; j<nitems; j++) {
110 name = XGetAtomName( d, ((Atom *) prop)[j] );
111 _TRACE( ( "\t[%d] = \"%s\"\n", j, name ) );
112 XFree( name );
114 break;
116 case XA_STRING:
117 _TRACE( ( "\t is a string\n", Atoms[i].name ) );
118 break;
120 default:
121 _TRACE( ( "\tunknown type %s\n", XGetAtomName( d, type ) ) );
122 break;
124 #endif
126 /* done */
127 XFree( (caddr_t) prop );
131 _TRACE( ( "retval = %d\n", retval ) );
132 return retval >= Present;
135 #if SelfTest
137 main () {
138 Display *d = XOpenDisplay( 0 );
140 if ( d == 0 )
141 printf ( "Could not open display\n" );
142 else {
143 printf ( "_vi_is_cde() == %d\n", _vi_is_cde( d ) );
144 XCloseDisplay( d );
147 #endif