diff options
author | Keith Packard <keithp@keithp.com> | 2012-03-21 12:55:09 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2012-03-21 13:54:42 -0700 |
commit | 9838b7032ea9792bec21af424c53c07078636d21 (patch) | |
tree | b72d0827dac50f0f3b8eab29b3b7639546d735d7 /hw/dmx/dmxcursor.c | |
parent | 75199129c603fc8567185ac31866c9518193cb78 (diff) |
Introduce a consistent coding style
This is strictly the application of the script 'x-indent-all.sh'
from util/modular. Compared to the patch that Daniel posted in
January, I've added a few indent flags:
-bap
-psl
-T PrivatePtr
-T pmWait
-T _XFUNCPROTOBEGIN
-T _XFUNCPROTOEND
-T _X_EXPORT
The typedefs were needed to make the output of sdksyms.sh match the
previous output, otherwise, the code is formatted badly enough that
sdksyms.sh generates incorrect output.
The generated code was compared with the previous version and found to
be essentially identical -- "assert" line numbers and BUILD_TIME were
the only differences found.
The comparison was done with this script:
dir1=$1
dir2=$2
for dir in $dir1 $dir2; do
(cd $dir && find . -name '*.o' | while read file; do
dir=`dirname $file`
base=`basename $file .o`
dump=$dir/$base.dump
objdump -d $file > $dump
done)
done
find $dir1 -name '*.dump' | while read dump; do
otherdump=`echo $dump | sed "s;$dir1;$dir2;"`
diff -u $dump $otherdump
done
Signed-off-by: Keith Packard <keithp@keithp.com>
Acked-by: Daniel Stone <daniel@fooishbar.org>
Acked-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'hw/dmx/dmxcursor.c')
-rw-r--r-- | hw/dmx/dmxcursor.c | 522 |
1 files changed, 278 insertions, 244 deletions
diff --git a/hw/dmx/dmxcursor.c b/hw/dmx/dmxcursor.c index 7e0368699..1a77c7d78 100644 --- a/hw/dmx/dmxcursor.c +++ b/hw/dmx/dmxcursor.c @@ -116,38 +116,39 @@ static int dmxCursorDoMultiCursors = 1; /** Turn off support for displaying multiple cursors on overlapped back-end displays. See #dmxCursorDoMultiCursors. */ -void dmxCursorNoMulti(void) +void +dmxCursorNoMulti(void) { dmxCursorDoMultiCursors = 0; } -static Bool dmxCursorOffScreen(ScreenPtr *ppScreen, int *x, int *y) +static Bool +dmxCursorOffScreen(ScreenPtr *ppScreen, int *x, int *y) { DMXScreenInfo *dmxScreen; - int i; - int localX = *x; - int localY = *y; - int globalX; - int globalY; - + int i; + int localX = *x; + int localY = *y; + int globalX; + int globalY; + if (screenInfo.numScreens == 1) return FALSE; - /* On current screen? */ + /* On current screen? */ dmxScreen = &dmxScreens[(*ppScreen)->myNum]; if (localX >= 0 && localX < dmxScreen->rootWidth - && localY >= 0 - && localY < dmxScreen->rootHeight) + && localY >= 0 && localY < dmxScreen->rootHeight) return FALSE; - /* Convert to global coordinate space */ + /* Convert to global coordinate space */ globalX = dmxScreen->rootXOrigin + localX; globalY = dmxScreen->rootYOrigin + localY; - /* Is cursor on the current screen? - * This efficiently exits this routine - * for the most common case. */ + /* Is cursor on the current screen? + * This efficiently exits this routine + * for the most common case. */ if (ppScreen && *ppScreen) { dmxScreen = &dmxScreens[(*ppScreen)->myNum]; if (globalX >= dmxScreen->rootXOrigin @@ -157,7 +158,7 @@ static Bool dmxCursorOffScreen(ScreenPtr *ppScreen, int *x, int *y) return FALSE; } - /* Find first screen cursor is on */ + /* Find first screen cursor is on */ for (i = 0; i < dmxNumScreens; i++) { dmxScreen = &dmxScreens[i]; if (globalX >= dmxScreen->rootXOrigin @@ -167,31 +168,32 @@ static Bool dmxCursorOffScreen(ScreenPtr *ppScreen, int *x, int *y) if (dmxScreen->index == (*ppScreen)->myNum) return FALSE; *ppScreen = screenInfo.screens[dmxScreen->index]; - *x = globalX - dmxScreen->rootXOrigin; - *y = globalY - dmxScreen->rootYOrigin; + *x = globalX - dmxScreen->rootXOrigin; + *y = globalY - dmxScreen->rootYOrigin; return TRUE; } } return FALSE; } -static void dmxCrossScreen(ScreenPtr pScreen, Bool entering) +static void +dmxCrossScreen(ScreenPtr pScreen, Bool entering) { } -static void dmxWarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y) +static void +dmxWarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y) { DMXDBG3("dmxWarpCursor(%d,%d,%d)\n", pScreen->myNum, x, y); #if 11 /*BP*/ - /* This call is depracated. Replace with???? */ - miPointerWarpCursor(pDev, pScreen, x, y); + /* This call is depracated. Replace with???? */ + miPointerWarpCursor(pDev, pScreen, x, y); #else pScreen->SetCursorPosition(pDev, pScreen, x, y, FALSE); #endif } -miPointerScreenFuncRec dmxPointerCursorFuncs = -{ +miPointerScreenFuncRec dmxPointerCursorFuncs = { dmxCursorOffScreen, dmxCrossScreen, dmxWarpCursor, @@ -199,28 +201,31 @@ miPointerScreenFuncRec dmxPointerCursorFuncs = NULL, }; - /** Create a list of screens that we'll manipulate. */ -static int *dmxSLCreate(void) +static int * +dmxSLCreate(void) { int *list = malloc(dmxNumScreens * sizeof(*list)); int i; - + for (i = 0; i < dmxNumScreens; i++) list[i] = 1; return list; } /** Free list. */ -static void dmxSLFree(int *list) +static void +dmxSLFree(int *list) { free(list); } /** Find next uninitialized entry in list. */ -static int dmxSLFindNext(int *list) +static int +dmxSLFindNext(int *list) { int i; + for (i = 0; i < dmxNumScreens; i++) if (list[i]) return i; @@ -228,17 +233,18 @@ static int dmxSLFindNext(int *list) } /** Make one pass over all the screens and return the number updated. */ -static int dmxTryComputeScreenOrigins(int *screensLeft) +static int +dmxTryComputeScreenOrigins(int *screensLeft) { - ScreenPtr pScreen, refScreen; - DMXScreenInfo *screen; - int i, ref; - int changed = 0; + ScreenPtr pScreen, refScreen; + DMXScreenInfo *screen; + int i, ref; + int changed = 0; for (i = 0; i < dmxNumScreens; i++) { if (!screensLeft[i]) continue; - screen = &dmxScreens[i]; + screen = &dmxScreens[i]; pScreen = screenInfo.screens[i]; switch (screen->where) { case PosAbsolute: @@ -298,71 +304,71 @@ static int dmxTryComputeScreenOrigins(int *screensLeft) return changed; } -static void dmxComputeScreenOrigins(void) +static void +dmxComputeScreenOrigins(void) { - ScreenPtr pScreen; - int *screensLeft; - int i, ref; - int minX, minY; + ScreenPtr pScreen; + int *screensLeft; + int i, ref; + int minX, minY; - /* Compute origins based on - * configuration information. */ + /* Compute origins based on + * configuration information. */ screensLeft = dmxSLCreate(); while ((i = dmxSLFindNext(screensLeft)) >= 0) { while (dmxTryComputeScreenOrigins(screensLeft)); if ((i = dmxSLFindNext(screensLeft)) >= 0) { - /* All of the remaining screens are referencing each other. - * Assign a value to one of them and go through again. This - * guarantees that we will eventually terminate. - */ - ref = dmxScreens[i].whereRefScreen; - pScreen = screenInfo.screens[ref]; - pScreen->x = pScreen->y = 0; - screensLeft[ref] = 0; - } + /* All of the remaining screens are referencing each other. + * Assign a value to one of them and go through again. This + * guarantees that we will eventually terminate. + */ + ref = dmxScreens[i].whereRefScreen; + pScreen = screenInfo.screens[ref]; + pScreen->x = pScreen->y = 0; + screensLeft[ref] = 0; + } } dmxSLFree(screensLeft); - - /* Justify the topmost and leftmost to - * (0,0). */ + /* Justify the topmost and leftmost to + * (0,0). */ minX = screenInfo.screens[0]->x; minY = screenInfo.screens[0]->y; - for (i = 1; i < dmxNumScreens; i++) { /* Compute minX, minY */ - if (screenInfo.screens[i]->x < minX) + for (i = 1; i < dmxNumScreens; i++) { /* Compute minX, minY */ + if (screenInfo.screens[i]->x < minX) minX = screenInfo.screens[i]->x; - if (screenInfo.screens[i]->y < minY) + if (screenInfo.screens[i]->y < minY) minY = screenInfo.screens[i]->y; } if (minX || minY) { - for (i = 0; i < dmxNumScreens; i++) { - screenInfo.screens[i]->x -= minX; - screenInfo.screens[i]->y -= minY; - } + for (i = 0; i < dmxNumScreens; i++) { + screenInfo.screens[i]->x -= minX; + screenInfo.screens[i]->y -= minY; + } } } /** Recompute origin information in the #dmxScreens list. This is * called from #dmxInitOrigins. */ -void dmxReInitOrigins(void) +void +dmxReInitOrigins(void) { - int i; + int i; if (dmxNumScreens > MAXSCREENS) dmxLog(dmxFatal, "dmxNumScreens = %d > MAXSCREENS = %d\n", dmxNumScreens, MAXSCREENS); for (i = 0; i < dmxNumScreens; i++) { - DMXScreenInfo *dmxScreen = &dmxScreens[i]; + DMXScreenInfo *dmxScreen = &dmxScreens[i]; + dmxLogOutput(dmxScreen, "s=%dx%d%+d%+d r=%dx%d%+d%+d @%d,%d" " (be=%dx%d depth=%d bpp=%d)\n", dmxScreen->scrnWidth, dmxScreen->scrnHeight, dmxScreen->scrnX, dmxScreen->scrnY, - dmxScreen->rootWidth, dmxScreen->rootHeight, dmxScreen->rootX, dmxScreen->rootY, - dmxScreen->rootXOrigin, dmxScreen->rootYOrigin, dmxScreen->beWidth, dmxScreen->beHeight, dmxScreen->beDepth, dmxScreen->beBPP); @@ -372,28 +378,27 @@ void dmxReInitOrigins(void) /** Initialize screen origins (and relative position). This is called * for each server generation. For dynamic reconfiguration, use * #dmxReInitOrigins() instead. */ -void dmxInitOrigins(void) +void +dmxInitOrigins(void) { - int i; + int i; if (dmxNumScreens > MAXSCREENS) dmxLog(dmxFatal, "dmxNumScreens = %d > MAXSCREENS = %d\n", dmxNumScreens, MAXSCREENS); for (i = 0; i < dmxNumScreens; i++) { - DMXScreenInfo *dmxScreen = &dmxScreens[i]; + DMXScreenInfo *dmxScreen = &dmxScreens[i]; + dmxLogOutput(dmxScreen, "(request) s=%dx%d%+d%+d r=%dx%d%+d%+d @%d,%d (%d)" " (be=%dx%d depth=%d bpp=%d)\n", dmxScreen->scrnWidth, dmxScreen->scrnHeight, dmxScreen->scrnX, dmxScreen->scrnY, - dmxScreen->rootWidth, dmxScreen->rootHeight, dmxScreen->rootX, dmxScreen->rootY, - dmxScreen->whereX, dmxScreen->whereY, dmxScreen->where, - dmxScreen->beWidth, dmxScreen->beHeight, dmxScreen->beDepth, dmxScreen->beBPP); } @@ -401,7 +406,8 @@ void dmxInitOrigins(void) dmxComputeScreenOrigins(); for (i = 0; i < dmxNumScreens; i++) { - DMXScreenInfo *dmxScreen = &dmxScreens[i]; + DMXScreenInfo *dmxScreen = &dmxScreens[i]; + dmxScreen->rootXOrigin = screenInfo.screens[i]->x; dmxScreen->rootYOrigin = screenInfo.screens[i]->y; } @@ -411,7 +417,8 @@ void dmxInitOrigins(void) /** Returns non-zero if the global \a x, \a y coordinate is on the * screen window of the \a dmxScreen. */ -int dmxOnScreen(int x, int y, DMXScreenInfo *dmxScreen) +int +dmxOnScreen(int x, int y, DMXScreenInfo * dmxScreen) { #if DMX_CURSOR_DEBUG > 1 dmxLog(dmxDebug, @@ -426,43 +433,39 @@ int dmxOnScreen(int x, int y, DMXScreenInfo *dmxScreen) if (x >= dmxScreen->rootXOrigin && x < dmxScreen->rootXOrigin + dmxScreen->rootWidth && y >= dmxScreen->rootYOrigin - && y < dmxScreen->rootYOrigin + dmxScreen->rootHeight) return 1; + && y < dmxScreen->rootYOrigin + dmxScreen->rootHeight) + return 1; return 0; } /** Returns non-zero if \a a overlaps \a b. */ -static int dmxDoesOverlap(DMXScreenInfo *a, DMXScreenInfo *b) +static int +dmxDoesOverlap(DMXScreenInfo * a, DMXScreenInfo * b) { - if (dmxOnScreen(a->rootXOrigin, - a->rootYOrigin, b)) + if (dmxOnScreen(a->rootXOrigin, a->rootYOrigin, b)) return 1; - if (dmxOnScreen(a->rootXOrigin, - a->rootYOrigin + a->scrnWidth, b)) + if (dmxOnScreen(a->rootXOrigin, a->rootYOrigin + a->scrnWidth, b)) return 1; - if (dmxOnScreen(a->rootXOrigin + a->scrnHeight, - a->rootYOrigin, b)) + if (dmxOnScreen(a->rootXOrigin + a->scrnHeight, a->rootYOrigin, b)) return 1; if (dmxOnScreen(a->rootXOrigin + a->scrnHeight, - a->rootYOrigin + a->scrnWidth, b)) + a->rootYOrigin + a->scrnWidth, b)) return 1; - if (dmxOnScreen(b->rootXOrigin, - b->rootYOrigin, a)) + if (dmxOnScreen(b->rootXOrigin, b->rootYOrigin, a)) return 1; - if (dmxOnScreen(b->rootXOrigin, - b->rootYOrigin + b->scrnWidth, a)) + if (dmxOnScreen(b->rootXOrigin, b->rootYOrigin + b->scrnWidth, a)) return 1; - if (dmxOnScreen(b->rootXOrigin + b->scrnHeight, - b->rootYOrigin, a)) + if (dmxOnScreen(b->rootXOrigin + b->scrnHeight, b->rootYOrigin, a)) return 1; if (dmxOnScreen(b->rootXOrigin + b->scrnHeight, - b->rootYOrigin + b->scrnWidth, a)) + b->rootYOrigin + b->scrnWidth, a)) return 1; return 0; @@ -470,9 +473,11 @@ static int dmxDoesOverlap(DMXScreenInfo *a, DMXScreenInfo *b) /** Used with \a dmxInterateOverlap to print out a list of screens which * overlap each other. */ -static void *dmxPrintOverlap(DMXScreenInfo *dmxScreen, void *closure) +static void * +dmxPrintOverlap(DMXScreenInfo * dmxScreen, void *closure) { DMXScreenInfo *a = closure; + if (dmxScreen != a) { if (dmxScreen->cursorNotShared) dmxLogOutputCont(a, " [%d/%s]", dmxScreen->index, dmxScreen->name); @@ -485,25 +490,30 @@ static void *dmxPrintOverlap(DMXScreenInfo *dmxScreen, void *closure) /** Iterate over the screens which overlap with the \a start screen, * calling \a f with the \a closure for each argument. Often used with * #dmxPrintOverlap. */ -static void *dmxIterateOverlap(DMXScreenInfo *start, - void *(*f)(DMXScreenInfo *dmxScreen, void *), - void *closure) +static void * +dmxIterateOverlap(DMXScreenInfo * start, + void *(*f) (DMXScreenInfo * dmxScreen, void *), void *closure) { DMXScreenInfo *pt; - if (!start->over) return f(start, closure); + if (!start->over) + return f(start, closure); - for (pt = start->over; /* condition at end of loop */; pt = pt->over) { + for (pt = start->over; /* condition at end of loop */ ; pt = pt->over) { void *retval; - if ((retval = f(pt, closure))) return retval; - if (pt == start) break; + + if ((retval = f(pt, closure))) + return retval; + if (pt == start) + break; } return NULL; } /** Used with #dmxPropertyIterate to determine if screen \a a is the * same as the screen \a closure. */ -static void *dmxTestSameDisplay(DMXScreenInfo *a, void *closure) +static void * +dmxTestSameDisplay(DMXScreenInfo * a, void *closure) { DMXScreenInfo *b = closure; @@ -516,9 +526,10 @@ static void *dmxTestSameDisplay(DMXScreenInfo *a, void *closure) * 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 . */ -void dmxInitOverlap(void) +void +dmxInitOverlap(void) { - int i, j; + int i, j; DMXScreenInfo *a, *b, *pt; for (i = 0; i < dmxNumScreens; i++) @@ -526,12 +537,12 @@ void dmxInitOverlap(void) for (i = 0; i < dmxNumScreens; i++) { a = &dmxScreens[i]; - - for (j = i+1; j < dmxNumScreens; j++) { + + for (j = i + 1; j < dmxNumScreens; j++) { b = &dmxScreens[j]; if (b->over) continue; - + if (dmxDoesOverlap(a, b)) { DMXDBG6("%d overlaps %d: a=%p %p b=%p %p\n", a->index, b->index, a, a->over, b, b->over); @@ -543,11 +554,11 @@ void dmxInitOverlap(void) for (i = 0; i < dmxNumScreens; i++) { a = &dmxScreens[i]; - + if (!a->over) continue; - - /* Flag all pairs that are on same display */ + + /* Flag all pairs that are on same display */ for (pt = a->over; pt != a; pt = pt->over) { if (dmxPropertyIterate(a, dmxTestSameDisplay, pt)) { /* The ->over sets contain the transitive set of screens @@ -558,7 +569,7 @@ void dmxInitOverlap(void) * ->over set. */ if (!dmxDoesOverlap(a, pt)) continue; - a->cursorNotShared = 1; + a->cursorNotShared = 1; pt->cursorNotShared = 1; dmxLog(dmxInfo, "Screen %d and %d overlap on %s\n", @@ -569,7 +580,7 @@ void dmxInitOverlap(void) for (i = 0; i < dmxNumScreens; i++) { a = &dmxScreens[i]; - + if (a->over) { dmxLogOutput(a, "Overlaps"); dmxIterateOverlap(a, dmxPrintOverlap, a); @@ -579,21 +590,22 @@ void dmxInitOverlap(void) } /** Create \a pCursor on the back-end associated with \a pScreen. */ -void dmxBECreateCursor(ScreenPtr pScreen, CursorPtr pCursor) -{ - DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum]; - dmxCursorPrivPtr pCursorPriv = DMX_GET_CURSOR_PRIV(pCursor, pScreen); - CursorBitsPtr pBits = pCursor->bits; - Pixmap src, msk; - XColor fg, bg; - XImage *img; - XlibGC gc = NULL; - XGCValues v; - unsigned long m; - int i; +void +dmxBECreateCursor(ScreenPtr pScreen, CursorPtr pCursor) +{ + DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum]; + dmxCursorPrivPtr pCursorPriv = DMX_GET_CURSOR_PRIV(pCursor, pScreen); + CursorBitsPtr pBits = pCursor->bits; + Pixmap src, msk; + XColor fg, bg; + XImage *img; + XlibGC gc = NULL; + XGCValues v; + unsigned long m; + int i; if (!pCursorPriv) - return; + return; m = GCFunction | GCPlaneMask | GCForeground | GCBackground | GCClipMask; v.function = GXcopy; @@ -603,55 +615,55 @@ void dmxBECreateCursor(ScreenPtr pScreen, CursorPtr pCursor) v.clip_mask = None; for (i = 0; i < dmxScreen->beNumPixmapFormats; i++) { - if (dmxScreen->bePixmapFormats[i].depth == 1) { - /* Create GC in the back-end servers */ - gc = XCreateGC(dmxScreen->beDisplay, dmxScreen->scrnDefDrawables[i], - m, &v); - break; - } + if (dmxScreen->bePixmapFormats[i].depth == 1) { + /* Create GC in the back-end servers */ + gc = XCreateGC(dmxScreen->beDisplay, dmxScreen->scrnDefDrawables[i], + m, &v); + break; + } } if (!gc) dmxLog(dmxFatal, "dmxRealizeCursor: gc not initialized\n"); src = XCreatePixmap(dmxScreen->beDisplay, dmxScreen->scrnWin, - pBits->width, pBits->height, 1); + pBits->width, pBits->height, 1); msk = XCreatePixmap(dmxScreen->beDisplay, dmxScreen->scrnWin, - pBits->width, pBits->height, 1); + pBits->width, pBits->height, 1); img = XCreateImage(dmxScreen->beDisplay, - dmxScreen->beVisuals[dmxScreen->beDefVisualIndex].visual, - 1, XYBitmap, 0, (char *)pBits->source, - pBits->width, pBits->height, - BitmapPad(dmxScreen->beDisplay), 0); + dmxScreen->beVisuals[dmxScreen->beDefVisualIndex].visual, + 1, XYBitmap, 0, (char *) pBits->source, + pBits->width, pBits->height, + BitmapPad(dmxScreen->beDisplay), 0); XPutImage(dmxScreen->beDisplay, src, gc, img, 0, 0, 0, 0, - pBits->width, pBits->height); + pBits->width, pBits->height); XFree(img); - + img = XCreateImage(dmxScreen->beDisplay, - dmxScreen->beVisuals[dmxScreen->beDefVisualIndex].visual, - 1, XYBitmap, 0, (char *)pBits->mask, - pBits->width, pBits->height, - BitmapPad(dmxScreen->beDisplay), 0); + dmxScreen->beVisuals[dmxScreen->beDefVisualIndex].visual, + 1, XYBitmap, 0, (char *) pBits->mask, + pBits->width, pBits->height, + BitmapPad(dmxScreen->beDisplay), 0); XPutImage(dmxScreen->beDisplay, msk, gc, img, 0, 0, 0, 0, - pBits->width, pBits->height); + pBits->width, pBits->height); XFree(img); - fg.red = pCursor->foreRed; + fg.red = pCursor->foreRed; fg.green = pCursor->foreGreen; - fg.blue = pCursor->foreBlue; + fg.blue = pCursor->foreBlue; - bg.red = pCursor->backRed; + bg.red = pCursor->backRed; bg.green = pCursor->backGreen; - bg.blue = pCursor->backBlue; + bg.blue = pCursor->backBlue; pCursorPriv->cursor = XCreatePixmapCursor(dmxScreen->beDisplay, - src, msk, - &fg, &bg, - pBits->xhot, pBits->yhot); + src, msk, + &fg, &bg, + pBits->xhot, pBits->yhot); XFreePixmap(dmxScreen->beDisplay, src); XFreePixmap(dmxScreen->beDisplay, msk); @@ -660,105 +672,115 @@ void dmxBECreateCursor(ScreenPtr pScreen, CursorPtr pCursor) dmxSync(dmxScreen, FALSE); } -static Bool _dmxRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor) +static Bool +_dmxRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor) { - DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum]; - dmxCursorPrivPtr pCursorPriv; + DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum]; + dmxCursorPrivPtr pCursorPriv; DMXDBG2("_dmxRealizeCursor(%d,%p)\n", pScreen->myNum, pCursor); DMX_SET_CURSOR_PRIV(pCursor, pScreen, malloc(sizeof(*pCursorPriv))); if (!DMX_GET_CURSOR_PRIV(pCursor, pScreen)) - return FALSE; + return FALSE; pCursorPriv = DMX_GET_CURSOR_PRIV(pCursor, pScreen); - pCursorPriv->cursor = (Cursor)0; + pCursorPriv->cursor = (Cursor) 0; if (!dmxScreen->beDisplay) - return TRUE; + return TRUE; dmxBECreateCursor(pScreen, pCursor); return TRUE; } /** Free \a pCursor on the back-end associated with \a pScreen. */ -Bool dmxBEFreeCursor(ScreenPtr pScreen, CursorPtr pCursor) +Bool +dmxBEFreeCursor(ScreenPtr pScreen, CursorPtr pCursor) { - DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum]; - dmxCursorPrivPtr pCursorPriv = DMX_GET_CURSOR_PRIV(pCursor, pScreen); + DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum]; + dmxCursorPrivPtr pCursorPriv = DMX_GET_CURSOR_PRIV(pCursor, pScreen); if (pCursorPriv) { - XFreeCursor(dmxScreen->beDisplay, pCursorPriv->cursor); - pCursorPriv->cursor = (Cursor)0; - return TRUE; + XFreeCursor(dmxScreen->beDisplay, pCursorPriv->cursor); + pCursorPriv->cursor = (Cursor) 0; + return TRUE; } return FALSE; } -static Bool _dmxUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor) +static Bool +_dmxUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor) { - DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum]; + DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum]; - DMXDBG2("_dmxUnrealizeCursor(%d,%p)\n", - pScreen->myNum, pCursor); + DMXDBG2("_dmxUnrealizeCursor(%d,%p)\n", pScreen->myNum, pCursor); if (dmxScreen->beDisplay) { - if (dmxBEFreeCursor(pScreen, pCursor)) - free(DMX_GET_CURSOR_PRIV(pCursor, pScreen)); + if (dmxBEFreeCursor(pScreen, pCursor)) + free(DMX_GET_CURSOR_PRIV(pCursor, pScreen)); } DMX_SET_CURSOR_PRIV(pCursor, pScreen, NULL); return TRUE; } -static void _dmxMoveCursor(ScreenPtr pScreen, int x, int y) +static void +_dmxMoveCursor(ScreenPtr pScreen, int x, int y) { DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum]; - int newX = x + dmxScreen->rootX; - int newY = y + dmxScreen->rootY; + int newX = x + dmxScreen->rootX; + int newY = y + dmxScreen->rootY; - if (newX < 0) newX = 0; - if (newY < 0) newY = 0; + if (newX < 0) + newX = 0; + if (newY < 0) + newY = 0; DMXDBG5("_dmxMoveCursor(%d,%d,%d) -> %d,%d\n", pScreen->myNum, x, y, newX, newY); if (dmxScreen->beDisplay) { - XWarpPointer(dmxScreen->beDisplay, None, dmxScreen->scrnWin, - 0, 0, 0, 0, newX, newY); - dmxSync(dmxScreen, TRUE); + XWarpPointer(dmxScreen->beDisplay, None, dmxScreen->scrnWin, + 0, 0, 0, 0, newX, newY); + dmxSync(dmxScreen, TRUE); } } -static void _dmxSetCursor(ScreenPtr pScreen, CursorPtr pCursor, int x, int y) +static void +_dmxSetCursor(ScreenPtr pScreen, CursorPtr pCursor, int x, int y) { - DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum]; + DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum]; DMXDBG4("_dmxSetCursor(%d,%p,%d,%d)\n", pScreen->myNum, pCursor, x, y); if (pCursor) { - dmxCursorPrivPtr pCursorPriv = DMX_GET_CURSOR_PRIV(pCursor, pScreen); - if (pCursorPriv && dmxScreen->curCursor != pCursorPriv->cursor) { - if (dmxScreen->beDisplay) - XDefineCursor(dmxScreen->beDisplay, dmxScreen->scrnWin, - pCursorPriv->cursor); - dmxScreen->cursor = pCursor; - dmxScreen->curCursor = pCursorPriv->cursor; + dmxCursorPrivPtr pCursorPriv = DMX_GET_CURSOR_PRIV(pCursor, pScreen); + + if (pCursorPriv && dmxScreen->curCursor != pCursorPriv->cursor) { + if (dmxScreen->beDisplay) + XDefineCursor(dmxScreen->beDisplay, dmxScreen->scrnWin, + pCursorPriv->cursor); + dmxScreen->cursor = pCursor; + dmxScreen->curCursor = pCursorPriv->cursor; dmxScreen->cursorVisible = 1; - } - _dmxMoveCursor(pScreen, x, y); - } else { - if (dmxScreen->beDisplay) - XDefineCursor(dmxScreen->beDisplay, dmxScreen->scrnWin, - dmxScreen->noCursor); - dmxScreen->cursor = NULL; - dmxScreen->curCursor = (Cursor)0; + } + _dmxMoveCursor(pScreen, x, y); + } + else { + if (dmxScreen->beDisplay) + XDefineCursor(dmxScreen->beDisplay, dmxScreen->scrnWin, + dmxScreen->noCursor); + dmxScreen->cursor = NULL; + dmxScreen->curCursor = (Cursor) 0; dmxScreen->cursorVisible = 0; } - if (dmxScreen->beDisplay) dmxSync(dmxScreen, TRUE); + if (dmxScreen->beDisplay) + dmxSync(dmxScreen, TRUE); } -static Bool dmxRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor) +static Bool +dmxRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor) { DMXScreenInfo *start = &dmxScreens[pScreen->myNum]; DMXScreenInfo *pt; @@ -766,7 +788,7 @@ static Bool dmxRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCu if (!start->over || !dmxCursorDoMultiCursors || start->cursorNotShared) return _dmxRealizeCursor(pScreen, pCursor); - for (pt = start->over; /* condition at end of loop */; pt = pt->over) { + for (pt = start->over; /* condition at end of loop */ ; pt = pt->over) { if (pt->cursorNotShared) continue; _dmxRealizeCursor(screenInfo.screens[pt->index], pCursor); @@ -776,7 +798,8 @@ static Bool dmxRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCu return TRUE; } -static Bool dmxUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor) +static Bool +dmxUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor) { DMXScreenInfo *start = &dmxScreens[pScreen->myNum]; DMXScreenInfo *pt; @@ -784,7 +807,7 @@ static Bool dmxUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr p if (!start->over || !dmxCursorDoMultiCursors || start->cursorNotShared) return _dmxUnrealizeCursor(pScreen, pCursor); - for (pt = start->over; /* condition at end of loop */; pt = pt->over) { + for (pt = start->over; /* condition at end of loop */ ; pt = pt->over) { if (pt->cursorNotShared) continue; _dmxUnrealizeCursor(screenInfo.screens[pt->index], pCursor); @@ -794,13 +817,14 @@ static Bool dmxUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr p return TRUE; } -static CursorPtr dmxFindCursor(DMXScreenInfo *start) +static CursorPtr +dmxFindCursor(DMXScreenInfo * start) { DMXScreenInfo *pt; if (!start || !start->over) return GetSpriteCursor(inputInfo.pointer); - for (pt = start->over; /* condition at end of loop */; pt = pt->over) { + for (pt = start->over; /* condition at end of loop */ ; pt = pt->over) { if (pt->cursor) return pt->cursor; if (pt == start) @@ -818,7 +842,8 @@ static CursorPtr dmxFindCursor(DMXScreenInfo *start) * back-end screens and see if they contain the global coord. If so, call * _dmxMoveCursor() (XWarpPointer) to position the pointer on that screen. */ -void dmxMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y) +void +dmxMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y) { DMXScreenInfo *start = &dmxScreens[pScreen->myNum]; DMXScreenInfo *pt; @@ -830,21 +855,21 @@ void dmxMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y) return; } - for (pt = start->over; /* condition at end of loop */; pt = pt->over) { + for (pt = start->over; /* condition at end of loop */ ; pt = pt->over) { if (pt->cursorNotShared) continue; if (dmxOnScreen(x + start->rootXOrigin, y + start->rootYOrigin, pt)) { - if (/* pt != start && */ !pt->cursorVisible) { + if ( /* pt != start && */ !pt->cursorVisible) { if (!pt->cursor) { - /* This only happens during - * reconfiguration when a new overlap - * occurs. */ + /* This only happens during + * reconfiguration when a new overlap + * occurs. */ CursorPtr pCursor; - + if ((pCursor = dmxFindCursor(start))) _dmxRealizeCursor(screenInfo.screens[pt->index], pt->cursor = pCursor); - + } _dmxSetCursor(screenInfo.screens[pt->index], pt->cursor, @@ -854,7 +879,8 @@ void dmxMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y) _dmxMoveCursor(screenInfo.screens[pt->index], x + start->rootXOrigin - pt->rootXOrigin, y + start->rootYOrigin - pt->rootYOrigin); - } else if (/* pt != start && */ pt->cursorVisible) { + } + else if ( /* pt != start && */ pt->cursorVisible) { _dmxSetCursor(screenInfo.screens[pt->index], NULL, x + start->rootXOrigin - pt->rootXOrigin, @@ -865,49 +891,52 @@ void dmxMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y) } } -static void dmxSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, int x, int y) +static void +dmxSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, int x, + int y) { DMXScreenInfo *start = &dmxScreens[pScreen->myNum]; DMXScreenInfo *pt; - int GX, GY, gx, gy; + int GX, GY, gx, gy; DMXDBG5("dmxSetCursor(%d %p, %p,%d,%d)\n", pScreen->myNum, start, pCursor, x, y); - /* We do this check here because of two cases: - * - * 1) if a client calls XWarpPointer() - * and Xinerama is not running, we can - * have mi's notion of the pointer - * position out of phase with DMX's - * notion. - * - * 2) if a down button is held while the - * cursor moves outside the root window, - * mi's notion of the pointer position - * is out of phase with DMX's notion and - * the cursor can remain visible when it - * shouldn't be. */ + /* We do this check here because of two cases: + * + * 1) if a client calls XWarpPointer() + * and Xinerama is not running, we can + * have mi's notion of the pointer + * position out of phase with DMX's + * notion. + * + * 2) if a down button is held while the + * cursor moves outside the root window, + * mi's notion of the pointer position + * is out of phase with DMX's notion and + * the cursor can remain visible when it + * shouldn't be. */ dmxGetGlobalPosition(&GX, &GY); gx = start->rootXOrigin + x; gy = start->rootYOrigin + y; if (x && y && (GX != gx || GY != gy)) dmxCoreMotion(NULL, gx, gy, 0, DMX_NO_BLOCK); - + if (!start->over || !dmxCursorDoMultiCursors || start->cursorNotShared) { _dmxSetCursor(pScreen, pCursor, x, y); return; } - for (pt = start->over; /* condition at end of loop */; pt = pt->over) { + for (pt = start->over; /* condition at end of loop */ ; pt = pt->over) { if (pt->cursorNotShared) continue; if (dmxOnScreen(x + start->rootXOrigin, y + start->rootYOrigin, pt)) { _dmxSetCursor(screenInfo.screens[pt->index], pCursor, x + start->rootXOrigin - pt->rootXOrigin, y + start->rootYOrigin - pt->rootYOrigin); - } else { + } + else { _dmxSetCursor(screenInfo.screens[pt->index], NULL, x + start->rootXOrigin - pt->rootXOrigin, y + start->rootYOrigin - pt->rootYOrigin); @@ -917,13 +946,13 @@ static void dmxSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor } } - /** This routine is used by the backend input routines to hide the * cursor on a screen that is being used for relative input. \see * dmxbackend.c */ -void dmxHideCursor(DMXScreenInfo *dmxScreen) +void +dmxHideCursor(DMXScreenInfo * dmxScreen) { - int x, y; + int x, y; ScreenPtr pScreen = screenInfo.screens[dmxScreen->index]; dmxGetGlobalPosition(&x, &y); @@ -932,11 +961,12 @@ void dmxHideCursor(DMXScreenInfo *dmxScreen) /** This routine is called during reconfiguration to make sure the * cursor is visible. */ -void dmxCheckCursor(void) +void +dmxCheckCursor(void) { - int i; - int x, y; - ScreenPtr pScreen; + int i; + int x, y; + ScreenPtr pScreen; DMXScreenInfo *firstScreen; dmxGetGlobalPosition(&x, &y); @@ -945,18 +975,21 @@ void dmxCheckCursor(void) DMXDBG2("dmxCheckCursor %d %d\n", x, y); for (i = 0; i < dmxNumScreens; i++) { DMXScreenInfo *dmxScreen = &dmxScreens[i]; - pScreen = screenInfo.screens[dmxScreen->index]; + + pScreen = screenInfo.screens[dmxScreen->index]; if (!dmxOnScreen(x, y, dmxScreen)) { - if (firstScreen && i == miPointerGetScreen(inputInfo.pointer)->myNum) - miPointerSetScreen(inputInfo.pointer, firstScreen->index, x, y); - _dmxSetCursor(pScreen, NULL, - x - dmxScreen->rootXOrigin, + if (firstScreen && + i == miPointerGetScreen(inputInfo.pointer)->myNum) + miPointerSetScreen(inputInfo.pointer, firstScreen->index, x, + y); + _dmxSetCursor(pScreen, NULL, x - dmxScreen->rootXOrigin, y - dmxScreen->rootYOrigin); - } else { + } + else { if (!dmxScreen->cursor) { CursorPtr pCursor; - + if ((pCursor = dmxFindCursor(dmxScreen))) { _dmxRealizeCursor(pScreen, dmxScreen->cursor = pCursor); } @@ -969,17 +1002,18 @@ void dmxCheckCursor(void) DMXDBG2(" leave dmxCheckCursor %d %d\n", x, y); } -static Bool dmxDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScr) +static Bool +dmxDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScr) { return TRUE; } -static void dmxDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScr) +static void +dmxDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScr) { } -miPointerSpriteFuncRec dmxPointerSpriteFuncs = -{ +miPointerSpriteFuncRec dmxPointerSpriteFuncs = { dmxRealizeCursor, dmxUnrealizeCursor, dmxSetCursor, |