dmxcursor.c File Reference
#include "dmx.h"
#include "dmxsync.h"
#include "dmxcursor.h"
#include "dmxlog.h"
#include "dmxprop.h"
#include "dmxinput.h"
#include "mipointer.h"
#include "windowstr.h"
#include "globals.h"
#include "cursorstr.h"
#include "dixevents.h"
#include "inputstr.h"

Defines

#define DMX_CURSOR_DEBUG   0
#define DMXDBG0(f)
#define DMXDBG1(f, a)
#define DMXDBG2(f, a, b)
#define DMXDBG3(f, a, b, c)
#define DMXDBG4(f, a, b, c, d)
#define DMXDBG5(f, a, b, c, d, e)
#define DMXDBG6(f, a, b, c, d, e, g)
#define DMXDBG7(f, a, b, c, d, e, g, h)

Functions

void dmxCursorNoMulti (void)
static Bool dmxCursorOffScreen (ScreenPtr *ppScreen, int *x, int *y)
static void dmxCrossScreen (ScreenPtr pScreen, Bool entering)
static void dmxWarpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
static int * dmxSLCreate (void)
static void dmxSLFree (int *list)
static int dmxSLFindNext (int *list)
static int dmxTryComputeScreenOrigins (int *screensLeft)
static void dmxComputeScreenOrigins (void)
void dmxReInitOrigins (void)
void dmxInitOrigins (void)
int dmxOnScreen (int x, int y, DMXScreenInfo *dmxScreen)
static int dmxDoesOverlap (DMXScreenInfo *a, DMXScreenInfo *b)
static void * dmxPrintOverlap (DMXScreenInfo *dmxScreen, void *closure)
static void * dmxIterateOverlap (DMXScreenInfo *start, void *(*f)(DMXScreenInfo *dmxScreen, void *), void *closure)
static void * dmxTestSameDisplay (DMXScreenInfo *a, void *closure)
void dmxInitOverlap (void)
void dmxBECreateCursor (ScreenPtr pScreen, CursorPtr pCursor)
static Bool _dmxRealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
Bool dmxBEFreeCursor (ScreenPtr pScreen, CursorPtr pCursor)
static Bool _dmxUnrealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
static void _dmxMoveCursor (ScreenPtr pScreen, int x, int y)
static void _dmxSetCursor (ScreenPtr pScreen, CursorPtr pCursor, int x, int y)
static Bool dmxRealizeCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
static Bool dmxUnrealizeCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
static CursorPtr dmxFindCursor (DMXScreenInfo *start)
void dmxMoveCursor (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
static void dmxSetCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, int x, int y)
void dmxHideCursor (DMXScreenInfo *dmxScreen)
void dmxCheckCursor (void)
static Bool dmxDeviceCursorInitialize (DeviceIntPtr pDev, ScreenPtr pScr)
static void dmxDeviceCursorCleanup (DeviceIntPtr pDev, ScreenPtr pScr)

Variables

static int dmxCursorDoMultiCursors = 1
miPointerScreenFuncRec dmxPointerCursorFuncs
miPointerSpriteFuncRec dmxPointerSpriteFuncs

Detailed Description

This file contains code than supports cursor movement, including the code that initializes and reinitializes the screen positions and computes screen overlap.

"This code is based very closely on the XFree86 equivalent (xfree86/common/xf86Cursor.c)." --David Dawes.

"This code was then extensively re-written, as explained here." --Rik Faith

The code in xf86Cursor.c used edge lists to implement the CursorOffScreen function. The edge list computation was complex (especially in the face of arbitrarily overlapping screens) compared with the speed savings in the CursorOffScreen function. The new implementation has erred on the side of correctness, readability, and maintainability over efficiency. For the common (non-edge) case, the dmxCursorOffScreen function does avoid a loop over all the screens. When the cursor has left the screen, all the screens are searched, and the first screen (in dmxScreens order) containing the cursor will be returned. If run-time profiling shows that this routing is a performance bottle-neck, then an edge list may have to be reimplemented. An edge list algorithm is O(edges) whereas the new algorithm is O(dmxNumScreens). Since edges is usually 1-3 and dmxNumScreens may be 30-60 for large backend walls, this trade off may be compelling.

