home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / d / ddx-mips.zip / MIPSCURS.C < prev    next >
C/C++ Source or Header  |  1992-07-31  |  3KB  |  146 lines

  1. /*
  2.  * $XConsortium$
  3.  *
  4.  * Copyright 1991 MIPS Computer Systems, Inc.
  5.  *
  6.  * Permission to use, copy, modify, distribute, and sell this software and its
  7.  * documentation for any purpose is hereby granted without fee, provided that
  8.  * the above copyright notice appear in all copies and that both that
  9.  * copyright notice and this permission notice appear in supporting
  10.  * documentation, and that the name of MIPS not be used in advertising or
  11.  * publicity pertaining to distribution of the software without specific,
  12.  * written prior permission.  MIPS makes no representations about the
  13.  * suitability of this software for any purpose.  It is provided "as is"
  14.  * without express or implied warranty.
  15.  *
  16.  * MIPS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  17.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL MIPS
  18.  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  19.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  20.  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
  21.  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  22.  */
  23. #ident    "$Header: mipsCursor.c,v 1.2 91/07/15 19:47:28 dd Exp $"
  24.  
  25. /*
  26.  * Device independent (?) part of HW cursor support
  27.  */
  28.  
  29. #ifndef X11R4
  30.  
  31. #include <X.h>
  32. #define NEED_EVENTS
  33. #include <misc.h>
  34. #include <input.h>
  35. #include <cursorstr.h>
  36. #include <mipointer.h>
  37. #include <regionstr.h>
  38. #include <scrnintstr.h>
  39. #include <servermd.h>
  40. #include <windowstr.h>
  41.  
  42. #include "mipsFb.h"
  43. #include "mipsIo.h"
  44.  
  45. static Bool mipsRealizeCursor();
  46. static Bool mipsUnrealizeCursor();
  47. static void mipsSetCursor();
  48. static void mipsMoveCursor();
  49. static void mipsRecolorCursor();
  50.  
  51. static miPointerSpriteFuncRec mipsPointerSpriteFuncs = {
  52.     mipsRealizeCursor,
  53.     mipsUnrealizeCursor,
  54.     mipsSetCursor,
  55.     mipsMoveCursor,
  56. };
  57.  
  58. extern miPointerScreenFuncRec mipsPointerScreenFuncs;
  59.  
  60. Bool
  61. mipsCursorInit(pm, pScr)
  62.     MipsScreenPtr pm;
  63.     ScreenPtr pScr;
  64. {
  65.     if ((pm->cap & MIPS_SCR_CURSOR) && pm->RealizeCursor) {
  66.         if (!(miPointerInitialize(pScr, &mipsPointerSpriteFuncs,
  67.             &mipsPointerScreenFuncs, FALSE)))
  68.             return FALSE;
  69.  
  70.         pScr->RecolorCursor = mipsRecolorCursor;
  71.     }
  72.     else
  73.         return miDCInitialize(pScr, &mipsPointerScreenFuncs);
  74. }
  75.  
  76. static Bool
  77. mipsRealizeCursor(pScr, pCurs)
  78.     ScreenPtr pScr;
  79.     CursorPtr pCurs;
  80. {
  81.     if (pCurs->bits->refcnt <= 1) {
  82.         int index = pScr->myNum;
  83.         MipsScreenPtr pm = MipsScreenNumToPriv(index);
  84.         pointer *pPriv = &pCurs->bits->devPriv[index];
  85.  
  86.         return (*pm->RealizeCursor)(pm, pCurs, pPriv);
  87.     }
  88.  
  89.     return TRUE;
  90. }
  91.  
  92. static Bool
  93. mipsUnrealizeCursor(pScr, pCurs)
  94.     ScreenPtr pScr;
  95.     CursorPtr pCurs;
  96. {
  97.     pointer priv;
  98.  
  99.     if (pCurs->bits->refcnt <= 1 &&
  100.         (priv = pCurs->bits->devPriv[pScr->myNum]))
  101.         xfree(priv);
  102.     return TRUE;
  103. }
  104.  
  105. static void
  106. mipsSetCursor(pScr, pCurs, x, y)
  107.     ScreenPtr pScr;
  108.     CursorPtr pCurs;
  109.     int x, y;
  110. {
  111.     SIGHOLD_DCL
  112.     int index = pScr->myNum;
  113.     MipsScreenPtr pm = MipsScreenNumToPriv(index);
  114.     pointer priv =     pCurs ? pCurs->bits->devPriv[index] : 0;
  115.  
  116.     SIGHOLD;
  117.  
  118.     (*pm->SetCursor)(pm, pCurs, priv, x, y);
  119.  
  120.     SIGRELEASE;
  121. }
  122.  
  123. static void
  124. mipsMoveCursor(pScr, x, y)
  125.     ScreenPtr pScr;
  126.     int x, y;
  127. {
  128.     MipsScreenPtr pm = MipsScreenToPriv(pScr);
  129.  
  130.     (*pm->MoveCursor)(pm, x, y);
  131. }
  132.  
  133. static void
  134. mipsRecolorCursor(pScr, pCurs, displayed)
  135.     ScreenPtr pScr;
  136.     CursorPtr pCurs;
  137.     Bool displayed;
  138. {
  139.     MipsScreenPtr pm = MipsScreenToPriv(pScr);
  140.  
  141.     if (displayed)
  142.         (*pm->RecolorCursor)(pm, pCurs);
  143. }
  144.  
  145. #endif /* not X11R4 */
  146.