Remove building with NOCRYPTO option
[minix.git] / external / bsd / nvi / dist / motif / m_cde.c
blob62c9ab74f3736f80585c1650bb4346b86e645ffe
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 #include <sys/cdefs.h>
13 #if 0
14 #ifndef lint
15 static const char sccsid[] = "Id: m_cde.c,v 8.11 2003/11/05 17:09:58 skimo Exp (Berkeley) Date: 2003/11/05 17:09:58 ";
16 #endif /* not lint */
17 #else
18 __RCSID("$NetBSD: m_cde.c,v 1.3 2014/01/26 21:43:45 christos Exp $");
19 #endif
21 #include <sys/types.h>
22 #include <sys/queue.h>
24 #include <X11/X.h>
25 #include <X11/Xlib.h>
26 #include <X11/Xatom.h>
28 #include <bitstring.h>
29 #include <stdio.h>
31 #undef LOCK_SUCCESS
32 #include "../common/common.h"
33 #include "motif_extern.h"
35 #if SelfTest
36 #define _TRACE( x ) printf x
37 #else
38 #define _TRACE( x )
39 #endif
41 #define Required 10
42 #define Useful 3
43 #define Present (Required+Useful)
45 static struct {
46 char *name;
47 int value;
48 } Atoms[] = {
49 { "_VUE_SM_WINDOW_INFO", Required, /* "vue" */ },
50 { "_DT_SM_WINDOW_INFO", Required, /* "dtwm" */ },
51 { "_SUN_WM_PROTOCOLS", Useful, /* "olwm" */ },
52 { "_MOTIF_WM_INFO", Useful, /* "mwm/dtwm" */ },
56 * is_cde --
58 * When running under CDE (or VUE on HPUX) applications should not define
59 * fallback colors (or fonts). The only way to tell is to check the atoms
60 * attached to the server. This routine does that.
62 * PUBLIC: int is_cde __P((Display *));
64 int
65 is_cde(Display *d)
67 int i, r, format;
68 unsigned long nitems, remaining;
69 unsigned char *prop;
70 Window root = DefaultRootWindow( d );
71 Atom atom, type;
72 int retval = 0;
74 _TRACE( ( "Root window is 0x%x\n", root ) );
76 /* create our atoms */
77 for (i=0; i< (sizeof(Atoms)/sizeof(Atoms[0])); i++ ) {
79 atom = XInternAtom( d, Atoms[i].name, True );
80 if ( atom == None ) {
81 _TRACE( ( "Atom \"%s\" does not exist\n", Atoms[i].name ) );
82 continue;
85 /* what is the value of the atom? */
86 r = XGetWindowProperty( d,
87 root,
88 atom,
90 1024,
91 False, /* do not delete */
92 AnyPropertyType, /* request type */
93 &type, /* actual type */
94 &format, /* byte size */
95 &nitems, /* number of items */
96 &remaining, /* anything left over? */
97 &prop /* the data itself */
99 if ( r != Success ) {
100 _TRACE( ( "Atom \"%s\" cannot be converted to string\n", Atoms[i].name ) );
101 continue;
104 retval += Atoms[i].value;
107 #if SelfTest
108 _TRACE( ( "Atom \"%s\"\n", Atoms[i].name ) );
110 switch ( type ) {
111 case 0:
112 _TRACE( ( "\t does not exist on the root window\n", Atoms[i].name ) );
114 case XA_ATOM:
115 for (j=0; j<nitems; j++) {
116 name = XGetAtomName( d, ((Atom *) prop)[j] );
117 _TRACE( ( "\t[%d] = \"%s\"\n", j, name ) );
118 XFree( name );
120 break;
122 case XA_STRING:
123 _TRACE( ( "\t is a string\n", Atoms[i].name ) );
124 break;
126 default:
127 _TRACE( ( "\tunknown type %s\n", XGetAtomName( d, type ) ) );
128 break;
130 #endif
132 /* done */
133 XFree( (caddr_t) prop );
137 _TRACE( ( "retval = %d\n", retval ) );
138 return retval >= Present;
141 #if SelfTest
143 main () {
144 Display *d = XOpenDisplay( 0 );
146 if ( d == 0 )
147 printf ( "Could not open display\n" );
148 else {
149 printf ( "_vi_is_cde() == %d\n", _vi_is_cde( d ) );
150 XCloseDisplay( d );
153 #endif