deal with split input
[nvi.git] / motif / m_cde.c
blob0c808f27ce7fd119d22b292746b7a55ec67361d9
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.9 1996/12/16 17:24:16 bostic Exp $ (Berkeley) $Date: 1996/12/16 17:24:16 $";
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(d)
60 Display *d;
62 int i, r, format;
63 unsigned long nitems, remaining;
64 unsigned char *prop;
65 Window root = DefaultRootWindow( d );
66 Atom atom, type;
67 int retval = 0;
69 _TRACE( ( "Root window is 0x%x\n", root ) );
71 /* create our atoms */
72 for (i=0; i< (sizeof(Atoms)/sizeof(Atoms[0])); i++ ) {
74 atom = XInternAtom( d, Atoms[i].name, True );
75 if ( atom == None ) {
76 _TRACE( ( "Atom \"%s\" does not exist\n", Atoms[i].name ) );
77 continue;
80 /* what is the value of the atom? */
81 r = XGetWindowProperty( d,
82 root,
83 atom,
85 1024,
86 False, /* do not delete */
87 AnyPropertyType, /* request type */
88 &type, /* actual type */
89 &format, /* byte size */
90 &nitems, /* number of items */
91 &remaining, /* anything left over? */
92 &prop /* the data itself */
94 if ( r != Success ) {
95 _TRACE( ( "Atom \"%s\" cannot be converted to string\n", Atoms[i].name ) );
96 continue;
99 retval += Atoms[i].value;
102 #if SelfTest
103 _TRACE( ( "Atom \"%s\"\n", Atoms[i].name ) );
105 switch ( type ) {
106 case 0:
107 _TRACE( ( "\t does not exist on the root window\n", Atoms[i].name ) );
109 case XA_ATOM:
110 for (j=0; j<nitems; j++) {
111 name = XGetAtomName( d, ((Atom *) prop)[j] );
112 _TRACE( ( "\t[%d] = \"%s\"\n", j, name ) );
113 XFree( name );
115 break;
117 case XA_STRING:
118 _TRACE( ( "\t is a string\n", Atoms[i].name ) );
119 break;
121 default:
122 _TRACE( ( "\tunknown type %s\n", XGetAtomName( d, type ) ) );
123 break;
125 #endif
127 /* done */
128 XFree( (caddr_t) prop );
132 _TRACE( ( "retval = %d\n", retval ) );
133 return retval >= Present;
136 #if SelfTest
138 main () {
139 Display *d = XOpenDisplay( 0 );
141 if ( d == 0 )
142 printf ( "Could not open display\n" );
143 else {
144 printf ( "_vi_is_cde() == %d\n", _vi_is_cde( d ) );
145 XCloseDisplay( d );
148 #endif