Subversion Repositories planix.SVN

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
/* Copyright (C) 1989, 2000 Aladdin Enterprises.  All rights reserved.
2
 
3
  This software is provided AS-IS with no warranty, either express or
4
  implied.
5
 
6
  This software is distributed under license and may not be copied,
7
  modified or distributed except as expressly authorized under the terms
8
  of the license contained in the file LICENSE in this distribution.
9
 
10
  For more information about licensing, please refer to
11
  http://www.ghostscript.com/licensing/. For information on
12
  commercial licensing, go to http://www.artifex.com/licensing/ or
13
  contact Artifex Software, Inc., 101 Lucas Valley Road #110,
14
  San Rafael, CA  94903, U.S.A., +1(415)492-9861.
15
*/
16
 
17
/* $Id: gdevx.h,v 1.7 2002/06/16 07:25:26 lpd Exp $ */
18
/* Definitions for X Windows drivers */
19
/* Requires gxdevice.h and x_.h */
20
 
21
#ifndef gdevx_INCLUDED
22
#  define gdevx_INCLUDED
23
 
24
/* Define the type of an X pixel. */
25
typedef unsigned long x_pixel;
26
 
27
#include "gdevbbox.h"
28
#include "gdevxcmp.h"
29
 
30
/* Declare the X resource tables compiled separately in gdevxres.c. */
31
extern XtResource gdev_x_resources[];
32
extern const int gdev_x_resource_count;
33
extern String gdev_x_fallback_resources[];
34
 
35
/* Define PostScript to X11 font name mapping */
36
/*
37
 * x11fontlist is only used within x11fontmap.
38
 * The names array is managed by Xlib, so the structure is simple.
39
 */
40
typedef struct x11fontlist_s {
41
    char **names;
42
    int count;
43
} x11fontlist;
44
typedef struct x11fontmap_s x11fontmap;
45
struct x11fontmap_s {
46
    char *ps_name;
47
    char *x11_name;
48
    x11fontlist std, iso;
49
    x11fontmap *next;
50
};
51
#define private_st_x11fontmap()	/* in gdevxini.c */\
52
  gs_private_st_ptrs3(st_x11fontmap, x11fontmap, "x11fontmap",\
53
    x11fontmap_enum_ptrs, x11fontmap_reloc_ptrs, ps_name, x11_name, next)
54
 
