home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / server / ddx / mips / mipsCursor.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-07-18  |  3.6 KB  |  158 lines

  1. /*
  2.  * $XConsortium: mipsCursor.c,v 1.2 91/07/18 22:58:13 keith Exp $
  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/18 22:58:13 keith Exp $"
  24.  
  25. /*
  26.  * Device independent (?) part of HW cursor support
  27.  */
  28.  
  29. #ifndef X11R4
  30.  
  31. #include <signal.h>
  32.  
  33. #include <X.h>
  34. #define NEED_EVENTS
  35. #include <misc.h>
  36. #include <input.h>
  37. #include <cursorstr.h>
  38. #include <mipointer.h>
  39. #include <regionstr.h>
  40. #include <scrnintstr.h>
  41. #include <servermd.h>
  42. #include <windowstr.h>
  43.  
  44. #include "mipsFb.h"
  45.  
  46. static Bool mipsRealizeCursor();
  47. static Bool mipsUnrealizeCursor();
  48. static void mipsSetCursor();
  49. static void mipsMoveCursor();
  50. static void mipsRecolorCursor();
  51.  
  52. static miPointerSpriteFuncRec mipsPointerSpriteFuncs = {
  53.     mipsRealizeCursor,
  54.     mipsUnrealizeCursor,
  55.     mipsSetCursor,
  56.     mipsMoveCursor,
  57. };
  58.  
  59. extern miPointerScreenFuncRec mipsPointerScreenFuncs;
  60.  
  61. Bool
  62. mipsCursorInit(pm, pScr)
  63.     MipsScreenPtr pm;
  64.     ScreenPtr pScr;
  65. {
  66.     if ((pm->cap & MIPS_SCR_CURSOR) && pm->RealizeCursor) {
  67.         if (!(miPointerInitialize(pScr, &mipsPointerSpriteFuncs,
  68.             &mipsPointerScreenFuncs, FALSE)))
  69.             return FALSE;
  70.  
  71.         pScr->RecolorCursor = mipsRecolorCursor;
  72.     }
  73.     else
  74.         return miDCInitialize(pScr, &mipsPointerScreenFuncs);
  75. }
  76.  
  77. static Bool
  78. mipsRealizeCursor(pScr, pCurs)
  79.     ScreenPtr pScr;
  80.     CursorPtr pCurs;
  81. {
  82.     if (pCurs->bits->refcnt <= 1) {
  83.         int index = pScr->myNum;
  84.         MipsScreenPtr pm = MipsScreenNumToPriv(index);
  85.         pointer *pPriv = &pCurs->bits->devPriv[index];
  86.  
  87.         return (*pm->RealizeCursor)(pm, pCurs, pPriv);
  88.     }
  89.  
  90.     return TRUE;
  91. }
  92.  
  93. static Bool
  94. mipsUnrealizeCursor(pScr, pCurs)
  95.     ScreenPtr pScr;
  96.     CursorPtr pCurs;
  97. {
  98.     pointer priv;
  99.  
  100.     if (pCurs->bits->refcnt <= 1 &&
  101.         (priv = pCurs->bits->devPriv[pScr->myNum]))
  102.         xfree(priv);
  103.     return TRUE;
  104. }
  105.  
  106. static void
  107. mipsSetCursor(pScr, pCurs, x, y)
  108.     ScreenPtr pScr;
  109.     CursorPtr pCurs;
  110.     int x, y;
  111. {
  112.     int index = pScr->myNum;
  113.     MipsScreenPtr pm = MipsScreenNumToPriv(index);
  114.     pointer priv =     pCurs ? pCurs->bits->devPriv[index] : 0;
  115.  
  116. #ifdef SYSV
  117.     void (*poll) ();
  118.  
  119.     poll = sigset(SIGPOLL, SIG_HOLD);
  120. #else /* SYSV */
  121.     int block;
  122.  
  123.     block = sigblock(sigmask(SIGIO));
  124. #endif /* SYSV */
  125.  
  126.     (*pm->SetCursor)(pm, pCurs, priv, x, y);
  127.  
  128. #ifdef SYSV
  129.     (void) sigset(SIGPOLL, poll);
  130. #else /* SYSV */
  131.     (void) sigsetmask(block);
  132. #endif /* SYSV */
  133. }
  134.  
  135. static void
  136. mipsMoveCursor(pScr, x, y)
  137.     ScreenPtr pScr;
  138.     int x, y;
  139. {
  140.     MipsScreenPtr pm = MipsScreenToPriv(pScr);
  141.  
  142.     (*pm->MoveCursor)(pm, x, y);
  143. }
  144.  
  145. static void
  146. mipsRecolorCursor(pScr, pCurs, displayed)
  147.     ScreenPtr pScr;
  148.     CursorPtr pCurs;
  149.     Bool displayed;
  150. {
  151.     MipsScreenPtr pm = MipsScreenToPriv(pScr);
  152.  
  153.     if (displayed)
  154.         (*pm->RecolorCursor)(pm, pCurs);
  155. }
  156.  
  157. #endif /* not X11R4 */
  158.