2 * WindowMaker miscelaneous functions
4 * Copyright (c) 1997 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., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include <X11/Xutil.h>
25 #include <X11/Xatom.h>
34 static Atom Clipboard
=0;
37 static char *requestCodes
[] = {
40 "X_ChangeWindowAttributes",
41 "X_GetWindowAttributes",
43 "X_DestroySubwindows",
60 "X_SetSelectionOwner",
61 "X_GetSelectionOwner",
68 "X_ChangeActivePointerGrab",
88 "X_ListFontsWithInfo",
97 "X_SetClipRectangles",
108 "X_PolyFillRectangle",
118 "X_CopyColormapAndFree",
120 "X_UninstallColormap",
121 "X_ListInstalledColormaps",
125 "X_AllocColorPlanes",
132 "X_CreateGlyphCursor",
138 "X_ChangeKeyboardMapping",
139 "X_GetKeyboardMapping",
140 "X_ChangeKeyboardControl",
141 "X_GetKeyboardControl",
143 "X_ChangePointerControl",
144 "X_GetPointerControl",
149 "X_SetAccessControl",
150 "X_SetCloseDownMode",
152 "X_RotateProperties",
153 "X_ForceScreenSaver",
154 "X_SetPointerMapping",
155 "X_GetPointerMapping",
156 "X_SetModifierMapping",
157 "X_GetModifierMapping",
163 FormatXError(Display
*dpy
, XErrorEvent
*error
, char *buffer
, int size
)
167 XGetErrorText(dpy
, error
->error_code
, buffer
, size
);
172 if (error
->request_code
>= sizeof(requestCodes
)/sizeof(char*)) {
173 sprintf(buffer
, "\n Request code: %i\n",
174 error
->request_code
);
176 sprintf(buffer
, "\n Request code: %i %s\n", error
->request_code
,
177 requestCodes
[error
->request_code
]);
179 i
+= p
= strlen(buffer
);
183 sprintf(buffer
, " Request minor code: %i\n", error
->minor_code
);
184 i
+= p
= strlen(buffer
);
188 sprintf(buffer
, " Resource ID: 0x%x\n", (unsigned int)error
->resourceid
);
189 i
+= p
= strlen(buffer
);
193 sprintf(buffer
, " Error serial: %li\n", error
->serial
);
200 *----------------------------------------------------------------------
202 * Request for the current primary selection.
203 *----------------------------------------------------------------------
206 RequestSelection(Display
*dpy
, Window requestor
, Time timestamp
)
209 Clipboard
= XInternAtom(dpy
, "CLIPBOARD", False
);
211 XConvertSelection(dpy
, XA_PRIMARY
, XA_STRING
, Clipboard
, requestor
,
217 GetSelection(Display
*dpy
, Window requestor
)
221 unsigned long len
, bytes
;
224 XGetWindowProperty(dpy
, requestor
, Clipboard
,
225 0, MAXLINE
/4, False
, XA_STRING
,
226 &rtype
, &bits
, &len
, &bytes
, &data
);
227 if ((rtype
!=XA_STRING
) || (bits
!=8)) {
228 wwarning(_("invalid data in selection"));
229 if (data
) XFree(data
);