1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-01-16 16:19:10 +00:00
Nick Briggs 0ad69fc6fe Create a new inc/xxxdefs.h for each src/xxx.c containing appropriate function prototypes.
This also involves removing unnecessary forward declarations, inserting
       includes for all cross-file function references, making some definitions
       static if they are not otherwise used, correcting errors that were exposed
       by having correct prototypes.

	new file:   inc/allocmdsdefs.h
	new file:   inc/arith2defs.h
	new file:   inc/arith3defs.h
	new file:   inc/arith4defs.h
	new file:   inc/array2defs.h
	new file:   inc/array3defs.h
	new file:   inc/array4defs.h
	new file:   inc/array5defs.h
	new file:   inc/array6defs.h
	new file:   inc/arraydefs.h
	new file:   inc/bbtsubdefs.h
	new file:   inc/bindefs.h
	new file:   inc/bindsdefs.h
	new file:   inc/bitbltdefs.h
	new file:   inc/bltdefs.h
	new file:   inc/byteswapdefs.h
	new file:   inc/car-cdrdefs.h
	new file:   inc/chardevdefs.h
	new file:   inc/commondefs.h
	new file:   inc/conspagedefs.h
	new file:   inc/dbgtooldefs.h
	new file:   inc/dirdefs.h
	new file:   inc/drawdefs.h
	new file:   inc/dskdefs.h
	new file:   inc/dspifdefs.h
	new file:   inc/dspsubrsdefs.h
	new file:   inc/eqfdefs.h
	new file:   inc/etherdefs.h
	new file:   inc/findkeydefs.h
	new file:   inc/fpdefs.h
	new file:   inc/fvardefs.h
	new file:   inc/gc2defs.h
	new file:   inc/gcarraydefs.h
	new file:   inc/gccodedefs.h
	new file:   inc/gcdefs.h
	new file:   inc/gcfinaldefs.h
	new file:   inc/gchtfinddefs.h
	new file:   inc/gcmain3defs.h
	new file:   inc/gcoflowdefs.h
	new file:   inc/gcrcelldefs.h
	new file:   inc/gcrdefs.h
	new file:   inc/gcscandefs.h
	new file:   inc/gvar2defs.h
	new file:   inc/hacksdefs.h
	new file:   inc/hardrtndefs.h
	new file:   inc/inetdefs.h
	new file:   inc/initdspdefs.h
	new file:   inc/initkbddefs.h
	new file:   inc/initsoutdefs.h
	modified:   inc/inlineC.h
	new file:   inc/intcalldefs.h
	new file:   inc/kbdsubrsdefs.h
	new file:   inc/keyeventdefs.h
	new file:   inc/keylibdefs.h
	new file:   inc/kprintdefs.h
	new file:   inc/ldsoutdefs.h
	new file:   inc/lineblt8defs.h
	new file:   inc/lisp2cdefs.h
	modified:   inc/lispemul.h
	new file:   inc/llcolordefs.h
	new file:   inc/llstkdefs.h
	modified:   inc/lnk-inlineC.h
	new file:   inc/loopsopsdefs.h
	new file:   inc/lowlev1defs.h
	new file:   inc/lowlev2defs.h
	new file:   inc/lsthandldefs.h
	new file:   inc/maindefs.h
	new file:   inc/misc7defs.h
	new file:   inc/miscndefs.h
	new file:   inc/mkatomdefs.h
	new file:   inc/mkcelldefs.h
	new file:   inc/mvsdefs.h
	new file:   inc/osmsgdefs.h
	new file:   inc/perrnodefs.h
	new file:   inc/returndefs.h
	new file:   inc/rpcdefs.h
	new file:   inc/rplconsdefs.h
	new file:   inc/shiftdefs.h
	new file:   inc/storagedefs.h
	new file:   inc/subr0374defs.h
	new file:   inc/subrdefs.h
	new file:   inc/sxhashdefs.h
	new file:   inc/testtooldefs.h
	new file:   inc/timerdefs.h
	new file:   inc/typeofdefs.h
	new file:   inc/ubf1defs.h
	new file:   inc/ubf2defs.h
	new file:   inc/ubf3defs.h
	new file:   inc/ufsdefs.h
	new file:   inc/unixcommdefs.h
	new file:   inc/unwinddefs.h
	new file:   inc/uraiddefs.h
	new file:   inc/usrsubrdefs.h
	new file:   inc/uutilsdefs.h
	new file:   inc/vars3defs.h
	new file:   inc/vmemsavedefs.h
	new file:   inc/xbbtdefs.h
	new file:   inc/xcdefs.h
	new file:   inc/xcursordefs.h
	new file:   inc/xinitdefs.h
	new file:   inc/xlspwindefs.h
	new file:   inc/xmkicondefs.h
	new file:   inc/xrdoptdefs.h
	new file:   inc/xscrolldefs.h
	new file:   inc/xwinmandefs.h
	new file:   inc/z2defs.h
	modified:   src/allocmds.c
	modified:   src/arith2.c
	modified:   src/arith3.c
	modified:   src/arith4.c
	modified:   src/array.c
	modified:   src/array2.c
	modified:   src/array3.c
	modified:   src/array4.c
	modified:   src/array5.c
	modified:   src/array6.c
	modified:   src/bbtsub.c
	modified:   src/bin.c
	modified:   src/binds.c
	modified:   src/bitblt.c
	modified:   src/blt.c
	modified:   src/byteswap.c
	modified:   src/car-cdr.c
	modified:   src/chardev.c
	modified:   src/common.c
	modified:   src/conspage.c
	modified:   src/dbgtool.c
	modified:   src/dir.c
	modified:   src/draw.c
	modified:   src/dsk.c
	modified:   src/dspif.c
	modified:   src/dspsubrs.c
	modified:   src/eqf.c
	modified:   src/ether.c
	modified:   src/findkey.c
	modified:   src/foreign.c
	modified:   src/fp.c
	modified:   src/fvar.c
	modified:   src/gc.c
	modified:   src/gc2.c
	modified:   src/gcarray.c
	modified:   src/gccode.c
	modified:   src/gcfinal.c
	modified:   src/gchtfind.c
	modified:   src/gcmain3.c
	modified:   src/gcoflow.c
	modified:   src/gcr.c
	modified:   src/gcrcell.c
	modified:   src/gcscan.c
	modified:   src/gvar2.c
	modified:   src/hacks.c
	modified:   src/hardrtn.c
	modified:   src/inet.c
	modified:   src/initdsp.c
	modified:   src/initkbd.c
	modified:   src/initsout.c
	modified:   src/intcall.c
	modified:   src/kbdsubrs.c
	modified:   src/keyevent.c
	modified:   src/keylib.c
	modified:   src/kprint.c
	modified:   src/ldsout.c
	modified:   src/lineblt8.c
	modified:   src/lisp2c.c
	modified:   src/llcolor.c
	modified:   src/llstk.c
	modified:   src/loopsops.c
	modified:   src/lowlev1.c
	modified:   src/lowlev2.c
	modified:   src/lsthandl.c
	modified:   src/main.c
	modified:   src/misc7.c
	modified:   src/miscn.c
	modified:   src/mkatom.c
	modified:   src/mkcell.c
	modified:   src/mvs.c
	modified:   src/osmsg.c
	modified:   src/perrno.c
	modified:   src/return.c
	modified:   src/rpc.c
	modified:   src/rplcons.c
	modified:   src/setsout.c
	modified:   src/shift.c
	modified:   src/storage.c
	modified:   src/subr.c
	modified:   src/subr0374.c
	modified:   src/sxhash.c
	modified:   src/testtool.c
	modified:   src/timer.c
	modified:   src/truecolor.c
	modified:   src/tstsout.c
	modified:   src/typeof.c
	modified:   src/ubf1.c
	modified:   src/ubf2.c
	modified:   src/ubf3.c
	modified:   src/ufn.c
	modified:   src/ufs.c
	modified:   src/unixcomm.c
	modified:   src/unwind.c
	modified:   src/uraid.c
	modified:   src/usrsubr.c
	modified:   src/uutils.c
	modified:   src/vars3.c
	modified:   src/vmemsave.c
	modified:   src/xbbt.c
	modified:   src/xc.c
	modified:   src/xcursor.c
	modified:   src/xinit.c
	modified:   src/xlspwin.c
	modified:   src/xmkicon.c
	modified:   src/xrdopt.c
	modified:   src/xscroll.c
	modified:   src/xwinman.c
	modified:   src/z2.c
