Annotation of researchv9/X11/src/X.V11R1/server/dix/cursor.c, revision 1.1

1.1     ! root        1: /***********************************************************
        !             2: Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
        !             3: and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
        !             4: 
        !             5:                         All Rights Reserved
        !             6: 
        !             7: Permission to use, copy, modify, and distribute this software and its 
        !             8: documentation for any purpose and without fee is hereby granted, 
        !             9: provided that the above copyright notice appear in all copies and that
        !            10: both that copyright notice and this permission notice appear in 
        !            11: supporting documentation, and that the names of Digital or MIT not be
        !            12: used in advertising or publicity pertaining to distribution of the
        !            13: software without specific, written prior permission.  
        !            14: 
        !            15: DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
        !            16: ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
        !            17: DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
        !            18: ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
        !            19: WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
        !            20: ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
        !            21: SOFTWARE.
        !            22: 
        !            23: ******************************************************************/
        !            24: 
        !            25: 
        !            26: /* $Header: cursor.c,v 1.27 87/09/11 07:18:41 toddb Exp $ */
        !            27: 
        !            28: #include "X.h"
        !            29: #include "scrnintstr.h"
        !            30: #include "cursorstr.h"
        !            31: #include "dixfont.h"   /* for CreateRootCursor */
        !            32: #include "resource.h"  /* for CreateRootCursor */
        !            33: 
        !            34: #include "Xmd.h"
        !            35: #include "dix.h"       /* for CreateRootCursor  */
        !            36: #include "opaque.h"    /* for CloseFont  */
        !            37: 
        !            38: /*
        !            39:  * To be called indirectly by DeleteResource; must use exactly two args
        !            40:  */
        !            41: void
        !            42: FreeCursor( pCurs, cid)
        !            43:     CursorPtr  pCurs;
        !            44:     int        cid;    
        !            45: {
        !            46:     int                nscr;
        !            47: 
        !            48:     ScreenPtr  pscr;
        !            49: 
        !            50:     if ( --pCurs->refcnt > 0)
        !            51:        return;
        !            52: 
        !            53:     for ( nscr=0, pscr=screenInfo.screen;
        !            54:          nscr<screenInfo.numScreens;
        !            55:          nscr++, pscr++)
        !            56:     {
        !            57:         if ( pscr->UnrealizeCursor)
        !            58:            ( *pscr->UnrealizeCursor)( pscr, pCurs);
        !            59:     }
        !            60:     Xfree( pCurs->source);
        !            61:     Xfree( pCurs->mask);
        !            62:     Xfree( pCurs);
        !            63: }
        !            64: 
        !            65: /*
        !            66:  * does nothing about the resource table, just creates the data structure.
        !            67:  * allocates no storage.
        !            68:  */
        !            69: CursorPtr 
        !            70: AllocCursor( psrcbits, pmaskbits, cm,
        !            71:            foreRed, foreGreen, foreBlue, backRed, backGreen, backBlue)
        !            72:     unsigned char *    psrcbits;               /* server-defined padding */
        !            73:     unsigned char *    pmaskbits;              /* server-defined padding */
        !            74:     CursorMetricPtr    cm;
        !            75:     unsigned   int foreRed, foreGreen, foreBlue;
        !            76:     unsigned   int backRed, backGreen, backBlue;
        !            77: {
        !            78:     CursorPtr  pCurs;
        !            79:     int                nscr;
        !            80:     ScreenPtr  pscr;
        !            81: 
        !            82:     pCurs = (CursorPtr )Xalloc( sizeof(CursorRec)); 
        !            83: 
        !            84:     pCurs->source = psrcbits;
        !            85:     pCurs->mask = pmaskbits;
        !            86: 
        !            87:     pCurs->width = cm->width;
        !            88:     pCurs->height = cm->height;
        !            89: 
        !            90:     pCurs->refcnt = 1;         
        !            91:     pCurs->xhot = cm->xhot;
        !            92:     pCurs->yhot = cm->yhot;
        !            93: 
        !            94:     pCurs->foreRed = foreRed;
        !            95:     pCurs->foreGreen = foreGreen;
        !            96:     pCurs->foreBlue = foreBlue;
        !            97: 
        !            98:     pCurs->backRed = backRed;
        !            99:     pCurs->backGreen = backGreen;
        !           100:     pCurs->backBlue = backBlue;
        !           101: 
        !           102:     /*
        !           103:      * realize the cursor for every screen
        !           104:      */
        !           105:     for ( nscr=0, pscr=screenInfo.screen;
        !           106:          nscr<screenInfo.numScreens;
        !           107:          nscr++, pscr++)
        !           108:     {
        !           109:         if ( pscr->RealizeCursor)
        !           110:            ( *pscr->RealizeCursor)( pscr, pCurs);
        !           111:     }
        !           112:     return pCurs;
        !           113: }
        !           114: 
        !           115: 
        !           116: /***********************************************************
        !           117:  * CreateRootCursor
        !           118:  *
        !           119:  * look up the name of a font
        !           120:  * open the font
        !           121:  * add the font to the resource table
        !           122:  * make bitmaps from glyphs "glyph" and "glyph + 1" of the font
        !           123:  * make a cursor from the bitmaps
        !           124:  * add the cursor to the resource table
        !           125:  *************************************************************/
        !           126: 
        !           127: CursorPtr 
        !           128: CreateRootCursor(pfilename, glyph)
        !           129:     char *     pfilename;
        !           130:     int                glyph;
        !           131: {
        !           132:     CursorPtr  curs;
        !           133:     FontPtr    cursorfont;
        !           134:     char *     psrcbits;
        !           135:     char *     pmskbits;
        !           136:     CursorMetricRec cm;
        !           137:     XID                fontID;
        !           138: 
        !           139:     fontID = FakeClientID(0);
        !           140:     if (cursorfont = OpenFont( strlen( pfilename), pfilename))
        !           141:        AddResource(
        !           142:           fontID, RT_FONT, cursorfont, CloseFont, RC_CORE);
        !           143:     else
        !           144:        return NullCursor;
        !           145: 
        !           146:     if (!CursorMetricsFromGlyph(cursorfont, glyph+1, &cm))
        !           147:        return NullCursor;
        !           148: 
        !           149:     if (ServerBitsFromGlyph(fontID, cursorfont, glyph, &cm, &psrcbits))
        !           150:        return NullCursor;
        !           151:     if (ServerBitsFromGlyph(fontID, cursorfont, glyph+1, &cm, &pmskbits))
        !           152:        return NullCursor;
        !           153: 
        !           154:     curs = AllocCursor( psrcbits, pmskbits, &cm, 0, 0, 0, ~0, ~0, ~0);
        !           155: 
        !           156:     AddResource(FakeClientID(0), RT_CURSOR, curs, FreeCursor, RC_CORE);
        !           157:     return curs;
        !           158: }
        !           159: 
        !           160: 

unix.superglobalmegacorp.com

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