1: #ifdef  sun
   2: /*
   3:  * The Sun X drivers are a product of Sun Microsystems, Inc. and are provided
   4:  * for unrestricted use provided that this legend is included on all tape
   5:  * media and as a part of the software program in whole or part.  Users
   6:  * may copy or modify these drivers without charge, but are not authorized
   7:  * to license or distribute them to anyone else except as part of a product or
   8:  * program developed by the user.
   9:  *
  10:  * THE SUN X DRIVERS ARE PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND
  11:  * INCLUDING THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A
  12:  * PARTICULAR PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE
  13:  * PRACTICE.
  14:  *
  15:  * The Sun X Drivers are provided with no support and without any obligation
  16:  * on the part of Sun Microsystems, Inc. to assist in their use, correction,
  17:  * modification or enhancement.
  18:  *
  19:  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  20:  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THE SUN X
  21:  * DRIVERS OR ANY PART THEREOF.
  22:  *
  23:  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  24:  * or profits or other special, indirect and consequential damages, even if
  25:  * Sun has been advised of the possibility of such damages.
  26:  *
  27:  * Sun Microsystems, Inc.
  28:  * 2550 Garcia Avenue
  29:  * Mountain View, California  94043
  30:  */
  31: 
  32: #ifndef lint
  33: static char sccsid[] = "@(#)cursor.c 2.1 86/01/28 Copyright 1986 Sun Micro";
  34: #endif
  35: 
  36: /*-
  37:  * Copyright (c) 1986 by Sun Microsystems,  Inc.
  38:  */
  39: 
  40: /* cursor.c	various stuff with the mouse & cursor
  41:  *
  42:  *	StoreCursor		Creates a cursor
  43:  *	FreeCursor		Frees the storage taken by a cursor
  44:  *	LoadCursor		Loads a bitmap to use as cursor
  45:  *	InitMouse		Initialize the mouse
  46:  *	SetCursorPosition	Forces cursor to a particular position
  47:  *	SetMouseCharacteristics	Controls speed of cursor relative to mouse
  48:  *
  49:  */
  50: 
  51: /*
  52:  *	ToDo:
  53:  *		Threshold/Acceleration
  54:  *		Use macros for CheckCursor()
  55:  */
  56: 
  57: #include "Xsun.h"
  58: 
  59: extern struct pixrect *PixRect;
  60: extern char *Xalloc();
  61: extern DEVICE *CurrentDevice;
  62: CURSOR *CurrentCursor;
  63: int CursorDisplayed;
  64: static struct pixrect *CursorPixrect;
  65: 
  66: CURSOR *StoreCursor (func, image, fore, back, mask, xoff, yoff)
  67:     BITMAP *image;
  68:     BITMAP *mask;
  69:     int func, fore, back, xoff, yoff;
  70: {
  71:     register CURSOR *cursor;
  72:     register CursPriv *data;
  73: 
  74:     if (!image)
  75:     return (NULL);
  76:     cursor = (CURSOR *) Xalloc(sizeof(CURSOR));
  77:     cursor->width = image->width;
  78:     cursor->height = image->height;
  79:     /* Only the tip need be on-screen */
  80:     cursor->xmin = 0;
  81:     cursor->ymin = 0;
  82:     cursor->xoff = xoff;
  83:     cursor->yoff = yoff;
  84:     cursor->xmax = PixRect->pr_size.x;
  85:     cursor->ymax = PixRect->pr_size.y;
  86:     cursor->refcnt = 1;
  87:     data = (CursPriv *) Xalloc(sizeof(CursPriv));
  88:     cursor->data = (caddr_t) data;
  89:     data->top = mem_point(image->width, image->height, 1, image->data);
  90:     data->top_bit = image;
  91:     image->refcnt++;
  92:     if (mask) {
  93:     data->bot = mem_point(mask->width, mask->height, 1, mask->data);
  94:     data->bot_bit = mask;
  95:     mask->refcnt++;
  96:     } else {
  97:     data->bot = NULL;
  98:     data->bot_bit = NULL;
  99:     }
 100:     data->sv = mem_create(cursor->width, cursor->height, PixRect->pr_depth);
 101:     data->fore = fore;
 102:     data->back = back;
 103:     return (cursor);
 104: }
 105: 
 106: FreeCursor (cursor)
 107:     register CURSOR *cursor;
 108: {
 109:     CursPriv   *cp = CDATA(cursor);
 110:     pr_destroy(cp->top);
 111:     if (cp->top_bit && --(cp->top_bit)->refcnt <= 0)
 112:     FreeBitmap(cp->top_bit);
 113:     if (cp->bot) {
 114:     pr_destroy(cp->bot);
 115:     if (cp->bot_bit && --(cp->bot_bit)->refcnt <= 0)
 116:         FreeBitmap(cp->bot_bit);
 117:     }
 118:     pr_destroy(cp->sv);
 119:     free((caddr_t) CDATA(cursor));
 120:     free((caddr_t) cursor);
 121: }
 122: 
 123: struct pr_prpos topbatch, botbatch;
 124: 
 125: LoadCursor (cursor)
 126:     register CURSOR *cursor;
 127: {
 128:     if (CursorDisplayed)
 129:     DisplayCursor(NULL);
 130:     if ((CurrentCursor = cursor) != NULL) {
 131:     topbatch.pr = CDATA(cursor)->top;
 132:     topbatch.pos.x = 0;
 133:     topbatch.pos.y = 0;
 134:     botbatch.pr = CDATA(cursor)->bot;
 135:     botbatch.pos.x = 0;
 136:     botbatch.pos.y = 0;
 137:     DisplayCursor(cursor);
 138:     }
 139: }
 140: 
 141: InitMouse ()
 142: {
 143: }
 144: 
 145: SetCursorPosition(pos)
 146:     register vsCursor *pos;
 147: {
 148:     if (pos->x != (CurrentDevice->mouse->x) || pos->y != (CurrentDevice->mouse->y)) {
 149:     if (CursorDisplayed)
 150:         DisplayCursor(NULL);
 151:     *(CurrentDevice->mouse) = *pos;
 152:     DisplayCursor(CurrentCursor);
 153:     }
 154: }
 155: 
 156: SetMouseCharacteristics (threshold, accelaration)
 157:     int threshold, accelaration;
 158: {
 159: }
 160: 
 161: DisplayCursor(cs)
 162: CURSOR *cs;
 163: {
 164:     extern struct pixrect *PixRect;
 165:     vsCursor   *ms = CurrentDevice->mouse;
 166: 
 167:     if (cs == NULL) {
 168:     if (CurrentCursor) {
 169:         /* take it out */
 170:         extern private_czmask;
 171:         int old_zmask = private_czmask, allmask = -1;
 172: 
 173:         SetZmask(PixRect, &allmask);
 174:         pr_rop(PixRect, ms->x, ms->y, CurrentCursor->width,
 175:            CurrentCursor->height, PIX_SRC, CDATA(CurrentCursor)->sv, 0, 0);
 176:         SetZmask(PixRect, &old_zmask);
 177:         CursorDisplayed = 0;
 178:     }
 179:     }
 180:     else {
 181:     CursPriv   *cp = CDATA(cs);
 182:     /* put it in */
 183: 
 184:     pr_rop(cp->sv, 0, 0, cs->width, cs->height, PIX_SRC,
 185:            PixRect, ms->x, ms->y);
 186:     if (PixRect->pr_depth == 1) {
 187:         int botop = (cp->back == 1 ? PIX_SRC | PIX_DST : PIX_NOT(PIX_SRC) & PIX_DST);
 188:         int topop = (cp->fore == 1 ? PIX_SRC | PIX_DST : PIX_NOT(PIX_SRC) & PIX_DST);
 189: 
 190:         if (botbatch.pr)
 191:         pr_batchrop(PixRect, ms->x, ms->y,
 192:                 botop,
 193:                 &botbatch, 1);
 194:         if (topbatch.pr)
 195:         pr_batchrop(PixRect, ms->x, ms->y,
 196:                 topop,
 197:                 &topbatch, 1);
 198:     }
 199:     else {
 200:         extern private_bgcolor, private_fgcolor, private_czmask;
 201:         int old_zmask = private_czmask;
 202: 
 203:         private_bgcolor = -1;
 204:         private_czmask = -1;
 205:         if (botbatch.pr) {
 206:         private_fgcolor = cp->back;
 207:         pr_batchrop(PixRect, ms->x, ms->y,
 208:                 PIX_SRC | PIX_DST,
 209:                 &botbatch, 1);
 210:         }
 211:         private_fgcolor = cp->fore;
 212:         if (topbatch.pr)
 213:         pr_batchrop(PixRect, ms->x, ms->y,
 214:                 PIX_NOT(PIX_SRC) & PIX_DST,
 215:                 &topbatch, 1);
 216:         private_czmask = old_zmask;
 217:     }
 218:     CursorDisplayed = 1;
 219:     }
 220: }
 221: 
 222: int
 223: CheckCursor(x, y, w, h)
 224: {
 225:     register vsCursor *ms = CurrentDevice->mouse;
 226:     register CURSOR *cs = CurrentCursor;
 227: 
 228:     if (CursorDisplayed
 229:     && OverLap(x, y, w, h, ms->x, ms->y, cs->width, cs->height)) {
 230:         DisplayCursor(NULL);
 231:     }
 232: }
 233: 
 234: RestoreCursor()
 235: {
 236:     if (!CursorDisplayed)
 237:     DisplayCursor(CurrentCursor);
 238: }
 239: #endif	sun

Defined functions

DisplayCursor defined in line 161; used 10 times
FreeCursor defined in line 106; never used
InitMouse defined in line 141; never used
LoadCursor defined in line 125; never used
SetCursorPosition defined in line 145; used 1 times
SetMouseCharacteristics defined in line 156; never used
StoreCursor defined in line 66; never used

Defined variables

CurrentCursor defined in line 62; used 8 times
CursorDisplayed defined in line 63; used 6 times
CursorPixrect defined in line 64; never used
botbatch defined in line 123; used 7 times
sccsid defined in line 33; never used
topbatch defined in line 123; used 7 times
Last modified: 1986-02-02
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1575
Valid CSS Valid XHTML 1.0 Strict