2020-09-04 18:21:44 -07:00

362 lines
13 KiB
C

/* $Id: xinit.c,v 1.5 2001/12/26 22:17:06 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */
static char *id = "$Id: xinit.c,v 1.5 2001/12/26 22:17:06 sybalsky Exp $ Copyright (C) Venue";
/************************************************************************/
/* */
/* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */
/* All Rights Reserved. */
/* Manufactured in the United States of America. */
/* */
/************************************************************************/
#include "version.h"
#include <stdio.h>
#include <unistd.h>
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <sys/types.h>
#include <sys/file.h>
#include "lispemul.h"
#include "dbprint.h"
#include "xdefs.h"
#include "devif.h"
#include "adr68k.h"
#include "xinitdefs.h"
#include "dspifdefs.h"
#include "xbbtdefs.h"
#include "xlspwindefs.h"
#include "xwinmandefs.h"
#ifdef HPUX
#define FASYNC O_NONBLOCK
#endif /* HPUX */
#include <fcntl.h>
#include <sys/ioctl.h>
#ifndef APOLLO
#ifndef HPUX
#ifndef ULTRIX
#ifndef LINUX
#ifndef MACOSX
#ifndef FREEBSD
#include <stropts.h>
#endif /* FREEBSD */
#endif /* MACOSX */
#endif /* LINUX */
#endif /* ULTRIX */
#endif /* HPUX */
#endif /* APOLLO */
#ifdef ISC
#define FASYNC O_NONBLOCK
#define SIGIO SIGPOLL
#endif /* ISC */
#define FALSE 0
#define TRUE !FALSE
#define PERCENT_OF_SCREEN 95
#define DISPLAY_MAX 65536 * 16 * 2 /* same magic number is */
/* in loadsysout.c */
extern DLword *Lisp_world;
extern int Lisp_Xinitialized;
extern char Display_Name[128];
extern DLword *DisplayRegion68k;
int xsync = False;
int Byte_Order, Bitmap_Bit_Order, Bitmap_Pad, Default_Depth, Display_Height, Display_Width;
int LispWindowRequestedX = 0;
int LispWindowRequestedY = 0;
unsigned LispWindowRequestedWidth = DEF_WIN_WIDTH;
unsigned LispWindowRequestedHeight = DEF_WIN_HEIGHT;
int LispDisplayRequestedX, LispDisplayRequestedY;
unsigned LispDisplayRequestedWidth, LispDisplayRequestedHeight;
Colormap Colors;
int XLocked = 0; /* non-zero while doing X ops, to avoid signals */
extern int LispReadFds;
/************************************************************************/
/* */
/* i n i t _ X e v e n t */
/* */
/* Turn on the X window we've been using for display. */
/* */
/************************************************************************/
void init_Xevent(DspInterface dsp)
{
int GravMask, BarMask, LispMask, DisplayMask;
GravMask =
ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | StructureNotifyMask;
BarMask = GravMask;
DisplayMask = GravMask | PointerMotionMask | ExposureMask | KeyPressMask | KeyReleaseMask;
LispMask = StructureNotifyMask;
XSelectInput(dsp->display_id, dsp->LispWindow, dsp->EnableEventMask);
XSelectInput(dsp->display_id, dsp->DisplayWindow, dsp->EnableEventMask);
XSelectInput(dsp->display_id, dsp->HorScrollBar, BarMask);
XSelectInput(dsp->display_id, dsp->VerScrollBar, BarMask);
XSelectInput(dsp->display_id, dsp->HorScrollButton, NoEventMask);
XSelectInput(dsp->display_id, dsp->VerScrollButton, NoEventMask);
XSelectInput(dsp->display_id, dsp->NEGrav, GravMask);
XSelectInput(dsp->display_id, dsp->SEGrav, GravMask);
XSelectInput(dsp->display_id, dsp->SWGrav, GravMask);
XSelectInput(dsp->display_id, dsp->NWGrav, GravMask);
#ifdef SYSVONLY
#ifndef LINUX
#ifndef MACOSX
ioctl(ConnectionNumber(dsp->display_id), I_SETSIG, S_INPUT); /* so we see X events fast */
#endif
#endif
#endif /* SYSVONLY */
} /*end init_Xevent */
/************************************************************************/
/* */
/* l i s p _ X e x i t */
/* */
/* Turn off the X window we've been using for display. */
/* */
/************************************************************************/
void lisp_Xexit(DspInterface dsp)
{
#ifdef SYSVONLY
#ifndef LINUX
#ifndef MACOSX
ioctl(ConnectionNumber(dsp->display_id), I_SETSIG, 0); /* so no interrupts happen during */
#endif
#endif
#endif /* SYSVONLY */
XDestroySubwindows(dsp->display_id, dsp->LispWindow);
XDestroyWindow(dsp->display_id, dsp->LispWindow);
XCloseDisplay(dsp->display_id);
Lisp_Xinitialized = FALSE;
} /* end lisp_Xexit */
/************************************************************************/
/* */
/* X e v e n t _ b e f o r e _ r a i d */
/* */
/* Called before Medley enters URAID, to turn off events in */
/* the X windows we use for Medley's display. */
/* */
/************************************************************************/
void Xevent_before_raid(DspInterface dsp)
{
TPRINT(("TRACE: Xevent_before_raid()\n"));
XSelectInput(dsp->display_id, dsp->LispWindow, NoEventMask);
XSelectInput(dsp->display_id, dsp->DisplayWindow, NoEventMask);
XSelectInput(dsp->display_id, dsp->VerScrollBar, NoEventMask);
XSelectInput(dsp->display_id, dsp->HorScrollBar, NoEventMask);
XSelectInput(dsp->display_id, dsp->NEGrav, NoEventMask);
XSelectInput(dsp->display_id, dsp->SEGrav, NoEventMask);
XSelectInput(dsp->display_id, dsp->SWGrav, NoEventMask);
XSelectInput(dsp->display_id, dsp->NWGrav, NoEventMask);
XLOCK;
XFlush(dsp->display_id);
XUNLOCK;
} /* end Xevent_before_raid */
/************************************************************************/
/* */
/* X e v e n t _ a f t e r _ r a i d */
/* */
/* Called after Medley returns from URAID, to re-enable events */
/* from the X server in the windows we use for the display. */
/* */
/************************************************************************/
void Xevent_after_raid(DspInterface dsp)
{
init_Xevent(dsp);
(dsp->bitblt_to_screen)(dsp, 0, dsp->Visible.x, dsp->Visible.y, dsp->Visible.width,
dsp->Visible.height);
XLOCK;
XFlush(dsp->display_id);
XUNLOCK;
} /* end Xevent_after_raid */
/************************************************************************/
/* */
/* O p e n _ D i s p l a y */
/* */
/* Open the connection to the X client/window manager display, */
/* gather information from it that we'll need (pixel depth, etc), */
/* and initialize the lisp display-bank size to fit the screen. */
/* */
/* */
/************************************************************************/
void Open_Display(DspInterface dsp)
{
LispReadFds |= (1 << ConnectionNumber(dsp->display_id));
#ifndef ISC
#ifndef HPUX
fcntl(ConnectionNumber(dsp->display_id), F_SETOWN, getpid());
#endif /* HPUX */
#endif /* ISC */
/****************************************************/
/* If debugging, set the X connection so that */
/* we run synchronized--so a debugger can */
/* 'stop in _XError' and know EXACTLY where */
/* an error got caused. */
/****************************************************/
XSynchronize(dsp->display_id, xsync);
Colors =
DefaultColormapOfScreen(ScreenOfDisplay(dsp->display_id, DefaultScreen(dsp->display_id)));
/* When we make the initial screen we haven't yet read in the */
/* displayregion bitmap. Fix this now. */
if (dsp->ScreenBitmap.data == NULL) dsp->ScreenBitmap.data = (char *)DisplayRegion68k;
Create_LispWindow(dsp); /* Make the main window */
Lisp_Xinitialized = TRUE;
init_Xevent(dsp); /* Turn on the intrpts. */
} /* end OpenDisplay */
/*********************************************************************/
/* */
/* X _ i n i t */
/* dsp: a display structure to be filled with all the neccessary */
/* information. */
/* */
/* lispbitmap: The bitmapdata that is to be dumped to the screen. */
/* width_hint and height_hint: The requested size of the screen. The */
/* width and height hints will be obeyed as close as possible */
/* with respect to the physicalk limitations. This makes it */
/* possible to get a screen that is larger (or smaller) than */
/* the physical screen. 0 will give you some default value */
/* depth_hint: The requested depth in bits. depth 1 can allways be */
/* granted. Any value of 1 or less will yeild depth 1. */
/* */
/* Return value: the lispbitmap or 1 if all is ok. else FALSE is */
/* returned */
/* */
/* This is the init function for X displays. To create a new display */
/* you call this function. If you want to know what you got you will */
/* have to read the individual fields of the dsp structure. */
/* */
/*********************************************************************/
DspInterface X_init(DspInterface dsp, char *lispbitmap, int width_hint, int height_hint,
int depth_hint)
{
Screen *Xscreen;
dsp->identifier = Display_Name; /* This is a hack. The display name */
/* has to dealt with in a more */
/* gracefull way. */
/* Try to open the X display. If this isn't possible, we just */
/* return FALSE. */
if ((dsp->display_id = XOpenDisplay(dsp->identifier)) == NULL) return (NULL);
/* Load the dsp structure */
Xscreen = ScreenOfDisplay(dsp->display_id, DefaultScreen(dsp->display_id));
/* Set the scrollbar and border widths */
dsp->ScrollBarWidth = SCROLL_WIDTH;
dsp->InternalBorderWidth = DEF_BDRWIDE;
dsp->Visible.x = LispDisplayRequestedX;
dsp->Visible.y = LispDisplayRequestedY;
/* Set the width and height of the display. */
if (height_hint == 0) {
dsp->Display.height =
HeightOfScreen(Xscreen) - OUTER_SB_WIDTH(dsp); /* In the default case,
adjust for scroll gadgets*/
} else
dsp->Display.height = bound(WIN_MIN_HEIGHT, height_hint, WIN_MAX_HEIGHT);
if (width_hint == 0) {
dsp->Display.width =
WidthOfScreen(Xscreen) - OUTER_SB_WIDTH(dsp); /* In the default case,
adjust for scroll gadgets*/
} else
dsp->Display.width = bound(WIN_MIN_WIDTH, width_hint, WIN_MAX_WIDTH);
/************************************************************/
/* Set the size of ScreenBitMap */
/* The display's width is rounded to a 32-bit multiple, */
/* so that little-Endian machines can display right. */
/************************************************************/
dsp->Display.width = ((dsp->Display.width + 31) >> 5) << 5;
dsp->device.enter = (PFV)Open_Display;
dsp->device.exit = (PFV)lisp_Xexit;
dsp->bitblt_to_screen = (PFUL)clipping_Xbitblt;
dsp->device.before_raid = (PFV)Xevent_before_raid;
dsp->device.after_raid = (PFV)Xevent_after_raid;
dsp->BitGravity = NorthWestGravity;
dsp->cleardisplay = (PFV)GenericReturnT;
dsp->set_color_map_entry = (PFUL)GenericReturnT;
/* Set the geometry of the Visible (Lisp) window. */
dsp->Visible.width =
bound(OUTER_SB_WIDTH(dsp), LispWindowRequestedWidth,
min(dsp->Display.width, (WidthOfScreen(Xscreen) - OUTER_SB_WIDTH(dsp))));
dsp->Visible.height =
bound(OUTER_SB_WIDTH(dsp), LispWindowRequestedHeight,
min(dsp->Display.height, (HeightOfScreen(Xscreen) - OUTER_SB_WIDTH(dsp))));
/* Initialize the screen image structure. */
dsp->ScreenBitmap.width = dsp->Display.width;
dsp->ScreenBitmap.height = dsp->Display.height;
dsp->ScreenBitmap.xoffset = 0;
dsp->bitsperpixel =
DefaultDepthOfScreen(ScreenOfDisplay(dsp->display_id, DefaultScreen(dsp->display_id)));
#if (defined(BYTESWAP))
dsp->ScreenBitmap.byte_order = LSBFirst;
#else /* BYTESWAP */
dsp->ScreenBitmap.byte_order = MSBFirst;
#endif /* BYTESWAP */
dsp->ScreenBitmap.data = (char *)(lispbitmap ? Addr68k_from_LADDR((LispPTR)lispbitmap) : 0);
switch (depth_hint) {
case 8: /* Color Screen */
dsp->ScreenBitmap.format = ZPixmap;
dsp->ScreenBitmap.bitmap_unit = BitmapUnit(dsp->display_id);
dsp->ScreenBitmap.bitmap_bit_order = MSBFirst;
dsp->ScreenBitmap.bitmap_pad = 32;
dsp->ScreenBitmap.depth = 8;
dsp->ScreenBitmap.bits_per_pixel = 8;
dsp->ScreenBitmap.bytes_per_line = (dsp->Display.width);
dsp->ScreenBitmap.red_mask = 7;
dsp->ScreenBitmap.green_mask = 7;
dsp->ScreenBitmap.blue_mask = 3;
break;
default: /* B/W Screen */
dsp->ScreenBitmap.format = XYBitmap;
dsp->ScreenBitmap.bitmap_unit = BitmapUnit(dsp->display_id);
dsp->ScreenBitmap.bitmap_bit_order = MSBFirst;
dsp->ScreenBitmap.bitmap_pad = 32;
dsp->ScreenBitmap.depth = 1;
dsp->ScreenBitmap.bytes_per_line =
((dsp->Display.width + (BITSPER_DLWORD - 1)) / BITSPER_DLWORD) * (BITSPER_DLWORD / 8);
break;
}
return (dsp);
}