Path: utzoo!utgpu!watmath!iuvax!purdue!tut.cis.ohio-state.edu!boring.cray.com!hrp From: hrp@boring.cray.com (Hal Peterson) Newsgroups: gnu.ghostscript.bug Subject: two windows is too many Message-ID: <8907282004.AA02231@rothko.cray.com> Date: 28 Jul 89 20:04:08 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 136 On startup under X, Ghostscript opens two windows; the first one stays blank and the second one gets all of the graphics. This is happening because the X device is being initialized twice, once from the C code in gs_set_device and once from the Ghostscript setup code in ghost.ps. This is a fix in multiple steps: 1. since ghost.ps will initialize and set the real device, I modified gs_state_alloc to initialize with the null device instead of with a real one. 2. ghost.ps now needs a way to get the real default device, so I dropped defaultdevice into C code. 3. and while I was at it I cleaned up a bunch of incorrect declarations at the beginning of gsdevice.c (they were missing ``private'' keywords and gcc yelled at me). -- Hal Peterson Domain: hrp@cray.com Cray Research Old style: hrp%cray.com@uc.msc.umn.edu 1440 Northland Dr. UUCP: uunet!cray!hrp Mendota Hts, MN 55120 USA Telephone: +1 612 681 3145 ======================================================================== *** ghost-DIST.ps Tue Jun 20 06:31:52 1989 --- ghost.ps Fri Jul 28 14:21:56 1989 *************** *** 39,47 **** /true 0 0 eq def /false 0 1 eq def - % Acquire the default device. - /defaultdevice currentdevice def - % Define the predefined procedures, in alphabetical order. /[ /mark load def /] {counttomark array astore exch pop} bind def --- 39,44 ---- *** gsdevice-DIST.c Tue Jun 20 07:38:22 1989 --- gsdevice.c Fri Jul 28 14:36:28 1989 *************** *** 124,129 **** --- 124,135 ---- { return pgs->device->info; } + /* Get the current device from the graphics state */ + gx_device * + gs_defaultdevice(gs_state *pgs) + { return gx_device_default_p; + } + /* Read out the current device parameters */ void gs_deviceparams(gx_device *dev, gs_matrix *pmat, int *pwidth, int *pheight) *************** *** 220,237 **** #define rprocs (trace_find_procs(dev->procs)) /* Procedure structure */ ! int trace_open_device(P1(gx_device *)); ! int trace_close_device(P1(gx_device *)); ! int trace_sync_output(P1(gx_device *)); ! gx_color_index trace_map_rgb_color(P4(gx_device *, ushort, ushort, ushort)); ! int trace_map_color_rgb(P3(gx_device *, gx_color_index, ushort *)); ! int trace_fill_rectangle(P6(gx_device *, int, int, int, int, gx_color_index)); ! int trace_tile_rectangle(P8(gx_device *, gx_bitmap *, int, int, int, int, gx_color_index, gx_color_index)); ! int trace_copy_mono(P10(gx_device *, byte *, int, int, int, int, int, int, gx_color_index, gx_color_index)); ! int trace_copy_color(P8(gx_device *, byte *, int, int, int, int, int, int)); ! int trace_draw_line(P6(gx_device *, int, int, int, int, gx_color_index)); ! int trace_fill_trapezoid(P8(gx_device *, int, int, int, int, int, int, gx_color_index)); ! int trace_tile_trapezoid(P10(gx_device *, gx_bitmap *, int, int, int, int, int, int, gx_color_index, gx_color_index)); private gx_device_procs trace_procs = { trace_open_device, trace_close_device, --- 226,243 ---- #define rprocs (trace_find_procs(dev->procs)) /* Procedure structure */ ! private int trace_open_device(P1(gx_device *)); ! private int trace_close_device(P1(gx_device *)); ! private int trace_sync_output(P1(gx_device *)); ! private gx_color_index trace_map_rgb_color(P4(gx_device *, ushort, ushort, ushort)); ! private int trace_map_color_rgb(P3(gx_device *, gx_color_index, ushort *)); ! private int trace_fill_rectangle(P6(gx_device *, int, int, int, int, gx_color_index)); ! private int trace_tile_rectangle(P8(gx_device *, gx_bitmap *, int, int, int, int, gx_color_index, gx_color_index)); ! private int trace_copy_mono(P10(gx_device *, byte *, int, int, int, int, int, int, gx_color_index, gx_color_index)); ! private int trace_copy_color(P8(gx_device *, byte *, int, int, int, int, int, int)); ! private int trace_draw_line(P6(gx_device *, int, int, int, int, gx_color_index)); ! private int trace_fill_trapezoid(P8(gx_device *, int, int, int, int, int, int, gx_color_index)); ! private int trace_tile_trapezoid(P10(gx_device *, gx_bitmap *, int, int, int, int, int, int, gx_color_index, gx_color_index)); private gx_device_procs trace_procs = { trace_open_device, trace_close_device, *** gsstate-DIST.h Tue Jun 20 06:43:38 1989 --- gsstate.h Fri Jul 28 14:26:29 1989 *************** *** 52,57 **** --- 52,58 ---- void gs_nulldevice(P1(gs_state *)); int gs_setdevice(P2(gs_state *, gx_device *)); gx_device * gs_currentdevice(P1(gs_state *)); + gx_device * gs_defaultdevice(P1(gs_state *)); void gs_deviceparams(P4(gx_device *, gs_matrix *, int *, int *)); /* Line parameters and quality */ *** zdevice-DIST.c Tue Jun 20 07:19:22 1989 --- zdevice.c Fri Jul 28 14:42:59 1989 *************** *** 44,49 **** --- 44,58 ---- return 0; } + /* currentdevice */ + int + zdefaultdevice(register ref *op) + { gx_device *dev = gs_defaultdevice(igs); + push(1); + make_tv(op, t_device, pdevice, dev); + return 0; + } + /* defaultdevicename */ int zdefaultdevicename(register ref *op) *************** *** 128,133 **** --- 137,143 ---- { static op_def my_defs[] = { {"0copypage", zcopypage}, {"0currentdevice", zcurrentdevice}, + {"0defaultdevice", zdefaultdevice}, {"0defaultdevicename", zdefaultdevicename}, {"1deviceparams", zdeviceparams}, {"4makedevice", zmakedevice},