(file) Return to xf86Cursor.c CVS log (file) (dir) Up to [XFree86 CVS] / xc / programs / Xserver / hw / xfree86 / common

  1 dawes 3.13 /* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Cursor.c,v 3.12 1996/08/23 11:03:15 dawes Exp $ */
  2 dawes 3.5  /*
  3 dawes 1.1   * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
  4             *
  5             * Permission to use, copy, modify, distribute, and sell this software and its
  6             * documentation for any purpose is hereby granted without fee, provided that
  7             * the above copyright notice appear in all copies and that both that
  8             * copyright notice and this permission notice appear in supporting
  9             * documentation, and that the name of Thomas Roell not be used in
 10             * advertising or publicity pertaining to distribution of the software without
 11             * specific, written prior permission.  Thomas Roell makes no representations
 12             * about the suitability of this software for any purpose.  It is provided
 13             * "as is" without express or implied warranty.
 14             *
 15             * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 16             * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
 17             * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 18             * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
 19             * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 20             * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 21             * PERFORMANCE OF THIS SOFTWARE.
 22             *
 23             */
 24 dawes 3.13 /* $XConsortium: xf86Cursor.c /main/10 1996/10/19 17:58:23 kaleb $ */
 25 dawes 1.1  
 26 dawes 3.11 #define NEED_EVENTS
 27 dawes 1.1  #include "X.h"
 28            #include "Xmd.h"
 29            #include "input.h"
 30 dawes 3.10 #include "cursor.h"
 31 dawes 1.1  #include "mipointer.h"
 32            #include "scrnintstr.h"
 33            
 34            #include "compiler.h"
 35            
 36            #include "xf86.h"
 37            #include "xf86Procs.h"
 38 dawes 3.8  #ifdef XFreeXDGA
 39            #include "Xproto.h"
 40            #include "extnsionst.h"
 41            #include "scrnintstr.h"
 42            #include "servermd.h"
 43            
 44            #define _XF86DGA_SERVER_
 45            #include "extensions/xf86dgastr.h"
 46            #endif
 47            
 48 dawes 3.11 #ifdef XINPUT
 49            #include "xf86_Config.h"
 50            #include "XIproto.h"
 51            #include "xf86Xinput.h"
 52            #endif
 53            
 54 dawes 1.1  /* #include "atKeynames.h" -hv- dont need that include here */
 55            
 56            
 57 dawes 3.11 static Bool   xf86CursorOffScreen(
 58            #if NeedFunctionPrototypes
 59                 ScreenPtr   *pScreen,
 60                 int         *x,
 61                 int         *y
 62            #endif
 63            );
 64            static void   xf86CrossScreen(
 65            #if NeedFunctionPrototypes
 66                 ScreenPtr   pScreen,
 67                 Bool        entering
 68            #endif
 69            );
 70            static void   xf86WrapCursor(
 71            #if NeedFunctionPrototypes
 72                 ScreenPtr   pScreen,
 73                 int         x,
 74                 int	 y
 75 dawes 3.7  #endif
 76 dawes 3.11 );
 77 dawes 1.1  
 78            miPointerScreenFuncRec xf86PointerScreenFuncs = {
 79              xf86CursorOffScreen,
 80              xf86CrossScreen,
 81              xf86WrapCursor,
 82 dawes 3.7  #ifdef XINPUT
 83              xf86eqEnqueue,
 84            #endif
 85 dawes 1.1  };
 86            
 87            
 88            
 89            /*
 90             * xf86InitViewport --
 91             *      Initialize paning & zooming parameters, so that a driver must only
 92             *      check what resolutions are possible and whether the virtual area
 93             *      is valid if specifyed.
 94             */
 95            
 96            void
 97            xf86InitViewport(pScr)
 98                 ScrnInfoPtr pScr;
 99            {
100              /*
101               * Compute the initial Viewport if necessary
102               */
103              if (pScr->frameX0 < 0)
104                {
105                  pScr->frameX0 = (pScr->virtualX - pScr->modes->HDisplay) / 2;
106 dawes 3.3        pScr->frameY0 = (pScr->virtualY - pScr->modes->VDisplay) / 2;
107 dawes 1.1      }
108              pScr->frameX1 = pScr->frameX0 + pScr->modes->HDisplay - 1;
109 dawes 3.3    pScr->frameY1 = pScr->frameY0 + pScr->modes->VDisplay - 1;
110 dawes 1.1  
111              /*
112               * Now adjust the initial Viewport, so it lies within the virtual area
113               */
114              if (pScr->frameX1 >= pScr->virtualX)
115                {
116            	pScr->frameX0 = pScr->virtualX - pScr->modes->HDisplay;
117            	pScr->frameX1 = pScr->frameX0 + pScr->modes->HDisplay - 1;
118                }
119            
120              if (pScr->frameY1 >= pScr->virtualY)
121                {
122 dawes 3.3  	pScr->frameY0 = pScr->virtualY - pScr->modes->VDisplay;
123            	pScr->frameY1 = pScr->frameY0 + pScr->modes->VDisplay - 1;
124 dawes 1.1      }
125            }
126            
127            
128            /*
129             * xf86SetViewport --
130             *      Scroll the visual part of the screen so the pointer is visible.
131             */
132            
133            void
134            xf86SetViewport(pScreen, x, y)
135                 ScreenPtr   pScreen;
136                 int         x, y;
137            {
138              Bool          frameChanged = FALSE;
139              ScrnInfoPtr   pScr = XF86SCRNINFO(pScreen);
140 dawes 3.0  
141 dawes 1.1    /*
142               * check wether (x,y) belongs to the visual part of the screen
143               * if not, change the base of the displayed frame accoring
144               */
145              if ( pScr->frameX0 > x) { 
146                pScr->frameX0 = x;
147                pScr->frameX1 = x + pScr->modes->HDisplay - 1;
148                frameChanged = TRUE ;
149              }
150              
151              if ( pScr->frameX1 < x) { 
152                pScr->frameX1 = x + 1;
153 dawes 3.12     pScr->frameX0 = x - pScr->modes->HDisplay + 1;
154 dawes 1.1      frameChanged = TRUE ;
155              }
156              
157              if ( pScr->frameY0 > y) { 
158                pScr->frameY0 = y;
159 dawes 3.3      pScr->frameY1 = y + pScr->modes->VDisplay - 1;
160 dawes 1.1      frameChanged = TRUE;
161              }
162              
163              if ( pScr->frameY1 < y) { 
164                pScr->frameY1 = y;
165 dawes 3.3      pScr->frameY0 = y - pScr->modes->VDisplay + 1;
166 dawes 1.1      frameChanged = TRUE; 
167              }
168              
169              if (frameChanged) (pScr->AdjustFrame)(pScr->frameX0, pScr->frameY0);
170            }
171            
172            
173 dawes 3.6  static Bool xf86ZoomLocked = FALSE;
174 dawes 1.1  
175            /*
176 dawes 3.6   * xf86LockZoom --
177             *	Enable/disable ZoomViewport
178             */
179            
180            void
181            xf86LockZoom (pScreen, lock)
182                 ScreenPtr	pScreen;
183                 Bool	lock;
184            {
185              /*
186               * pScreen is currently ignored, but may be used later to enable locking
187               * of individual screens.
188               */
189            
190              xf86ZoomLocked = lock;
191            }
192            
193            /*
194 dawes 1.1   * xf86ZoomViewport --
195             *      Reinitialize the visual part of the screen for another modes->
196             */
197            
198            void
199            xf86ZoomViewport (pScreen, zoom)
200                 ScreenPtr   pScreen;
201                 int        zoom;
202            {
203              ScrnInfoPtr   pScr = XF86SCRNINFO(pScreen);
204 dawes 3.6  
205              if (xf86ZoomLocked)
206                return;
207 dawes 3.8  
208            #ifdef XFreeXDGA
209              /*
210               * We should really send the mode change request to the DGA client and let
211               * it decide what to do. For now just bin the request
212               */
213               if (((ScrnInfoPtr)(xf86Info.currentScreen->devPrivates[xf86ScreenIndex].ptr))->directMode&XF86DGADirectGraphics)
214               return;
215            #endif
216 dawes 1.1  
217              if (pScr->modes != pScr->modes->next)
218              {
219                pScr->modes = zoom > 0 ? pScr->modes->next : pScr->modes->prev;
220            
221                if ((pScr->SwitchMode)(pScr->modes))
222                {
223                  /* 
224                   * adjust new frame for the displaysize
225                   */
226                  pScr->frameX0 = (pScr->frameX1 + pScr->frameX0 -pScr->modes->HDisplay)/2;
227                  pScr->frameX1 = pScr->frameX0 + pScr->modes->HDisplay - 1;
228            
229                  if (pScr->frameX0 < 0)
230            	{
231            	  pScr->frameX0 = 0;
232            	  pScr->frameX1 = pScr->frameX0 + pScr->modes->HDisplay - 1;
233            	}
234                  else if (pScr->frameX1 >= pScr->virtualX)
235            	{
236            	  pScr->frameX0 = pScr->virtualX - pScr->modes->HDisplay;
237 dawes 1.1  	  pScr->frameX1 = pScr->frameX0 + pScr->modes->HDisplay - 1;
238            	}
239                  
240 dawes 3.3        pScr->frameY0 = (pScr->frameY1 + pScr->frameY0 - pScr->modes->VDisplay)/2;
241                  pScr->frameY1 = pScr->frameY0 + pScr->modes->VDisplay - 1;
242 dawes 1.1  
243                  if (pScr->frameY0 < 0)
244            	{
245            	  pScr->frameY0 = 0;
246 dawes 3.3  	  pScr->frameY1 = pScr->frameY0 + pScr->modes->VDisplay - 1;
247 dawes 1.1  	}
248                  else if (pScr->frameY1 >= pScr->virtualY)
249            	{
250 dawes 3.3  	  pScr->frameY0 = pScr->virtualY - pScr->modes->VDisplay;
251            	  pScr->frameY1 = pScr->frameY0 + pScr->modes->VDisplay - 1;
252 dawes 1.1  	}
253                }
254                else /* switch failed, so go back to old mode */
255                  pScr->modes = zoom > 0 ? pScr->modes->prev : pScr->modes->next;
256              }
257            
258              (pScr->AdjustFrame)(pScr->frameX0, pScr->frameY0);
259            }
260            
261            
262            
263            /*
264             * xf86CursorOffScreen --
265             *      Check whether it is necessary to switch to another screen
266             */
267            
268            /* ARGSUSED */
269            static Bool
270            xf86CursorOffScreen (pScreen, x, y)
271                 ScreenPtr   *pScreen;
272                 int         *x, *y;
273 dawes 1.1  {
274              int		i;
275            
276              if ((screenInfo.numScreens > 1) && ((*x < 0) || ((*pScreen)->width <= *x))) {
277                i = (*pScreen)->myNum;
278                if (*x < 0) {
279                  i = (i ? i : screenInfo.numScreens) -1;
280                  *pScreen = screenInfo.screens[i];
281                  *x += (*pScreen)->width;
282                }
283                else {
284                  *x -= (*pScreen)->width;
285                  i = (i+1) % screenInfo.numScreens;
286                  *pScreen = screenInfo.screens[i];
287                }
288                return(TRUE);
289              }
290              return(FALSE);
291            }
292            
293            
294 dawes 1.1  
295            /*
296             * xf86CrossScreen --
297             *      Switch to another screen
298             */
299            
300            /* ARGSUSED */
301            static void
302            xf86CrossScreen (pScreen, entering)
303                 ScreenPtr   pScreen;
304                 Bool        entering;
305            {
306              if (xf86Info.sharedMonitor)
307                (XF86SCRNINFO(pScreen)->EnterLeaveMonitor)(entering);
308              (XF86SCRNINFO(pScreen)->EnterLeaveCursor)(entering);
309            }
310            
311            
312            /*
313             * xf86WrapCursor --
314             *      Wrap possible to another screen
315 dawes 1.1   */
316            
317            /* ARGSUSED */
318            static void
319            xf86WrapCursor (pScreen, x, y)
320                 ScreenPtr   pScreen;
321                 int         x,y;
322            {
323              miPointerWarpCursor(pScreen,x,y);
324            
325              xf86Info.currentScreen = pScreen;
326            }

Powered by
ViewCVS 0.9.2