- Main Page
- Data Structures
- Files

- File List
- Globals

Defines | Functions | Variables
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,
|  |  | a
| ) |  |

#define DMXDBG2 | ( |  | f,
|  |  | a,
|  |  | b
| ) |  |

Referenced by _dmxRealizeCursor(), _dmxUnrealizeCursor(), and dmxCheckCursor().

#define DMXDBG3 | ( |  | f,
|  |  | a,
|  |  | b,
|  |  | c
| ) |  |

Referenced by dmxMoveCursor(), and dmxWarpCursor().

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

Referenced by _dmxSetCursor().

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

Referenced by _dmxMoveCursor(), and dmxSetCursor().

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

Referenced by dmxInitOverlap().

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

## Function Documentation

static void _dmxMoveCursor | ( | ScreenPtr | pScreen,
|  | int | x,
|  | int | y
| ) |  | `[static]`

References _DMXScreenInfo::beDisplay, DMXDBG5, dmxScreens, dmxSync(), _DMXScreenInfo::rootX, _DMXScreenInfo::rootY, and _DMXScreenInfo::scrnWin.

Referenced by _dmxSetCursor(), and dmxMoveCursor().

static Bool _dmxRealizeCursor | ( | ScreenPtr | pScreen,
|  | CursorPtr | pCursor
| ) |  | `[static]`

References _DMXScreenInfo::beDisplay, _dmxCursorPriv::cursor, DMX_GET_CURSOR_PRIV, DMX_SET_CURSOR_PRIV, dmxBECreateCursor(), DMXDBG2, and dmxScreens.

Referenced by dmxCheckCursor(), dmxMoveCursor(), and dmxRealizeCursor().

static void _dmxSetCursor | ( | ScreenPtr | pScreen,
|  | CursorPtr | pCursor,
|  | int | x,
|  | int | y
| ) |  | `[static]`

References _dmxMoveCursor(), _DMXScreenInfo::beDisplay, _DMXScreenInfo::curCursor, _DMXScreenInfo::cursor, _dmxCursorPriv::cursor, _DMXScreenInfo::cursorVisible, DMX_GET_CURSOR_PRIV, DMXDBG4, dmxScreens, dmxSync(), _DMXScreenInfo::noCursor, and _DMXScreenInfo::scrnWin.

Referenced by dmxCheckCursor(), dmxHideCursor(), dmxMoveCursor(), and dmxSetCursor().

static Bool _dmxUnrealizeCursor | ( | ScreenPtr | pScreen,
|  | CursorPtr | pCursor
| ) |  | `[static]`

References _DMXScreenInfo::beDisplay, DMX_GET_CURSOR_PRIV, DMX_SET_CURSOR_PRIV, dmxBEFreeCursor(), DMXDBG2, and dmxScreens.

Referenced by dmxUnrealizeCursor().

void dmxBECreateCursor | ( | ScreenPtr | pScreen,
|  | CursorPtr | pCursor
| ) |  |

Create pCursor on the back-end associated with pScreen.

References _DMXScreenInfo::beDefVisualIndex, _DMXScreenInfo::beDisplay, _DMXScreenInfo::beNumPixmapFormats, _DMXScreenInfo::bePixmapFormats, _DMXScreenInfo::beVisuals, _dmxCursorPriv::cursor, DMX_GET_CURSOR_PRIV, dmxFatal, dmxLog(), dmxScreens, dmxSync(), _myPrivate::gc, _DMXScreenInfo::scrnDefDrawables, and _DMXScreenInfo::scrnWin.

Referenced by _dmxRealizeCursor(), and dmxBECreateResources().

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().

void dmxCheckCursor | ( | void |  | ) |

This routine is called during reconfiguration to make sure the cursor is visible.

References _dmxRealizeCursor(), _dmxSetCursor(), _DMXScreenInfo::cursor, DMXDBG2, dmxFindCursor(), dmxFindFirstScreen(), dmxGetGlobalPosition(), dmxNumScreens, dmxOnScreen(), dmxScreens, _DMXScreenInfo::index, _DMXScreenInfo::rootXOrigin, and _DMXScreenInfo::rootYOrigin.