55
/* Define the X Windows device */
56
typedef struct gx_device_X_s {
57
    gx_device_bbox_common;	/* if target != 0, is image buffer */
58
    /*
59
     * Normally, an X device has an image buffer iff target != 0.  However,
60
     * the bbox device sometimes sets target to NULL temporarily, so we need
61
     * a separate flag to record whether this device is buffered.
62
     */
63
    bool is_buffered;
64
    bool IsPageDevice;
65
    long MaxBitmap;
66
    byte *buffer;		/* full-window image */
67
    long buffer_size;
68
 
69
    /* An XImage object for writing bitmap images to the screen */
70
    XImage image;
71
 
72
    /* Global X state */
73
    Display *dpy;
74
    Screen *scr;
75
    XVisualInfo *vinfo;
76
    Colormap cmap;
77
    Window win;
78
    GC gc;
79
 
80
    /* An optional Window ID supplied as a device parameter */
81
    Window pwin;
82
 
83
    /* A backing pixmap so X will handle exposure automatically */
84
    Pixmap bpixmap;		/* 0 if useBackingPixmap is false, */
85
				/* or if it can't be allocated */
86
    int ghostview;		/* flag to tell if ghostview is in control */
87
    Window mwin;		/* window to receive ghostview messages */
88
    gs_matrix initial_matrix;	/* the initial transformation */
89
    Atom NEXT, PAGE, DONE;	/* Atoms used to talk to ghostview */
90
    struct {
91
	gs_int_rect box;	/* region needing updating */
92
	long area;		/* total area of update */
93
	long total;		/* total of individual area updates */
94
	int count;		/* # of updates since flush */
95
    } update;
96
    Pixmap dest;		/* bpixmap if non-0, else use win */
97
    x_pixel colors_or;		/* 'or' of all device colors used so far */
98
    x_pixel colors_and;		/* 'and' ditto */
99
 
100
    /* An intermediate pixmap for the stencil case of copy_mono */
101
    struct {
102
	Pixmap pixmap;
103
	GC gc;
104
	int raster, height;
105
    } cp;
106
 
107
    /* Structure for dealing with the halftone tile. */
108
    /* Later this might become a multi-element cache. */
109
    struct {
110
	Pixmap pixmap;
111
	Pixmap no_pixmap;	/* kludge to get around X bug */
112
	gx_bitmap_id id;
113
	int width, height, raster;
114
	x_pixel fore_c, back_c;
115
    } ht;
116
 
117
    /* Cache the function and fill style from the GC */
118
    int function;
119
    int fill_style;
120
    Font fid;
121
 
122
#define X_SET_FILL_STYLE(xdev, style)\
123
  BEGIN\
124
    if (xdev->fill_style != (style))\
125
      XSetFillStyle(xdev->dpy, xdev->gc, (xdev->fill_style = (style)));\
126
  END
127
#define X_SET_FUNCTION(xdev, func)\
128
  BEGIN\
129
    if (xdev->function != (func))\
130
      XSetFunction(xdev->dpy, xdev->gc, (xdev->function = (func)));\
131
  END
132
#define X_SET_FONT(xdev, font)\
133
  BEGIN\
134
    if (xdev->fid != (font))\
135
      XSetFont(xdev->dpy, xdev->gc, (xdev->fid = (font)));\
136
  END
137
 
138
    x_pixel back_color, fore_color;
139
 
140
    Pixel background, foreground;
141
 
142
    /*
143
     * The color management structure is defined in gdevxcmp.h and is
144
     * managed by the code in gdevxcmp.c.
145
     */
146
    x11_cman_t cman;
147
 
148
#define NOTE_COLOR(xdev, pixel)\
149
  (xdev->colors_or |= (pixel),\
150
   xdev->colors_and &= (pixel))
151
#define X_SET_BACK_COLOR(xdev, pixel)\
152
  BEGIN\
153
    if (xdev->back_color != (pixel)) {\
154
      xdev->back_color = (pixel);\
155
      NOTE_COLOR(xdev, pixel);\
156
      XSetBackground(xdev->dpy, xdev->gc, (pixel));\
157
    }\
158
  END
159
#define X_SET_FORE_COLOR(xdev, pixel)\
160
  BEGIN\
161
    if (xdev->fore_color != (pixel)) {\
162
      xdev->fore_color = (pixel);\
163
      NOTE_COLOR(xdev, pixel);\
164
      XSetForeground(xdev->dpy, xdev->gc, (pixel));\
165
    }\
166
  END
167
 
168
    /* Defaults set by resources */
169
    Pixel borderColor;
170
    Dimension borderWidth;
171
    String geometry;
172
    int maxGrayRamp, maxRGBRamp;
173
    String palette;
174
    String regularFonts;
175
    String symbolFonts;
176
    String dingbatFonts;
177
    x11fontmap *regular_fonts;
178
    x11fontmap *symbol_fonts;
179
    x11fontmap *dingbat_fonts;
180
    Boolean useXFonts, useFontExtensions, useScalableFonts, logXFonts;
181
    float xResolution, yResolution;
182
 
183
    /* Flags work around various X server problems. */
184
    Boolean useBackingPixmap;
185
    Boolean useXPutImage;
186
    Boolean useXSetTile;
187
 
188
    /*
189
     * Parameters for the screen update algorithms.
190
     */
191
 
192
    /*
193
     * Define whether to update after every write, for debugging.
194
     * Note that one can obtain the same effect by setting any of
195
     */
196
    bool AlwaysUpdate;
197
    /*
198
     * Define the maximum size of the temporary pixmap for copy_mono
199
     * that we are willing to leave lying around in the server
200
     * between uses.
201
     */
202
    int MaxTempPixmap;
203
    /*
204
     * Define the maximum size of the temporary image created in memory
205
     * for get_bits_rectangle.
206
     */
207
    int MaxTempImage;
208
    /*
209
     * Define the maximum buffered updates before doing a screen write.
210
     */
211
    int MaxBufferedTotal;		/* sum of individual areas */
212
    int MaxBufferedArea;		/* area of merged bounding box */
213
    int MaxBufferedCount;		/* number of writes */
214
 
215
    /*
216
     * Buffered text awaiting display.
217
     */
218
    struct {
219
	int item_count;
220
#define IN_TEXT(xdev) ((xdev)->text.item_count != 0)
221
	int char_count;
222
	gs_int_point origin;
223
	int x;			/* after last buffered char */
224
#define MAX_TEXT_ITEMS 12
225
	XTextItem items[MAX_TEXT_ITEMS];
226
#define MAX_TEXT_CHARS 25
227
	char chars[MAX_TEXT_CHARS];
228
    } text;
229
/*
230
 * All the GC parameters are set correctly when we buffer the first
231
 * character: we must call DRAW_TEXT before resetting any of them.
232
 * DRAW_TEXT assumes xdev->text.{item,char}_count > 0.
233
 */
234
#define DRAW_TEXT(xdev)\
235
   XDrawText(xdev->dpy, xdev->dest, xdev->gc, xdev->text.origin.x,\
236
	     xdev->text.origin.y, xdev->text.items, xdev->text.item_count)
237
 
238
} gx_device_X;
239
#define private_st_device_X()	/* in gdevx.c */\
240
  gs_public_st_suffix_add4_final(st_device_X, gx_device_X,\
241
    "gx_device_X", device_x_enum_ptrs, device_x_reloc_ptrs,\
242
    gx_device_finalize, st_device_bbox, buffer, regular_fonts,\
243
    symbol_fonts, dingbat_fonts)
