3 * Rob Zimmermann. All rights reserved.
5 * Keith Bostic. All rights reserved.
7 * See the LICENSE file for redistribution information.
12 #include <sys/cdefs.h>
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 ";
18 __RCSID("$NetBSD: m_cde.c,v 1.3 2014/01/26 21:43:45 christos Exp $");
21 #include <sys/types.h>
22 #include <sys/queue.h>
26 #include <X11/Xatom.h>
28 #include <bitstring.h>
32 #include "../common/common.h"
33 #include "motif_extern.h"
36 #define _TRACE( x ) printf x
43 #define Present (Required+Useful)
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" */ },
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 *));
68 unsigned long nitems
, remaining
;
70 Window root
= DefaultRootWindow( d
);
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
);
81 _TRACE( ( "Atom \"%s\" does not exist\n", Atoms
[i
].name
) );
85 /* what is the value of the atom? */
86 r
= XGetWindowProperty( d
,
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 */
100 _TRACE( ( "Atom \"%s\" cannot be converted to string\n", Atoms
[i
].name
) );
104 retval
+= Atoms
[i
].value
;
108 _TRACE( ( "Atom \"%s\"\n", Atoms
[i
].name
) );
112 _TRACE( ( "\t does not exist on the root window\n", Atoms
[i
].name
) );
115 for (j
=0; j
<nitems
; j
++) {
116 name
= XGetAtomName( d
, ((Atom
*) prop
)[j
] );
117 _TRACE( ( "\t[%d] = \"%s\"\n", j
, name
) );
123 _TRACE( ( "\t is a string\n", Atoms
[i
].name
) );
127 _TRACE( ( "\tunknown type %s\n", XGetAtomName( d
, type
) ) );
133 XFree( (caddr_t
) prop
);
137 _TRACE( ( "retval = %d\n", retval
) );
138 return retval
>= Present
;
144 Display
*d
= XOpenDisplay( 0 );
147 printf ( "Could not open display\n" );
149 printf ( "_vi_is_cde() == %d\n", _vi_is_cde( d
) );