Referenced by dmxAdjustCursorBoundaries(), and dmxBackendUpdatePosition().

static void dmxComputeScreenOrigins | ( | void |  | ) | `[static]`

References dmxNumScreens, dmxScreens, dmxSLCreate(), dmxSLFindNext(), dmxSLFree(), dmxTryComputeScreenOrigins(), and _DMXScreenInfo::whereRefScreen.

Referenced by dmxInitOrigins().

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]`

References dmxNumScreens, dmxScreens, _myPrivate::globalX, _myPrivate::globalY, _DMXScreenInfo::index, _DMXScreenInfo::rootHeight, _DMXScreenInfo::rootWidth, _DMXScreenInfo::rootXOrigin, and _DMXScreenInfo::rootYOrigin.

static void dmxDeviceCursorCleanup | ( | DeviceIntPtr | pDev,
|  | ScreenPtr | pScr
| ) |  | `[static]`

static Bool dmxDeviceCursorInitialize | ( | DeviceIntPtr | pDev,
|  | ScreenPtr | pScr
| ) |  | `[static]`

static int dmxDoesOverlap | ( | DMXScreenInfo * | a,
|  | DMXScreenInfo * | b
| ) |  | `[static]`

Returns non-zero if a overlaps b.

References dmxOnScreen(), _DMXScreenInfo::rootXOrigin, _DMXScreenInfo::rootYOrigin, _DMXScreenInfo::scrnHeight, and _DMXScreenInfo::scrnWidth.

Referenced by dmxInitOverlap().

static CursorPtr dmxFindCursor | ( | DMXScreenInfo * | start | ) | `[static]`

References _DMXScreenInfo::cursor, and _DMXScreenInfo::over.

Referenced by dmxCheckCursor(), and dmxMoveCursor().

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 dmxInitOrigins | ( | void |  | ) |

Initialize screen origins (and relative position). This is called for each server generation. For dynamic reconfiguration, use dmxReInitOrigins() instead.

References _DMXScreenInfo::beBPP, _DMXScreenInfo::beDepth, _DMXScreenInfo::beHeight, _DMXScreenInfo::beWidth, dmxComputeScreenOrigins(), dmxFatal, dmxLog(), dmxLogOutput(), dmxNumScreens, dmxReInitOrigins(), dmxScreens, _DMXScreenInfo::rootHeight, _DMXScreenInfo::rootWidth, _DMXScreenInfo::rootX, _DMXScreenInfo::rootXOrigin, _DMXScreenInfo::rootY, _DMXScreenInfo::rootYOrigin, _DMXScreenInfo::scrnHeight, _DMXScreenInfo::scrnWidth, _DMXScreenInfo::scrnX, _DMXScreenInfo::scrnY, _DMXScreenInfo::where, _DMXScreenInfo::whereX, and _DMXScreenInfo::whereY.

Referenced by InitOutput().

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.

int dmxOnScreen | ( | int | x,
|  | int | y,
|  | DMXScreenInfo * | dmxScreen
| ) |  |

Returns non-zero if the global x, y coordinate is on the screen window of the dmxScreen.

References dmxDebug, dmxLog(), _DMXScreenInfo::index, _DMXScreenInfo::rootHeight, _DMXScreenInfo::rootWidth, _DMXScreenInfo::rootX, _DMXScreenInfo::rootXOrigin, _DMXScreenInfo::rootY, _DMXScreenInfo::rootYOrigin, _DMXScreenInfo::scrnHeight, _DMXScreenInfo::scrnWidth, _DMXScreenInfo::scrnX, and _DMXScreenInfo::scrnY.

Referenced by dmxBackendFindOverlapping(), dmxBackendOffscreen(), dmxCheckCursor(), dmxDoesOverlap(), dmxFindFirstScreen(), dmxMoveCursor(), and dmxSetCursor().

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]`