244
 
245
/* Send an event to the Ghostview process */
246
void gdev_x_send_event(gx_device_X *xdev, Atom msg);
247
 
248
/* function to keep track of screen updates */
249
void x_update_add(gx_device_X *, int, int, int, int);
250
void gdev_x_clear_window(gx_device_X *);
251
int x_catch_free_colors(Display *, XErrorEvent *);
252
 
253
/* Number used to distinguish when resolution was set from the command line */
254
#define FAKE_RES (16*72)
255
 
256
/* ------ Inter-module procedures ------ */
257
 
258
/* Exported by gdevxcmp.c for gdevxini.c */
259
int gdev_x_setup_colors(gx_device_X *);
260
void gdev_x_free_colors(gx_device_X *);
261
void gdev_x_free_dynamic_colors(gx_device_X *);
262
 
263
/* Exported by gdevxini.c for gdevx.c */
264
int gdev_x_open(gx_device_X *);
265
int gdev_x_close(gx_device_X *);
266
 
267
/* Driver procedures exported for gdevx.c */
268
dev_proc_map_rgb_color(gdev_x_map_rgb_color);  /* gdevxcmp.c */
269
dev_proc_map_color_rgb(gdev_x_map_color_rgb);  /* gdevxcmp.c */
270
dev_proc_get_params(gdev_x_get_params);  /* gdevxini.c */
271
dev_proc_put_params(gdev_x_put_params);  /* gdevxini.c */
272
dev_proc_get_xfont_procs(gdev_x_get_xfont_procs);  /* gdevxxf.c */
273
dev_proc_finish_copydevice(gdev_x_finish_copydevice);  /* gdevxini.c */
274
 
275
#endif /* gdevx_INCLUDED */