The xf86InitOrigins routine uses bit masks during the computation and is therefore limited to the length of a word (e.g., 32 or 64 bits) screens. Because Xdmx is expected to be used with a large number of backend displays, this limitation was removed. The new implementation has erred on the side of readability over efficiency, using the dmxSL* routines to manage a screen list instead of a bitmap, and a function call to decrease the length of the main routine. Both algorithms are of the same order, and both are called only at server generation time, so trading clarity and long-term maintainability for efficiency does not seem justified in this case.


Define Documentation

#define DMX_CURSOR_DEBUG   0
#define DMXDBG0 (   f)
#define DMXDBG1 (   f,
 
)
#define DMXDBG2 (   f,
  a,
 
)
#define DMXDBG3 (   f,
  a,
  b,
 
)

Referenced by dmxMoveCursor(), and dmxWarpCursor().

#define DMXDBG4 (   f,
  a,
  b,
  c,
 
)

Referenced by _dmxSetCursor().

#define DMXDBG5 (   f,
  a,
  b,
  c,
  d,
 
)

Referenced by _dmxMoveCursor(), and dmxSetCursor().

#define DMXDBG6 (   f,
  a,
  b,
  c,
  d,
  e,
 
)

Referenced by dmxInitOverlap().

#define DMXDBG7 (   f,
  a,
  b,
  c,
  d,
  e,
  g,
 
)

Function Documentation

static void _dmxMoveCursor ( ScreenPtr  pScreen,
int  x,
int  y 
) [static]
static Bool _dmxRealizeCursor ( ScreenPtr  pScreen,
CursorPtr  pCursor 
) [static]
static Bool _dmxUnrealizeCursor ( ScreenPtr  pScreen,
CursorPtr  pCursor 
) [static]
Bool dmxBEFreeCursor ( ScreenPtr  pScreen,
CursorPtr  pCursor 
)

Free pCursor on the back-end associated with pScreen.

References _DMXScreenInfo::beDisplay, _dmxCursorPriv::cursor, DMX_GET_CURSOR_PRIV, and dmxScreens.

Referenced by _dmxUnrealizeCursor(), and dmxBEDestroyResources().

static void dmxComputeScreenOrigins ( void  ) [static]
static void dmxCrossScreen ( ScreenPtr  pScreen,
Bool  entering 
) [static]
void dmxCursorNoMulti ( void  )

Turn off support for displaying multiple cursors on overlapped back-end displays. See dmxCursorDoMultiCursors.

References dmxCursorDoMultiCursors.

Referenced by ddxProcessArgument().

static Bool dmxCursorOffScreen ( ScreenPtr *  ppScreen,
int *  x,
int *  y 
) [static]
static void dmxDeviceCursorCleanup ( DeviceIntPtr  pDev,
ScreenPtr  pScr 
) [static]
static Bool dmxDeviceCursorInitialize ( DeviceIntPtr  pDev,
ScreenPtr  pScr 
) [static]
static int dmxDoesOverlap ( DMXScreenInfo a,
DMXScreenInfo b 
) [static]
static CursorPtr dmxFindCursor ( DMXScreenInfo start) [static]
void dmxHideCursor ( DMXScreenInfo dmxScreen)

This routine is used by the backend input routines to hide the cursor on a screen that is being used for relative input.

See also:
dmxbackend.c

References _dmxSetCursor(), dmxGetGlobalPosition(), and _DMXScreenInfo::index.

Referenced by dmxBackendUpdatePosition().

void dmxInitOverlap ( void  )

Detects overlapping dmxScreens and creates circular lists. This uses an O(dmxNumScreens^2) algorithm, but dmxNumScreens is < 100 and the computation only needs to be performed for every server generation or dynamic reconfiguration .