References _dmxRealizeCursor(), _DMXScreenInfo::cursorNotShared, dmxCursorDoMultiCursors, dmxScreens, _DMXScreenInfo::index, and _DMXScreenInfo::over.

void dmxReInitOrigins | ( | void |  | ) |

Recompute origin information in the dmxScreens list. This is called from dmxInitOrigins.

References _DMXScreenInfo::beBPP, _DMXScreenInfo::beDepth, _DMXScreenInfo::beHeight, _DMXScreenInfo::beWidth, dmxFatal, dmxLog(), dmxLogOutput(), dmxNumScreens, dmxScreens, _DMXScreenInfo::rootHeight, _DMXScreenInfo::rootWidth, _DMXScreenInfo::rootX, _DMXScreenInfo::rootXOrigin, _DMXScreenInfo::rootY, _DMXScreenInfo::rootYOrigin, _DMXScreenInfo::scrnHeight, _DMXScreenInfo::scrnWidth, _DMXScreenInfo::scrnX, and _DMXScreenInfo::scrnY.

Referenced by dmxAdjustCursorBoundaries(), and dmxInitOrigins().

static void dmxSetCursor | ( | DeviceIntPtr | pDev,
|  | ScreenPtr | pScreen,
|  | CursorPtr | pCursor,
|  | int | x,
|  | int | y
| ) |  | `[static]`

References _dmxSetCursor(), _DMXScreenInfo::cursorNotShared, DMX_NO_BLOCK, dmxCoreMotion(), dmxCursorDoMultiCursors, DMXDBG5, dmxGetGlobalPosition(), dmxOnScreen(), dmxScreens, _DMXScreenInfo::index, _DMXScreenInfo::over, _DMXScreenInfo::rootXOrigin, and _DMXScreenInfo::rootYOrigin.

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]`

Make one pass over all the screens and return the number updated.

References dmxFatal, dmxLog(), dmxNumScreens, dmxScreens, PosAbove, PosAbsolute, PosBelow, PosLeftOf, PosNone, PosRelative, PosRightOf, _DMXScreenInfo::where, _DMXScreenInfo::whereRefScreen, _DMXScreenInfo::whereX, and _DMXScreenInfo::whereY.

Referenced by dmxComputeScreenOrigins().

static Bool dmxUnrealizeCursor | ( | DeviceIntPtr | pDev,
|  | ScreenPtr | pScreen,
|  | CursorPtr | pCursor
| ) |  | `[static]`

References _dmxUnrealizeCursor(), _DMXScreenInfo::cursorNotShared, dmxCursorDoMultiCursors, dmxScreens, _DMXScreenInfo::index, and _DMXScreenInfo::over.

static void dmxWarpCursor | ( | DeviceIntPtr | pDev,
|  | ScreenPtr | pScreen,
|  | int | x,
|  | int | y
| ) |  | `[static]`

References DMXDBG3.

## Variable Documentation

int dmxCursorDoMultiCursors = 1`[static]`

Referenced by dmxCursorNoMulti(), dmxMoveCursor(), dmxRealizeCursor(), dmxSetCursor(), and dmxUnrealizeCursor().

miPointerScreenFuncRec dmxPointerCursorFuncs

Initial value:

    {
        dmxCursorOffScreen,
        dmxCrossScreen,
        dmxWarpCursor,
        NULL,
        NULL,
    }

Cursor functions for mi layer.

See also:
  dmxcursor.c
  dmxscrinit.c

Referenced by dmxScreenInit().

miPointerSpriteFuncRec dmxPointerSpriteFuncs

Initial value:

    {
        dmxRealizeCursor,
        dmxUnrealizeCursor,
        dmxSetCursor,
        dmxMoveCursor,
        dmxDeviceCursorInitialize,
        dmxDeviceCursorCleanup
    }

Sprite functions for mi layer.

See also:
  dmxcursor.c
  dmxscrinit.c

Referenced by dmxScreenInit().