Window placement fix
[wmaker-crm.git] / src / xutil.c
blob566d500d272634b81e475e60d1322aae70ff2a7e
1 /*
2 * WindowMaker miscelaneous functions
3 *
4 * Copyright (c) 1997 Alfredo K. Kojima
5 *
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., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include <X11/Xlib.h>
23 #include <stdlib.h>
24 #include <X11/Xutil.h>
25 #include <X11/Xatom.h>
26 #include <stdio.h>
28 #include "wconfig.h"
30 #include "xutil.h"
32 #include <WUtil.h>
33 #if 0
34 static Atom Clipboard=0;
35 #endif
37 static char *requestCodes[] = {
38 "DUMMY",
39 "X_CreateWindow",
40 "X_ChangeWindowAttributes",
41 "X_GetWindowAttributes",
42 "X_DestroyWindow",
43 "X_DestroySubwindows",
44 "X_ChangeSaveSet",
45 "X_ReparentWindow",
46 "X_MapWindow",
47 "X_MapSubwindows",
48 "X_UnmapWindow",
49 "X_UnmapSubwindows",
50 "X_ConfigureWindow",
51 "X_CirculateWindow",
52 "X_GetGeometry",
53 "X_QueryTree",
54 "X_InternAtom",
55 "X_GetAtomName",
56 "X_ChangeProperty",
57 "X_DeleteProperty",
58 "X_GetProperty",
59 "X_ListProperties",
60 "X_SetSelectionOwner",
61 "X_GetSelectionOwner",
62 "X_ConvertSelection",
63 "X_SendEvent",
64 "X_GrabPointer",
65 "X_UngrabPointer",
66 "X_GrabButton",
67 "X_UngrabButton",
68 "X_ChangeActivePointerGrab",
69 "X_GrabKeyboard",
70 "X_UngrabKeyboard",
71 "X_GrabKey",
72 "X_UngrabKey",
73 "X_AllowEvents",
74 "X_GrabServer",
75 "X_UngrabServer",
76 "X_QueryPointer",
77 "X_GetMotionEvents",
78 "X_TranslateCoords",
79 "X_WarpPointer",
80 "X_SetInputFocus",
81 "X_GetInputFocus",
82 "X_QueryKeymap",
83 "X_OpenFont",
84 "X_CloseFont",
85 "X_QueryFont",
86 "X_QueryTextExtents",
87 "X_ListFonts",
88 "X_ListFontsWithInfo",
89 "X_SetFontPath",
90 "X_GetFontPath",
91 "X_CreatePixmap",
92 "X_FreePixmap",
93 "X_CreateGC",
94 "X_ChangeGC",
95 "X_CopyGC",
96 "X_SetDashes",
97 "X_SetClipRectangles",
98 "X_FreeGC",
99 "X_ClearArea",
100 "X_CopyArea",
101 "X_CopyPlane",
102 "X_PolyPoint",
103 "X_PolyLine",
104 "X_PolySegment",
105 "X_PolyRectangle",
106 "X_PolyArc",
107 "X_FillPoly",
108 "X_PolyFillRectangle",
109 "X_PolyFillArc",
110 "X_PutImage",
111 "X_GetImage",
112 "X_PolyText8",
113 "X_PolyText16",
114 "X_ImageText8",
115 "X_ImageText16",
116 "X_CreateColormap",
117 "X_FreeColormap",
118 "X_CopyColormapAndFree",
119 "X_InstallColormap",
120 "X_UninstallColormap",
121 "X_ListInstalledColormaps",
122 "X_AllocColor",
123 "X_AllocNamedColor",
124 "X_AllocColorCells",
125 "X_AllocColorPlanes",
126 "X_FreeColors",
127 "X_StoreColors",
128 "X_StoreNamedColor",
129 "X_QueryColors",
130 "X_LookupColor",
131 "X_CreateCursor",
132 "X_CreateGlyphCursor",
133 "X_FreeCursor",
134 "X_RecolorCursor",
135 "X_QueryBestSize",
136 "X_QueryExtension",
137 "X_ListExtensions",
138 "X_ChangeKeyboardMapping",
139 "X_GetKeyboardMapping",
140 "X_ChangeKeyboardControl",
141 "X_GetKeyboardControl",
142 "X_Bell",
143 "X_ChangePointerControl",
144 "X_GetPointerControl",
145 "X_SetScreenSaver",
146 "X_GetScreenSaver",
147 "X_ChangeHosts",
148 "X_ListHosts",
149 "X_SetAccessControl",
150 "X_SetCloseDownMode",
151 "X_KillClient",
152 "X_RotateProperties",
153 "X_ForceScreenSaver",
154 "X_SetPointerMapping",
155 "X_GetPointerMapping",
156 "X_SetModifierMapping",
157 "X_GetModifierMapping",
158 "X_NoOperation"
162 void
163 FormatXError(Display *dpy, XErrorEvent *error, char *buffer, int size)
165 int i, p;
167 XGetErrorText(dpy, error->error_code, buffer, size);
168 i = strlen(buffer);
169 if (i > size-100)
170 return;
171 buffer += i;
172 if (error->request_code >= sizeof(requestCodes)/sizeof(char*)) {
173 sprintf(buffer, "\n Request code: %i\n",
174 error->request_code);
175 } else {
176 sprintf(buffer, "\n Request code: %i %s\n", error->request_code,
177 requestCodes[error->request_code]);
179 i += p = strlen(buffer);
180 if (i > size - 40)
181 return;
182 buffer += p;
183 sprintf(buffer, " Request minor code: %i\n", error->minor_code);
184 i += p = strlen(buffer);
185 if (i > size - 30)
186 return;
187 buffer += p;
188 sprintf(buffer, " Resource ID: 0x%x\n", (unsigned int)error->resourceid);
189 i += p = strlen(buffer);
190 if (i > size - 30)
191 return;
192 buffer += p;
193 sprintf(buffer, " Error serial: %li\n", error->serial);
194 return;