Xft support under OpenMotif 2.3.3 - I've been using this for quite a while on
[nedit.git] / util / motif.c
blobcb9679b1e121b6a4aa49f1fd3b92e06f51b6dc08
1 /*******************************************************************************
2 * *
3 * motif.c: Determine stability of Motif *
4 * *
5 * Copyright (C) 2003 Nathaniel Gray *
6 * *
7 * This is free software; you can redistribute it and/or modify it under the *
8 * terms of the GNU General Public License as published by the Free Software *
9 * Foundation; either version 2 of the License, or (at your option) any later *
10 * version. In addition, you may distribute versions of this program linked to *
11 * Motif or Open Motif. See README for details. *
12 * *
13 * This software is distributed in the hope that it will be useful, but WITHOUT *
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License *
16 * for more details. *
17 * *
18 * You should have received a copy of the GNU General Public License along with *
19 * software; if not, write to the Free Software Foundation, Inc., 59 Temple *
20 * Place, Suite 330, Boston, MA 02111-1307 USA *
21 * *
22 * Nirvana Text Editor *
23 * July 28, 1992 *
24 * *
25 * Written by Nathaniel Gray *
26 * *
27 * Modifications by: *
28 * Scott Tringali *
29 * *
30 *******************************************************************************/
33 * About the different #defines that Motif gives us:
34 * All Motifs #define several values. These are the values in
35 * Open Motif 2.1.30, for example:
36 * #define XmVERSION 2
37 * #define XmREVISION 1
38 * #define XmUPDATE_LEVEL 30
39 * #define XmVersion (XmVERSION * 1000 + XmREVISION)
40 * #define XmVERSION_STRING "@(#)Motif Version 2.1.30"
42 * In addition, LessTif #defines several values as shown here for
43 * version 0.93.0:
44 * #define LESSTIF_VERSION 0
45 * #define LESSTIF_REVISION 93
46 * #define LesstifVersion (LESSTIF_VERSION * 1000 + LESSTIF_REVISION)
47 * #define LesstifVERSION_STRING \
48 * "@(#)GNU/LessTif Version 2.1 Release 0.93.0"
50 * Also, in LessTif the XmVERSION_STRING is identical to the
51 * LesstifVERSION_STRING. Unfortunately, the only way to find out the
52 * "update level" of a LessTif release is to parse the LesstifVERSION_STRING.
55 #include "motif.h"
56 #include <Xm/Xm.h>
57 #include <string.h>
59 #ifdef LESSTIF_VERSION
60 static enum MotifStability GetLessTifStability(void);
61 #else
62 static enum MotifStability GetOpenMotifStability(void);
63 #endif
65 /*
66 * These are versions of LessTif that are known to be stable with NEdit in
67 * Motif 2.1 mode.
69 static const char *const knownGoodLesstif[] = {
70 "0.92.32",
71 "0.93.0",
72 "0.93.12",
73 "0.93.18",
74 #ifndef __x86_64
75 "0.93.94", /* 64-bit build .93.94 is broken */
76 #endif
77 NULL
80 /*
81 * These are versions of LessTif that are known NOT to be stable with NEdit in
82 * Motif 2.1 mode.
84 const char *const knownBadLessTif[] = {
85 "0.93.25",
86 "0.93.29",
87 "0.93.34"
88 "0.93.36",
89 "0.93.39",
90 "0.93.40",
91 "0.93.41",
92 "0.93.44",
93 #ifdef __x86_64
94 "0.93.94", /* 64-bit build .93.94 is broken */
95 #endif
96 "0.93.95b", /* SF bug 1087192 */
97 "0.94.4", /* Alt-H, ESC => crash */
98 "0.95.0", /* same as above */
99 NULL
103 #ifdef LESSTIF_VERSION
105 static enum MotifStability GetLessTifStability(void)
107 int i;
108 const char *rev = NULL;
110 /* We assume that the lesstif version is the string after the last
111 space. */
113 rev = strrchr(LesstifVERSION_STRING, ' ');
115 if (rev == NULL)
116 return MotifUnknown;
118 rev += 1;
120 /* Check for known good LessTif versions */
121 for (i = 0; knownGoodLesstif[i]; i++)
122 if (!strcmp(rev, knownGoodLesstif[i]))
123 return MotifKnownGood;
125 /* Check for known bad LessTif versions */
126 for (i = 0; knownBadLessTif[i]; i++)
127 if (!strcmp(rev, knownBadLessTif[i]))
128 return MotifKnownBad;
130 return MotifUnknown;
133 #else
135 /* The stability depends on the patch level, so fold it into the
136 usual XmVersion for easy comparison. */
137 static const int XmFullVersion = (XmVersion * 100 + XmUPDATE_LEVEL);
139 static enum MotifStability GetOpenMotifStability(void)
141 enum MotifStability result = MotifUnknown;
143 const Boolean really222 =
144 (strcmp("@(#)Motif Version 2.2.2", XmVERSION_STRING) == 0);
146 if (XmFullVersion <= 200200) /* 1.0 - 2.1 are fine */
148 result = MotifKnownGood;
150 else if ((XmFullVersion < 200202) || really222) /* 2.2.0 - 2.2.2 are bad */
152 result = MotifKnownBad;
154 else if (XmFullVersion >= 200203 && XmFullVersion <= 200303) /* 2.2.3 - 2.3 is good */
156 result = MotifKnownGood;
158 else /* Anything else unknown */
160 result = MotifUnknown;
163 return result;
166 #endif
169 enum MotifStability GetMotifStability(void)
171 #ifdef LESSTIF_VERSION
172 return GetLessTifStability();
173 #else
174 return GetOpenMotifStability();
175 #endif
179 const char *GetMotifStableVersions(void)
181 int i;
182 static char msg[sizeof knownGoodLesstif * 80];
184 for (i = 0; knownGoodLesstif[i] != NULL; i++)
186 strcat(msg, knownGoodLesstif[i]);
187 strcat(msg, "\n");
190 strcat(msg, "OpenMotif 2.1.30\n");
191 strcat(msg, "OpenMotif 2.2.3\n");
192 strcat(msg, "OpenMotif 2.3\n");
194 return msg;