break Motif code up into motif and motif_l
[nvi.git] / motif / m_cde.c
blobd5e248c40ab69ce19decaf5977c383dd6305311b
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.8 1996/12/11 20:56:42 bostic Exp $ (Berkeley) $Date: 1996/12/11 20:56:42 $";
14 #endif /* not lint */
16 #include <X11/X.h>
17 #include <X11/Xlib.h>
18 #include <X11/Xatom.h>
20 #include "extern.h"
22 #if SelfTest
23 #define _TRACE( x ) printf x
24 #else
25 #define _TRACE( x )
26 #endif
28 #define Required 10
29 #define Useful 3
30 #define Present (Required+Useful)
32 static struct {
33 char *name;
34 int value;
35 } Atoms[] = {
36 { "_VUE_SM_WINDOW_INFO", Required, /* "vue" */ },
37 { "_DT_SM_WINDOW_INFO", Required, /* "dtwm" */ },
38 { "_SUN_WM_PROTOCOLS", Useful, /* "olwm" */ },
39 { "_MOTIF_WM_INFO", Useful, /* "mwm/dtwm" */ },
43 * is_cde --
45 * When running under CDE (or VUE on HPUX) applications should not define
46 * fallback colors (or fonts). The only way to tell is to check the atoms
47 * attached to the server. This routine does that.
49 * PUBLIC: int is_cde __P((Display *));
51 int
52 is_cde(d)
53 Display *d;
55 int i, r, format;
56 unsigned long nitems, remaining;
57 unsigned char *prop;
58 Window root = DefaultRootWindow( d );
59 Atom atom, type;
60 int retval = 0;
62 _TRACE( ( "Root window is 0x%x\n", root ) );
64 /* create our atoms */
65 for (i=0; i< (sizeof(Atoms)/sizeof(Atoms[0])); i++ ) {
67 atom = XInternAtom( d, Atoms[i].name, True );
68 if ( atom == None ) {
69 _TRACE( ( "Atom \"%s\" does not exist\n", Atoms[i].name ) );
70 continue;
73 /* what is the value of the atom? */
74 r = XGetWindowProperty( d,
75 root,
76 atom,
78 1024,
79 False, /* do not delete */
80 AnyPropertyType, /* request type */
81 &type, /* actual type */
82 &format, /* byte size */
83 &nitems, /* number of items */
84 &remaining, /* anything left over? */
85 &prop /* the data itself */
87 if ( r != Success ) {
88 _TRACE( ( "Atom \"%s\" cannot be converted to string\n", Atoms[i].name ) );
89 continue;
92 retval += Atoms[i].value;
95 #if SelfTest
96 _TRACE( ( "Atom \"%s\"\n", Atoms[i].name ) );
98 switch ( type ) {
99 case 0:
100 _TRACE( ( "\t does not exist on the root window\n", Atoms[i].name ) );
102 case XA_ATOM:
103 for (j=0; j<nitems; j++) {
104 name = XGetAtomName( d, ((Atom *) prop)[j] );
105 _TRACE( ( "\t[%d] = \"%s\"\n", j, name ) );
106 XFree( name );
108 break;
110 case XA_STRING:
111 _TRACE( ( "\t is a string\n", Atoms[i].name ) );
112 break;
114 default:
115 _TRACE( ( "\tunknown type %s\n", XGetAtomName( d, type ) ) );
116 break;
118 #endif
120 /* done */
121 XFree( (caddr_t) prop );
125 _TRACE( ( "retval = %d\n", retval ) );
126 return retval >= Present;
129 #if SelfTest
131 main () {
132 Display *d = XOpenDisplay( 0 );
134 if ( d == 0 )
135 printf ( "Could not open display\n" );
136 else {
137 printf ( "_vi_is_cde() == %d\n", _vi_is_cde( d ) );
138 XCloseDisplay( d );
141 #endif