1
/* $Xorg: pl_escape.c,v 1.4 2001/02/09 02:03:27 xorgcvs Exp $ */
4
Copyright 1992, 1998 The Open Group
6
Permission to use, copy, modify, distribute, and sell this software and its
7
documentation for any purpose is hereby granted without fee, provided that
8
the above copyright notice appear in all copies and that both that
9
copyright notice and this permission notice appear in supporting
12
The above copyright notice and this permission notice shall be included
13
in all copies or substantial portions of the Software.
15
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
19
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21
OTHER DEALINGS IN THE SOFTWARE.
23
Except as contained in this notice, the name of The Open Group shall
24
not be used in advertising or otherwise to promote the sale, use or
25
other dealings in this Software without prior written authorization
31
#include "PEXlibint.h"
35
PEXEscape (display, escapeID, escapeDataSize, escapeData)
37
INPUT Display *display;
38
INPUT unsigned long escapeID;
39
INPUT int escapeDataSize;
40
INPUT char *escapeData;
43
register pexEscapeReq *req;
48
* Lock around the critical section, for multithreading.
51
LockDisplay (display);
55
* Put the request in the X request buffer.
58
PEXGetReq (Escape, pBuf);
60
BEGIN_REQUEST_HEADER (Escape, pBuf, req);
62
PEXStoreReqExtraHead (Escape, escapeDataSize, req);
63
req->escapeID = escapeID;
65
END_REQUEST_HEADER (Escape, pBuf, req);
67
Data (display, escapeData, escapeDataSize);
71
* Done, so unlock and check for synchronous-ness.
74
UnlockDisplay (display);
75
PEXSyncHandle (display);
80
PEXEscapeWithReply (display, escapeID, escapeDataSize,
81
escapeData, escapeOutDataSize)
83
INPUT Display *display;
84
INPUT unsigned long escapeID;
85
INPUT int escapeDataSize;
86
INPUT char *escapeData;
87
OUTPUT unsigned long *escapeOutDataSize;
90
register pexEscapeWithReplyReq *req;
92
pexEscapeWithReplyReply rep;
98
* Lock around the critical section, for multithreading.
101
LockDisplay (display);
105
* Put the request in the X request buffer and get a reply.
108
PEXGetReq (EscapeWithReply, pBuf);
110
BEGIN_REQUEST_HEADER (EscapeWithReply, pBuf, req);
112
PEXStoreReqExtraHead (EscapeWithReply, escapeDataSize, req);
113
req->escapeID = escapeID;
115
END_REQUEST_HEADER (EscapeWithReply, pBuf, req);
117
Data (display, escapeData, escapeDataSize);
119
if (_XReply (display, (xReply *)&rep, 0, xFalse) == 0)
121
UnlockDisplay (display);
122
PEXSyncHandle (display);
123
*escapeOutDataSize = 0;
124
return (NULL); /* return an error */
127
*escapeOutDataSize = 20 + (rep.length << 2);
131
* Allocate a buffer for the reply escape data
134
escRepData = escRepDataRet = Xmalloc ((unsigned) *escapeOutDataSize);
136
memcpy (escRepData, rep.escape_specific, 20);
140
_XRead (display, (char *) escRepData, (long) (rep.length << 2));
144
* Done, so unlock and check for synchronous-ness.
147
UnlockDisplay (display);
148
PEXSyncHandle (display);
150
return (escRepDataRet);
154
void PEXSetEchoColor (display, renderer, color_type, color)
156
INPUT Display *display;
157
INPUT PEXRenderer renderer;
158
INPUT int color_type;
159
INPUT PEXColor *color;
164
pexEscapeSetEchoColorData *header;
171
* Fill in the escape record.
174
escapeSize = SIZEOF (pexEscapeSetEchoColorData) +
175
SIZEOF (pexColorSpecifier) + GetColorSize (color_type);
177
escapeData = Xmalloc (escapeSize);
179
fpFormat = PEXGetProtocolFloatFormat (display);
180
fpConvert = (fpFormat != NATIVE_FP_FORMAT);
182
header = (pexEscapeSetEchoColorData *) escapeData;
183
header->fpFormat = fpFormat;
184
header->rdr = renderer;
186
ptr = escapeData + SIZEOF (pexEscapeSetEchoColorData);
187
STORE_INT16 (color_type, ptr);
189
STORE_COLOR_VAL (color_type, (*color), ptr, fpConvert, fpFormat);
193
* Generate the escape.
196
PEXEscape (display, PEXEscapeSetEchoColor, (int) escapeSize, escapeData);