3
* (c) Copyright 1990-1994 Adobe Systems Incorporated.
6
* Permission to use, copy, modify, distribute, and sublicense this software
7
* and its documentation for any purpose and without fee is hereby granted,
8
* provided that the above copyright notices appear in all copies and that
9
* both those copyright notices and this permission notice appear in
10
* supporting documentation and that the name of Adobe Systems Incorporated
11
* not be used in advertising or publicity pertaining to distribution of the
12
* software without specific, written prior permission. No trademark license
13
* to use the Adobe trademarks is hereby granted. If the Adobe trademark
14
* "Display PostScript"(tm) is used to describe this software, its
15
* functionality or for any other purpose, such use shall be limited to a
16
* statement that this software works in conjunction with the Display
17
* PostScript system. Proper trademark attribution to reflect Adobe's
18
* ownership of the trademark shall be given whenever any such reference to
19
* the Display PostScript system is made.
21
* ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
22
* ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
23
* ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
24
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25
* NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
26
* TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
27
* DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
28
* NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
29
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
30
* PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
32
* Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
33
* Incorporated which may be registered in certain jurisdictions
35
* Author: Adobe Systems Incorporated
37
/* $XFree86: xc/programs/dpsexec/dpsexec.c,v 1.7 2002/03/05 21:50:15 herrb Exp $ */
49
#include <DPS/XDPSlib.h>
50
#include <DPS/dpsXclient.h>
53
#include <sys/select.h>
62
#define ARGCAST void *
65
static void MyStatusProc (ctxt, code)
69
if (code == PSZOMBIE) {
70
/* Zombie event means context died */
79
char *displayname = "";
90
XSetWindowAttributes xswa;
95
int height = W_HEIGHT;
96
Drawable drawable = None;
98
for (i = 1; i < argc; i++) {
99
if (strncmp(argv[i], "-display", strlen(argv[i])) == 0) {
101
displayname = argv[i];
102
} else if (strncmp(argv[i], "-sync", strlen(argv[i])) == 0)
104
else if (strncmp(argv[i], "-backup", strlen(argv[i])) == 0)
106
else if (strncmp(argv[i], "-noexec", strlen(argv[i])) == 0)
108
else if (strncmp(argv[i], "-root", strlen(argv[i])) == 0)
110
else if (strncmp(argv[i], "-width", strlen(argv[i])) == 0)
111
width = atoi(argv[++i]);
112
else if (strncmp(argv[i], "-height", strlen(argv[i])) == 0)
113
height = atoi(argv[++i]);
114
else if (strncmp(argv[i], "-drawable", strlen(argv[i])) == 0)
115
drawable = (Drawable) atoi(argv[++i]);
118
"usage: %s [-display displayname][-sync][-backup][-noexec]\n",
121
" [-root][-width w][-height h][-drawable xid]\n");
126
dpy = XOpenDisplay(displayname);
128
fprintf(stderr, "%s: Can't open display %s!\n", argv[0], displayname);
132
if (sync) (void) XSynchronize(dpy, True);
134
gc = XCreateGC(dpy, drawable != None ? drawable :
135
RootWindow (dpy, DefaultScreen (dpy)), 0, NULL);
136
XSetForeground(dpy, gc, BlackPixel (dpy, DefaultScreen (dpy)));
137
XSetBackground(dpy, gc, WhitePixel (dpy, DefaultScreen (dpy)));
140
win = DefaultRootWindow(dpy);
141
height = DisplayHeight(dpy, DefaultScreen(dpy));
142
} else if (drawable != None) {
145
unsigned int wwidth, wheight, border, depth;
147
(void) XGetGeometry(dpy, win, &root, &x, &y, &wwidth,
148
&wheight, &border, &depth);
151
win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy),
152
3, 385, width, height, 1,
153
BlackPixel(dpy, DefaultScreen(dpy)),
154
WhitePixel(dpy, DefaultScreen(dpy)));
156
hints = XAllocWMHints();
158
hints->flags = InputHint;
159
hints->input = False;
160
XSetWMHints(dpy, win, hints);
161
XFree((char *) hints);
164
XStoreName(dpy, win, "Display PostScript Executive");
165
XSetIconName(dpy, win, "DPS Exec");
167
xswa.bit_gravity = SouthWestGravity;
168
if (backingStore) xswa.backing_store = WhenMapped;
169
else xswa.backing_store = NotUseful;
170
xswa.event_mask = 0x0;
171
mask = CWBitGravity | CWBackingStore | CWEventMask;
172
XChangeWindowAttributes(dpy, win, mask, &xswa);
174
XMapWindow(dpy, win);
177
/* Make it possible for this client to start a DPS NX agent,
178
if "dpsnx.agent" is on the executable search path. */
180
(void) XDPSNXSetClientArg(XDPSNX_AUTO_LAUNCH, (ARGCAST) True);
182
ctxt = XDPSCreateSimpleContext(dpy, win, gc, 0, height,
183
DPSDefaultTextBackstop,
184
DPSDefaultErrorProc, NULL);
187
fprintf (stderr, "\ndpsexec: DPS is not available\n");
189
"You need an X server with the DPS extension, or a DPS NX agent.\n");
195
/* Allow zombie events to be delivered so application can exit
196
if context dies. Detach context so it doesn't wait for a join
199
XDPSRegisterStatusProc(ctxt, MyStatusProc);
200
XDPSSetStatusMask(ctxt, PSZOMBIEMASK, 0, 0);
201
DPSPrintf(ctxt, "currentcontext detach ");
203
if (exe) DPSPrintf(ctxt, "executive");
204
DPSPrintf(ctxt, "\n");
205
DPSFlushContext(ctxt);
206
DPSSuppressBinaryConversion(ctxt, True);
212
FD_SET(ConnectionNumber(dpy), &fdmask);
213
DPSFlushContext(ctxt);
214
if (select(ConnectionNumber(dpy)+1, &fdmask, NULL, NULL, NULL) < 0)
215
fprintf(stderr, "select() error %d\n", errno);
216
else if (FD_ISSET(0, &fdmask)) {
217
/* Read from command line, send to context */
218
if (fgets(buf, 1000, stdin) == NULL) break;
219
DPSWriteData(ctxt, buf, strlen(buf));
222
while (XPending(dpy) > 0) {
223
/* No special event handling - just throw them away.
224
Must call XNextEvent to allow DPS status events to
226
XNextEvent(dpy, &ev);
230
DPSDestroySpace(DPSSpaceFromContext(ctxt));