|
Packit |
5bd3a9 |
/*
|
|
Packit |
5bd3a9 |
|
|
Packit |
5bd3a9 |
Copyright 1986, 1998 The Open Group
|
|
Packit |
5bd3a9 |
|
|
Packit |
5bd3a9 |
Permission to use, copy, modify, distribute, and sell this software and its
|
|
Packit |
5bd3a9 |
documentation for any purpose is hereby granted without fee, provided that
|
|
Packit |
5bd3a9 |
the above copyright notice appear in all copies and that both that
|
|
Packit |
5bd3a9 |
copyright notice and this permission notice appear in supporting
|
|
Packit |
5bd3a9 |
documentation.
|
|
Packit |
5bd3a9 |
|
|
Packit |
5bd3a9 |
The above copyright notice and this permission notice shall be included in
|
|
Packit |
5bd3a9 |
all copies or substantial portions of the Software.
|
|
Packit |
5bd3a9 |
|
|
Packit |
5bd3a9 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
Packit |
5bd3a9 |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
Packit |
5bd3a9 |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
Packit |
5bd3a9 |
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
|
Packit |
5bd3a9 |
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
Packit |
5bd3a9 |
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
Packit |
5bd3a9 |
|
|
Packit |
5bd3a9 |
Except as contained in this notice, the name of The Open Group shall not be
|
|
Packit |
5bd3a9 |
used in advertising or otherwise to promote the sale, use or other dealings
|
|
Packit |
5bd3a9 |
in this Software without prior written authorization from The Open Group.
|
|
Packit |
5bd3a9 |
|
|
Packit |
5bd3a9 |
*/
|
|
Packit |
5bd3a9 |
|
|
Packit |
5bd3a9 |
#ifdef HAVE_CONFIG_H
|
|
Packit |
5bd3a9 |
#include <config.h>
|
|
Packit |
5bd3a9 |
#endif
|
|
Packit |
5bd3a9 |
#include <X11/Xlibint.h>
|
|
Packit |
5bd3a9 |
#include <X11/Xatom.h>
|
|
Packit |
5bd3a9 |
|
|
Packit |
5bd3a9 |
/* insulate predefined atom numbers from cut routines */
|
|
Packit |
5bd3a9 |
static const Atom n_to_atom[8] = {
|
|
Packit |
5bd3a9 |
XA_CUT_BUFFER0,
|
|
Packit |
5bd3a9 |
XA_CUT_BUFFER1,
|
|
Packit |
5bd3a9 |
XA_CUT_BUFFER2,
|
|
Packit |
5bd3a9 |
XA_CUT_BUFFER3,
|
|
Packit |
5bd3a9 |
XA_CUT_BUFFER4,
|
|
Packit |
5bd3a9 |
XA_CUT_BUFFER5,
|
|
Packit |
5bd3a9 |
XA_CUT_BUFFER6,
|
|
Packit |
5bd3a9 |
XA_CUT_BUFFER7};
|
|
Packit |
5bd3a9 |
|
|
Packit |
5bd3a9 |
int
|
|
Packit |
5bd3a9 |
XRotateBuffers (
|
|
Packit |
5bd3a9 |
register Display *dpy,
|
|
Packit |
5bd3a9 |
int rotate)
|
|
Packit |
5bd3a9 |
{
|
|
Packit |
5bd3a9 |
/* XRotateWindowProperties wants a non-const Atom*, but it doesn't
|
|
Packit |
5bd3a9 |
* modify it, so this is safe.
|
|
Packit |
5bd3a9 |
*/
|
|
Packit |
5bd3a9 |
return XRotateWindowProperties(dpy, RootWindow(dpy, 0), (Atom *)n_to_atom, 8, rotate);
|
|
Packit |
5bd3a9 |
}
|
|
Packit |
5bd3a9 |
|
|
Packit |
5bd3a9 |
char *XFetchBuffer (
|
|
Packit |
5bd3a9 |
register Display *dpy,
|
|
Packit |
5bd3a9 |
int *nbytes,
|
|
Packit |
5bd3a9 |
register int buffer)
|
|
Packit |
5bd3a9 |
{
|
|
Packit |
5bd3a9 |
Atom actual_type;
|
|
Packit |
5bd3a9 |
int actual_format;
|
|
Packit |
5bd3a9 |
unsigned long nitems;
|
|
Packit |
5bd3a9 |
unsigned long leftover;
|
|
Packit |
5bd3a9 |
unsigned char *data;
|
|
Packit |
5bd3a9 |
*nbytes = 0;
|
|
Packit |
5bd3a9 |
if ((buffer < 0) || (buffer > 7)) return (NULL);
|
|
Packit |
5bd3a9 |
/* XXX should be (sizeof (maxint) - 1)/4 */
|
|
Packit |
5bd3a9 |
if (XGetWindowProperty(dpy, RootWindow(dpy, 0), n_to_atom[buffer],
|
|
Packit |
5bd3a9 |
0L, 10000000L, False, XA_STRING,
|
|
Packit |
5bd3a9 |
&actual_type, &actual_format, &nitems, &leftover, &data) != Success) {
|
|
Packit |
5bd3a9 |
return (NULL);
|
|
Packit |
5bd3a9 |
}
|
|
Packit |
5bd3a9 |
if ( (actual_type == XA_STRING) && (actual_format != 32) ) {
|
|
Packit |
5bd3a9 |
*nbytes = nitems;
|
|
Packit |
5bd3a9 |
return((char *)data);
|
|
Packit |
5bd3a9 |
}
|
|
Packit |
5bd3a9 |
Xfree (data);
|
|
Packit |
5bd3a9 |
return(NULL);
|
|
Packit |
5bd3a9 |
}
|
|
Packit |
5bd3a9 |
|
|
Packit |
5bd3a9 |
char *XFetchBytes (
|
|
Packit |
5bd3a9 |
register Display *dpy,
|
|
Packit |
5bd3a9 |
int *nbytes)
|
|
Packit |
5bd3a9 |
{
|
|
Packit |
5bd3a9 |
return (XFetchBuffer (dpy, nbytes, 0));
|
|
Packit |
5bd3a9 |
}
|
|
Packit |
5bd3a9 |
|
|
Packit |
5bd3a9 |
int
|
|
Packit |
5bd3a9 |
XStoreBuffer (
|
|
Packit |
5bd3a9 |
register Display *dpy,
|
|
Packit |
5bd3a9 |
_Xconst char *bytes,
|
|
Packit |
5bd3a9 |
int nbytes,
|
|
Packit |
5bd3a9 |
register int buffer)
|
|
Packit |
5bd3a9 |
{
|
|
Packit |
5bd3a9 |
if ((buffer < 0) || (buffer > 7)) return 0;
|
|
Packit |
5bd3a9 |
return XChangeProperty(dpy, RootWindow(dpy, 0), n_to_atom[buffer],
|
|
Packit |
5bd3a9 |
XA_STRING, 8, PropModeReplace, (_Xconst unsigned char *) bytes, nbytes);
|
|
Packit |
5bd3a9 |
}
|
|
Packit |
5bd3a9 |
|
|
Packit |
5bd3a9 |
int
|
|
Packit |
5bd3a9 |
XStoreBytes (
|
|
Packit |
5bd3a9 |
register Display *dpy,
|
|
Packit |
5bd3a9 |
_Xconst char *bytes,
|
|
Packit |
5bd3a9 |
int nbytes)
|
|
Packit |
5bd3a9 |
{
|
|
Packit |
5bd3a9 |
return XStoreBuffer (dpy, bytes, nbytes, 0);
|
|
Packit |
5bd3a9 |
}
|