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;
36 static char *requestCodes
[] = {
39 "X_ChangeWindowAttributes",
40 "X_GetWindowAttributes",
42 "X_DestroySubwindows",
59 "X_SetSelectionOwner",
60 "X_GetSelectionOwner",
67 "X_ChangeActivePointerGrab",
87 "X_ListFontsWithInfo",
96 "X_SetClipRectangles",
107 "X_PolyFillRectangle",
117 "X_CopyColormapAndFree",
119 "X_UninstallColormap",
120 "X_ListInstalledColormaps",
124 "X_AllocColorPlanes",
131 "X_CreateGlyphCursor",
137 "X_ChangeKeyboardMapping",
138 "X_GetKeyboardMapping",
139 "X_ChangeKeyboardControl",
140 "X_GetKeyboardControl",
142 "X_ChangePointerControl",
143 "X_GetPointerControl",
148 "X_SetAccessControl",
149 "X_SetCloseDownMode",
151 "X_RotateProperties",
152 "X_ForceScreenSaver",
153 "X_SetPointerMapping",
154 "X_GetPointerMapping",
155 "X_SetModifierMapping",
156 "X_GetModifierMapping",
162 FormatXError(Display
*dpy
, XErrorEvent
*error
, char *buffer
, int size
)
166 XGetErrorText(dpy
, error
->error_code
, buffer
, size
);
171 if (error
->request_code
>= sizeof(requestCodes
)/sizeof(char*)) {
172 sprintf(buffer
, "\n Unknown request code: %i\n",
173 error
->request_code
);
175 sprintf(buffer
, "\n Request code: %i %s\n", error
->request_code
,
176 requestCodes
[error
->request_code
]);
178 i
+= p
= strlen(buffer
);
182 sprintf(buffer
, " Request minor code: %i\n", error
->minor_code
);
183 i
+= p
= strlen(buffer
);
187 sprintf(buffer
, " Resource ID: 0x%x\n", (unsigned int)error
->resourceid
);
188 i
+= p
= strlen(buffer
);
192 sprintf(buffer
, " Error serial: %li\n", error
->serial
);
198 *----------------------------------------------------------------------
200 * Request for the current primary selection.
201 *----------------------------------------------------------------------
204 RequestSelection(Display
*dpy
, Window requestor
, Time timestamp
)
207 Clipboard
= XInternAtom(dpy
, "CLIPBOARD", False
);
209 XConvertSelection(dpy
, XA_PRIMARY
, XA_STRING
, Clipboard
, requestor
,
215 GetSelection(Display
*dpy
, Window requestor
)
219 unsigned long len
, bytes
;
222 XGetWindowProperty(dpy
, requestor
, Clipboard
,
223 0, MAXLINE
/4, False
, XA_STRING
,
224 &rtype
, &bits
, &len
, &bytes
, &data
);
225 if ((rtype
!=XA_STRING
) || (bits
!=8)) {
226 wwarning(_("invalid data in selection"));
227 if (data
) XFree(data
);