wmaker: Replaced local 'extern' definition of wPreferences by proper header usage
[wmaker-crm.git] / src / xutil.c
blob3d1e83eda01c216c10697745f833292f5bd766bf
1 /*
2 * WindowMaker miscelaneous functions
4 * Copyright (c) 1997-2003 Alfredo K. Kojima
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
19 * MA 02110-1301, USA.
22 #include <X11/Xlib.h>
23 #include <stdlib.h>
24 #include <X11/Xutil.h>
25 #include <X11/Xatom.h>
26 #include <stdio.h>
27 #include <string.h>
29 #include "wconfig.h"
31 #include "xutil.h"
33 #include <WINGs/WUtil.h>
34 #if 0
35 static Atom Clipboard = 0;
36 #endif
38 static char *requestCodes[] = {
39 "DUMMY",
40 "X_CreateWindow",
41 "X_ChangeWindowAttributes",
42 "X_GetWindowAttributes",
43 "X_DestroyWindow",
44 "X_DestroySubwindows",
45 "X_ChangeSaveSet",
46 "X_ReparentWindow",
47 "X_MapWindow",
48 "X_MapSubwindows",
49 "X_UnmapWindow",
50 "X_UnmapSubwindows",
51 "X_ConfigureWindow",
52 "X_CirculateWindow",
53 "X_GetGeometry",
54 "X_QueryTree",
55 "X_InternAtom",
56 "X_GetAtomName",
57 "X_ChangeProperty",
58 "X_DeleteProperty",
59 "X_GetProperty",
60 "X_ListProperties",
61 "X_SetSelectionOwner",
62 "X_GetSelectionOwner",
63 "X_ConvertSelection",
64 "X_SendEvent",
65 "X_GrabPointer",
66 "X_UngrabPointer",
67 "X_GrabButton",
68 "X_UngrabButton",
69 "X_ChangeActivePointerGrab",
70 "X_GrabKeyboard",
71 "X_UngrabKeyboard",
72 "X_GrabKey",
73 "X_UngrabKey",
74 "X_AllowEvents",
75 "X_GrabServer",
76 "X_UngrabServer",
77 "X_QueryPointer",
78 "X_GetMotionEvents",
79 "X_TranslateCoords",
80 "X_WarpPointer",
81 "X_SetInputFocus",
82 "X_GetInputFocus",
83 "X_QueryKeymap",
84 "X_OpenFont",
85 "X_CloseFont",
86 "X_QueryFont",
87 "X_QueryTextExtents",
88 "X_ListFonts",
89 "X_ListFontsWithInfo",
90 "X_SetFontPath",
91 "X_GetFontPath",
92 "X_CreatePixmap",
93 "X_FreePixmap",
94 "X_CreateGC",
95 "X_ChangeGC",
96 "X_CopyGC",
97 "X_SetDashes",
98 "X_SetClipRectangles",
99 "X_FreeGC",
100 "X_ClearArea",
101 "X_CopyArea",
102 "X_CopyPlane",
103 "X_PolyPoint",
104 "X_PolyLine",
105 "X_PolySegment",
106 "X_PolyRectangle",
107 "X_PolyArc",
108 "X_FillPoly",
109 "X_PolyFillRectangle",
110 "X_PolyFillArc",
111 "X_PutImage",
112 "X_GetImage",
113 "X_PolyText8",
114 "X_PolyText16",
115 "X_ImageText8",
116 "X_ImageText16",
117 "X_CreateColormap",
118 "X_FreeColormap",
119 "X_CopyColormapAndFree",
120 "X_InstallColormap",
121 "X_UninstallColormap",
122 "X_ListInstalledColormaps",
123 "X_AllocColor",
124 "X_AllocNamedColor",
125 "X_AllocColorCells",
126 "X_AllocColorPlanes",
127 "X_FreeColors",
128 "X_StoreColors",
129 "X_StoreNamedColor",
130 "X_QueryColors",
131 "X_LookupColor",
132 "X_CreateCursor",
133 "X_CreateGlyphCursor",
134 "X_FreeCursor",
135 "X_RecolorCursor",
136 "X_QueryBestSize",
137 "X_QueryExtension",
138 "X_ListExtensions",
139 "X_ChangeKeyboardMapping",
140 "X_GetKeyboardMapping",
141 "X_ChangeKeyboardControl",
142 "X_GetKeyboardControl",
143 "X_Bell",
144 "X_ChangePointerControl",
145 "X_GetPointerControl",
146 "X_SetScreenSaver",
147 "X_GetScreenSaver",
148 "X_ChangeHosts",
149 "X_ListHosts",
150 "X_SetAccessControl",
151 "X_SetCloseDownMode",
152 "X_KillClient",
153 "X_RotateProperties",
154 "X_ForceScreenSaver",
155 "X_SetPointerMapping",
156 "X_GetPointerMapping",
157 "X_SetModifierMapping",
158 "X_GetModifierMapping",
159 "X_NoOperation"
162 void FormatXError(Display * dpy, XErrorEvent * error, char *buffer, int size)
164 int i, p;
166 XGetErrorText(dpy, error->error_code, buffer, size);
167 i = strlen(buffer);
168 if (i > size - 100)
169 return;
170 buffer += i;
171 if (error->request_code >= sizeof(requestCodes) / sizeof(requestCodes[0])) {
172 sprintf(buffer, "\n Request code: %i\n", error->request_code);
173 } else {
174 sprintf(buffer, "\n Request code: %i %s\n", error->request_code,
175 requestCodes[error->request_code]);
177 i += p = strlen(buffer);
178 if (i > size - 40)
179 return;
180 buffer += p;
181 sprintf(buffer, " Request minor code: %i\n", error->minor_code);
182 i += p = strlen(buffer);
183 if (i > size - 30)
184 return;
185 buffer += p;
186 sprintf(buffer, " Resource ID: 0x%x\n", (unsigned int)error->resourceid);
187 i += p = strlen(buffer);
188 if (i > size - 30)
189 return;
190 buffer += p;
191 sprintf(buffer, " Error serial: %li\n", error->serial);
192 return;