References _DMXScreenInfo::cursorNotShared, DMXDBG6, dmxDoesOverlap(), dmxInfo, dmxIterateOverlap(), dmxLog(), dmxLogOutput(), dmxLogOutputCont(), dmxNumScreens, dmxPrintOverlap(), dmxPropertyIterate(), dmxScreens, dmxTestSameDisplay(), _DMXScreenInfo::index, _DMXScreenInfo::name, and _DMXScreenInfo::over.

Referenced by dmxAdjustCursorBoundaries(), and InitOutput().

static void* dmxIterateOverlap ( DMXScreenInfo start,
void *(*)(DMXScreenInfo *dmxScreen, void *)  f,
void *  closure 
) [static]

Iterate over the screens which overlap with the start screen, calling f with the closure for each argument. Often used with dmxPrintOverlap.

References _DMXScreenInfo::over.

Referenced by dmxInitOverlap().

void dmxMoveCursor ( DeviceIntPtr  pDev,
ScreenPtr  pScreen,
int  x,
int  y 
)

Move the cursor to coordinates (x, y)on pScreen. This function is usually called via dmxPointerSpriteFuncs, except during reconfiguration when the cursor is repositioned to force an update on newley overlapping screens and on screens that no longer overlap.

The coords (x,y) are in global coord space. We'll loop over the back-end screens and see if they contain the global coord. If so, call _dmxMoveCursor() (XWarpPointer) to position the pointer on that screen.

References _dmxMoveCursor(), _dmxRealizeCursor(), _dmxSetCursor(), _DMXScreenInfo::cursor, _DMXScreenInfo::cursorNotShared, _DMXScreenInfo::cursorVisible, dmxCursorDoMultiCursors, DMXDBG3, dmxFindCursor(), dmxOnScreen(), dmxScreens, _DMXScreenInfo::index, _DMXScreenInfo::over, _DMXScreenInfo::rootXOrigin, and _DMXScreenInfo::rootYOrigin.

static void* dmxPrintOverlap ( DMXScreenInfo dmxScreen,
void *  closure 
) [static]

Used with dmxInterateOverlap to print out a list of screens which overlap each other.

References _DMXScreenInfo::cursorNotShared, dmxLogOutputCont(), _DMXScreenInfo::index, and _DMXScreenInfo::name.

Referenced by dmxInitOverlap().

static Bool dmxRealizeCursor ( DeviceIntPtr  pDev,
ScreenPtr  pScreen,
CursorPtr  pCursor 
) [static]
static void dmxSetCursor ( DeviceIntPtr  pDev,
ScreenPtr  pScreen,
CursorPtr  pCursor,
int  x,
int  y 
) [static]
static int* dmxSLCreate ( void  ) [static]

Create a list of screens that we'll manipulate.

References dmxNumScreens.

Referenced by dmxComputeScreenOrigins().

static int dmxSLFindNext ( int *  list) [static]

Find next uninitialized entry in list.

References dmxNumScreens.

Referenced by dmxComputeScreenOrigins().

static void dmxSLFree ( int *  list) [static]

Free list.

Referenced by dmxComputeScreenOrigins().

static void* dmxTestSameDisplay ( DMXScreenInfo a,
void *  closure 
) [static]

Used with dmxPropertyIterate to determine if screen a is the same as the screen closure.

Referenced by dmxInitOverlap().

static int dmxTryComputeScreenOrigins ( int *  screensLeft) [static]
static Bool dmxUnrealizeCursor ( DeviceIntPtr  pDev,
ScreenPtr  pScreen,
CursorPtr  pCursor 
) [static]
static void dmxWarpCursor ( DeviceIntPtr  pDev,
ScreenPtr  pScreen,
int  x,
int  y 
) [static]

References DMXDBG3.


Variable Documentation

miPointerScreenFuncRec dmxPointerCursorFuncs
Initial value:

Cursor functions for mi layer.

See also:
dmxcursor.c
dmxscrinit.c

Referenced by dmxScreenInit().

miPointerSpriteFuncRec dmxPointerSpriteFuncs