perl: remove conflicting re_compile define
[nvi.git] / motif / m_cde.c
blob91bf6f87d90a1acbe2b71f11f883915b3478b2fd
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.11 2003/11/05 17:09:58 skimo Exp $ (Berkeley) $Date: 2003/11/05 17:09:58 $";
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 #undef LOCK_SUCCESS
27 #include "../common/common.h"
28 #include "extern.h"
30 #if SelfTest
31 #define _TRACE( x ) printf x
32 #else
33 #define _TRACE( x )
34 #endif
36 #define Required 10
37 #define Useful 3
38 #define Present (Required+Useful)
40 static struct {
41 char *name;
42 int value;
43 } Atoms[] = {
44 { "_VUE_SM_WINDOW_INFO", Required, /* "vue" */ },
45 { "_DT_SM_WINDOW_INFO", Required, /* "dtwm" */ },
46 { "_SUN_WM_PROTOCOLS", Useful, /* "olwm" */ },
47 { "_MOTIF_WM_INFO", Useful, /* "mwm/dtwm" */ },
51 * is_cde --
53 * When running under CDE (or VUE on HPUX) applications should not define
54 * fallback colors (or fonts). The only way to tell is to check the atoms
55 * attached to the server. This routine does that.
57 * PUBLIC: int is_cde __P((Display *));
59 int
60 is_cde(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