annotate src/xmu.c @ 2898:578cac55e68a

[xemacs-hg @ 2005-08-15 21:51:36 by viteno] Update xemacs_extra_name.
author viteno
date Mon, 15 Aug 2005 21:51:36 +0000
parents b39c14581166
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* This file contains compatibility routines for systems without Xmu.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 * You would be better served by installing Xmu on your machine or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 * yelling at your vendor to ship it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 /* XEmacs changes: rindex -> strrchr */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 /* Synched up with: Not in FSF. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 #ifndef HAVE_XMU
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 * Copyright 1989 Massachusetts Institute of Technology
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 * Permission to use, copy, modify, and distribute this software and its
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 * documentation for any purpose and without fee is hereby granted, provided
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 * that the above copyright notice appear in all copies and that both that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 * copyright notice and this permission notice appear in supporting
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 * documentation, and that the name of M.I.T. not be used in advertising
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 * or publicity pertaining to distribution of the software without specific,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 * written prior permission. M.I.T. makes no representations about the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 * suitability of this software for any purpose. It is provided "as is"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 * without express or implied warranty.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 #include <X11/cursorfont.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 #include <X11/Xlib.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 #include <X11/Xutil.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 #include <X11/Intrinsic.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 /* for XmuCopyISOLatin1Lowered */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 #define XK_LATIN1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 #include <X11/keysymdef.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 #undef XK_LATIN1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 #if (XtSpecificationRelease >= 5)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 * Don't know why, but this works with X11R5, not X11R4.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 * Anyway, _XExtension is defined in Xlib.h in X11R4, so we do not need
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 * Xlibint in that case...
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 #include <X11/Xlibint.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 #include <X11/Xproto.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 #include <stdio.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 #include <ctype.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
56 int XmuCursorNameToIndex (const char *name)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
58 static const struct _CursorName {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
59 const char *name;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 unsigned int shape;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 } cursor_names[] = {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 {"x_cursor", XC_X_cursor},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 {"arrow", XC_arrow},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 {"based_arrow_down", XC_based_arrow_down},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 {"based_arrow_up", XC_based_arrow_up},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 {"boat", XC_boat},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 {"bogosity", XC_bogosity},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 {"bottom_left_corner", XC_bottom_left_corner},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 {"bottom_right_corner", XC_bottom_right_corner},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 {"bottom_side", XC_bottom_side},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 {"bottom_tee", XC_bottom_tee},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 {"box_spiral", XC_box_spiral},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 {"center_ptr", XC_center_ptr},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 {"circle", XC_circle},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 {"clock", XC_clock},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 {"coffee_mug", XC_coffee_mug},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 {"cross", XC_cross},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 {"cross_reverse", XC_cross_reverse},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 {"crosshair", XC_crosshair},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 {"diamond_cross", XC_diamond_cross},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 {"dot", XC_dot},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 {"dotbox", XC_dotbox},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 {"double_arrow", XC_double_arrow},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 {"draft_large", XC_draft_large},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 {"draft_small", XC_draft_small},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 {"draped_box", XC_draped_box},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 {"exchange", XC_exchange},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 {"fleur", XC_fleur},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 {"gobbler", XC_gobbler},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 {"gumby", XC_gumby},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 {"hand1", XC_hand1},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 {"hand2", XC_hand2},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 {"heart", XC_heart},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 {"icon", XC_icon},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 {"iron_cross", XC_iron_cross},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 {"left_ptr", XC_left_ptr},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 {"left_side", XC_left_side},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 {"left_tee", XC_left_tee},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 {"leftbutton", XC_leftbutton},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 {"ll_angle", XC_ll_angle},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 {"lr_angle", XC_lr_angle},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 {"man", XC_man},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 {"middlebutton", XC_middlebutton},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 {"mouse", XC_mouse},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 {"pencil", XC_pencil},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 {"pirate", XC_pirate},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 {"plus", XC_plus},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 {"question_arrow", XC_question_arrow},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 {"right_ptr", XC_right_ptr},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 {"right_side", XC_right_side},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 {"right_tee", XC_right_tee},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 {"rightbutton", XC_rightbutton},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 {"rtl_logo", XC_rtl_logo},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 {"sailboat", XC_sailboat},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 {"sb_down_arrow", XC_sb_down_arrow},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 {"sb_h_double_arrow", XC_sb_h_double_arrow},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 {"sb_left_arrow", XC_sb_left_arrow},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 {"sb_right_arrow", XC_sb_right_arrow},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 {"sb_up_arrow", XC_sb_up_arrow},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 {"sb_v_double_arrow", XC_sb_v_double_arrow},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 {"shuttle", XC_shuttle},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 {"sizing", XC_sizing},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 {"spider", XC_spider},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 {"spraycan", XC_spraycan},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 {"star", XC_star},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 {"target", XC_target},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 {"tcross", XC_tcross},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 {"top_left_arrow", XC_top_left_arrow},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 {"top_left_corner", XC_top_left_corner},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 {"top_right_corner", XC_top_right_corner},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 {"top_side", XC_top_side},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 {"top_tee", XC_top_tee},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 {"trek", XC_trek},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 {"ul_angle", XC_ul_angle},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 {"umbrella", XC_umbrella},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 {"ur_angle", XC_ur_angle},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 {"watch", XC_watch},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 {"xterm", XC_xterm},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 };
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
140 const struct _CursorName *table;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 char tmp[40];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 608
diff changeset
144 if (strlen (name) >= sizeof (tmp)) return -1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 for (i=0; i<strlen(name); i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 if (isupper((unsigned char) name[i]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 tmp[i] = tolower((unsigned char) name[i]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 tmp[i] = name[i];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 tmp[i] = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 for (i=0, table=cursor_names; i < XtNumber(cursor_names); i++, table++ ) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 if (strcmp(tmp, table->name) == 0) return table->shape;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158
608
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 442
diff changeset
159 /* Definition of XmuReadBitmapDataFromFile replaced with the code in
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 442
diff changeset
160 * glyphs-shared.c
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 442
diff changeset
161 *
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 442
diff changeset
162 * wmperry Jun 1, 2001
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 * XmuPrintDefaultErrorMessage - print a nice error that looks like the usual
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 * message. Return 1 if the caller should consider exiting, else 0.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 int XmuPrintDefaultErrorMessage (Display *dpy, XErrorEvent *event, FILE *fp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 char buffer[BUFSIZ];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 char mesg[BUFSIZ];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 char number[32];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 char *mtype = "XlibMessage";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 _XExtension *ext = (_XExtension *)NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 XGetErrorText(dpy, event->error_code, buffer, BUFSIZ);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 fprintf(fp, "%s: %s\n ", mesg, buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 mesg, BUFSIZ);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 fprintf(fp, mesg, event->request_code);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 if (event->request_code < 128) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 sprintf(number, "%d", event->request_code);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 } else {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 /* XXX this is non-portable */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 for (ext = dpy->ext_procs;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 ext && (ext->codes.major_opcode != event->request_code);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 ext = ext->next)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 if (ext)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 strcpy(buffer, ext->name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 buffer[0] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 fprintf(fp, " (%s)", buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 fputs("\n ", fp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 #if (XtSpecificationRelease >= 5)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 if (event->request_code >= 128) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 mesg, BUFSIZ);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 fprintf(fp, mesg, event->minor_code);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 if (ext) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 sprintf(mesg, "%s.%d", ext->name, event->minor_code);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 XGetErrorDatabaseText(dpy, "XRequest", mesg, "", buffer, BUFSIZ);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 fprintf(fp, " (%s)", buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 fputs("\n ", fp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 if (event->error_code >= 128) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 /* let extensions try to print the values */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 /* XXX this is non-portable code */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 for (ext = dpy->ext_procs; ext; ext = ext->next) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 if (ext->error_values)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 (*ext->error_values)(dpy, event, fp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 /* the rest is a fallback, providing a simple default */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 /* kludge, try to find the extension that caused it */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 buffer[0] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 for (ext = dpy->ext_procs; ext; ext = ext->next) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 if (ext->error_string)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 (*ext->error_string)(dpy, event->error_code, &ext->codes,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 buffer, BUFSIZ);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 if (buffer[0])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 if (buffer[0])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 sprintf(buffer, "%s.%d", ext->name,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 event->error_code - ext->codes.first_error);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 strcpy(buffer, "Value");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 XGetErrorDatabaseText(dpy, mtype, buffer, "", mesg, BUFSIZ);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 if (*mesg) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 fprintf(fp, mesg, event->resourceid);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 fputs("\n ", fp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 } else if ((event->error_code == BadWindow) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 (event->error_code == BadPixmap) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 (event->error_code == BadCursor) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 (event->error_code == BadFont) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 (event->error_code == BadDrawable) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 (event->error_code == BadColor) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 (event->error_code == BadGC) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 (event->error_code == BadIDChoice) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 (event->error_code == BadValue) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 (event->error_code == BadAtom)) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 if (event->error_code == BadValue)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 XGetErrorDatabaseText(dpy, mtype, "Value", "Value 0x%x",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 mesg, BUFSIZ);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 else if (event->error_code == BadAtom)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 XGetErrorDatabaseText(dpy, mtype, "AtomID", "AtomID 0x%x",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 mesg, BUFSIZ);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 mesg, BUFSIZ);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 fprintf(fp, mesg, event->resourceid);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 fputs("\n ", fp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 #elif (XtSpecificationRelease == 4)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 mesg, BUFSIZ);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 fprintf(fp, mesg, event->minor_code);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 fputs("\n ", fp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 if (ext) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 sprintf(mesg, "%s.%d", ext->name, event->minor_code);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 XGetErrorDatabaseText(dpy, "XRequest", mesg, "", buffer, BUFSIZ);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 fprintf(fp, " (%s)", buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 mesg, BUFSIZ);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 fprintf(fp, mesg, event->resourceid);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 fputs("\n ", fp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 ERROR! Unsupported release of X11
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 mesg, BUFSIZ);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 fprintf(fp, mesg, event->serial);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 fputs("\n ", fp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 XGetErrorDatabaseText(dpy, mtype, "CurrentSerial", "Current Serial #%d",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 mesg, BUFSIZ);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 fprintf(fp, mesg, NextRequest(dpy)-1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 fputs("\n", fp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 if (event->error_code == BadImplementation) return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 return 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 * XmuSimpleErrorHandler - ignore errors for XQueryTree, XGetWindowAttributes,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 * and XGetGeometry; print a message for everything else. In all case, do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 * not exit.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 int XmuSimpleErrorHandler (Display *dpy, XErrorEvent *errorp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 switch (errorp->request_code) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 case X_QueryTree:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 case X_GetWindowAttributes:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 if (errorp->error_code == BadWindow) return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 case X_GetGeometry:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 if (errorp->error_code == BadDrawable) return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 /* got a "real" X error */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 return XmuPrintDefaultErrorMessage (dpy, errorp, stderr);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
309 void XmuCopyISOLatin1Lowered(char *dst, const char *src)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 unsigned char *dest = (unsigned char *) dst;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 unsigned char *source = (unsigned char *) src;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 for ( ; *source; source++, dest++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 if ((*source >= XK_A) && (*source <= XK_Z))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 *dest = *source + (XK_a - XK_A);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 else if ((*source >= XK_Agrave) && (*source <= XK_Odiaeresis))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 *dest = *source + (XK_agrave - XK_Agrave);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 else if ((*source >= XK_Ooblique) && (*source <= XK_Thorn))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 *dest = *source + (XK_oslash - XK_Ooblique);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 *dest = *source;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 *dest = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 #endif /* !HAVE_XMU */