1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-01-16 00:04:59 +00:00
Interlisp.maiko/src/xcursor.c
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

259 lines
8.5 KiB
C

/* $Id: xcursor.c,v 1.4 2001/12/26 22:17:06 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved
*/
static char *id = "$Id: xcursor.c,v 1.4 2001/12/26 22:17:06 sybalsky Exp $ Copyright (C) Venue";
/************************************************************************/
/* */
/* (C) Copyright 1989-1995, 2000 Venue. */
/* All Rights Reserved. */
/* Manufactured in the United States of America. */
/* */
/************************************************************************/
#include "version.h"
#include <stdio.h>
#if defined(MACOSX) || defined(FREEBSD)
#include <stdlib.h>
#else
#include <malloc.h>
#endif
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include "xdefs.h"
#include "lispemul.h"
#include "iopage.h"
#include "display.h"
#include "dbprint.h"
#include "devif.h"
#include "xcursordefs.h"
extern IOPAGE *IOPage;
extern XGCValues gcv;
extern int Lisp_Xinitialized, Bitmap_Pad, Default_Depth;
XImage CursorImage;
Pixmap CursorPixmap_source, CursorPixmap_mask;
GC cursor_source_gc, cursor_mask_gc;
XColor cursor_fore_xcsd, cursor_back_xcsd, xced;
extern Colormap Colors;
extern DspInterface currentdsp;
/* a simple linked list to remember X cursors */
struct MXCURSOR {
struct MXCURSOR *next;
DLword bitmap[CURSORHEIGHT];
Cursor Xid;
} *cursorlist = NULL;
/*
Cursor LispCursor[2];
int cursor_sw;
*/
/* Hotspot X and Y values for current cursor. SUBTRACT these from */
/* mouse positions before reporting them upward to the sysout, and */
/* ADD these to the positions we get in SetMouseXY calls. This */
/* way, X and lisp agree where the mouse is */
int Current_Hot_X = 0, Current_Hot_Y = 0;
/************************************************************************/
/* */
/* I n i t _ X C u r s o r */
/* */
/* Initial setup for X cursor handling--create an initial */
/* cursor, and get it displayed. */
/* */
/************************************************************************/
void Init_XCursor() {
int i;
DLword *newbm = (DLword *)(IOPage->dlcursorbitmap);
TPRINT(("TRACE: Init_DisplayCursor()\n"));
/* this is guaranteed to be our first cursor, isn't it? */
cursorlist = (struct MXCURSOR *)malloc(sizeof(struct MXCURSOR));
cursorlist->next = NULL;
for (i = 0; i < CURSORHEIGHT; i++) cursorlist->bitmap[i] = newbm[i];
set_Xcursor(currentdsp, (unsigned char *)newbm, 0, 0, &(cursorlist->Xid), 1);
DefineCursor(currentdsp->display_id, currentdsp->DisplayWindow, &(cursorlist->Xid));
} /* end Init_XCursor */
/************************************************************************/
/* */
/* S e t _ X C u r s o r */
/* */
/* Set the X cursor from the Lisp bitmap, with hot spot at x,y */
/* */
/* WARNING: If you call this function inside the C code to change */
/* the cursor or flip a cursor bar, DON'T just use */
/* Current_Hot_Y as the 2nd arg. Instead use */
/* "15-Current_Hot_Y", because this function SETS C_H_Y */
/* to 15-its 2nd arg. This has led to cursor-alignment */
/* bugs in the past. */
/* */
/************************************************************************/
void Set_XCursor(int x, int y)
{
/* compare cursor in IOPage memory with cursors we've seen before */
register struct MXCURSOR *clp, *clbp;
register DLword *newbm = ((DLword *)(IOPage->dlcursorbitmap));
register int i;
XLOCK; /* No signals while setting the cursor */
for (clp = cursorlist; clp != NULL; clbp = clp, clp = clp->next) {
for (i = 0; i < CURSORHEIGHT; i++)
if (clp->bitmap[i] != newbm[i]) break;
if (i == CURSORHEIGHT) break;
}
if (clp == NULL) { /* it isn't there, push on a new one */
clp = (struct MXCURSOR *)malloc(sizeof(struct MXCURSOR));
/* and fill it up with the current new cursor */
for (i = 0; i < CURSORHEIGHT; i++) clp->bitmap[i] = newbm[i];
#ifdef NEWXCURSOR
/* JDS 000521 Added "15-" to fix cursor troubles at window edge */
set_Xcursor(currentdsp, (unsigned char *)newbm, x, 15 - y, &(clp->Xid), 1);
#else
set_Xcursor(currentdsp, (unsigned char *)newbm, 0, 0, &(clp->Xid), 1);
#endif /* NEWXCURSOR */
clp->next = cursorlist;
cursorlist = clp;
} else
/* found it, move it to the front of the list
(this should reduce search time on the average by keeping
the popular cursors near the front of the list)
*/
if (clp != cursorlist) { /* don't move if it's already there */
clbp->next = clp->next;
clp->next = cursorlist;
cursorlist = clp;
}
DefineCursor(currentdsp->display_id, currentdsp->DisplayWindow, &(clp->Xid));
XUNLOCK; /* Signals OK now */
#ifdef NEWXCURSOR
/* Save the hotspot for later position reporting/setting */
Current_Hot_X = x;
Current_Hot_Y = 15 - y; /* Added 15- to fix window-edge trouble */
#endif /* NEWXCURSOR */
} /* end Set_XCursor */
/************************************************************************/
/* */
/* i n i t _ X c u r s o r */
/* */
/* Initialization code for X-windows cursors. */
/* */
/************************************************************************/
void init_Xcursor(Display *display, int window)
{
TPRINT(("TRACE: init_Xcursor()\n"));
XLOCK; /* Take no X signals during this activity (ISC 386) */
CursorImage.width = CURSORWIDTH;
CursorImage.height = CURSORHEIGHT;
CursorImage.xoffset = 0;
CursorImage.format = XYBitmap;
#if (defined(XV11R1) || defined(BYTESWAP))
CursorImage.byte_order = LSBFirst;
#else /* XV11R1 | BYTESWAP */
CursorImage.byte_order = MSBFirst;
#endif /* XV11R1 | BYTESWAP */
CursorImage.bitmap_unit = BITSPER_DLWORD;
#ifdef AIX
CursorImage.bitmap_pad = 32;
#else
CursorImage.bitmap_pad = Bitmap_Pad;
#endif /* AIX */
CursorImage.depth = 1;
CursorImage.bytes_per_line = BITSPER_DLWORD / 8;
CursorImage.bitmap_bit_order = MSBFirst;
CursorPixmap_source = XCreatePixmap(display, window, CURSORWIDTH, CURSORHEIGHT, 1);
CursorPixmap_mask = XCreatePixmap(display, window, CURSORWIDTH, CURSORHEIGHT, 1);
gcv.function = GXcopy;
gcv.foreground = BlackPixelOfScreen(ScreenOfDisplay(display, DefaultScreen(display)));
gcv.background = WhitePixelOfScreen(ScreenOfDisplay(display, DefaultScreen(display)));
#ifdef AIX
gcv.plane_mask = 1;
#endif /* AIX */
cursor_source_gc = XCreateGC(display, window,
GCForeground | GCBackground | GCFunction
#ifdef AIX
| GCPlaneMask
#endif /* AIX */
,
&gcv);
cursor_mask_gc = XCreateGC(display, window,
GCForeground | GCBackground | GCFunction
#ifdef AIX
| GCPlaneMask
#endif /* AIX */
,
&gcv);
XAllocNamedColor(display, Colors, "black", &cursor_fore_xcsd, &xced);
XAllocNamedColor(display, Colors, "white", &cursor_back_xcsd, &xced);
XUNLOCK; /* OK to take signals again */
} /* end init_Xcursor */
/************************************************************************/
/* */
/* s e t _ X c u r s o r */
/* */
/* */
/* */
/************************************************************************/
void set_Xcursor(DspInterface dsp, unsigned char *bitmap, int hotspot_x, int hotspot_y, Cursor *return_cursor, int from_lisp)
{
extern unsigned char reversedbits[];
unsigned char image[32];
int i;
Pixmap Cursor_src, Cursor_msk;
Screen *screen;
#ifdef BYTESWAP
if (from_lisp)
for (i = 0; i < 32; i++) image[i] = reversedbits[bitmap[i ^ 3]];
else
for (i = 0; i < 32; i++) image[i] = reversedbits[bitmap[i]];
#else
for (i = 0; i < 32; i++) image[i] = reversedbits[bitmap[i]];
#endif /* BYTESWAP */
XLOCK;
screen = ScreenOfDisplay(dsp->display_id, DefaultScreen(dsp->display_id));
Cursor_src = XCreatePixmapFromBitmapData(dsp->display_id, dsp->DisplayWindow, (char *)image,
16, 16, 1, 0, 1); /* Has to have a depth of 1! */
Cursor_msk = XCreatePixmapFromBitmapData(dsp->display_id, dsp->DisplayWindow, (char *)image,
16, 16, 1, 0, 1); /* Has to have a depth of 1! */
*return_cursor = XCreatePixmapCursor(dsp->display_id, Cursor_src, Cursor_msk, &cursor_fore_xcsd,
&cursor_back_xcsd, hotspot_x, hotspot_y);
/* Should free these now (doc says server may not copy them) */
XFreePixmap(dsp->display_id, Cursor_src);
XFreePixmap(dsp->display_id, Cursor_msk);
XFlush(dsp->display_id);
XUNLOCK;
} /* end set_Xcursor */