Annotation of 43BSDTahoe/new/X/libibm/bitblt/bitblt_cur.c, revision 1.1

1.1     ! root        1: #ifndef lint
        !             2: static char *rcsid_bitblt_cur_c = "$Header: bitblt_cur.c,v 10.1 86/11/19 10:51:09 jg Exp $";
        !             3: #endif lint
        !             4: /*
        !             5:  *             Copyright (c) 1986 Brown University
        !             6:  *
        !             7:  * Permission to use, copy, modify and distribute this software and its
        !             8:  * documentation for any purpose and without fee is hereby granted, provided
        !             9:  * that the above copyright notice appear in all copies, and that both
        !            10:  * that copyright notice and this permission notice appear in supporting
        !            11:  * documentation, and that the name of Brown University not be used in
        !            12:  * advertising or publicity pertaining to distribution of the software without
        !            13:  * specific, written prior permission. Brown University makes no
        !            14:  * representations about the suitability of this software for any purpose.
        !            15:  * It is provided "as-is" without express or implied warranty.
        !            16:  *
        !            17:  * Written by Daniel Stone, Brown University/IRIS  (des@iris)
        !            18:  *
        !            19:  * NOTE: A "cursor" is the thing that moves on the screen when it
        !            20:  *      is attached to the mouse.  It is sometimes refered to as a
        !            21:  *      "locator" also.
        !            22:  *
        !            23:  * If the screen to be dealt with uses a software cursor then the bits
        !            24:  * the cursor overlayed must be replaced.  This is needed because
        !            25:  * the cursor (or locator) is put on the the ACTUAL bitmap.
        !            26:  */
        !            27: 
        !            28: #include "bitblt_int.h"
        !            29: 
        !            30: static short rem_loc = 0;
        !            31: 
        !            32: /*
        !            33:  * This macro checks the XAddr shared memory area to see if the cursor
        !            34:  * is in the way.
        !            35:  */
        !            36: #define S_ORIGIN_X (XAddr->mouse.x & (~(BPW-1)))
        !            37: #define S_ORIGIN_Y (XAddr->mouse.y)
        !            38: #define S_CORNER_X (S_ORIGIN_X + (2*BPW))
        !            39: #define S_CORNER_Y (S_ORIGIN_Y + BPW)
        !            40: #define LOC_IN_BOUNDS(oX,oY,cX,cY) ((oX < S_CORNER_X) && (S_ORIGIN_X < cX) &&\
        !            41:                                    (oY < S_CORNER_Y) && (S_ORIGIN_Y < cY))
        !            42: 
        !            43: /*
        !            44:  * Save_cursor set up the shared memory, checks to see if the cursor
        !            45:  * is in the rectangle bounds handed to save_cursor.  If it is then
        !            46:  * an ioctl is done to the kernel to remove the cursor.  If the ioctl
        !            47:  * fails then -1 is returned otherwise 0 is returned.
        !            48:  */
        !            49: save_cursor(oX,oY,cX,cY)
        !            50: register short oX,oY,cX,cY;
        !            51: {
        !            52:        register XIoAddr *xptr;
        !            53: 
        !            54:        xptr = XAddr;
        !            55:        xptr->hmbox.left = oX;
        !            56:        xptr->hmbox.top = oY;
        !            57:        xptr->hmbox.right = cX;
        !            58:        xptr->hmbox.bottom = cY;
        !            59:        xptr->hmbox.flags = 1;
        !            60:        if (LOC_IN_BOUNDS(oX,oY,cX,cY)) {
        !            61:                rem_loc = 1;
        !            62:                if (ioctl(xdev,QIOCHIDECUR,0) == -1)
        !            63:                        return(-1);
        !            64:        }
        !            65:        return(0);
        !            66: }
        !            67: 
        !            68: /*
        !            69:  * Restore_cursor checks the shared memory area and if set it checks
        !            70:  * to see if the cursor was removed by save_cursor or if it currently
        !            71:  * is in the critical rectangle defined by hmbox.  If it is then
        !            72:  * the approprate ioctl is called.  If the ioctl fails then -1 is return
        !            73:  * otherwise 0 is returned.
        !            74:  */
        !            75: restore_cursor()
        !            76: {
        !            77:        register XIoAddr *xptr;
        !            78: 
        !            79:        xptr = XAddr;
        !            80:        if (xptr->hmbox.flags)  {
        !            81:                if (rem_loc || LOC_IN_BOUNDS(xptr->hmbox.left,
        !            82:                                             xptr->hmbox.top,
        !            83:                                             xptr->hmbox.right,
        !            84:                                             xptr->hmbox.bottom)) {
        !            85:                        xptr->hmbox.flags = 0;
        !            86:                        if (ioctl(xdev,QIOCSHOWCUR,0) == -1)
        !            87:                                return(-1);
        !            88:                }
        !            89:                else {
        !            90:                        xptr->hmbox.flags = 0;
        !            91:                }
        !            92:        }
        !            93:        rem_loc = 0;
        !            94:        return(0);
        !            95: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.