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/xnest | |
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/xnest')
35 files changed, 2429 insertions, 2436 deletions
diff --git a/hw/xnest/Args.c b/hw/xnest/Args.c index cdc831133..21faf2e3a 100644 --- a/hw/xnest/Args.c +++ b/hw/xnest/Args.c @@ -29,162 +29,164 @@ is" without express or implied warranty. #include "Display.h" #include "Args.h" -char *xnestDisplayName = NULL; +char *xnestDisplayName = NULL; Bool xnestSynchronize = False; Bool xnestFullGeneration = False; -int xnestDefaultClass; +int xnestDefaultClass; Bool xnestUserDefaultClass = False; int xnestDefaultDepth; Bool xnestUserDefaultDepth = False; Bool xnestSoftwareScreenSaver = False; -int xnestX; -int xnestY; +int xnestX; +int xnestY; unsigned int xnestWidth; unsigned int xnestHeight; int xnestUserGeometry = 0; -int xnestBorderWidth; +int xnestBorderWidth; Bool xnestUserBorderWidth = False; -char *xnestWindowName = NULL; +char *xnestWindowName = NULL; int xnestNumScreens = 0; Bool xnestDoDirectColormaps = False; Window xnestParentWindow = 0; int -ddxProcessArgument (int argc, char *argv[], int i) +ddxProcessArgument(int argc, char *argv[], int i) { - if (!strcmp(argv[i], "-display")) { - if (++i < argc) { - xnestDisplayName = argv[i]; - return 2; + if (!strcmp(argv[i], "-display")) { + if (++i < argc) { + xnestDisplayName = argv[i]; + return 2; + } + return 0; } - return 0; - } - if (!strcmp(argv[i], "-sync")) { - xnestSynchronize = True; - return 1; - } - if (!strcmp(argv[i], "-full")) { - xnestFullGeneration = True; - return 1; - } - if (!strcmp(argv[i], "-class")) { - if (++i < argc) { - if (!strcmp(argv[i], "StaticGray")) { - xnestDefaultClass = StaticGray; - xnestUserDefaultClass = True; - return 2; - } - else if (!strcmp(argv[i], "GrayScale")) { - xnestDefaultClass = GrayScale; - xnestUserDefaultClass = True; - return 2; - } - else if (!strcmp(argv[i], "StaticColor")) { - xnestDefaultClass = StaticColor; - xnestUserDefaultClass = True; - return 2; - } - else if (!strcmp(argv[i], "PseudoColor")) { - xnestDefaultClass = PseudoColor; - xnestUserDefaultClass = True; - return 2; - } - else if (!strcmp(argv[i], "TrueColor")) { - xnestDefaultClass = TrueColor; - xnestUserDefaultClass = True; - return 2; - } - else if (!strcmp(argv[i], "DirectColor")) { - xnestDefaultClass = DirectColor; - xnestUserDefaultClass = True; - return 2; - } + if (!strcmp(argv[i], "-sync")) { + xnestSynchronize = True; + return 1; } - return 0; - } - if (!strcmp(argv[i], "-cc")) { - if (++i < argc && sscanf(argv[i], "%i", &xnestDefaultClass) == 1) { - if (xnestDefaultClass >= 0 && xnestDefaultClass <= 5) { - xnestUserDefaultClass = True; - /* lex the OS layer process it as well, so return 0 */ - } + if (!strcmp(argv[i], "-full")) { + xnestFullGeneration = True; + return 1; } - return 0; - } - if (!strcmp(argv[i], "-depth")) { - if (++i < argc && sscanf(argv[i], "%i", &xnestDefaultDepth) == 1) { - if (xnestDefaultDepth > 0) { - xnestUserDefaultDepth = True; - return 2; - } + if (!strcmp(argv[i], "-class")) { + if (++i < argc) { + if (!strcmp(argv[i], "StaticGray")) { + xnestDefaultClass = StaticGray; + xnestUserDefaultClass = True; + return 2; + } + else if (!strcmp(argv[i], "GrayScale")) { + xnestDefaultClass = GrayScale; + xnestUserDefaultClass = True; + return 2; + } + else if (!strcmp(argv[i], "StaticColor")) { + xnestDefaultClass = StaticColor; + xnestUserDefaultClass = True; + return 2; + } + else if (!strcmp(argv[i], "PseudoColor")) { + xnestDefaultClass = PseudoColor; + xnestUserDefaultClass = True; + return 2; + } + else if (!strcmp(argv[i], "TrueColor")) { + xnestDefaultClass = TrueColor; + xnestUserDefaultClass = True; + return 2; + } + else if (!strcmp(argv[i], "DirectColor")) { + xnestDefaultClass = DirectColor; + xnestUserDefaultClass = True; + return 2; + } + } + return 0; } - return 0; - } - if (!strcmp(argv[i], "-sss")) { - xnestSoftwareScreenSaver = True; - return 1; - } - if (!strcmp(argv[i], "-geometry")) { - if (++i < argc) { - xnestUserGeometry = XParseGeometry(argv[i], - &xnestX, &xnestY, - &xnestWidth, &xnestHeight); - if (xnestUserGeometry) return 2; + if (!strcmp(argv[i], "-cc")) { + if (++i < argc && sscanf(argv[i], "%i", &xnestDefaultClass) == 1) { + if (xnestDefaultClass >= 0 && xnestDefaultClass <= 5) { + xnestUserDefaultClass = True; + /* lex the OS layer process it as well, so return 0 */ + } + } + return 0; } - return 0; - } - if (!strcmp(argv[i], "-bw")) { - if (++i < argc && sscanf(argv[i], "%i", &xnestBorderWidth) == 1) { - if (xnestBorderWidth >= 0) { - xnestUserBorderWidth = True; - return 2; - } + if (!strcmp(argv[i], "-depth")) { + if (++i < argc && sscanf(argv[i], "%i", &xnestDefaultDepth) == 1) { + if (xnestDefaultDepth > 0) { + xnestUserDefaultDepth = True; + return 2; + } + } + return 0; } - return 0; - } - if (!strcmp(argv[i], "-name")) { - if (++i < argc) { - xnestWindowName = argv[i]; - return 2; + if (!strcmp(argv[i], "-sss")) { + xnestSoftwareScreenSaver = True; + return 1; } - return 0; - } - if (!strcmp(argv[i], "-scrns")) { - if (++i < argc && sscanf(argv[i], "%i", &xnestNumScreens) == 1) { - if (xnestNumScreens > 0) { - if (xnestNumScreens > MAXSCREENS) { - ErrorF("Maximum number of screens is %d.\n", MAXSCREENS); - xnestNumScreens = MAXSCREENS; - } - return 2; - } + if (!strcmp(argv[i], "-geometry")) { + if (++i < argc) { + xnestUserGeometry = XParseGeometry(argv[i], + &xnestX, &xnestY, + &xnestWidth, &xnestHeight); + if (xnestUserGeometry) + return 2; + } + return 0; } - return 0; - } - if (!strcmp(argv[i], "-install")) { - xnestDoDirectColormaps = True; - return 1; - } - if (!strcmp(argv[i], "-parent")) { - if (++i < argc) { - xnestParentWindow = (XID) strtol (argv[i], (char**)NULL, 0); - return 2; + if (!strcmp(argv[i], "-bw")) { + if (++i < argc && sscanf(argv[i], "%i", &xnestBorderWidth) == 1) { + if (xnestBorderWidth >= 0) { + xnestUserBorderWidth = True; + return 2; + } + } + return 0; + } + if (!strcmp(argv[i], "-name")) { + if (++i < argc) { + xnestWindowName = argv[i]; + return 2; + } + return 0; + } + if (!strcmp(argv[i], "-scrns")) { + if (++i < argc && sscanf(argv[i], "%i", &xnestNumScreens) == 1) { + if (xnestNumScreens > 0) { + if (xnestNumScreens > MAXSCREENS) { + ErrorF("Maximum number of screens is %d.\n", MAXSCREENS); + xnestNumScreens = MAXSCREENS; + } + return 2; + } + } + return 0; } - } - return 0; + if (!strcmp(argv[i], "-install")) { + xnestDoDirectColormaps = True; + return 1; + } + if (!strcmp(argv[i], "-parent")) { + if (++i < argc) { + xnestParentWindow = (XID) strtol(argv[i], (char **) NULL, 0); + return 2; + } + } + return 0; } -void ddxUseMsg(void) +void +ddxUseMsg(void) { - ErrorF("-display string display name of the real server\n"); - ErrorF("-sync sinchronize with the real server\n"); - ErrorF("-full utilize full regeneration\n"); - ErrorF("-class string default visual class\n"); - ErrorF("-depth int default depth\n"); - ErrorF("-sss use software screen saver\n"); - ErrorF("-geometry WxH+X+Y window size and position\n"); - ErrorF("-bw int window border width\n"); - ErrorF("-name string window name\n"); - ErrorF("-scrns int number of screens to generate\n"); - ErrorF("-install instal colormaps directly\n"); + ErrorF("-display string display name of the real server\n"); + ErrorF("-sync sinchronize with the real server\n"); + ErrorF("-full utilize full regeneration\n"); + ErrorF("-class string default visual class\n"); + ErrorF("-depth int default depth\n"); + ErrorF("-sss use software screen saver\n"); + ErrorF("-geometry WxH+X+Y window size and position\n"); + ErrorF("-bw int window border width\n"); + ErrorF("-name string window name\n"); + ErrorF("-scrns int number of screens to generate\n"); + ErrorF("-install instal colormaps directly\n"); } diff --git a/hw/xnest/Args.h b/hw/xnest/Args.h index c3002bfca..514a39513 100644 --- a/hw/xnest/Args.h +++ b/hw/xnest/Args.h @@ -15,24 +15,24 @@ is" without express or implied warranty. #ifndef XNESTARGC_H #define XNESTARGS_H -extern char *xnestDisplayName; +extern char *xnestDisplayName; extern Bool xnestSynchronize; extern Bool xnestFullGeneration; -extern int xnestDefaultClass; +extern int xnestDefaultClass; extern Bool xnestUserDefaultClass; -extern int xnestDefaultDepth; +extern int xnestDefaultDepth; extern Bool xnestUserDefaultDepth; extern Bool xnestSoftwareScreenSaver; -extern int xnestX; -extern int xnestY; -extern unsigned int xnestWidth; -extern unsigned int xnestHeight; +extern int xnestX; +extern int xnestY; +extern unsigned int xnestWidth; +extern unsigned int xnestHeight; extern int xnestUserGeometry; -extern int xnestBorderWidth; +extern int xnestBorderWidth; extern Bool xnestUserBorderWidth; -extern char *xnestWindowName; +extern char *xnestWindowName; extern int xnestNumScreens; extern Bool xnestDoDirectColormaps; extern Window xnestParentWindow; -#endif /* XNESTARGS_H */ +#endif /* XNESTARGS_H */ diff --git a/hw/xnest/Color.c b/hw/xnest/Color.c index 0aae8e9c9..7ef137d59 100644 --- a/hw/xnest/Color.c +++ b/hw/xnest/Color.c @@ -26,7 +26,6 @@ is" without express or implied warranty. #include "Xnest.h" - #include "Display.h" #include "Screen.h" #include "Color.h" @@ -37,6 +36,7 @@ is" without express or implied warranty. DevPrivateKeyRec xnestColormapPrivateKeyRec; static DevPrivateKeyRec cmapScrPrivateKeyRec; + #define cmapScrPrivateKey (&cmapScrPrivateKeyRec) #define GetInstalledColormap(s) ((ColormapPtr) dixLookupPrivate(&(s)->devPrivates, cmapScrPrivateKey)) @@ -45,91 +45,92 @@ static DevPrivateKeyRec cmapScrPrivateKeyRec; Bool xnestCreateColormap(ColormapPtr pCmap) { - VisualPtr pVisual; - XColor *colors; - int i, ncolors; - Pixel red, green, blue; - Pixel redInc, greenInc, blueInc; - - pVisual = pCmap->pVisual; - ncolors = pVisual->ColormapEntries; - - xnestColormapPriv(pCmap)->colormap = - XCreateColormap(xnestDisplay, - xnestDefaultWindows[pCmap->pScreen->myNum], - xnestVisual(pVisual), - (pVisual->class & DynamicClass) ? - AllocAll : AllocNone); - - - switch (pVisual->class) { - case StaticGray: /* read only */ - colors = (XColor *)malloc(ncolors * sizeof(XColor)); - for (i = 0; i < ncolors; i++) - colors[i].pixel = i; - XQueryColors(xnestDisplay, xnestColormap(pCmap), colors, ncolors); - for (i = 0; i < ncolors; i++) { - pCmap->red[i].co.local.red = colors[i].red; - pCmap->red[i].co.local.green = colors[i].red; - pCmap->red[i].co.local.blue = colors[i].red; - } - free(colors); - break; - - case StaticColor: /* read only */ - colors = (XColor *)malloc(ncolors * sizeof(XColor)); - for (i = 0; i < ncolors; i++) - colors[i].pixel = i; - XQueryColors(xnestDisplay, xnestColormap(pCmap), colors, ncolors); - for (i = 0; i < ncolors; i++) { - pCmap->red[i].co.local.red = colors[i].red; - pCmap->red[i].co.local.green = colors[i].green; - pCmap->red[i].co.local.blue = colors[i].blue; - } - free(colors); - break; - - case TrueColor: /* read only */ - colors = (XColor *)malloc(ncolors * sizeof(XColor)); - red = green = blue = 0L; - redInc = lowbit(pVisual->redMask); - greenInc = lowbit(pVisual->greenMask); - blueInc = lowbit(pVisual->blueMask); - for (i = 0; i < ncolors; i++) { - colors[i].pixel = red | green | blue; - red += redInc; - if (red > pVisual->redMask) red = 0L; - green += greenInc; - if (green > pVisual->greenMask) green = 0L; - blue += blueInc; - if (blue > pVisual->blueMask) blue = 0L; - } - XQueryColors(xnestDisplay, xnestColormap(pCmap), colors, ncolors); - for (i = 0; i < ncolors; i++) { - pCmap->red[i].co.local.red = colors[i].red; - pCmap->green[i].co.local.green = colors[i].green; - pCmap->blue[i].co.local.blue = colors[i].blue; + VisualPtr pVisual; + XColor *colors; + int i, ncolors; + Pixel red, green, blue; + Pixel redInc, greenInc, blueInc; + + pVisual = pCmap->pVisual; + ncolors = pVisual->ColormapEntries; + + xnestColormapPriv(pCmap)->colormap = + XCreateColormap(xnestDisplay, + xnestDefaultWindows[pCmap->pScreen->myNum], + xnestVisual(pVisual), + (pVisual->class & DynamicClass) ? AllocAll : AllocNone); + + switch (pVisual->class) { + case StaticGray: /* read only */ + colors = (XColor *) malloc(ncolors * sizeof(XColor)); + for (i = 0; i < ncolors; i++) + colors[i].pixel = i; + XQueryColors(xnestDisplay, xnestColormap(pCmap), colors, ncolors); + for (i = 0; i < ncolors; i++) { + pCmap->red[i].co.local.red = colors[i].red; + pCmap->red[i].co.local.green = colors[i].red; + pCmap->red[i].co.local.blue = colors[i].red; + } + free(colors); + break; + + case StaticColor: /* read only */ + colors = (XColor *) malloc(ncolors * sizeof(XColor)); + for (i = 0; i < ncolors; i++) + colors[i].pixel = i; + XQueryColors(xnestDisplay, xnestColormap(pCmap), colors, ncolors); + for (i = 0; i < ncolors; i++) { + pCmap->red[i].co.local.red = colors[i].red; + pCmap->red[i].co.local.green = colors[i].green; + pCmap->red[i].co.local.blue = colors[i].blue; + } + free(colors); + break; + + case TrueColor: /* read only */ + colors = (XColor *) malloc(ncolors * sizeof(XColor)); + red = green = blue = 0L; + redInc = lowbit(pVisual->redMask); + greenInc = lowbit(pVisual->greenMask); + blueInc = lowbit(pVisual->blueMask); + for (i = 0; i < ncolors; i++) { + colors[i].pixel = red | green | blue; + red += redInc; + if (red > pVisual->redMask) + red = 0L; + green += greenInc; + if (green > pVisual->greenMask) + green = 0L; + blue += blueInc; + if (blue > pVisual->blueMask) + blue = 0L; + } + XQueryColors(xnestDisplay, xnestColormap(pCmap), colors, ncolors); + for (i = 0; i < ncolors; i++) { + pCmap->red[i].co.local.red = colors[i].red; + pCmap->green[i].co.local.green = colors[i].green; + pCmap->blue[i].co.local.blue = colors[i].blue; + } + free(colors); + break; + + case GrayScale: /* read and write */ + break; + + case PseudoColor: /* read and write */ + break; + + case DirectColor: /* read and write */ + break; } - free(colors); - break; - - case GrayScale: /* read and write */ - break; - - case PseudoColor: /* read and write */ - break; - - case DirectColor: /* read and write */ - break; - } - - return True; + + return True; } void xnestDestroyColormap(ColormapPtr pCmap) { - XFreeColormap(xnestDisplay, xnestColormap(pCmap)); + XFreeColormap(xnestDisplay, xnestColormap(pCmap)); } #define SEARCH_PREDICATE \ @@ -138,31 +139,31 @@ xnestDestroyColormap(ColormapPtr pCmap) static int xnestCountInstalledColormapWindows(WindowPtr pWin, pointer ptr) { - xnestInstalledColormapWindows *icws = (xnestInstalledColormapWindows *)ptr; - int i; - - for (i = 0; i < icws->numCmapIDs; i++) - if (SEARCH_PREDICATE) { - icws->numWindows++; - return WT_DONTWALKCHILDREN; - } - - return WT_WALKCHILDREN; + xnestInstalledColormapWindows *icws = (xnestInstalledColormapWindows *) ptr; + int i; + + for (i = 0; i < icws->numCmapIDs; i++) + if (SEARCH_PREDICATE) { + icws->numWindows++; + return WT_DONTWALKCHILDREN; + } + + return WT_WALKCHILDREN; } static int xnestGetInstalledColormapWindows(WindowPtr pWin, pointer ptr) { - xnestInstalledColormapWindows *icws = (xnestInstalledColormapWindows *)ptr; - int i; - - for (i = 0; i < icws->numCmapIDs; i++) - if (SEARCH_PREDICATE) { - icws->windows[icws->index++] = xnestWindow(pWin); - return WT_DONTWALKCHILDREN; - } - - return WT_WALKCHILDREN; + xnestInstalledColormapWindows *icws = (xnestInstalledColormapWindows *) ptr; + int i; + + for (i = 0; i < icws->numCmapIDs; i++) + if (SEARCH_PREDICATE) { + icws->windows[icws->index++] = xnestWindow(pWin); + return WT_DONTWALKCHILDREN; + } + + return WT_WALKCHILDREN; } static Window *xnestOldInstalledColormapWindows = NULL; @@ -171,200 +172,203 @@ static int xnestNumOldInstalledColormapWindows = 0; static Bool xnestSameInstalledColormapWindows(Window *windows, int numWindows) { - if (xnestNumOldInstalledColormapWindows != numWindows) - return False; + if (xnestNumOldInstalledColormapWindows != numWindows) + return False; - if (xnestOldInstalledColormapWindows == windows) - return True; + if (xnestOldInstalledColormapWindows == windows) + return True; - if (xnestOldInstalledColormapWindows == NULL || windows == NULL) - return False; + if (xnestOldInstalledColormapWindows == NULL || windows == NULL) + return False; - if (memcmp(xnestOldInstalledColormapWindows, windows, - numWindows * sizeof(Window))) - return False; + if (memcmp(xnestOldInstalledColormapWindows, windows, + numWindows * sizeof(Window))) + return False; - return True; + return True; } void xnestSetInstalledColormapWindows(ScreenPtr pScreen) { - xnestInstalledColormapWindows icws; - int numWindows; - - icws.cmapIDs = (Colormap *)malloc(pScreen->maxInstalledCmaps * - sizeof(Colormap)); - icws.numCmapIDs = xnestListInstalledColormaps(pScreen, icws.cmapIDs); - icws.numWindows = 0; - WalkTree(pScreen, xnestCountInstalledColormapWindows, (pointer)&icws); - if (icws.numWindows) { - icws.windows = (Window *)malloc((icws.numWindows + 1) * sizeof(Window)); - icws.index = 0; - WalkTree(pScreen, xnestGetInstalledColormapWindows, (pointer)&icws); - icws.windows[icws.numWindows] = xnestDefaultWindows[pScreen->myNum]; - numWindows = icws.numWindows + 1; - } - else { - icws.windows = NULL; - numWindows = 0; - } - - free(icws.cmapIDs); - - if (!xnestSameInstalledColormapWindows(icws.windows, icws.numWindows)) { - free(xnestOldInstalledColormapWindows); + xnestInstalledColormapWindows icws; + int numWindows; + + icws.cmapIDs = (Colormap *) malloc(pScreen->maxInstalledCmaps * + sizeof(Colormap)); + icws.numCmapIDs = xnestListInstalledColormaps(pScreen, icws.cmapIDs); + icws.numWindows = 0; + WalkTree(pScreen, xnestCountInstalledColormapWindows, (pointer) &icws); + if (icws.numWindows) { + icws.windows = + (Window *) malloc((icws.numWindows + 1) * sizeof(Window)); + icws.index = 0; + WalkTree(pScreen, xnestGetInstalledColormapWindows, (pointer) &icws); + icws.windows[icws.numWindows] = xnestDefaultWindows[pScreen->myNum]; + numWindows = icws.numWindows + 1; + } + else { + icws.windows = NULL; + numWindows = 0; + } + + free(icws.cmapIDs); + + if (!xnestSameInstalledColormapWindows(icws.windows, icws.numWindows)) { + free(xnestOldInstalledColormapWindows); #ifdef _XSERVER64 - { - int i; - Window64 *windows = (Window64 *)malloc(numWindows * sizeof(Window64)); - - for(i = 0; i < numWindows; ++i) - windows[i] = icws.windows[i]; - XSetWMColormapWindows(xnestDisplay, xnestDefaultWindows[pScreen->myNum], - windows, numWindows); - free(windows); - } + { + int i; + Window64 *windows = + (Window64 *) malloc(numWindows * sizeof(Window64)); + + for (i = 0; i < numWindows; ++i) + windows[i] = icws.windows[i]; + XSetWMColormapWindows(xnestDisplay, + xnestDefaultWindows[pScreen->myNum], windows, + numWindows); + free(windows); + } #else - XSetWMColormapWindows(xnestDisplay, xnestDefaultWindows[pScreen->myNum], - icws.windows, numWindows); + XSetWMColormapWindows(xnestDisplay, xnestDefaultWindows[pScreen->myNum], + icws.windows, numWindows); #endif - xnestOldInstalledColormapWindows = icws.windows; - xnestNumOldInstalledColormapWindows = icws.numWindows; + xnestOldInstalledColormapWindows = icws.windows; + xnestNumOldInstalledColormapWindows = icws.numWindows; #ifdef DUMB_WINDOW_MANAGERS - /* - This code is for dumb window managers. - This will only work with default local visual colormaps. - */ - if (icws.numWindows) - { - WindowPtr pWin; - Visual *visual; - ColormapPtr pCmap; - - pWin = xnestWindowPtr(icws.windows[0]); - visual = xnestVisualFromID(pScreen, wVisual(pWin)); - - if (visual == xnestDefaultVisual(pScreen)) - dixLookupResourceByType((pointer *)&pCmap, wColormap(pWin), - RT_COLORMAP, serverClient, DixUseAccess); - else - dixLookupResourceByType((pointer *)&pCmap, pScreen->defColormap, - RT_COLORMAP, serverClient, DixUseAccess); - - XSetWindowColormap(xnestDisplay, - xnestDefaultWindows[pScreen->myNum], - xnestColormap(pCmap)); - } -#endif /* DUMB_WINDOW_MANAGERS */ - } - else - free(icws.windows); + /* + This code is for dumb window managers. + This will only work with default local visual colormaps. + */ + if (icws.numWindows) { + WindowPtr pWin; + Visual *visual; + ColormapPtr pCmap; + + pWin = xnestWindowPtr(icws.windows[0]); + visual = xnestVisualFromID(pScreen, wVisual(pWin)); + + if (visual == xnestDefaultVisual(pScreen)) + dixLookupResourceByType((pointer *) &pCmap, wColormap(pWin), + RT_COLORMAP, serverClient, + DixUseAccess); + else + dixLookupResourceByType((pointer *) &pCmap, + pScreen->defColormap, RT_COLORMAP, + serverClient, DixUseAccess); + + XSetWindowColormap(xnestDisplay, + xnestDefaultWindows[pScreen->myNum], + xnestColormap(pCmap)); + } +#endif /* DUMB_WINDOW_MANAGERS */ + } + else + free(icws.windows); } void xnestSetScreenSaverColormapWindow(ScreenPtr pScreen) { - free(xnestOldInstalledColormapWindows); - + free(xnestOldInstalledColormapWindows); + #ifdef _XSERVER64 - { - Window64 window; + { + Window64 window; - window = xnestScreenSaverWindows[pScreen->myNum]; - XSetWMColormapWindows(xnestDisplay, xnestDefaultWindows[pScreen->myNum], - &window, 1); - xnestScreenSaverWindows[pScreen->myNum] = window; - } + window = xnestScreenSaverWindows[pScreen->myNum]; + XSetWMColormapWindows(xnestDisplay, xnestDefaultWindows[pScreen->myNum], + &window, 1); + xnestScreenSaverWindows[pScreen->myNum] = window; + } #else - XSetWMColormapWindows(xnestDisplay, xnestDefaultWindows[pScreen->myNum], - &xnestScreenSaverWindows[pScreen->myNum], 1); -#endif /* _XSERVER64 */ - - xnestOldInstalledColormapWindows = NULL; - xnestNumOldInstalledColormapWindows = 0; - - xnestDirectUninstallColormaps(pScreen); + XSetWMColormapWindows(xnestDisplay, xnestDefaultWindows[pScreen->myNum], + &xnestScreenSaverWindows[pScreen->myNum], 1); +#endif /* _XSERVER64 */ + + xnestOldInstalledColormapWindows = NULL; + xnestNumOldInstalledColormapWindows = 0; + + xnestDirectUninstallColormaps(pScreen); } void xnestDirectInstallColormaps(ScreenPtr pScreen) { - int i, n; - Colormap pCmapIDs[MAXCMAPS]; - - if (!xnestDoDirectColormaps) return; + int i, n; + Colormap pCmapIDs[MAXCMAPS]; - n = (*pScreen->ListInstalledColormaps)(pScreen, pCmapIDs); + if (!xnestDoDirectColormaps) + return; - for (i = 0; i < n; i++) { - ColormapPtr pCmap; - - dixLookupResourceByType((pointer *)&pCmap, pCmapIDs[i], RT_COLORMAP, - serverClient, DixInstallAccess); - if (pCmap) - XInstallColormap(xnestDisplay, xnestColormap(pCmap)); - } + n = (*pScreen->ListInstalledColormaps) (pScreen, pCmapIDs); + + for (i = 0; i < n; i++) { + ColormapPtr pCmap; + + dixLookupResourceByType((pointer *) &pCmap, pCmapIDs[i], RT_COLORMAP, + serverClient, DixInstallAccess); + if (pCmap) + XInstallColormap(xnestDisplay, xnestColormap(pCmap)); + } } void xnestDirectUninstallColormaps(ScreenPtr pScreen) { - int i, n; - Colormap pCmapIDs[MAXCMAPS]; + int i, n; + Colormap pCmapIDs[MAXCMAPS]; - if (!xnestDoDirectColormaps) return; + if (!xnestDoDirectColormaps) + return; - n = (*pScreen->ListInstalledColormaps)(pScreen, pCmapIDs); + n = (*pScreen->ListInstalledColormaps) (pScreen, pCmapIDs); - for (i = 0; i < n; i++) { - ColormapPtr pCmap; - - dixLookupResourceByType((pointer *)&pCmap, pCmapIDs[i], RT_COLORMAP, - serverClient, DixUninstallAccess); - if (pCmap) - XUninstallColormap(xnestDisplay, xnestColormap(pCmap)); - } + for (i = 0; i < n; i++) { + ColormapPtr pCmap; + + dixLookupResourceByType((pointer *) &pCmap, pCmapIDs[i], RT_COLORMAP, + serverClient, DixUninstallAccess); + if (pCmap) + XUninstallColormap(xnestDisplay, xnestColormap(pCmap)); + } } void xnestInstallColormap(ColormapPtr pCmap) { - ColormapPtr pOldCmap = GetInstalledColormap(pCmap->pScreen); - - if(pCmap != pOldCmap) - { - xnestDirectUninstallColormaps(pCmap->pScreen); - - /* Uninstall pInstalledMap. Notify all interested parties. */ - if(pOldCmap != (ColormapPtr)None) - WalkTree(pCmap->pScreen, TellLostMap, (pointer)&pOldCmap->mid); - - SetInstalledColormap(pCmap->pScreen, pCmap); - WalkTree(pCmap->pScreen, TellGainedMap, (pointer)&pCmap->mid); - - xnestSetInstalledColormapWindows(pCmap->pScreen); - xnestDirectInstallColormaps(pCmap->pScreen); + ColormapPtr pOldCmap = GetInstalledColormap(pCmap->pScreen); + + if (pCmap != pOldCmap) { + xnestDirectUninstallColormaps(pCmap->pScreen); + + /* Uninstall pInstalledMap. Notify all interested parties. */ + if (pOldCmap != (ColormapPtr) None) + WalkTree(pCmap->pScreen, TellLostMap, (pointer) &pOldCmap->mid); + + SetInstalledColormap(pCmap->pScreen, pCmap); + WalkTree(pCmap->pScreen, TellGainedMap, (pointer) &pCmap->mid); + + xnestSetInstalledColormapWindows(pCmap->pScreen); + xnestDirectInstallColormaps(pCmap->pScreen); } } void xnestUninstallColormap(ColormapPtr pCmap) { - ColormapPtr pCurCmap = GetInstalledColormap(pCmap->pScreen); - - if(pCmap == pCurCmap) - { - if (pCmap->mid != pCmap->pScreen->defColormap) - { - dixLookupResourceByType((pointer *)&pCurCmap, - pCmap->pScreen->defColormap, - RT_COLORMAP, - serverClient, DixInstallAccess); - (*pCmap->pScreen->InstallColormap)(pCurCmap); + ColormapPtr pCurCmap = GetInstalledColormap(pCmap->pScreen); + + if (pCmap == pCurCmap) { + if (pCmap->mid != pCmap->pScreen->defColormap) { + dixLookupResourceByType((pointer *) &pCurCmap, + pCmap->pScreen->defColormap, + RT_COLORMAP, + serverClient, DixInstallAccess); + (*pCmap->pScreen->InstallColormap) (pCurCmap); } } } @@ -372,124 +376,118 @@ xnestUninstallColormap(ColormapPtr pCmap) static Bool xnestInstalledDefaultColormap = False; int -xnestListInstalledColormaps(ScreenPtr pScreen, Colormap *pCmapIDs) +xnestListInstalledColormaps(ScreenPtr pScreen, Colormap * pCmapIDs) { - if (xnestInstalledDefaultColormap) { - *pCmapIDs = GetInstalledColormap(pScreen)->mid; - return 1; - } - else - return 0; + if (xnestInstalledDefaultColormap) { + *pCmapIDs = GetInstalledColormap(pScreen)->mid; + return 1; + } + else + return 0; } void -xnestStoreColors(ColormapPtr pCmap, int nColors, xColorItem *pColors) +xnestStoreColors(ColormapPtr pCmap, int nColors, xColorItem * pColors) { - if (pCmap->pVisual->class & DynamicClass) + if (pCmap->pVisual->class & DynamicClass) #ifdef _XSERVER64 - { - int i; - XColor *pColors64 = (XColor *)malloc(nColors * sizeof(XColor) ); - - for(i = 0; i < nColors; ++i) { - pColors64[i].pixel = pColors[i].pixel; - pColors64[i].red = pColors[i].red; - pColors64[i].green = pColors[i].green; - pColors64[i].blue = pColors[i].blue; - pColors64[i].flags = pColors[i].flags; + int i; + XColor *pColors64 = (XColor *) malloc(nColors * sizeof(XColor)); + + for (i = 0; i < nColors; ++i) { + pColors64[i].pixel = pColors[i].pixel; + pColors64[i].red = pColors[i].red; + pColors64[i].green = pColors[i].green; + pColors64[i].blue = pColors[i].blue; + pColors64[i].flags = pColors[i].flags; + } + XStoreColors(xnestDisplay, xnestColormap(pCmap), pColors64, nColors); + free(pColors64); } - XStoreColors(xnestDisplay, xnestColormap(pCmap), pColors64, nColors); - free(pColors64); - } #else - XStoreColors(xnestDisplay, xnestColormap(pCmap), - (XColor *)pColors, nColors); + XStoreColors(xnestDisplay, xnestColormap(pCmap), + (XColor *) pColors, nColors); #endif } void xnestResolveColor(unsigned short *pRed, unsigned short *pGreen, - unsigned short *pBlue, VisualPtr pVisual) + unsigned short *pBlue, VisualPtr pVisual) { - int shift; - unsigned int lim; - - shift = 16 - pVisual->bitsPerRGBValue; - lim = (1 << pVisual->bitsPerRGBValue) - 1; + int shift; + unsigned int lim; - if ((pVisual->class == PseudoColor) || (pVisual->class == DirectColor)) - { - /* rescale to rgb bits */ - *pRed = ((*pRed >> shift) * 65535) / lim; - *pGreen = ((*pGreen >> shift) * 65535) / lim; - *pBlue = ((*pBlue >> shift) * 65535) / lim; + shift = 16 - pVisual->bitsPerRGBValue; + lim = (1 << pVisual->bitsPerRGBValue) - 1; + + if ((pVisual->class == PseudoColor) || (pVisual->class == DirectColor)) { + /* rescale to rgb bits */ + *pRed = ((*pRed >> shift) * 65535) / lim; + *pGreen = ((*pGreen >> shift) * 65535) / lim; + *pBlue = ((*pBlue >> shift) * 65535) / lim; } - else if (pVisual->class == GrayScale) - { - /* rescale to gray then rgb bits */ - *pRed = (30L * *pRed + 59L * *pGreen + 11L * *pBlue) / 100; - *pBlue = *pGreen = *pRed = ((*pRed >> shift) * 65535) / lim; + else if (pVisual->class == GrayScale) { + /* rescale to gray then rgb bits */ + *pRed = (30L * *pRed + 59L * *pGreen + 11L * *pBlue) / 100; + *pBlue = *pGreen = *pRed = ((*pRed >> shift) * 65535) / lim; } - else if (pVisual->class == StaticGray) - { - unsigned int limg; - - limg = pVisual->ColormapEntries - 1; - /* rescale to gray then [0..limg] then [0..65535] then rgb bits */ - *pRed = (30L * *pRed + 59L * *pGreen + 11L * *pBlue) / 100; - *pRed = ((((*pRed * (limg + 1))) >> 16) * 65535) / limg; - *pBlue = *pGreen = *pRed = ((*pRed >> shift) * 65535) / lim; + else if (pVisual->class == StaticGray) { + unsigned int limg; + + limg = pVisual->ColormapEntries - 1; + /* rescale to gray then [0..limg] then [0..65535] then rgb bits */ + *pRed = (30L * *pRed + 59L * *pGreen + 11L * *pBlue) / 100; + *pRed = ((((*pRed * (limg + 1))) >> 16) * 65535) / limg; + *pBlue = *pGreen = *pRed = ((*pRed >> shift) * 65535) / lim; } - else - { - unsigned limr, limg, limb; - - limr = pVisual->redMask >> pVisual->offsetRed; - limg = pVisual->greenMask >> pVisual->offsetGreen; - limb = pVisual->blueMask >> pVisual->offsetBlue; - /* rescale to [0..limN] then [0..65535] then rgb bits */ - *pRed = ((((((*pRed * (limr + 1)) >> 16) * - 65535) / limr) >> shift) * 65535) / lim; - *pGreen = ((((((*pGreen * (limg + 1)) >> 16) * - 65535) / limg) >> shift) * 65535) / lim; - *pBlue = ((((((*pBlue * (limb + 1)) >> 16) * - 65535) / limb) >> shift) * 65535) / lim; + else { + unsigned limr, limg, limb; + + limr = pVisual->redMask >> pVisual->offsetRed; + limg = pVisual->greenMask >> pVisual->offsetGreen; + limb = pVisual->blueMask >> pVisual->offsetBlue; + /* rescale to [0..limN] then [0..65535] then rgb bits */ + *pRed = ((((((*pRed * (limr + 1)) >> 16) * + 65535) / limr) >> shift) * 65535) / lim; + *pGreen = ((((((*pGreen * (limg + 1)) >> 16) * + 65535) / limg) >> shift) * 65535) / lim; + *pBlue = ((((((*pBlue * (limb + 1)) >> 16) * + 65535) / limb) >> shift) * 65535) / lim; } } Bool xnestCreateDefaultColormap(ScreenPtr pScreen) { - VisualPtr pVisual; - ColormapPtr pCmap; - unsigned short zero = 0, ones = 0xFFFF; - Pixel wp, bp; - - if (!dixRegisterPrivateKey(&cmapScrPrivateKeyRec, PRIVATE_SCREEN, 0)) - return FALSE; - - for (pVisual = pScreen->visuals; - pVisual->vid != pScreen->rootVisual; - pVisual++); - - if (CreateColormap(pScreen->defColormap, pScreen, pVisual, &pCmap, - (pVisual->class & DynamicClass) ? AllocNone : AllocAll, 0) - != Success) - return False; - - wp = pScreen->whitePixel; - bp = pScreen->blackPixel; - if ((AllocColor(pCmap, &ones, &ones, &ones, &wp, 0) != - Success) || - (AllocColor(pCmap, &zero, &zero, &zero, &bp, 0) != - Success)) - return FALSE; - pScreen->whitePixel = wp; - pScreen->blackPixel = bp; - (*pScreen->InstallColormap)(pCmap); - - xnestInstalledDefaultColormap = True; - - return True; + VisualPtr pVisual; + ColormapPtr pCmap; + unsigned short zero = 0, ones = 0xFFFF; + Pixel wp, bp; + + if (!dixRegisterPrivateKey(&cmapScrPrivateKeyRec, PRIVATE_SCREEN, 0)) + return FALSE; + + for (pVisual = pScreen->visuals; + pVisual->vid != pScreen->rootVisual; pVisual++); + + if (CreateColormap(pScreen->defColormap, pScreen, pVisual, &pCmap, + (pVisual->class & DynamicClass) ? AllocNone : AllocAll, + 0) + != Success) + return False; + + wp = pScreen->whitePixel; + bp = pScreen->blackPixel; + if ((AllocColor(pCmap, &ones, &ones, &ones, &wp, 0) != + Success) || + (AllocColor(pCmap, &zero, &zero, &zero, &bp, 0) != Success)) + return FALSE; + pScreen->whitePixel = wp; + pScreen->blackPixel = bp; + (*pScreen->InstallColormap) (pCmap); + + xnestInstalledDefaultColormap = True; + + return True; } diff --git a/hw/xnest/Color.h b/hw/xnest/Color.h index d39c638f9..2c4e0be2a 100644 --- a/hw/xnest/Color.h +++ b/hw/xnest/Color.h @@ -21,18 +21,19 @@ is" without express or implied warranty. #define MINCMAPS 1 typedef struct { - Colormap colormap; + Colormap colormap; } xnestPrivColormap; typedef struct { - int numCmapIDs; - Colormap *cmapIDs; - int numWindows; - Window *windows; - int index; + int numCmapIDs; + Colormap *cmapIDs; + int numWindows; + Window *windows; + int index; } xnestInstalledColormapWindows; extern DevPrivateKeyRec xnestColormapPrivateKeyRec; + #define xnestColormapPriv(pCmap) \ ((xnestPrivColormap *) dixLookupPrivate(&(pCmap)->devPrivates, &xnestColormapPrivateKeyRec)) @@ -48,10 +49,10 @@ void xnestDirectInstallColormaps(ScreenPtr pScreen); void xnestDirectUninstallColormaps(ScreenPtr pScreen); void xnestInstallColormap(ColormapPtr pCmap); void xnestUninstallColormap(ColormapPtr pCmap); -int xnestListInstalledColormaps(ScreenPtr pScreen, Colormap *pCmapIDs); -void xnestStoreColors(ColormapPtr pCmap, int nColors, xColorItem *pColors); +int xnestListInstalledColormaps(ScreenPtr pScreen, Colormap * pCmapIDs); +void xnestStoreColors(ColormapPtr pCmap, int nColors, xColorItem * pColors); void xnestResolveColor(unsigned short *pRed, unsigned short *pGreen, - unsigned short *pBlue, VisualPtr pVisual); + unsigned short *pBlue, VisualPtr pVisual); Bool xnestCreateDefaultColormap(ScreenPtr pScreen); -#endif /* XNESTCOLOR_H */ +#endif /* XNESTCOLOR_H */ diff --git a/hw/xnest/Cursor.c b/hw/xnest/Cursor.c index 5491ee97b..285e10ebf 100644 --- a/hw/xnest/Cursor.c +++ b/hw/xnest/Cursor.c @@ -36,126 +36,117 @@ is" without express or implied warranty. #include "Keyboard.h" #include "Args.h" -xnestCursorFuncRec xnestCursorFuncs = {NULL}; +xnestCursorFuncRec xnestCursorFuncs = { NULL }; Bool xnestRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor) { - XImage *ximage; - Pixmap source, mask; - XColor fg_color, bg_color; - unsigned long valuemask; - XGCValues values; - - valuemask = GCFunction | - GCPlaneMask | - GCForeground | - GCBackground | - GCClipMask; - - values.function = GXcopy; - values.plane_mask = AllPlanes; - values.foreground = 1L; - values.background = 0L; - values.clip_mask = None; - - XChangeGC(xnestDisplay, xnestBitmapGC, valuemask, &values); - - source = XCreatePixmap(xnestDisplay, - xnestDefaultWindows[pScreen->myNum], - pCursor->bits->width, - pCursor->bits->height, - 1); - - mask = XCreatePixmap(xnestDisplay, - xnestDefaultWindows[pScreen->myNum], - pCursor->bits->width, - pCursor->bits->height, - 1); - - ximage = XCreateImage(xnestDisplay, - xnestDefaultVisual(pScreen), - 1, XYBitmap, 0, - (char *)pCursor->bits->source, - pCursor->bits->width, - pCursor->bits->height, - BitmapPad(xnestDisplay), 0); - - XPutImage(xnestDisplay, source, xnestBitmapGC, ximage, - 0, 0, 0, 0, pCursor->bits->width, pCursor->bits->height); - - XFree(ximage); - - ximage = XCreateImage(xnestDisplay, - xnestDefaultVisual(pScreen), - 1, XYBitmap, 0, - (char *)pCursor->bits->mask, - pCursor->bits->width, - pCursor->bits->height, - BitmapPad(xnestDisplay), 0); - - XPutImage(xnestDisplay, mask, xnestBitmapGC, ximage, - 0, 0, 0, 0, pCursor->bits->width, pCursor->bits->height); - - XFree(ximage); - - fg_color.red = pCursor->foreRed; - fg_color.green = pCursor->foreGreen; - fg_color.blue = pCursor->foreBlue; - - bg_color.red = pCursor->backRed; - bg_color.green = pCursor->backGreen; - bg_color.blue = pCursor->backBlue; - - xnestSetCursorPriv(pCursor, pScreen, malloc(sizeof(xnestPrivCursor))); - xnestCursor(pCursor, pScreen) = - XCreatePixmapCursor(xnestDisplay, source, mask, &fg_color, &bg_color, - pCursor->bits->xhot, pCursor->bits->yhot); - - XFreePixmap(xnestDisplay, source); - XFreePixmap(xnestDisplay, mask); - - return True; + XImage *ximage; + Pixmap source, mask; + XColor fg_color, bg_color; + unsigned long valuemask; + XGCValues values; + + valuemask = GCFunction | + GCPlaneMask | GCForeground | GCBackground | GCClipMask; + + values.function = GXcopy; + values.plane_mask = AllPlanes; + values.foreground = 1L; + values.background = 0L; + values.clip_mask = None; + + XChangeGC(xnestDisplay, xnestBitmapGC, valuemask, &values); + + source = XCreatePixmap(xnestDisplay, + xnestDefaultWindows[pScreen->myNum], + pCursor->bits->width, pCursor->bits->height, 1); + + mask = XCreatePixmap(xnestDisplay, + xnestDefaultWindows[pScreen->myNum], + pCursor->bits->width, pCursor->bits->height, 1); + + ximage = XCreateImage(xnestDisplay, + xnestDefaultVisual(pScreen), + 1, XYBitmap, 0, + (char *) pCursor->bits->source, + pCursor->bits->width, + pCursor->bits->height, BitmapPad(xnestDisplay), 0); + + XPutImage(xnestDisplay, source, xnestBitmapGC, ximage, + 0, 0, 0, 0, pCursor->bits->width, pCursor->bits->height); + + XFree(ximage); + + ximage = XCreateImage(xnestDisplay, + xnestDefaultVisual(pScreen), + 1, XYBitmap, 0, + (char *) pCursor->bits->mask, + pCursor->bits->width, + pCursor->bits->height, BitmapPad(xnestDisplay), 0); + + XPutImage(xnestDisplay, mask, xnestBitmapGC, ximage, + 0, 0, 0, 0, pCursor->bits->width, pCursor->bits->height); + + XFree(ximage); + + fg_color.red = pCursor->foreRed; + fg_color.green = pCursor->foreGreen; + fg_color.blue = pCursor->foreBlue; + + bg_color.red = pCursor->backRed; + bg_color.green = pCursor->backGreen; + bg_color.blue = pCursor->backBlue; + + xnestSetCursorPriv(pCursor, pScreen, malloc(sizeof(xnestPrivCursor))); + xnestCursor(pCursor, pScreen) = + XCreatePixmapCursor(xnestDisplay, source, mask, &fg_color, &bg_color, + pCursor->bits->xhot, pCursor->bits->yhot); + + XFreePixmap(xnestDisplay, source); + XFreePixmap(xnestDisplay, mask); + + return True; } Bool xnestUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor) { - XFreeCursor(xnestDisplay, xnestCursor(pCursor, pScreen)); - free(xnestGetCursorPriv(pCursor, pScreen)); - return True; + XFreeCursor(xnestDisplay, xnestCursor(pCursor, pScreen)); + free(xnestGetCursorPriv(pCursor, pScreen)); + return True; } void xnestRecolorCursor(ScreenPtr pScreen, CursorPtr pCursor, Bool displayed) { - XColor fg_color, bg_color; - - fg_color.red = pCursor->foreRed; - fg_color.green = pCursor->foreGreen; - fg_color.blue = pCursor->foreBlue; - - bg_color.red = pCursor->backRed; - bg_color.green = pCursor->backGreen; - bg_color.blue = pCursor->backBlue; - - XRecolorCursor(xnestDisplay, - xnestCursor(pCursor, pScreen), - &fg_color, &bg_color); + XColor fg_color, bg_color; + + fg_color.red = pCursor->foreRed; + fg_color.green = pCursor->foreGreen; + fg_color.blue = pCursor->foreBlue; + + bg_color.red = pCursor->backRed; + bg_color.green = pCursor->backGreen; + bg_color.blue = pCursor->backBlue; + + XRecolorCursor(xnestDisplay, + xnestCursor(pCursor, pScreen), &fg_color, &bg_color); } -void xnestSetCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, int x, int y) +void +xnestSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, int x, + int y) { - if (pCursor) - { - XDefineCursor(xnestDisplay, - xnestDefaultWindows[pScreen->myNum], - xnestCursor(pCursor, pScreen)); + if (pCursor) { + XDefineCursor(xnestDisplay, + xnestDefaultWindows[pScreen->myNum], + xnestCursor(pCursor, pScreen)); } } void -xnestMoveCursor (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y) +xnestMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y) { } @@ -165,7 +156,7 @@ xnestDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScreen) xnestCursorFuncPtr pScreenPriv; pScreenPriv = (xnestCursorFuncPtr) - dixLookupPrivate(&pScreen->devPrivates, xnestCursorScreenKey); + dixLookupPrivate(&pScreen->devPrivates, xnestCursorScreenKey); return pScreenPriv->spriteFuncs->DeviceCursorInitialize(pDev, pScreen); } @@ -176,7 +167,7 @@ xnestDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScreen) xnestCursorFuncPtr pScreenPriv; pScreenPriv = (xnestCursorFuncPtr) - dixLookupPrivate(&pScreen->devPrivates, xnestCursorScreenKey); + dixLookupPrivate(&pScreen->devPrivates, xnestCursorScreenKey); pScreenPriv->spriteFuncs->DeviceCursorCleanup(pDev, pScreen); } diff --git a/hw/xnest/Display.c b/hw/xnest/Display.c index 3176b60d7..a2f8acbaa 100644 --- a/hw/xnest/Display.c +++ b/hw/xnest/Display.c @@ -12,7 +12,6 @@ is" without express or implied warranty. */ - #ifdef HAVE_XNEST_CONFIG_H #include <xnest-config.h> #endif @@ -47,8 +46,8 @@ int *xnestDepths; int xnestNumDepths; XPixmapFormatValues *xnestPixmapFormats; int xnestNumPixmapFormats; -Pixel xnestBlackPixel; -Pixel xnestWhitePixel; +Pixel xnestBlackPixel; +Pixel xnestWhitePixel; Drawable xnestDefaultDrawables[MAXDEPTH + 1]; Pixmap xnestIconBitmap; Pixmap xnestScreenSaverPixmap; @@ -61,7 +60,8 @@ unsigned long xnestEventMask; #endif static int _X_NORETURN -x_io_error_handler (Display *dpy) { +x_io_error_handler(Display * dpy) +{ ErrorF("Lost connection to X server: %s\n", strerror(errno)); CloseWellKnownConnections(); OsCleanup(1); @@ -71,141 +71,143 @@ x_io_error_handler (Display *dpy) { void xnestOpenDisplay(int argc, char *argv[]) { - XVisualInfo vi; - long mask; - int i, j; - - if (!xnestDoFullGeneration) return; - - XSetIOErrorHandler(x_io_error_handler); - - xnestCloseDisplay(); - - xnestDisplay = XOpenDisplay(xnestDisplayName); - if (xnestDisplay == NULL) - FatalError("Unable to open display \"%s\".\n", - XDisplayName(xnestDisplayName)); - - if (xnestSynchronize) - XSynchronize(xnestDisplay, True); - - mask = VisualScreenMask; - vi.screen = DefaultScreen(xnestDisplay); - xnestVisuals = XGetVisualInfo(xnestDisplay, mask, &vi, &xnestNumVisuals); - if (xnestNumVisuals == 0 || xnestVisuals == NULL) - FatalError("Unable to find any visuals.\n"); - - if (xnestUserDefaultClass || xnestUserDefaultDepth) { - xnestDefaultVisualIndex = UNDEFINED; - for (i = 0; i < xnestNumVisuals; i++) - if ((!xnestUserDefaultClass || - xnestVisuals[i].class == xnestDefaultClass) - && - (!xnestUserDefaultDepth || - xnestVisuals[i].depth == xnestDefaultDepth)) { - xnestDefaultVisualIndex = i; - break; - } - if (xnestDefaultVisualIndex == UNDEFINED) - FatalError("Unable to find desired default visual.\n"); - } - else { - vi.visualid = XVisualIDFromVisual(DefaultVisual(xnestDisplay, - DefaultScreen(xnestDisplay))); - xnestDefaultVisualIndex = 0; - for (i = 0; i < xnestNumVisuals; i++) - if (vi.visualid == xnestVisuals[i].visualid) - xnestDefaultVisualIndex = i; - } - - xnestNumDefaultColormaps = xnestNumVisuals; - xnestDefaultColormaps = (Colormap *)malloc(xnestNumDefaultColormaps * - sizeof(Colormap)); - for (i = 0; i < xnestNumDefaultColormaps; i++) - xnestDefaultColormaps[i] = XCreateColormap(xnestDisplay, - DefaultRootWindow(xnestDisplay), - xnestVisuals[i].visual, - AllocNone); - - xnestDepths = XListDepths(xnestDisplay, DefaultScreen(xnestDisplay), - &xnestNumDepths); - - xnestPixmapFormats = XListPixmapFormats(xnestDisplay, - &xnestNumPixmapFormats); - - xnestBlackPixel = BlackPixel(xnestDisplay, DefaultScreen(xnestDisplay)); - xnestWhitePixel = WhitePixel(xnestDisplay, DefaultScreen(xnestDisplay)); - - if (xnestParentWindow != (Window) 0) - xnestEventMask = StructureNotifyMask; - else - xnestEventMask = 0L; - - for (i = 0; i <= MAXDEPTH; i++) - xnestDefaultDrawables[i] = None; - - for (i = 0; i < xnestNumPixmapFormats; i++) - for (j = 0; j < xnestNumDepths; j++) - if (xnestPixmapFormats[i].depth == 1 || - xnestPixmapFormats[i].depth == xnestDepths[j]) { - xnestDefaultDrawables[xnestPixmapFormats[i].depth] = - XCreatePixmap(xnestDisplay, DefaultRootWindow(xnestDisplay), - 1, 1, xnestPixmapFormats[i].depth); - } - - xnestBitmapGC = XCreateGC(xnestDisplay, xnestDefaultDrawables[1], 0L, NULL); - - if (!(xnestUserGeometry & XValue)) - xnestX = 0; - - if (!(xnestUserGeometry & YValue)) - xnestY = 0; - - if (xnestParentWindow == 0) { - if (!(xnestUserGeometry & WidthValue)) - xnestWidth = 3 * DisplayWidth(xnestDisplay, - DefaultScreen(xnestDisplay)) / 4; - - if (!(xnestUserGeometry & HeightValue)) - xnestHeight = 3 * DisplayHeight(xnestDisplay, - DefaultScreen(xnestDisplay)) / 4; - } - - if (!xnestUserBorderWidth) - xnestBorderWidth = 1; - - xnestIconBitmap = - XCreateBitmapFromData(xnestDisplay, - DefaultRootWindow(xnestDisplay), - (char *)icon_bits, - icon_width, - icon_height); - - xnestScreenSaverPixmap = - XCreatePixmapFromBitmapData(xnestDisplay, - DefaultRootWindow(xnestDisplay), - (char *)screensaver_bits, - screensaver_width, - screensaver_height, - xnestWhitePixel, - xnestBlackPixel, - DefaultDepth(xnestDisplay, - DefaultScreen(xnestDisplay))); + XVisualInfo vi; + long mask; + int i, j; + + if (!xnestDoFullGeneration) + return; + + XSetIOErrorHandler(x_io_error_handler); + + xnestCloseDisplay(); + + xnestDisplay = XOpenDisplay(xnestDisplayName); + if (xnestDisplay == NULL) + FatalError("Unable to open display \"%s\".\n", + XDisplayName(xnestDisplayName)); + + if (xnestSynchronize) + XSynchronize(xnestDisplay, True); + + mask = VisualScreenMask; + vi.screen = DefaultScreen(xnestDisplay); + xnestVisuals = XGetVisualInfo(xnestDisplay, mask, &vi, &xnestNumVisuals); + if (xnestNumVisuals == 0 || xnestVisuals == NULL) + FatalError("Unable to find any visuals.\n"); + + if (xnestUserDefaultClass || xnestUserDefaultDepth) { + xnestDefaultVisualIndex = UNDEFINED; + for (i = 0; i < xnestNumVisuals; i++) + if ((!xnestUserDefaultClass || + xnestVisuals[i].class == xnestDefaultClass) + && + (!xnestUserDefaultDepth || + xnestVisuals[i].depth == xnestDefaultDepth)) { + xnestDefaultVisualIndex = i; + break; + } + if (xnestDefaultVisualIndex == UNDEFINED) + FatalError("Unable to find desired default visual.\n"); + } + else { + vi.visualid = XVisualIDFromVisual(DefaultVisual(xnestDisplay, + DefaultScreen + (xnestDisplay))); + xnestDefaultVisualIndex = 0; + for (i = 0; i < xnestNumVisuals; i++) + if (vi.visualid == xnestVisuals[i].visualid) + xnestDefaultVisualIndex = i; + } + + xnestNumDefaultColormaps = xnestNumVisuals; + xnestDefaultColormaps = (Colormap *) malloc(xnestNumDefaultColormaps * + sizeof(Colormap)); + for (i = 0; i < xnestNumDefaultColormaps; i++) + xnestDefaultColormaps[i] = XCreateColormap(xnestDisplay, + DefaultRootWindow + (xnestDisplay), + xnestVisuals[i].visual, + AllocNone); + + xnestDepths = XListDepths(xnestDisplay, DefaultScreen(xnestDisplay), + &xnestNumDepths); + + xnestPixmapFormats = XListPixmapFormats(xnestDisplay, + &xnestNumPixmapFormats); + + xnestBlackPixel = BlackPixel(xnestDisplay, DefaultScreen(xnestDisplay)); + xnestWhitePixel = WhitePixel(xnestDisplay, DefaultScreen(xnestDisplay)); + + if (xnestParentWindow != (Window) 0) + xnestEventMask = StructureNotifyMask; + else + xnestEventMask = 0L; + + for (i = 0; i <= MAXDEPTH; i++) + xnestDefaultDrawables[i] = None; + + for (i = 0; i < xnestNumPixmapFormats; i++) + for (j = 0; j < xnestNumDepths; j++) + if (xnestPixmapFormats[i].depth == 1 || + xnestPixmapFormats[i].depth == xnestDepths[j]) { + xnestDefaultDrawables[xnestPixmapFormats[i].depth] = + XCreatePixmap(xnestDisplay, DefaultRootWindow(xnestDisplay), + 1, 1, xnestPixmapFormats[i].depth); + } + + xnestBitmapGC = XCreateGC(xnestDisplay, xnestDefaultDrawables[1], 0L, NULL); + + if (!(xnestUserGeometry & XValue)) + xnestX = 0; + + if (!(xnestUserGeometry & YValue)) + xnestY = 0; + + if (xnestParentWindow == 0) { + if (!(xnestUserGeometry & WidthValue)) + xnestWidth = 3 * DisplayWidth(xnestDisplay, + DefaultScreen(xnestDisplay)) / 4; + + if (!(xnestUserGeometry & HeightValue)) + xnestHeight = 3 * DisplayHeight(xnestDisplay, + DefaultScreen(xnestDisplay)) / 4; + } + + if (!xnestUserBorderWidth) + xnestBorderWidth = 1; + + xnestIconBitmap = + XCreateBitmapFromData(xnestDisplay, + DefaultRootWindow(xnestDisplay), + (char *) icon_bits, icon_width, icon_height); + + xnestScreenSaverPixmap = + XCreatePixmapFromBitmapData(xnestDisplay, + DefaultRootWindow(xnestDisplay), + (char *) screensaver_bits, + screensaver_width, + screensaver_height, + xnestWhitePixel, + xnestBlackPixel, + DefaultDepth(xnestDisplay, + DefaultScreen(xnestDisplay))); } void xnestCloseDisplay(void) { - if (!xnestDoFullGeneration || !xnestDisplay) return; - - /* - If xnestDoFullGeneration all x resources will be destroyed upon closing - the display connection. There is no need to generate extra protocol. - */ - - free(xnestDefaultColormaps); - XFree(xnestVisuals); - XFree(xnestDepths); - XFree(xnestPixmapFormats); - XCloseDisplay(xnestDisplay); + if (!xnestDoFullGeneration || !xnestDisplay) + return; + + /* + If xnestDoFullGeneration all x resources will be destroyed upon closing + the display connection. There is no need to generate extra protocol. + */ + + free(xnestDefaultColormaps); + XFree(xnestVisuals); + XFree(xnestDepths); + XFree(xnestPixmapFormats); + XCloseDisplay(xnestDisplay); } diff --git a/hw/xnest/Display.h b/hw/xnest/Display.h index d0eefd57c..4e9dbf463 100644 --- a/hw/xnest/Display.h +++ b/hw/xnest/Display.h @@ -21,7 +21,7 @@ is" without express or implied warranty. #define MAXVISUALSPERDEPTH 256 extern Display *xnestDisplay; -extern XVisualInfo *xnestVisuals; +extern XVisualInfo *xnestVisuals; extern int xnestNumVisuals; extern int xnestDefaultVisualIndex; extern Colormap *xnestDefaultColormaps; @@ -30,8 +30,8 @@ extern int *xnestDepths; extern int xnestNumDepths; extern XPixmapFormatValues *xnestPixmapFormats; extern int xnestNumPixmapFormats; -extern Pixel xnestBlackPixel; -extern Pixel xnestWhitePixel; +extern Pixel xnestBlackPixel; +extern Pixel xnestWhitePixel; extern Drawable xnestDefaultDrawables[MAXDEPTH + 1]; extern Pixmap xnestIconBitmap; extern Pixmap xnestScreenSaverPixmap; @@ -41,4 +41,4 @@ extern unsigned long xnestEventMask; void xnestOpenDisplay(int argc, char *argv[]); void xnestCloseDisplay(void); -#endif /* XNESTCOMMON_H */ +#endif /* XNESTCOMMON_H */ diff --git a/hw/xnest/Drawable.h b/hw/xnest/Drawable.h index 4268b7b83..ea7b5bb21 100644 --- a/hw/xnest/Drawable.h +++ b/hw/xnest/Drawable.h @@ -23,4 +23,4 @@ is" without express or implied warranty. xnestWindow((WindowPtr)pDrawable) : \ xnestPixmap((PixmapPtr)pDrawable)) -#endif /* XNESTDRAWABLE_H */ +#endif /* XNESTDRAWABLE_H */ diff --git a/hw/xnest/Events.c b/hw/xnest/Events.c index 619427ded..447d5a72b 100644 --- a/hw/xnest/Events.c +++ b/hw/xnest/Events.c @@ -46,7 +46,7 @@ CARD32 lastEventTime = 0; void ProcessInputEvents(void) { - mieqProcessInputEvents(); + mieqProcessInputEvents(); } int @@ -60,158 +60,159 @@ TimeSinceLastInputEvent(void) void SetTimeSinceLastInputEvent(void) { - lastEventTime = GetTimeInMillis(); + lastEventTime = GetTimeInMillis(); } static Bool -xnestExposurePredicate(Display *display, XEvent *event, char *args) +xnestExposurePredicate(Display * display, XEvent * event, char *args) { - return event->type == Expose || event->type == ProcessedExpose; + return event->type == Expose || event->type == ProcessedExpose; } static Bool -xnestNotExposurePredicate(Display *display, XEvent *event, char *args) +xnestNotExposurePredicate(Display * display, XEvent * event, char *args) { - return !xnestExposurePredicate(display, event, args); + return !xnestExposurePredicate(display, event, args); } void xnestCollectExposures(void) { - XEvent X; - WindowPtr pWin; - RegionRec Rgn; - BoxRec Box; - - while (XCheckIfEvent(xnestDisplay, &X, xnestExposurePredicate, NULL)) { - pWin = xnestWindowPtr(X.xexpose.window); - - if (pWin && X.xexpose.width && X.xexpose.height) { - Box.x1 = pWin->drawable.x + wBorderWidth(pWin) + X.xexpose.x; - Box.y1 = pWin->drawable.y + wBorderWidth(pWin) + X.xexpose.y; - Box.x2 = Box.x1 + X.xexpose.width; - Box.y2 = Box.y1 + X.xexpose.height; - - RegionInit(&Rgn, &Box, 1); - - miSendExposures(pWin, &Rgn, Box.x2, Box.y2); + XEvent X; + WindowPtr pWin; + RegionRec Rgn; + BoxRec Box; + + while (XCheckIfEvent(xnestDisplay, &X, xnestExposurePredicate, NULL)) { + pWin = xnestWindowPtr(X.xexpose.window); + + if (pWin && X.xexpose.width && X.xexpose.height) { + Box.x1 = pWin->drawable.x + wBorderWidth(pWin) + X.xexpose.x; + Box.y1 = pWin->drawable.y + wBorderWidth(pWin) + X.xexpose.y; + Box.x2 = Box.x1 + X.xexpose.width; + Box.y2 = Box.y1 + X.xexpose.height; + + RegionInit(&Rgn, &Box, 1); + + miSendExposures(pWin, &Rgn, Box.x2, Box.y2); + } } - } } void xnestQueueKeyEvent(int type, unsigned int keycode) { - lastEventTime = GetTimeInMillis(); - QueueKeyboardEvents(xnestKeyboardDevice, type, keycode, NULL); + lastEventTime = GetTimeInMillis(); + QueueKeyboardEvents(xnestKeyboardDevice, type, keycode, NULL); } void xnestCollectEvents(void) { - XEvent X; - int valuators[2]; - ValuatorMask mask; - ScreenPtr pScreen; - - while (XCheckIfEvent(xnestDisplay, &X, xnestNotExposurePredicate, NULL)) { - switch (X.type) { - case KeyPress: - xnestUpdateModifierState(X.xkey.state); - xnestQueueKeyEvent(KeyPress, X.xkey.keycode); - break; - - case KeyRelease: - xnestUpdateModifierState(X.xkey.state); - xnestQueueKeyEvent(KeyRelease, X.xkey.keycode); - break; - - case ButtonPress: - valuator_mask_set_range(&mask, 0, 0, NULL); - xnestUpdateModifierState(X.xkey.state); - lastEventTime = GetTimeInMillis(); - QueuePointerEvents(xnestPointerDevice, ButtonPress, - X.xbutton.button, POINTER_RELATIVE, &mask); - break; - - case ButtonRelease: - valuator_mask_set_range(&mask, 0, 0, NULL); - xnestUpdateModifierState(X.xkey.state); - lastEventTime = GetTimeInMillis(); - QueuePointerEvents(xnestPointerDevice, ButtonRelease, - X.xbutton.button, POINTER_RELATIVE, &mask); - break; - - case MotionNotify: - valuators[0] = X.xmotion.x; - valuators[1] = X.xmotion.y; - valuator_mask_set_range(&mask, 0, 2, valuators); - lastEventTime = GetTimeInMillis(); - QueuePointerEvents(xnestPointerDevice, MotionNotify, - 0, POINTER_ABSOLUTE, &mask); - break; - - case FocusIn: - if (X.xfocus.detail != NotifyInferior) { - pScreen = xnestScreen(X.xfocus.window); - if (pScreen) - xnestDirectInstallColormaps(pScreen); - } - break; - - case FocusOut: - if (X.xfocus.detail != NotifyInferior) { - pScreen = xnestScreen(X.xfocus.window); - if (pScreen) - xnestDirectUninstallColormaps(pScreen); - } - break; - - case KeymapNotify: - break; - - case EnterNotify: - if (X.xcrossing.detail != NotifyInferior) { - pScreen = xnestScreen(X.xcrossing.window); - if (pScreen) { - NewCurrentScreen(inputInfo.pointer, pScreen, X.xcrossing.x, X.xcrossing.y); - valuators[0] = X.xcrossing.x; - valuators[1] = X.xcrossing.y; - valuator_mask_set_range(&mask, 0, 2, valuators); - lastEventTime = GetTimeInMillis(); - QueuePointerEvents(xnestPointerDevice, MotionNotify, - 0, POINTER_ABSOLUTE, &mask); - xnestDirectInstallColormaps(pScreen); - } - } - break; - - case LeaveNotify: - if (X.xcrossing.detail != NotifyInferior) { - pScreen = xnestScreen(X.xcrossing.window); - if (pScreen) { - xnestDirectUninstallColormaps(pScreen); - } - } - break; - - case DestroyNotify: - if (xnestParentWindow != (Window) 0 && - X.xdestroywindow.window == xnestParentWindow) - exit (0); - break; - - case CirculateNotify: - case ConfigureNotify: - case GravityNotify: - case MapNotify: - case ReparentNotify: - case UnmapNotify: - break; - - default: - ErrorF("xnest warning: unhandled event\n"); - break; + XEvent X; + int valuators[2]; + ValuatorMask mask; + ScreenPtr pScreen; + + while (XCheckIfEvent(xnestDisplay, &X, xnestNotExposurePredicate, NULL)) { + switch (X.type) { + case KeyPress: + xnestUpdateModifierState(X.xkey.state); + xnestQueueKeyEvent(KeyPress, X.xkey.keycode); + break; + + case KeyRelease: + xnestUpdateModifierState(X.xkey.state); + xnestQueueKeyEvent(KeyRelease, X.xkey.keycode); + break; + + case ButtonPress: + valuator_mask_set_range(&mask, 0, 0, NULL); + xnestUpdateModifierState(X.xkey.state); + lastEventTime = GetTimeInMillis(); + QueuePointerEvents(xnestPointerDevice, ButtonPress, + X.xbutton.button, POINTER_RELATIVE, &mask); + break; + + case ButtonRelease: + valuator_mask_set_range(&mask, 0, 0, NULL); + xnestUpdateModifierState(X.xkey.state); + lastEventTime = GetTimeInMillis(); + QueuePointerEvents(xnestPointerDevice, ButtonRelease, + X.xbutton.button, POINTER_RELATIVE, &mask); + break; + + case MotionNotify: + valuators[0] = X.xmotion.x; + valuators[1] = X.xmotion.y; + valuator_mask_set_range(&mask, 0, 2, valuators); + lastEventTime = GetTimeInMillis(); + QueuePointerEvents(xnestPointerDevice, MotionNotify, + 0, POINTER_ABSOLUTE, &mask); + break; + + case FocusIn: + if (X.xfocus.detail != NotifyInferior) { + pScreen = xnestScreen(X.xfocus.window); + if (pScreen) + xnestDirectInstallColormaps(pScreen); + } + break; + + case FocusOut: + if (X.xfocus.detail != NotifyInferior) { + pScreen = xnestScreen(X.xfocus.window); + if (pScreen) + xnestDirectUninstallColormaps(pScreen); + } + break; + + case KeymapNotify: + break; + + case EnterNotify: + if (X.xcrossing.detail != NotifyInferior) { + pScreen = xnestScreen(X.xcrossing.window); + if (pScreen) { + NewCurrentScreen(inputInfo.pointer, pScreen, X.xcrossing.x, + X.xcrossing.y); + valuators[0] = X.xcrossing.x; + valuators[1] = X.xcrossing.y; + valuator_mask_set_range(&mask, 0, 2, valuators); + lastEventTime = GetTimeInMillis(); + QueuePointerEvents(xnestPointerDevice, MotionNotify, + 0, POINTER_ABSOLUTE, &mask); + xnestDirectInstallColormaps(pScreen); + } + } + break; + + case LeaveNotify: + if (X.xcrossing.detail != NotifyInferior) { + pScreen = xnestScreen(X.xcrossing.window); + if (pScreen) { + xnestDirectUninstallColormaps(pScreen); + } + } + break; + + case DestroyNotify: + if (xnestParentWindow != (Window) 0 && + X.xdestroywindow.window == xnestParentWindow) + exit(0); + break; + + case CirculateNotify: + case ConfigureNotify: + case GravityNotify: + case MapNotify: + case ReparentNotify: + case UnmapNotify: + break; + + default: + ErrorF("xnest warning: unhandled event\n"); + break; + } } - } } diff --git a/hw/xnest/Events.h b/hw/xnest/Events.h index 2441accd5..1c1b8cd46 100644 --- a/hw/xnest/Events.h +++ b/hw/xnest/Events.h @@ -26,4 +26,4 @@ void xnestCollectExposures(void); void xnestCollectEvents(void); void xnestQueueKeyEvent(int type, unsigned int keycode); -#endif /* XNESTEVENTS_H */ +#endif /* XNESTEVENTS_H */ diff --git a/hw/xnest/Font.c b/hw/xnest/Font.c index f1ccd7e73..1e95588ef 100644 --- a/hw/xnest/Font.c +++ b/hw/xnest/Font.c @@ -35,52 +35,54 @@ int xnestFontPrivateIndex; Bool xnestRealizeFont(ScreenPtr pScreen, FontPtr pFont) { - pointer priv; - Atom name_atom, value_atom; - int nprops; - FontPropPtr props; - int i; - const char *name; + pointer priv; + Atom name_atom, value_atom; + int nprops; + FontPropPtr props; + int i; + const char *name; - FontSetPrivate(pFont, xnestFontPrivateIndex, NULL); + FontSetPrivate(pFont, xnestFontPrivateIndex, NULL); - name_atom = MakeAtom("FONT", 4, True); - value_atom = 0L; + name_atom = MakeAtom("FONT", 4, True); + value_atom = 0L; - nprops = pFont->info.nprops; - props = pFont->info.props; + nprops = pFont->info.nprops; + props = pFont->info.props; - for (i = 0; i < nprops; i++) - if (props[i].name == name_atom) { - value_atom = props[i].value; - break; - } + for (i = 0; i < nprops; i++) + if (props[i].name == name_atom) { + value_atom = props[i].value; + break; + } - if (!value_atom) return False; + if (!value_atom) + return False; - name = NameForAtom(value_atom); + name = NameForAtom(value_atom); - if (!name) return False; + if (!name) + return False; - priv = (pointer)malloc(sizeof(xnestPrivFont)); - FontSetPrivate(pFont, xnestFontPrivateIndex, priv); - - xnestFontPriv(pFont)->font_struct = XLoadQueryFont(xnestDisplay, name); + priv = (pointer) malloc(sizeof(xnestPrivFont)); + FontSetPrivate(pFont, xnestFontPrivateIndex, priv); - if (!xnestFontStruct(pFont)) return False; - - return True; -} + xnestFontPriv(pFont)->font_struct = XLoadQueryFont(xnestDisplay, name); + if (!xnestFontStruct(pFont)) + return False; + + return True; +} Bool xnestUnrealizeFont(ScreenPtr pScreen, FontPtr pFont) { - if (xnestFontPriv(pFont)) { - if (xnestFontStruct(pFont)) - XFreeFont(xnestDisplay, xnestFontStruct(pFont)); - free(xnestFontPriv(pFont)); - FontSetPrivate(pFont, xnestFontPrivateIndex, NULL); - } - return True; + if (xnestFontPriv(pFont)) { + if (xnestFontStruct(pFont)) + XFreeFont(xnestDisplay, xnestFontStruct(pFont)); + free(xnestFontPriv(pFont)); + FontSetPrivate(pFont, xnestFontPrivateIndex, NULL); + } + return True; } diff --git a/hw/xnest/GC.c b/hw/xnest/GC.c index 48fe4dcbc..cfaf71475 100644 --- a/hw/xnest/GC.c +++ b/hw/xnest/GC.c @@ -29,7 +29,7 @@ is" without express or implied warranty. #include "Xnest.h" #include "Display.h" -#include "XNGC.h" +#include "XNGC.h" #include "GCOps.h" #include "Drawable.h" #include "XNFont.h" @@ -38,51 +38,51 @@ is" without express or implied warranty. DevPrivateKeyRec xnestGCPrivateKeyRec; static GCFuncs xnestFuncs = { - xnestValidateGC, - xnestChangeGC, - xnestCopyGC, - xnestDestroyGC, - xnestChangeClip, - xnestDestroyClip, - xnestCopyClip, + xnestValidateGC, + xnestChangeGC, + xnestCopyGC, + xnestDestroyGC, + xnestChangeClip, + xnestDestroyClip, + xnestCopyClip, }; static GCOps xnestOps = { - xnestFillSpans, - xnestSetSpans, - xnestPutImage, - xnestCopyArea, - xnestCopyPlane, - xnestPolyPoint, - xnestPolylines, - xnestPolySegment, - xnestPolyRectangle, - xnestPolyArc, - xnestFillPolygon, - xnestPolyFillRect, - xnestPolyFillArc, - xnestPolyText8, - xnestPolyText16, - xnestImageText8, - xnestImageText16, - xnestImageGlyphBlt, - xnestPolyGlyphBlt, - xnestPushPixels + xnestFillSpans, + xnestSetSpans, + xnestPutImage, + xnestCopyArea, + xnestCopyPlane, + xnestPolyPoint, + xnestPolylines, + xnestPolySegment, + xnestPolyRectangle, + xnestPolyArc, + xnestFillPolygon, + xnestPolyFillRect, + xnestPolyFillArc, + xnestPolyText8, + xnestPolyText16, + xnestImageText8, + xnestImageText16, + xnestImageGlyphBlt, + xnestPolyGlyphBlt, + xnestPushPixels }; Bool xnestCreateGC(GCPtr pGC) { - pGC->funcs = &xnestFuncs; - pGC->ops = &xnestOps; - - pGC->miTranslate = 1; - - xnestGCPriv(pGC)->gc = XCreateGC(xnestDisplay, - xnestDefaultDrawables[pGC->depth], - 0L, NULL); - - return True; + pGC->funcs = &xnestFuncs; + pGC->ops = &xnestOps; + + pGC->miTranslate = 1; + + xnestGCPriv(pGC)->gc = XCreateGC(xnestDisplay, + xnestDefaultDrawables[pGC->depth], + 0L, NULL); + + return True; } void @@ -93,238 +93,236 @@ xnestValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable) void xnestChangeGC(GCPtr pGC, unsigned long mask) { - XGCValues values; - - if (mask & GCFunction) - values.function = pGC->alu; - - if (mask & GCPlaneMask) - values.plane_mask = pGC->planemask; - - if (mask & GCForeground) - values.foreground = xnestPixel(pGC->fgPixel); - - if (mask & GCBackground) - values.background = xnestPixel(pGC->bgPixel); - - if (mask & GCLineWidth) - values.line_width = pGC->lineWidth; - - if (mask & GCLineStyle) - values.line_style = pGC->lineStyle; - - if (mask & GCCapStyle) - values.cap_style = pGC->capStyle; - - if (mask & GCJoinStyle) - values.join_style = pGC->joinStyle; - - if (mask & GCFillStyle) - values.fill_style = pGC->fillStyle; - - if (mask & GCFillRule) - values.fill_rule = pGC->fillRule; - - if (mask & GCTile) { - if (pGC->tileIsPixel) - mask &= ~GCTile; - else - values.tile = xnestPixmap(pGC->tile.pixmap); - } - - if (mask & GCStipple) - values.stipple = xnestPixmap(pGC->stipple); - - if (mask & GCTileStipXOrigin) - values.ts_x_origin = pGC->patOrg.x; - - if (mask & GCTileStipYOrigin) - values.ts_y_origin = pGC->patOrg.y; - - if (mask & GCFont) - values.font = xnestFont(pGC->font); - - if (mask & GCSubwindowMode) - values.subwindow_mode = pGC->subWindowMode; - - if (mask & GCGraphicsExposures) - values.graphics_exposures = pGC->graphicsExposures; - - if (mask & GCClipXOrigin) - values.clip_x_origin = pGC->clipOrg.x; - - if (mask & GCClipYOrigin) - values.clip_y_origin = pGC->clipOrg.y; - - if (mask & GCClipMask) /* this is handled in change clip */ - mask &= ~GCClipMask; - - if (mask & GCDashOffset) - values.dash_offset = pGC->dashOffset; - - if (mask & GCDashList) { - mask &= ~GCDashList; - XSetDashes(xnestDisplay, xnestGC(pGC), - pGC->dashOffset, (char *)pGC->dash, pGC->numInDashList); - } - - if (mask & GCArcMode) - values.arc_mode = pGC->arcMode; - - if (mask) - XChangeGC(xnestDisplay, xnestGC(pGC), mask, &values); + XGCValues values; + + if (mask & GCFunction) + values.function = pGC->alu; + + if (mask & GCPlaneMask) + values.plane_mask = pGC->planemask; + + if (mask & GCForeground) + values.foreground = xnestPixel(pGC->fgPixel); + + if (mask & GCBackground) + values.background = xnestPixel(pGC->bgPixel); + + if (mask & GCLineWidth) + values.line_width = pGC->lineWidth; + + if (mask & GCLineStyle) + values.line_style = pGC->lineStyle; + + if (mask & GCCapStyle) + values.cap_style = pGC->capStyle; + + if (mask & GCJoinStyle) + values.join_style = pGC->joinStyle; + + if (mask & GCFillStyle) + values.fill_style = pGC->fillStyle; + + if (mask & GCFillRule) + values.fill_rule = pGC->fillRule; + + if (mask & GCTile) { + if (pGC->tileIsPixel) + mask &= ~GCTile; + else + values.tile = xnestPixmap(pGC->tile.pixmap); + } + + if (mask & GCStipple) + values.stipple = xnestPixmap(pGC->stipple); + + if (mask & GCTileStipXOrigin) + values.ts_x_origin = pGC->patOrg.x; + + if (mask & GCTileStipYOrigin) + values.ts_y_origin = pGC->patOrg.y; + + if (mask & GCFont) + values.font = xnestFont(pGC->font); + + if (mask & GCSubwindowMode) + values.subwindow_mode = pGC->subWindowMode; + + if (mask & GCGraphicsExposures) + values.graphics_exposures = pGC->graphicsExposures; + + if (mask & GCClipXOrigin) + values.clip_x_origin = pGC->clipOrg.x; + + if (mask & GCClipYOrigin) + values.clip_y_origin = pGC->clipOrg.y; + + if (mask & GCClipMask) /* this is handled in change clip */ + mask &= ~GCClipMask; + + if (mask & GCDashOffset) + values.dash_offset = pGC->dashOffset; + + if (mask & GCDashList) { + mask &= ~GCDashList; + XSetDashes(xnestDisplay, xnestGC(pGC), + pGC->dashOffset, (char *) pGC->dash, pGC->numInDashList); + } + + if (mask & GCArcMode) + values.arc_mode = pGC->arcMode; + + if (mask) + XChangeGC(xnestDisplay, xnestGC(pGC), mask, &values); } void xnestCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst) { - XCopyGC(xnestDisplay, xnestGC(pGCSrc), mask, xnestGC(pGCDst)); + XCopyGC(xnestDisplay, xnestGC(pGCSrc), mask, xnestGC(pGCDst)); } void xnestDestroyGC(GCPtr pGC) { - XFreeGC(xnestDisplay, xnestGC(pGC)); + XFreeGC(xnestDisplay, xnestGC(pGC)); } void xnestChangeClip(GCPtr pGC, int type, pointer pValue, int nRects) { - int i, size; - BoxPtr pBox; - XRectangle *pRects; + int i, size; + BoxPtr pBox; + XRectangle *pRects; - xnestDestroyClipHelper(pGC); + xnestDestroyClipHelper(pGC); - switch(type) - { + switch (type) { case CT_NONE: - XSetClipMask(xnestDisplay, xnestGC(pGC), None); - break; - + XSetClipMask(xnestDisplay, xnestGC(pGC), None); + break; + case CT_REGION: - nRects = RegionNumRects((RegionPtr)pValue); - size = nRects * sizeof(*pRects); - pRects = (XRectangle *) malloc(size); - pBox = RegionRects((RegionPtr)pValue); - for (i = nRects; i-- > 0; ) { - pRects[i].x = pBox[i].x1; - pRects[i].y = pBox[i].y1; - pRects[i].width = pBox[i].x2 - pBox[i].x1; - pRects[i].height = pBox[i].y2 - pBox[i].y1; - } - XSetClipRectangles(xnestDisplay, xnestGC(pGC), 0, 0, - pRects, nRects, Unsorted); - free((char *) pRects); - break; + nRects = RegionNumRects((RegionPtr) pValue); + size = nRects * sizeof(*pRects); + pRects = (XRectangle *) malloc(size); + pBox = RegionRects((RegionPtr) pValue); + for (i = nRects; i-- > 0;) { + pRects[i].x = pBox[i].x1; + pRects[i].y = pBox[i].y1; + pRects[i].width = pBox[i].x2 - pBox[i].x1; + pRects[i].height = pBox[i].y2 - pBox[i].y1; + } + XSetClipRectangles(xnestDisplay, xnestGC(pGC), 0, 0, + pRects, nRects, Unsorted); + free((char *) pRects); + break; case CT_PIXMAP: - XSetClipMask(xnestDisplay, xnestGC(pGC), - xnestPixmap((PixmapPtr)pValue)); - /* - * Need to change into region, so subsequent uses are with - * current pixmap contents. - */ - pGC->clientClip = (pointer) (*pGC->pScreen->BitmapToRegion)((PixmapPtr)pValue); - (*pGC->pScreen->DestroyPixmap)((PixmapPtr)pValue); - pValue = pGC->clientClip; - type = CT_REGION; - break; + XSetClipMask(xnestDisplay, xnestGC(pGC), + xnestPixmap((PixmapPtr) pValue)); + /* + * Need to change into region, so subsequent uses are with + * current pixmap contents. + */ + pGC->clientClip = + (pointer) (*pGC->pScreen->BitmapToRegion) ((PixmapPtr) pValue); + (*pGC->pScreen->DestroyPixmap) ((PixmapPtr) pValue); + pValue = pGC->clientClip; + type = CT_REGION; + break; case CT_UNSORTED: - XSetClipRectangles(xnestDisplay, xnestGC(pGC), - pGC->clipOrg.x, pGC->clipOrg.y, - (XRectangle *)pValue, nRects, Unsorted); - break; + XSetClipRectangles(xnestDisplay, xnestGC(pGC), + pGC->clipOrg.x, pGC->clipOrg.y, + (XRectangle *) pValue, nRects, Unsorted); + break; case CT_YSORTED: - XSetClipRectangles(xnestDisplay, xnestGC(pGC), - pGC->clipOrg.x, pGC->clipOrg.y, - (XRectangle *)pValue, nRects, YSorted); - break; + XSetClipRectangles(xnestDisplay, xnestGC(pGC), + pGC->clipOrg.x, pGC->clipOrg.y, + (XRectangle *) pValue, nRects, YSorted); + break; case CT_YXSORTED: - XSetClipRectangles(xnestDisplay, xnestGC(pGC), - pGC->clipOrg.x, pGC->clipOrg.y, - (XRectangle *)pValue, nRects, YXSorted); - break; + XSetClipRectangles(xnestDisplay, xnestGC(pGC), + pGC->clipOrg.x, pGC->clipOrg.y, + (XRectangle *) pValue, nRects, YXSorted); + break; case CT_YXBANDED: - XSetClipRectangles(xnestDisplay, xnestGC(pGC), - pGC->clipOrg.x, pGC->clipOrg.y, - (XRectangle *)pValue, nRects, YXBanded); - break; + XSetClipRectangles(xnestDisplay, xnestGC(pGC), + pGC->clipOrg.x, pGC->clipOrg.y, + (XRectangle *) pValue, nRects, YXBanded); + break; } - switch(type) - { + switch (type) { default: - break; + break; case CT_UNSORTED: case CT_YSORTED: case CT_YXSORTED: case CT_YXBANDED: - - /* - * other parts of server can only deal with CT_NONE, - * CT_PIXMAP and CT_REGION client clips. - */ - pGC->clientClip = (pointer) RegionFromRects(nRects, - (xRectangle *)pValue, type); - free(pValue); - pValue = pGC->clientClip; - type = CT_REGION; - - break; + + /* + * other parts of server can only deal with CT_NONE, + * CT_PIXMAP and CT_REGION client clips. + */ + pGC->clientClip = (pointer) RegionFromRects(nRects, + (xRectangle *) pValue, + type); + free(pValue); + pValue = pGC->clientClip; + type = CT_REGION; + + break; } - pGC->clientClipType = type; - pGC->clientClip = pValue; + pGC->clientClipType = type; + pGC->clientClip = pValue; } void xnestDestroyClip(GCPtr pGC) { - xnestDestroyClipHelper(pGC); + xnestDestroyClipHelper(pGC); - XSetClipMask(xnestDisplay, xnestGC(pGC), None); - - pGC->clientClipType = CT_NONE; - pGC->clientClip = NULL; + XSetClipMask(xnestDisplay, xnestGC(pGC), None); + + pGC->clientClipType = CT_NONE; + pGC->clientClip = NULL; } void xnestDestroyClipHelper(GCPtr pGC) { - switch (pGC->clientClipType) - { + switch (pGC->clientClipType) { default: case CT_NONE: - break; - + break; + case CT_REGION: - RegionDestroy(pGC->clientClip); - break; + RegionDestroy(pGC->clientClip); + break; } } void xnestCopyClip(GCPtr pGCDst, GCPtr pGCSrc) { - RegionPtr pRgn; + RegionPtr pRgn; - switch (pGCSrc->clientClipType) - { + switch (pGCSrc->clientClipType) { default: case CT_NONE: - xnestDestroyClip(pGCDst); - break; + xnestDestroyClip(pGCDst); + break; case CT_REGION: - pRgn = RegionCreate(NULL, 1); - RegionCopy(pRgn, pGCSrc->clientClip); - xnestChangeClip(pGCDst, CT_REGION, pRgn, 0); - break; + pRgn = RegionCreate(NULL, 1); + RegionCopy(pRgn, pGCSrc->clientClip); + xnestChangeClip(pGCDst, CT_REGION, pRgn, 0); + break; } } diff --git a/hw/xnest/GCOps.c b/hw/xnest/GCOps.c index 829b86b2b..e26a1363b 100644 --- a/hw/xnest/GCOps.c +++ b/hw/xnest/GCOps.c @@ -38,290 +38,289 @@ is" without express or implied warranty. #include "Visual.h" void -xnestFillSpans(DrawablePtr pDrawable, GCPtr pGC, int nSpans, xPoint *pPoints, - int *pWidths, int fSorted) +xnestFillSpans(DrawablePtr pDrawable, GCPtr pGC, int nSpans, xPoint * pPoints, + int *pWidths, int fSorted) { - ErrorF("xnest warning: function xnestFillSpans not implemented\n"); + ErrorF("xnest warning: function xnestFillSpans not implemented\n"); } void xnestSetSpans(DrawablePtr pDrawable, GCPtr pGC, char *pSrc, - xPoint *pPoints, int *pWidths, int nSpans, int fSorted) + xPoint * pPoints, int *pWidths, int nSpans, int fSorted) { - ErrorF("xnest warning: function xnestSetSpans not implemented\n"); + ErrorF("xnest warning: function xnestSetSpans not implemented\n"); } void xnestGetSpans(DrawablePtr pDrawable, int maxWidth, DDXPointPtr pPoints, - int *pWidths, int nSpans, char *pBuffer) + int *pWidths, int nSpans, char *pBuffer) { - ErrorF("xnest warning: function xnestGetSpans not implemented\n"); + ErrorF("xnest warning: function xnestGetSpans not implemented\n"); } void xnestQueryBestSize(int class, unsigned short *pWidth, unsigned short *pHeight, - ScreenPtr pScreen) + ScreenPtr pScreen) { - unsigned int width, height; + unsigned int width, height; - width = *pWidth; - height = *pHeight; + width = *pWidth; + height = *pHeight; - XQueryBestSize(xnestDisplay, class, - xnestDefaultWindows[pScreen->myNum], - width, height, &width, &height); - - *pWidth = width; - *pHeight = height; + XQueryBestSize(xnestDisplay, class, + xnestDefaultWindows[pScreen->myNum], + width, height, &width, &height); + + *pWidth = width; + *pHeight = height; } void xnestPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y, - int w, int h, int leftPad, int format, char *pImage) + int w, int h, int leftPad, int format, char *pImage) { - XImage *ximage; - - ximage = XCreateImage(xnestDisplay, xnestDefaultVisual(pDrawable->pScreen), - depth, format, leftPad, (char *)pImage, - w, h, BitmapPad(xnestDisplay), - (format == ZPixmap) ? - PixmapBytePad(w, depth) : BitmapBytePad(w+leftPad)); - - if (ximage) { - XPutImage(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC), - ximage, 0, 0, x, y, w, h); - XFree(ximage); - } + XImage *ximage; + + ximage = XCreateImage(xnestDisplay, xnestDefaultVisual(pDrawable->pScreen), + depth, format, leftPad, (char *) pImage, + w, h, BitmapPad(xnestDisplay), + (format == ZPixmap) ? + PixmapBytePad(w, depth) : BitmapBytePad(w + leftPad)); + + if (ximage) { + XPutImage(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC), + ximage, 0, 0, x, y, w, h); + XFree(ximage); + } } void xnestGetImage(DrawablePtr pDrawable, int x, int y, int w, int h, - unsigned int format, unsigned long planeMask, - char *pImage) + unsigned int format, unsigned long planeMask, char *pImage) { - XImage *ximage; - int length; - - ximage = XGetImage(xnestDisplay, xnestDrawable(pDrawable), - x, y, w, h, planeMask, format); - - if (ximage) { - length = ximage->bytes_per_line * ximage->height; - - memmove(pImage, ximage->data, length); - - XDestroyImage(ximage); - } + XImage *ximage; + int length; + + ximage = XGetImage(xnestDisplay, xnestDrawable(pDrawable), + x, y, w, h, planeMask, format); + + if (ximage) { + length = ximage->bytes_per_line * ximage->height; + + memmove(pImage, ximage->data, length); + + XDestroyImage(ximage); + } } static Bool -xnestBitBlitPredicate(Display *display, XEvent *event, char *args) +xnestBitBlitPredicate(Display * display, XEvent * event, char *args) { - return event->type == GraphicsExpose || event->type == NoExpose; + return event->type == GraphicsExpose || event->type == NoExpose; } static RegionPtr xnestBitBlitHelper(GCPtr pGC) { - if (!pGC->graphicsExposures) - return NullRegion; - else { - XEvent event; - RegionPtr pReg, pTmpReg; - BoxRec Box; - Bool pending, overlap; - - pReg = RegionCreate(NULL, 1); - pTmpReg = RegionCreate(NULL, 1); - if(!pReg || !pTmpReg) return NullRegion; - - pending = True; - while (pending) { - XIfEvent(xnestDisplay, &event, xnestBitBlitPredicate, NULL); - - switch (event.type) { - case NoExpose: - pending = False; - break; - - case GraphicsExpose: - Box.x1 = event.xgraphicsexpose.x; - Box.y1 = event.xgraphicsexpose.y; - Box.x2 = event.xgraphicsexpose.x + event.xgraphicsexpose.width; - Box.y2 = event.xgraphicsexpose.y + event.xgraphicsexpose.height; - RegionReset(pTmpReg, &Box); - RegionAppend(pReg, pTmpReg); - pending = event.xgraphicsexpose.count; - break; - } + if (!pGC->graphicsExposures) + return NullRegion; + else { + XEvent event; + RegionPtr pReg, pTmpReg; + BoxRec Box; + Bool pending, overlap; + + pReg = RegionCreate(NULL, 1); + pTmpReg = RegionCreate(NULL, 1); + if (!pReg || !pTmpReg) + return NullRegion; + + pending = True; + while (pending) { + XIfEvent(xnestDisplay, &event, xnestBitBlitPredicate, NULL); + + switch (event.type) { + case NoExpose: + pending = False; + break; + + case GraphicsExpose: + Box.x1 = event.xgraphicsexpose.x; + Box.y1 = event.xgraphicsexpose.y; + Box.x2 = event.xgraphicsexpose.x + event.xgraphicsexpose.width; + Box.y2 = event.xgraphicsexpose.y + event.xgraphicsexpose.height; + RegionReset(pTmpReg, &Box); + RegionAppend(pReg, pTmpReg); + pending = event.xgraphicsexpose.count; + break; + } + } + + RegionDestroy(pTmpReg); + RegionValidate(pReg, &overlap); + return pReg; } - - RegionDestroy(pTmpReg); - RegionValidate(pReg, &overlap); - return pReg; - } } RegionPtr xnestCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, - GCPtr pGC, int srcx, int srcy, int width, int height, - int dstx, int dsty) + GCPtr pGC, int srcx, int srcy, int width, int height, + int dstx, int dsty) { - XCopyArea(xnestDisplay, - xnestDrawable(pSrcDrawable), xnestDrawable(pDstDrawable), - xnestGC(pGC), srcx, srcy, width, height, dstx, dsty); - - return xnestBitBlitHelper(pGC); + XCopyArea(xnestDisplay, + xnestDrawable(pSrcDrawable), xnestDrawable(pDstDrawable), + xnestGC(pGC), srcx, srcy, width, height, dstx, dsty); + + return xnestBitBlitHelper(pGC); } RegionPtr xnestCopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, - GCPtr pGC, int srcx, int srcy, int width, int height, - int dstx, int dsty, unsigned long plane) + GCPtr pGC, int srcx, int srcy, int width, int height, + int dstx, int dsty, unsigned long plane) { - XCopyPlane(xnestDisplay, - xnestDrawable(pSrcDrawable), xnestDrawable(pDstDrawable), - xnestGC(pGC), srcx, srcy, width, height, dstx, dsty, plane); - - return xnestBitBlitHelper(pGC); + XCopyPlane(xnestDisplay, + xnestDrawable(pSrcDrawable), xnestDrawable(pDstDrawable), + xnestGC(pGC), srcx, srcy, width, height, dstx, dsty, plane); + + return xnestBitBlitHelper(pGC); } void xnestPolyPoint(DrawablePtr pDrawable, GCPtr pGC, int mode, int nPoints, - DDXPointPtr pPoints) + DDXPointPtr pPoints) { - XDrawPoints(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC), - (XPoint *)pPoints, nPoints, mode); + XDrawPoints(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC), + (XPoint *) pPoints, nPoints, mode); } void xnestPolylines(DrawablePtr pDrawable, GCPtr pGC, int mode, int nPoints, - DDXPointPtr pPoints) + DDXPointPtr pPoints) { - XDrawLines(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC), - (XPoint *)pPoints, nPoints, mode); + XDrawLines(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC), + (XPoint *) pPoints, nPoints, mode); } void xnestPolySegment(DrawablePtr pDrawable, GCPtr pGC, int nSegments, - xSegment *pSegments) + xSegment * pSegments) { - XDrawSegments(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC), - (XSegment *)pSegments, nSegments); + XDrawSegments(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC), + (XSegment *) pSegments, nSegments); } void xnestPolyRectangle(DrawablePtr pDrawable, GCPtr pGC, int nRectangles, - xRectangle *pRectangles) + xRectangle *pRectangles) { - XDrawRectangles(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC), - (XRectangle *)pRectangles, nRectangles); + XDrawRectangles(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC), + (XRectangle *) pRectangles, nRectangles); } void -xnestPolyArc(DrawablePtr pDrawable, GCPtr pGC, int nArcs, xArc *pArcs) +xnestPolyArc(DrawablePtr pDrawable, GCPtr pGC, int nArcs, xArc * pArcs) { - XDrawArcs(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC), - (XArc *)pArcs, nArcs); + XDrawArcs(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC), + (XArc *) pArcs, nArcs); } void xnestFillPolygon(DrawablePtr pDrawable, GCPtr pGC, int shape, int mode, - int nPoints, DDXPointPtr pPoints) + int nPoints, DDXPointPtr pPoints) { - XFillPolygon(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC), - (XPoint *)pPoints, nPoints, shape, mode); + XFillPolygon(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC), + (XPoint *) pPoints, nPoints, shape, mode); } void xnestPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nRectangles, - xRectangle *pRectangles) + xRectangle *pRectangles) { - XFillRectangles(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC), - (XRectangle *)pRectangles, nRectangles); + XFillRectangles(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC), + (XRectangle *) pRectangles, nRectangles); } void -xnestPolyFillArc(DrawablePtr pDrawable, GCPtr pGC, int nArcs, xArc *pArcs) +xnestPolyFillArc(DrawablePtr pDrawable, GCPtr pGC, int nArcs, xArc * pArcs) { - XFillArcs(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC), - (XArc *)pArcs, nArcs); + XFillArcs(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC), + (XArc *) pArcs, nArcs); } int xnestPolyText8(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count, - char *string) + char *string) { - int width; - - XDrawString(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC), - x, y, string, count); - - width = XTextWidth(xnestFontStruct(pGC->font), string, count); - - return width + x; + int width; + + XDrawString(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC), + x, y, string, count); + + width = XTextWidth(xnestFontStruct(pGC->font), string, count); + + return width + x; } int xnestPolyText16(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count, - unsigned short *string) + unsigned short *string) { - int width; + int width; - XDrawString16(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC), - x, y, (XChar2b *)string, count); + XDrawString16(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC), + x, y, (XChar2b *) string, count); - width = XTextWidth16(xnestFontStruct(pGC->font), (XChar2b *)string, count); + width = XTextWidth16(xnestFontStruct(pGC->font), (XChar2b *) string, count); - return width + x; + return width + x; } void xnestImageText8(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count, - char *string) + char *string) { - XDrawImageString(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC), - x, y, string, count); + XDrawImageString(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC), + x, y, string, count); } void xnestImageText16(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count, - unsigned short *string) + unsigned short *string) { - XDrawImageString16(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC), - x, y, (XChar2b *)string, count); + XDrawImageString16(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC), + x, y, (XChar2b *) string, count); } void xnestImageGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, int x, int y, - unsigned int nGlyphs, CharInfoPtr *pCharInfo, - pointer pGlyphBase) + unsigned int nGlyphs, CharInfoPtr * pCharInfo, + pointer pGlyphBase) { - ErrorF("xnest warning: function xnestImageGlyphBlt not implemented\n"); + ErrorF("xnest warning: function xnestImageGlyphBlt not implemented\n"); } void xnestPolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, int x, int y, - unsigned int nGlyphs, CharInfoPtr *pCharInfo, - pointer pGlyphBase) + unsigned int nGlyphs, CharInfoPtr * pCharInfo, + pointer pGlyphBase) { - ErrorF("xnest warning: function xnestPolyGlyphBlt not implemented\n"); + ErrorF("xnest warning: function xnestPolyGlyphBlt not implemented\n"); } void xnestPushPixels(GCPtr pGC, PixmapPtr pBitmap, DrawablePtr pDst, - int width, int height, int x, int y) + int width, int height, int x, int y) { - /* only works for solid bitmaps */ - if (pGC->fillStyle == FillSolid) - { - XSetStipple (xnestDisplay, xnestGC(pGC), xnestPixmap(pBitmap)); - XSetTSOrigin (xnestDisplay, xnestGC(pGC), x, y); - XSetFillStyle (xnestDisplay, xnestGC(pGC), FillStippled); - XFillRectangle (xnestDisplay, xnestDrawable(pDst), - xnestGC(pGC), x, y, width, height); - XSetFillStyle (xnestDisplay, xnestGC(pGC), FillSolid); - } - else - ErrorF("xnest warning: function xnestPushPixels not implemented\n"); + /* only works for solid bitmaps */ + if (pGC->fillStyle == FillSolid) { + XSetStipple(xnestDisplay, xnestGC(pGC), xnestPixmap(pBitmap)); + XSetTSOrigin(xnestDisplay, xnestGC(pGC), x, y); + XSetFillStyle(xnestDisplay, xnestGC(pGC), FillStippled); + XFillRectangle(xnestDisplay, xnestDrawable(pDst), + xnestGC(pGC), x, y, width, height); + XSetFillStyle(xnestDisplay, xnestGC(pGC), FillSolid); + } + else + ErrorF("xnest warning: function xnestPushPixels not implemented\n"); } diff --git a/hw/xnest/GCOps.h b/hw/xnest/GCOps.h index ca4cf33f7..b1cad110c 100644 --- a/hw/xnest/GCOps.h +++ b/hw/xnest/GCOps.h @@ -16,53 +16,53 @@ is" without express or implied warranty. #define XNESTGCOPS_H void xnestFillSpans(DrawablePtr pDrawable, GCPtr pGC, int nSpans, - xPoint *pPoints, int *pWidths, int fSorted); + xPoint * pPoints, int *pWidths, int fSorted); void xnestSetSpans(DrawablePtr pDrawable, GCPtr pGC, char *pSrc, - xPoint *pPoints, int *pWidths, int nSpans, int fSorted); + xPoint * pPoints, int *pWidths, int nSpans, int fSorted); void xnestGetSpans(DrawablePtr pDrawable, int maxWidth, DDXPointPtr pPoints, - int *pWidths, int nSpans, char *pBuffer); + int *pWidths, int nSpans, char *pBuffer); void xnestQueryBestSize(int class, unsigned short *pWidth, - unsigned short *pHeight, ScreenPtr pScreen); + unsigned short *pHeight, ScreenPtr pScreen); void xnestPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y, - int w, int h, int leftPad, int format, char *pImage); + int w, int h, int leftPad, int format, char *pImage); void xnestGetImage(DrawablePtr pDrawable, int x, int y, int w, int h, - unsigned int format, unsigned long planeMask, - char *pImage); + unsigned int format, unsigned long planeMask, char *pImage); RegionPtr xnestCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, - GCPtr pGC, int srcx, int srcy, int width, int height, - int dstx, int dsty); + GCPtr pGC, int srcx, int srcy, int width, int height, + int dstx, int dsty); RegionPtr xnestCopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, - GCPtr pGC, int srcx, int srcy, int width, int height, - int dstx, int dsty, unsigned long plane); + GCPtr pGC, int srcx, int srcy, int width, int height, + int dstx, int dsty, unsigned long plane); void xnestPolyPoint(DrawablePtr pDrawable, GCPtr pGC, int mode, int nPoints, - DDXPointPtr pPoints); + DDXPointPtr pPoints); void xnestPolylines(DrawablePtr pDrawable, GCPtr pGC, int mode, int nPoints, - DDXPointPtr pPoints); + DDXPointPtr pPoints); void xnestPolySegment(DrawablePtr pDrawable, GCPtr pGC, int nSegments, - xSegment *pSegments); + xSegment * pSegments); void xnestPolyRectangle(DrawablePtr pDrawable, GCPtr pGC, int nRectangles, - xRectangle *pRectangles); -void xnestPolyArc(DrawablePtr pDrawable, GCPtr pGC, int nArcs, xArc *pArcs); + xRectangle *pRectangles); +void xnestPolyArc(DrawablePtr pDrawable, GCPtr pGC, int nArcs, xArc * pArcs); void xnestFillPolygon(DrawablePtr pDrawable, GCPtr pGC, int shape, int mode, - int nPoints, DDXPointPtr pPoints); + int nPoints, DDXPointPtr pPoints); void xnestPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nRectangles, - xRectangle *pRectangles); -void xnestPolyFillArc(DrawablePtr pDrawable, GCPtr pGC, int nArcs, xArc *pArcs); + xRectangle *pRectangles); +void xnestPolyFillArc(DrawablePtr pDrawable, GCPtr pGC, int nArcs, + xArc * pArcs); int xnestPolyText8(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count, - char *string); + char *string); int xnestPolyText16(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count, - unsigned short *string); + unsigned short *string); void xnestImageText8(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count, - char *string); + char *string); void xnestImageText16(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count, - unsigned short *string); + unsigned short *string); void xnestImageGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, int x, int y, - unsigned int nGlyphs, CharInfoPtr *pCharInfo, - pointer pGlyphBase); + unsigned int nGlyphs, CharInfoPtr * pCharInfo, + pointer pGlyphBase); void xnestPolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, int x, int y, - unsigned int nGlyphs, CharInfoPtr *pCharInfo, - pointer pGlyphBase); + unsigned int nGlyphs, CharInfoPtr * pCharInfo, + pointer pGlyphBase); void xnestPushPixels(GCPtr pGC, PixmapPtr pBitmap, DrawablePtr pDrawable, - int width, int height, int x, int y); + int width, int height, int x, int y); -#endif /* XNESTGCOPS_H */ +#endif /* XNESTGCOPS_H */ diff --git a/hw/xnest/Handlers.c b/hw/xnest/Handlers.c index a113f488a..4605b90bd 100644 --- a/hw/xnest/Handlers.c +++ b/hw/xnest/Handlers.c @@ -34,12 +34,12 @@ is" without express or implied warranty. void xnestBlockHandler(pointer blockData, OSTimePtr pTimeout, pointer pReadMask) { - xnestCollectExposures(); - XFlush(xnestDisplay); + xnestCollectExposures(); + XFlush(xnestDisplay); } void xnestWakeupHandler(pointer blockData, int result, pointer pReadMask) { - xnestCollectEvents(); + xnestCollectEvents(); } diff --git a/hw/xnest/Handlers.h b/hw/xnest/Handlers.h index 16228a0c1..7160bdd13 100644 --- a/hw/xnest/Handlers.h +++ b/hw/xnest/Handlers.h @@ -16,7 +16,7 @@ is" without express or implied warranty. #define XNESTHANDLERS_H void xnestBlockHandler(pointer blockData, OSTimePtr pTimeout, - pointer pReadMask); + pointer pReadMask); void xnestWakeupHandler(pointer blockData, int result, pointer pReadMask); -#endif /* XNESTHANDLERS_H */ +#endif /* XNESTHANDLERS_H */ diff --git a/hw/xnest/Init.c b/hw/xnest/Init.c index af57518ba..0909826d9 100644 --- a/hw/xnest/Init.c +++ b/hw/xnest/Init.c @@ -46,84 +46,86 @@ is" without express or implied warranty. Bool xnestDoFullGeneration = True; void -InitOutput(ScreenInfo *screenInfo, int argc, char *argv[]) +InitOutput(ScreenInfo * screenInfo, int argc, char *argv[]) { - int i, j; - - xnestOpenDisplay(argc, argv); - - screenInfo->imageByteOrder = ImageByteOrder(xnestDisplay); - screenInfo->bitmapScanlineUnit = BitmapUnit(xnestDisplay); - screenInfo->bitmapScanlinePad = BitmapPad(xnestDisplay); - screenInfo->bitmapBitOrder = BitmapBitOrder(xnestDisplay); - - screenInfo->numPixmapFormats = 0; - for (i = 0; i < xnestNumPixmapFormats; i++) - for (j = 0; j < xnestNumDepths; j++) - if ((xnestPixmapFormats[i].depth == 1) || - (xnestPixmapFormats[i].depth == xnestDepths[j])) { - screenInfo->formats[screenInfo->numPixmapFormats].depth = - xnestPixmapFormats[i].depth; - screenInfo->formats[screenInfo->numPixmapFormats].bitsPerPixel = - xnestPixmapFormats[i].bits_per_pixel; - screenInfo->formats[screenInfo->numPixmapFormats].scanlinePad = - xnestPixmapFormats[i].scanline_pad; - screenInfo->numPixmapFormats++; - break; - } - - xnestFontPrivateIndex = AllocateFontPrivateIndex(); - - if (!xnestNumScreens) xnestNumScreens = 1; - - for (i = 0; i < xnestNumScreens; i++) - AddScreen(xnestOpenScreen, argc, argv); - - xnestNumScreens = screenInfo->numScreens; - - xnestDoFullGeneration = xnestFullGeneration; + int i, j; + + xnestOpenDisplay(argc, argv); + + screenInfo->imageByteOrder = ImageByteOrder(xnestDisplay); + screenInfo->bitmapScanlineUnit = BitmapUnit(xnestDisplay); + screenInfo->bitmapScanlinePad = BitmapPad(xnestDisplay); + screenInfo->bitmapBitOrder = BitmapBitOrder(xnestDisplay); + + screenInfo->numPixmapFormats = 0; + for (i = 0; i < xnestNumPixmapFormats; i++) + for (j = 0; j < xnestNumDepths; j++) + if ((xnestPixmapFormats[i].depth == 1) || + (xnestPixmapFormats[i].depth == xnestDepths[j])) { + screenInfo->formats[screenInfo->numPixmapFormats].depth = + xnestPixmapFormats[i].depth; + screenInfo->formats[screenInfo->numPixmapFormats].bitsPerPixel = + xnestPixmapFormats[i].bits_per_pixel; + screenInfo->formats[screenInfo->numPixmapFormats].scanlinePad = + xnestPixmapFormats[i].scanline_pad; + screenInfo->numPixmapFormats++; + break; + } + + xnestFontPrivateIndex = AllocateFontPrivateIndex(); + + if (!xnestNumScreens) + xnestNumScreens = 1; + + for (i = 0; i < xnestNumScreens; i++) + AddScreen(xnestOpenScreen, argc, argv); + + xnestNumScreens = screenInfo->numScreens; + + xnestDoFullGeneration = xnestFullGeneration; } void InitInput(int argc, char *argv[]) { - int rc; - rc = AllocDevicePair(serverClient, "Xnest", - &xnestPointerDevice, - &xnestKeyboardDevice, - xnestPointerProc, - xnestKeyboardProc, - FALSE); + int rc; + + rc = AllocDevicePair(serverClient, "Xnest", + &xnestPointerDevice, + &xnestKeyboardDevice, + xnestPointerProc, xnestKeyboardProc, FALSE); - if (rc != Success) - FatalError("Failed to init Xnest default devices.\n"); + if (rc != Success) + FatalError("Failed to init Xnest default devices.\n"); - mieqInit(); + mieqInit(); - AddEnabledDevice(XConnectionNumber(xnestDisplay)); + AddEnabledDevice(XConnectionNumber(xnestDisplay)); - RegisterBlockAndWakeupHandlers(xnestBlockHandler, xnestWakeupHandler, NULL); + RegisterBlockAndWakeupHandlers(xnestBlockHandler, xnestWakeupHandler, NULL); } void CloseInput(void) { - mieqFini(); + mieqFini(); } /* * DDX - specific abort routine. Called by AbortServer(). */ -void AbortDDX(enum ExitCode error) +void +AbortDDX(enum ExitCode error) { - xnestDoFullGeneration = True; - xnestCloseDisplay(); + xnestDoFullGeneration = True; + xnestCloseDisplay(); } /* Called by GiveUp(). */ -void ddxGiveUp(enum ExitCode error) +void +ddxGiveUp(enum ExitCode error) { - AbortDDX(error); + AbortDDX(error); } #ifdef __APPLE__ @@ -133,18 +135,21 @@ DarwinHandleGUI(int argc, char *argv[]) } #endif -void OsVendorInit(void) +void +OsVendorInit(void) { return; } -void OsVendorFatalError(void) +void +OsVendorFatalError(void) { return; } #if defined(DDXBEFORERESET) -void ddxBeforeReset(void) +void +ddxBeforeReset(void) { return; } diff --git a/hw/xnest/Init.h b/hw/xnest/Init.h index 4bed0ee67..7c0291ebf 100644 --- a/hw/xnest/Init.h +++ b/hw/xnest/Init.h @@ -17,4 +17,4 @@ is" without express or implied warranty. extern Bool xnestDoFullGeneration; -#endif /* XNESTINIT_H */ +#endif /* XNESTINIT_H */ diff --git a/hw/xnest/Keyboard.c b/hw/xnest/Keyboard.c index 5ef376b91..d013dc91e 100644 --- a/hw/xnest/Keyboard.c +++ b/hw/xnest/Keyboard.c @@ -38,231 +38,230 @@ is" without express or implied warranty. #include <X11/extensions/XKBconfig.h> extern Bool -XkbQueryExtension( - Display * /* dpy */, - int * /* opcodeReturn */, - int * /* eventBaseReturn */, - int * /* errorBaseReturn */, - int * /* majorRtrn */, - int * /* minorRtrn */ -); - -extern XkbDescPtr XkbGetKeyboard( - Display * /* dpy */, - unsigned int /* which */, - unsigned int /* deviceSpec */ -); - -extern Status XkbGetControls( - Display * /* dpy */, - unsigned long /* which */, - XkbDescPtr /* desc */ -); + XkbQueryExtension(Display * /* dpy */ , + int * /* opcodeReturn */ , + int * /* eventBaseReturn */ , + int * /* errorBaseReturn */ , + int * /* majorRtrn */ , + int * /* minorRtrn */ + ); + +extern XkbDescPtr XkbGetKeyboard(Display * /* dpy */ , + unsigned int /* which */ , + unsigned int /* deviceSpec */ + ); + +extern Status XkbGetControls(Display * /* dpy */ , + unsigned long /* which */ , + XkbDescPtr /* desc */ + ); DeviceIntPtr xnestKeyboardDevice = NULL; void xnestBell(int volume, DeviceIntPtr pDev, pointer ctrl, int cls) { - XBell(xnestDisplay, volume); + XBell(xnestDisplay, volume); } void DDXRingBell(int volume, int pitch, int duration) { - XBell(xnestDisplay, volume); + XBell(xnestDisplay, volume); } void -xnestChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl) +xnestChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl * ctrl) { #if 0 - unsigned long value_mask; - XKeyboardControl values; - int i; - - value_mask = KBKeyClickPercent | - KBBellPercent | - KBBellPitch | - KBBellDuration | - KBAutoRepeatMode; - - values.key_click_percent = ctrl->click; - values.bell_percent = ctrl->bell; - values.bell_pitch = ctrl->bell_pitch; - values.bell_duration = ctrl->bell_duration; - values.auto_repeat_mode = ctrl->autoRepeat ? - AutoRepeatModeOn : AutoRepeatModeOff; - - XChangeKeyboardControl(xnestDisplay, value_mask, &values); - - /* - value_mask = KBKey | KBAutoRepeatMode; - At this point, we need to walk through the vector and compare it - to the current server vector. If there are differences, report them. - */ - - value_mask = KBLed | KBLedMode; - for (i = 1; i <= 32; i++) { - values.led = i; - values.led_mode = (ctrl->leds & (1 << (i - 1))) ? LedModeOn : LedModeOff; + unsigned long value_mask; + XKeyboardControl values; + int i; + + value_mask = KBKeyClickPercent | + KBBellPercent | KBBellPitch | KBBellDuration | KBAutoRepeatMode; + + values.key_click_percent = ctrl->click; + values.bell_percent = ctrl->bell; + values.bell_pitch = ctrl->bell_pitch; + values.bell_duration = ctrl->bell_duration; + values.auto_repeat_mode = ctrl->autoRepeat ? + AutoRepeatModeOn : AutoRepeatModeOff; + XChangeKeyboardControl(xnestDisplay, value_mask, &values); - } + + /* + value_mask = KBKey | KBAutoRepeatMode; + At this point, we need to walk through the vector and compare it + to the current server vector. If there are differences, report them. + */ + + value_mask = KBLed | KBLedMode; + for (i = 1; i <= 32; i++) { + values.led = i; + values.led_mode = + (ctrl->leds & (1 << (i - 1))) ? LedModeOn : LedModeOff; + XChangeKeyboardControl(xnestDisplay, value_mask, &values); + } #endif } int xnestKeyboardProc(DeviceIntPtr pDev, int onoff) { - XModifierKeymap *modifier_keymap; - KeySym *keymap; - int mapWidth; - int min_keycode, max_keycode; - KeySymsRec keySyms; - CARD8 modmap[MAP_LENGTH]; - int i, j; - XKeyboardState values; - XkbDescPtr xkb; - int op, event, error, major, minor; - - switch (onoff) - { - case DEVICE_INIT: - XDisplayKeycodes(xnestDisplay, &min_keycode, &max_keycode); + XModifierKeymap *modifier_keymap; + KeySym *keymap; + int mapWidth; + int min_keycode, max_keycode; + KeySymsRec keySyms; + CARD8 modmap[MAP_LENGTH]; + int i, j; + XKeyboardState values; + XkbDescPtr xkb; + int op, event, error, major, minor; + + switch (onoff) { + case DEVICE_INIT: + XDisplayKeycodes(xnestDisplay, &min_keycode, &max_keycode); #ifdef _XSERVER64 - { - KeySym64 *keymap64; - int len; - keymap64 = XGetKeyboardMapping(xnestDisplay, - min_keycode, - max_keycode - min_keycode + 1, - &mapWidth); - len = (max_keycode - min_keycode + 1) * mapWidth; - keymap = (KeySym *)malloc(len * sizeof(KeySym)); - for(i = 0; i < len; ++i) - keymap[i] = keymap64[i]; - XFree(keymap64); - } + { + KeySym64 *keymap64; + int len; + + keymap64 = XGetKeyboardMapping(xnestDisplay, + min_keycode, + max_keycode - min_keycode + 1, + &mapWidth); + len = (max_keycode - min_keycode + 1) * mapWidth; + keymap = (KeySym *) malloc(len * sizeof(KeySym)); + for (i = 0; i < len; ++i) + keymap[i] = keymap64[i]; + XFree(keymap64); + } #else - keymap = XGetKeyboardMapping(xnestDisplay, - min_keycode, - max_keycode - min_keycode + 1, - &mapWidth); + keymap = XGetKeyboardMapping(xnestDisplay, + min_keycode, + max_keycode - min_keycode + 1, &mapWidth); #endif - memset(modmap, 0, sizeof(modmap)); - modifier_keymap = XGetModifierMapping(xnestDisplay); - for (j = 0; j < 8; j++) - for(i = 0; i < modifier_keymap->max_keypermod; i++) { - CARD8 keycode; - if ((keycode = modifier_keymap->modifiermap[j * modifier_keymap->max_keypermod + i])) - modmap[keycode] |= 1<<j; - } - XFreeModifiermap(modifier_keymap); - - keySyms.minKeyCode = min_keycode; - keySyms.maxKeyCode = max_keycode; - keySyms.mapWidth = mapWidth; - keySyms.map = keymap; - - if (XkbQueryExtension(xnestDisplay, &op, &event, &error, &major, &minor) == 0) { - ErrorF("Unable to initialize XKEYBOARD extension.\n"); - goto XkbError; - } - xkb = XkbGetKeyboard(xnestDisplay, XkbGBN_AllComponentsMask, XkbUseCoreKbd); - if (xkb == NULL || xkb->geom == NULL) { - ErrorF("Couldn't get keyboard.\n"); - goto XkbError; - } - XkbGetControls(xnestDisplay, XkbAllControlsMask, xkb); - - InitKeyboardDeviceStruct(pDev, NULL, - xnestBell, xnestChangeKeyboardControl); - - XkbApplyMappingChange(pDev, &keySyms, keySyms.minKeyCode, - keySyms.maxKeyCode - keySyms.minKeyCode + 1, - modmap, serverClient); - - XkbDDXChangeControls(pDev, xkb->ctrls, xkb->ctrls); - XkbFreeKeyboard(xkb, 0, False); - free(keymap); - break; - case DEVICE_ON: - xnestEventMask |= XNEST_KEYBOARD_EVENT_MASK; - for (i = 0; i < xnestNumScreens; i++) - XSelectInput(xnestDisplay, xnestDefaultWindows[i], xnestEventMask); - break; - case DEVICE_OFF: - xnestEventMask &= ~XNEST_KEYBOARD_EVENT_MASK; - for (i = 0; i < xnestNumScreens; i++) - XSelectInput(xnestDisplay, xnestDefaultWindows[i], xnestEventMask); - break; - case DEVICE_CLOSE: - break; + memset(modmap, 0, sizeof(modmap)); + modifier_keymap = XGetModifierMapping(xnestDisplay); + for (j = 0; j < 8; j++) + for (i = 0; i < modifier_keymap->max_keypermod; i++) { + CARD8 keycode; + + if ((keycode = + modifier_keymap->modifiermap[j * + modifier_keymap-> + max_keypermod + i])) + modmap[keycode] |= 1 << j; + } + XFreeModifiermap(modifier_keymap); + + keySyms.minKeyCode = min_keycode; + keySyms.maxKeyCode = max_keycode; + keySyms.mapWidth = mapWidth; + keySyms.map = keymap; + + if (XkbQueryExtension(xnestDisplay, &op, &event, &error, &major, &minor) + == 0) { + ErrorF("Unable to initialize XKEYBOARD extension.\n"); + goto XkbError; + } + xkb = + XkbGetKeyboard(xnestDisplay, XkbGBN_AllComponentsMask, + XkbUseCoreKbd); + if (xkb == NULL || xkb->geom == NULL) { + ErrorF("Couldn't get keyboard.\n"); + goto XkbError; + } + XkbGetControls(xnestDisplay, XkbAllControlsMask, xkb); + + InitKeyboardDeviceStruct(pDev, NULL, + xnestBell, xnestChangeKeyboardControl); + + XkbApplyMappingChange(pDev, &keySyms, keySyms.minKeyCode, + keySyms.maxKeyCode - keySyms.minKeyCode + 1, + modmap, serverClient); + + XkbDDXChangeControls(pDev, xkb->ctrls, xkb->ctrls); + XkbFreeKeyboard(xkb, 0, False); + free(keymap); + break; + case DEVICE_ON: + xnestEventMask |= XNEST_KEYBOARD_EVENT_MASK; + for (i = 0; i < xnestNumScreens; i++) + XSelectInput(xnestDisplay, xnestDefaultWindows[i], xnestEventMask); + break; + case DEVICE_OFF: + xnestEventMask &= ~XNEST_KEYBOARD_EVENT_MASK; + for (i = 0; i < xnestNumScreens; i++) + XSelectInput(xnestDisplay, xnestDefaultWindows[i], xnestEventMask); + break; + case DEVICE_CLOSE: + break; } - return Success; - -XkbError: - XGetKeyboardControl(xnestDisplay, &values); - memmove((char *)defaultKeyboardControl.autoRepeats, - (char *)values.auto_repeats, - sizeof(values.auto_repeats)); - - InitKeyboardDeviceStruct(pDev, NULL, - xnestBell, xnestChangeKeyboardControl); - free(keymap); - return Success; + return Success; + + XkbError: + XGetKeyboardControl(xnestDisplay, &values); + memmove((char *) defaultKeyboardControl.autoRepeats, + (char *) values.auto_repeats, sizeof(values.auto_repeats)); + + InitKeyboardDeviceStruct(pDev, NULL, xnestBell, xnestChangeKeyboardControl); + free(keymap); + return Success; } Bool LegalModifier(unsigned int key, DeviceIntPtr pDev) { - return TRUE; + return TRUE; } void xnestUpdateModifierState(unsigned int state) { - DeviceIntPtr pDev = xnestKeyboardDevice; - KeyClassPtr keyc = pDev->key; - int i; - CARD8 mask; - int xkb_state; - - if (!pDev) - return; - - xkb_state = XkbStateFieldFromRec(&pDev->key->xkbInfo->state); - state = state & 0xff; - - if (xkb_state == state) - return; - - for (i = 0, mask = 1; i < 8; i++, mask <<= 1) { - int key; - - /* Modifier is down, but shouldn't be - */ - if ((xkb_state & mask) && !(state & mask)) { - int count = keyc->modifierKeyCount[i]; - - for (key = 0; key < MAP_LENGTH; key++) - if (keyc->xkbInfo->desc->map->modmap[key] & mask) { - if (key_is_down(pDev, key, KEY_PROCESSED)) - xnestQueueKeyEvent(KeyRelease, key); - - if (--count == 0) - break; - } + DeviceIntPtr pDev = xnestKeyboardDevice; + KeyClassPtr keyc = pDev->key; + int i; + CARD8 mask; + int xkb_state; + + if (!pDev) + return; + + xkb_state = XkbStateFieldFromRec(&pDev->key->xkbInfo->state); + state = state & 0xff; + + if (xkb_state == state) + return; + + for (i = 0, mask = 1; i < 8; i++, mask <<= 1) { + int key; + + /* Modifier is down, but shouldn't be + */ + if ((xkb_state & mask) && !(state & mask)) { + int count = keyc->modifierKeyCount[i]; + + for (key = 0; key < MAP_LENGTH; key++) + if (keyc->xkbInfo->desc->map->modmap[key] & mask) { + if (key_is_down(pDev, key, KEY_PROCESSED)) + xnestQueueKeyEvent(KeyRelease, key); + + if (--count == 0) + break; + } + } + + /* Modifier shoud be down, but isn't + */ + if (!(xkb_state & mask) && (state & mask)) + for (key = 0; key < MAP_LENGTH; key++) + if (keyc->xkbInfo->desc->map->modmap[key] & mask) { + xnestQueueKeyEvent(KeyPress, key); + break; + } } - - /* Modifier shoud be down, but isn't - */ - if (!(xkb_state & mask) && (state & mask)) - for (key = 0; key < MAP_LENGTH; key++) - if (keyc->xkbInfo->desc->map->modmap[key] & mask) { - xnestQueueKeyEvent(KeyPress, key); - break; - } - } } diff --git a/hw/xnest/Keyboard.h b/hw/xnest/Keyboard.h index 546a1cbe4..45d56bc08 100644 --- a/hw/xnest/Keyboard.h +++ b/hw/xnest/Keyboard.h @@ -21,8 +21,8 @@ is" without express or implied warranty. extern DeviceIntPtr xnestKeyboardDevice; void xnestBell(int volume, DeviceIntPtr pDev, pointer ctrl, int cls); -void xnestChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl); +void xnestChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl * ctrl); int xnestKeyboardProc(DeviceIntPtr pDev, int onoff); void xnestUpdateModifierState(unsigned int state); -#endif /* XNESTKEYBOARD_H */ +#endif /* XNESTKEYBOARD_H */ diff --git a/hw/xnest/Pixmap.c b/hw/xnest/Pixmap.c index eccf56986..13e1610fd 100644 --- a/hw/xnest/Pixmap.c +++ b/hw/xnest/Pixmap.c @@ -36,101 +36,101 @@ DevPrivateKeyRec xnestPixmapPrivateKeyRec; PixmapPtr xnestCreatePixmap(ScreenPtr pScreen, int width, int height, int depth, - unsigned usage_hint) + unsigned usage_hint) { - PixmapPtr pPixmap; - - pPixmap = AllocatePixmap(pScreen, 0); - if (!pPixmap) - return NullPixmap; - pPixmap->drawable.type = DRAWABLE_PIXMAP; - pPixmap->drawable.class = 0; - pPixmap->drawable.depth = depth; - pPixmap->drawable.bitsPerPixel = depth; - pPixmap->drawable.id = 0; - pPixmap->drawable.x = 0; - pPixmap->drawable.y = 0; - pPixmap->drawable.width = width; - pPixmap->drawable.height = height; - pPixmap->drawable.pScreen = pScreen; - pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER; - pPixmap->refcnt = 1; - pPixmap->devKind = PixmapBytePad(width, depth); - pPixmap->usage_hint = usage_hint; - if (width && height) - xnestPixmapPriv(pPixmap)->pixmap = - XCreatePixmap(xnestDisplay, - xnestDefaultWindows[pScreen->myNum], - width, height, depth); - else - xnestPixmapPriv(pPixmap)->pixmap = 0; - - return pPixmap; + PixmapPtr pPixmap; + + pPixmap = AllocatePixmap(pScreen, 0); + if (!pPixmap) + return NullPixmap; + pPixmap->drawable.type = DRAWABLE_PIXMAP; + pPixmap->drawable.class = 0; + pPixmap->drawable.depth = depth; + pPixmap->drawable.bitsPerPixel = depth; + pPixmap->drawable.id = 0; + pPixmap->drawable.x = 0; + pPixmap->drawable.y = 0; + pPixmap->drawable.width = width; + pPixmap->drawable.height = height; + pPixmap->drawable.pScreen = pScreen; + pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER; + pPixmap->refcnt = 1; + pPixmap->devKind = PixmapBytePad(width, depth); + pPixmap->usage_hint = usage_hint; + if (width && height) + xnestPixmapPriv(pPixmap)->pixmap = + XCreatePixmap(xnestDisplay, + xnestDefaultWindows[pScreen->myNum], + width, height, depth); + else + xnestPixmapPriv(pPixmap)->pixmap = 0; + + return pPixmap; } Bool xnestDestroyPixmap(PixmapPtr pPixmap) { - if(--pPixmap->refcnt) + if (--pPixmap->refcnt) + return TRUE; + XFreePixmap(xnestDisplay, xnestPixmap(pPixmap)); + FreePixmap(pPixmap); return TRUE; - XFreePixmap(xnestDisplay, xnestPixmap(pPixmap)); - FreePixmap(pPixmap); - return TRUE; } RegionPtr xnestPixmapToRegion(PixmapPtr pPixmap) { - XImage *ximage; - register RegionPtr pReg, pTmpReg; - register int x, y; - unsigned long previousPixel, currentPixel; - BoxRec Box = { 0, 0, 0, 0 }; - Bool overlap; - - ximage = XGetImage(xnestDisplay, xnestPixmap(pPixmap), 0, 0, - pPixmap->drawable.width, pPixmap->drawable.height, - 1, XYPixmap); - - pReg = RegionCreate(NULL, 1); - pTmpReg = RegionCreate(NULL, 1); - if(!pReg || !pTmpReg) { - XDestroyImage(ximage); - return NullRegion; - } - - for (y = 0; y < pPixmap->drawable.height; y++) { - Box.y1 = y; - Box.y2 = y + 1; - previousPixel = 0L; - for (x = 0; x < pPixmap->drawable.width; x++) { - currentPixel = XGetPixel(ximage, x, y); - if (previousPixel != currentPixel) { - if (previousPixel == 0L) { - /* left edge */ - Box.x1 = x; - } - else if (currentPixel == 0L) { - /* right edge */ - Box.x2 = x; - RegionReset(pTmpReg, &Box); - RegionAppend(pReg, pTmpReg); - } - previousPixel = currentPixel; - } + XImage *ximage; + register RegionPtr pReg, pTmpReg; + register int x, y; + unsigned long previousPixel, currentPixel; + BoxRec Box = { 0, 0, 0, 0 }; + Bool overlap; + + ximage = XGetImage(xnestDisplay, xnestPixmap(pPixmap), 0, 0, + pPixmap->drawable.width, pPixmap->drawable.height, + 1, XYPixmap); + + pReg = RegionCreate(NULL, 1); + pTmpReg = RegionCreate(NULL, 1); + if (!pReg || !pTmpReg) { + XDestroyImage(ximage); + return NullRegion; } - if (previousPixel != 0L) { - /* right edge because of the end of pixmap */ - Box.x2 = pPixmap->drawable.width; - RegionReset(pTmpReg, &Box); - RegionAppend(pReg, pTmpReg); + + for (y = 0; y < pPixmap->drawable.height; y++) { + Box.y1 = y; + Box.y2 = y + 1; + previousPixel = 0L; + for (x = 0; x < pPixmap->drawable.width; x++) { + currentPixel = XGetPixel(ximage, x, y); + if (previousPixel != currentPixel) { + if (previousPixel == 0L) { + /* left edge */ + Box.x1 = x; + } + else if (currentPixel == 0L) { + /* right edge */ + Box.x2 = x; + RegionReset(pTmpReg, &Box); + RegionAppend(pReg, pTmpReg); + } + previousPixel = currentPixel; + } + } + if (previousPixel != 0L) { + /* right edge because of the end of pixmap */ + Box.x2 = pPixmap->drawable.width; + RegionReset(pTmpReg, &Box); + RegionAppend(pReg, pTmpReg); + } } - } - - RegionDestroy(pTmpReg); - XDestroyImage(ximage); - RegionValidate(pReg, &overlap); + RegionDestroy(pTmpReg); + XDestroyImage(ximage); + + RegionValidate(pReg, &overlap); - return pReg; + return pReg; } diff --git a/hw/xnest/Pointer.c b/hw/xnest/Pointer.c index fdc6181e9..a2ee90064 100644 --- a/hw/xnest/Pointer.c +++ b/hw/xnest/Pointer.c @@ -34,64 +34,63 @@ is" without express or implied warranty. #include "Args.h" #include "xserver-properties.h" -#include "exevents.h" /* For XIGetKnownProperty */ +#include "exevents.h" /* For XIGetKnownProperty */ DeviceIntPtr xnestPointerDevice = NULL; void -xnestChangePointerControl(DeviceIntPtr pDev, PtrCtrl *ctrl) +xnestChangePointerControl(DeviceIntPtr pDev, PtrCtrl * ctrl) { - XChangePointerControl(xnestDisplay, True, True, - ctrl->num, ctrl->den, ctrl->threshold); + XChangePointerControl(xnestDisplay, True, True, + ctrl->num, ctrl->den, ctrl->threshold); } int xnestPointerProc(DeviceIntPtr pDev, int onoff) { - CARD8 map[MAXBUTTONS]; - Atom btn_labels[MAXBUTTONS] = {0}; - Atom axes_labels[2] = {0}; - int nmap; - int i; + CARD8 map[MAXBUTTONS]; + Atom btn_labels[MAXBUTTONS] = { 0 }; + Atom axes_labels[2] = { 0 }; + int nmap; + int i; - switch (onoff) - { - case DEVICE_INIT: - nmap = XGetPointerMapping(xnestDisplay, map, MAXBUTTONS); - for (i = 0; i <= nmap; i++) - map[i] = i; /* buttons are already mapped */ + switch (onoff) { + case DEVICE_INIT: + nmap = XGetPointerMapping(xnestDisplay, map, MAXBUTTONS); + for (i = 0; i <= nmap; i++) + map[i] = i; /* buttons are already mapped */ - btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT); - btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE); - btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT); - btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP); - btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN); - btn_labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT); - btn_labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT); + btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT); + btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE); + btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT); + btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP); + btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN); + btn_labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT); + btn_labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT); - axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X); - axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y); + axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X); + axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y); - XGetPointerControl(xnestDisplay, - &defaultPointerControl.num, - &defaultPointerControl.den, - &defaultPointerControl.threshold); - InitPointerDeviceStruct(&pDev->public, map, nmap, btn_labels, - xnestChangePointerControl, - GetMotionHistorySize(), 2, axes_labels); - break; - case DEVICE_ON: - xnestEventMask |= XNEST_POINTER_EVENT_MASK; - for (i = 0; i < xnestNumScreens; i++) - XSelectInput(xnestDisplay, xnestDefaultWindows[i], xnestEventMask); - break; - case DEVICE_OFF: - xnestEventMask &= ~XNEST_POINTER_EVENT_MASK; - for (i = 0; i < xnestNumScreens; i++) - XSelectInput(xnestDisplay, xnestDefaultWindows[i], xnestEventMask); - break; - case DEVICE_CLOSE: - break; + XGetPointerControl(xnestDisplay, + &defaultPointerControl.num, + &defaultPointerControl.den, + &defaultPointerControl.threshold); + InitPointerDeviceStruct(&pDev->public, map, nmap, btn_labels, + xnestChangePointerControl, + GetMotionHistorySize(), 2, axes_labels); + break; + case DEVICE_ON: + xnestEventMask |= XNEST_POINTER_EVENT_MASK; + for (i = 0; i < xnestNumScreens; i++) + XSelectInput(xnestDisplay, xnestDefaultWindows[i], xnestEventMask); + break; + case DEVICE_OFF: + xnestEventMask &= ~XNEST_POINTER_EVENT_MASK; + for (i = 0; i < xnestNumScreens; i++) + XSelectInput(xnestDisplay, xnestDefaultWindows[i], xnestEventMask); + break; + case DEVICE_CLOSE: + break; } - return Success; + return Success; } diff --git a/hw/xnest/Pointer.h b/hw/xnest/Pointer.h index 890726f55..d0047c517 100644 --- a/hw/xnest/Pointer.h +++ b/hw/xnest/Pointer.h @@ -23,7 +23,7 @@ is" without express or implied warranty. extern DeviceIntPtr xnestPointerDevice; -void xnestChangePointerControl(DeviceIntPtr pDev, PtrCtrl *ctrl); +void xnestChangePointerControl(DeviceIntPtr pDev, PtrCtrl * ctrl); int xnestPointerProc(DeviceIntPtr pDev, int onoff); -#endif /* XNESTPOINTER_H */ +#endif /* XNESTPOINTER_H */ diff --git a/hw/xnest/Screen.c b/hw/xnest/Screen.c index d0c7fc8b0..dd76cb801 100644 --- a/hw/xnest/Screen.c +++ b/hw/xnest/Screen.c @@ -50,56 +50,56 @@ DevPrivateKeyRec xnestCursorScreenKeyRec; ScreenPtr xnestScreen(Window window) { - int i; - - for (i = 0; i < xnestNumScreens; i++) - if (xnestDefaultWindows[i] == window) - return screenInfo.screens[i]; + int i; - return NULL; + for (i = 0; i < xnestNumScreens; i++) + if (xnestDefaultWindows[i] == window) + return screenInfo.screens[i]; + + return NULL; } static int offset(unsigned long mask) { - int count; - - for (count = 0; !(mask & 1) && count < 32; count++) - mask >>= 1; - - return count; + int count; + + for (count = 0; !(mask & 1) && count < 32; count++) + mask >>= 1; + + return count; } static Bool xnestSaveScreen(ScreenPtr pScreen, int what) { - if (xnestSoftwareScreenSaver) - return False; - else { - switch (what) { - case SCREEN_SAVER_ON: - XMapRaised(xnestDisplay, xnestScreenSaverWindows[pScreen->myNum]); - xnestSetScreenSaverColormapWindow(pScreen); - break; - - case SCREEN_SAVER_OFF: - XUnmapWindow(xnestDisplay, xnestScreenSaverWindows[pScreen->myNum]); - xnestSetInstalledColormapWindows(pScreen); - break; - - case SCREEN_SAVER_FORCER: - lastEventTime = GetTimeInMillis(); - XUnmapWindow(xnestDisplay, xnestScreenSaverWindows[pScreen->myNum]); - xnestSetInstalledColormapWindows(pScreen); - break; - - case SCREEN_SAVER_CYCLE: - XUnmapWindow(xnestDisplay, xnestScreenSaverWindows[pScreen->myNum]); - xnestSetInstalledColormapWindows(pScreen); - break; + if (xnestSoftwareScreenSaver) + return False; + else { + switch (what) { + case SCREEN_SAVER_ON: + XMapRaised(xnestDisplay, xnestScreenSaverWindows[pScreen->myNum]); + xnestSetScreenSaverColormapWindow(pScreen); + break; + + case SCREEN_SAVER_OFF: + XUnmapWindow(xnestDisplay, xnestScreenSaverWindows[pScreen->myNum]); + xnestSetInstalledColormapWindows(pScreen); + break; + + case SCREEN_SAVER_FORCER: + lastEventTime = GetTimeInMillis(); + XUnmapWindow(xnestDisplay, xnestScreenSaverWindows[pScreen->myNum]); + xnestSetInstalledColormapWindows(pScreen); + break; + + case SCREEN_SAVER_CYCLE: + XUnmapWindow(xnestDisplay, xnestScreenSaverWindows[pScreen->myNum]); + xnestSetInstalledColormapWindows(pScreen); + break; + } + return True; } - return True; - } } static Bool @@ -113,15 +113,13 @@ xnestCrossScreen(ScreenPtr pScreen, Bool entering) { } -static miPointerScreenFuncRec xnestPointerCursorFuncs = -{ +static miPointerScreenFuncRec xnestPointerCursorFuncs = { xnestCursorOffScreen, xnestCrossScreen, miPointerWarpCursor }; -static miPointerSpriteFuncRec xnestPointerSpriteFuncs = -{ +static miPointerSpriteFuncRec xnestPointerSpriteFuncs = { xnestRealizeCursor, xnestUnrealizeCursor, xnestSetCursor, @@ -133,290 +131,298 @@ static miPointerSpriteFuncRec xnestPointerSpriteFuncs = Bool xnestOpenScreen(int index, ScreenPtr pScreen, int argc, char *argv[]) { - VisualPtr visuals; - DepthPtr depths; - int numVisuals, numDepths; - int i, j, depthIndex; - unsigned long valuemask; - XSetWindowAttributes attributes; - XWindowAttributes gattributes; - XSizeHints sizeHints; - VisualID defaultVisual; - int rootDepth; - miPointerScreenPtr PointPriv; - - if (!dixRegisterPrivateKey(&xnestWindowPrivateKeyRec, PRIVATE_WINDOW, sizeof(xnestPrivWin))) - return FALSE; - if (!dixRegisterPrivateKey(&xnestGCPrivateKeyRec, PRIVATE_GC, sizeof(xnestPrivGC))) - return FALSE; - if (!dixRegisterPrivateKey(&xnestPixmapPrivateKeyRec, PRIVATE_PIXMAP, sizeof (xnestPrivPixmap))) - return FALSE; - if (!dixRegisterPrivateKey(&xnestColormapPrivateKeyRec, PRIVATE_COLORMAP, sizeof (xnestPrivColormap))) - return FALSE; - if (!dixRegisterPrivateKey(&xnestCursorScreenKeyRec, PRIVATE_SCREEN, 0)) - return FALSE; - - visuals = (VisualPtr)malloc(xnestNumVisuals * sizeof(VisualRec)); - numVisuals = 0; - - depths = (DepthPtr)malloc(MAXDEPTH * sizeof(DepthRec)); - depths[0].depth = 1; - depths[0].numVids = 0; - depths[0].vids = (VisualID *)malloc(MAXVISUALSPERDEPTH * sizeof(VisualID)); - numDepths = 1; - - for (i = 0; i < xnestNumVisuals; i++) { - visuals[numVisuals].class = xnestVisuals[i].class; - visuals[numVisuals].bitsPerRGBValue = xnestVisuals[i].bits_per_rgb; - visuals[numVisuals].ColormapEntries = xnestVisuals[i].colormap_size; - visuals[numVisuals].nplanes = xnestVisuals[i].depth; - visuals[numVisuals].redMask = xnestVisuals[i].red_mask; - visuals[numVisuals].greenMask = xnestVisuals[i].green_mask; - visuals[numVisuals].blueMask = xnestVisuals[i].blue_mask; - visuals[numVisuals].offsetRed = offset(xnestVisuals[i].red_mask); - visuals[numVisuals].offsetGreen = offset(xnestVisuals[i].green_mask); - visuals[numVisuals].offsetBlue = offset(xnestVisuals[i].blue_mask); - - /* Check for and remove duplicates. */ - for (j = 0; j < numVisuals; j++) { - if (visuals[numVisuals].class == visuals[j].class && - visuals[numVisuals].bitsPerRGBValue == visuals[j].bitsPerRGBValue && - visuals[numVisuals].ColormapEntries == visuals[j].ColormapEntries && - visuals[numVisuals].nplanes == visuals[j].nplanes && - visuals[numVisuals].redMask == visuals[j].redMask && - visuals[numVisuals].greenMask == visuals[j].greenMask && - visuals[numVisuals].blueMask == visuals[j].blueMask && - visuals[numVisuals].offsetRed == visuals[j].offsetRed && - visuals[numVisuals].offsetGreen == visuals[j].offsetGreen && - visuals[numVisuals].offsetBlue == visuals[j].offsetBlue) - break; - } - if (j < numVisuals) - break; - - visuals[numVisuals].vid = FakeClientID(0); - - depthIndex = UNDEFINED; - for (j = 0; j < numDepths; j++) - if (depths[j].depth == xnestVisuals[i].depth) { - depthIndex = j; - break; - } - - if (depthIndex == UNDEFINED) { - depthIndex = numDepths; - depths[depthIndex].depth = xnestVisuals[i].depth; - depths[depthIndex].numVids = 0; - depths[depthIndex].vids = - (VisualID *)malloc(MAXVISUALSPERDEPTH * sizeof(VisualID)); - numDepths++; + VisualPtr visuals; + DepthPtr depths; + int numVisuals, numDepths; + int i, j, depthIndex; + unsigned long valuemask; + XSetWindowAttributes attributes; + XWindowAttributes gattributes; + XSizeHints sizeHints; + VisualID defaultVisual; + int rootDepth; + miPointerScreenPtr PointPriv; + + if (!dixRegisterPrivateKey + (&xnestWindowPrivateKeyRec, PRIVATE_WINDOW, sizeof(xnestPrivWin))) + return FALSE; + if (!dixRegisterPrivateKey + (&xnestGCPrivateKeyRec, PRIVATE_GC, sizeof(xnestPrivGC))) + return FALSE; + if (!dixRegisterPrivateKey + (&xnestPixmapPrivateKeyRec, PRIVATE_PIXMAP, sizeof(xnestPrivPixmap))) + return FALSE; + if (!dixRegisterPrivateKey + (&xnestColormapPrivateKeyRec, PRIVATE_COLORMAP, + sizeof(xnestPrivColormap))) + return FALSE; + if (!dixRegisterPrivateKey(&xnestCursorScreenKeyRec, PRIVATE_SCREEN, 0)) + return FALSE; + + visuals = (VisualPtr) malloc(xnestNumVisuals * sizeof(VisualRec)); + numVisuals = 0; + + depths = (DepthPtr) malloc(MAXDEPTH * sizeof(DepthRec)); + depths[0].depth = 1; + depths[0].numVids = 0; + depths[0].vids = (VisualID *) malloc(MAXVISUALSPERDEPTH * sizeof(VisualID)); + numDepths = 1; + + for (i = 0; i < xnestNumVisuals; i++) { + visuals[numVisuals].class = xnestVisuals[i].class; + visuals[numVisuals].bitsPerRGBValue = xnestVisuals[i].bits_per_rgb; + visuals[numVisuals].ColormapEntries = xnestVisuals[i].colormap_size; + visuals[numVisuals].nplanes = xnestVisuals[i].depth; + visuals[numVisuals].redMask = xnestVisuals[i].red_mask; + visuals[numVisuals].greenMask = xnestVisuals[i].green_mask; + visuals[numVisuals].blueMask = xnestVisuals[i].blue_mask; + visuals[numVisuals].offsetRed = offset(xnestVisuals[i].red_mask); + visuals[numVisuals].offsetGreen = offset(xnestVisuals[i].green_mask); + visuals[numVisuals].offsetBlue = offset(xnestVisuals[i].blue_mask); + + /* Check for and remove duplicates. */ + for (j = 0; j < numVisuals; j++) { + if (visuals[numVisuals].class == visuals[j].class && + visuals[numVisuals].bitsPerRGBValue == + visuals[j].bitsPerRGBValue && + visuals[numVisuals].ColormapEntries == + visuals[j].ColormapEntries && + visuals[numVisuals].nplanes == visuals[j].nplanes && + visuals[numVisuals].redMask == visuals[j].redMask && + visuals[numVisuals].greenMask == visuals[j].greenMask && + visuals[numVisuals].blueMask == visuals[j].blueMask && + visuals[numVisuals].offsetRed == visuals[j].offsetRed && + visuals[numVisuals].offsetGreen == visuals[j].offsetGreen && + visuals[numVisuals].offsetBlue == visuals[j].offsetBlue) + break; + } + if (j < numVisuals) + break; + + visuals[numVisuals].vid = FakeClientID(0); + + depthIndex = UNDEFINED; + for (j = 0; j < numDepths; j++) + if (depths[j].depth == xnestVisuals[i].depth) { + depthIndex = j; + break; + } + + if (depthIndex == UNDEFINED) { + depthIndex = numDepths; + depths[depthIndex].depth = xnestVisuals[i].depth; + depths[depthIndex].numVids = 0; + depths[depthIndex].vids = + (VisualID *) malloc(MAXVISUALSPERDEPTH * sizeof(VisualID)); + numDepths++; + } + if (depths[depthIndex].numVids >= MAXVISUALSPERDEPTH) { + FatalError("Visual table overflow"); + } + depths[depthIndex].vids[depths[depthIndex].numVids] = + visuals[numVisuals].vid; + depths[depthIndex].numVids++; + + numVisuals++; } - if (depths[depthIndex].numVids >= MAXVISUALSPERDEPTH) { - FatalError("Visual table overflow"); + visuals = (VisualPtr) realloc(visuals, numVisuals * sizeof(VisualRec)); + + defaultVisual = visuals[xnestDefaultVisualIndex].vid; + rootDepth = visuals[xnestDefaultVisualIndex].nplanes; + + if (xnestParentWindow != 0) { + XGetWindowAttributes(xnestDisplay, xnestParentWindow, &gattributes); + xnestWidth = gattributes.width; + xnestHeight = gattributes.height; } - depths[depthIndex].vids[depths[depthIndex].numVids] = - visuals[numVisuals].vid; - depths[depthIndex].numVids++; - - numVisuals++; - } - visuals = (VisualPtr)realloc(visuals, numVisuals * sizeof(VisualRec)); - - defaultVisual = visuals[xnestDefaultVisualIndex].vid; - rootDepth = visuals[xnestDefaultVisualIndex].nplanes; - - if (xnestParentWindow != 0) { - XGetWindowAttributes(xnestDisplay, xnestParentWindow, &gattributes); - xnestWidth = gattributes.width; - xnestHeight = gattributes.height; - } - - /* myNum */ - /* id */ - miScreenInit(pScreen, NULL, xnestWidth, xnestHeight, 1, 1, xnestWidth, - rootDepth, - numDepths, depths, - defaultVisual, /* root visual */ - numVisuals, visuals); - - pScreen->defColormap = (Colormap) FakeClientID(0); - pScreen->minInstalledCmaps = MINCMAPS; - pScreen->maxInstalledCmaps = MAXCMAPS; - pScreen->backingStoreSupport = NotUseful; - pScreen->saveUnderSupport = NotUseful; - pScreen->whitePixel = xnestWhitePixel; - pScreen->blackPixel = xnestBlackPixel; - /* GCperDepth */ - /* PixmapPerDepth */ - pScreen->devPrivate = NULL; - /* WindowPrivateLen */ - /* WindowPrivateSizes */ - /* totalWindowSize */ - /* GCPrivateLen */ - /* GCPrivateSizes */ - /* totalGCSize */ - - /* Random screen procedures */ - - pScreen->QueryBestSize = xnestQueryBestSize; - pScreen->SaveScreen = xnestSaveScreen; - pScreen->GetImage = xnestGetImage; - pScreen->GetSpans = xnestGetSpans; - pScreen->SourceValidate = NULL; - - /* Window Procedures */ - - pScreen->CreateWindow = xnestCreateWindow; - pScreen->DestroyWindow = xnestDestroyWindow; - pScreen->PositionWindow = xnestPositionWindow; - pScreen->ChangeWindowAttributes = xnestChangeWindowAttributes; - pScreen->RealizeWindow = xnestRealizeWindow; - pScreen->UnrealizeWindow = xnestUnrealizeWindow; - pScreen->PostValidateTree = NULL; - pScreen->WindowExposures = xnestWindowExposures; - pScreen->CopyWindow = xnestCopyWindow; - pScreen->ClipNotify = xnestClipNotify; - - /* Pixmap procedures */ - - pScreen->CreatePixmap = xnestCreatePixmap; - pScreen->DestroyPixmap = xnestDestroyPixmap; - - /* Font procedures */ - - pScreen->RealizeFont = xnestRealizeFont; - pScreen->UnrealizeFont = xnestUnrealizeFont; - - /* GC procedures */ - - pScreen->CreateGC = xnestCreateGC; - - /* Colormap procedures */ - - pScreen->CreateColormap = xnestCreateColormap; - pScreen->DestroyColormap = xnestDestroyColormap; - pScreen->InstallColormap = xnestInstallColormap; - pScreen->UninstallColormap = xnestUninstallColormap; - pScreen->ListInstalledColormaps = xnestListInstalledColormaps; - pScreen->StoreColors = xnestStoreColors; - pScreen->ResolveColor = xnestResolveColor; - - pScreen->BitmapToRegion = xnestPixmapToRegion; - - /* OS layer procedures */ - - pScreen->BlockHandler = (ScreenBlockHandlerProcPtr)NoopDDA; - pScreen->WakeupHandler = (ScreenWakeupHandlerProcPtr)NoopDDA; - pScreen->blockData = NULL; - pScreen->wakeupData = NULL; - - miDCInitialize(pScreen, &xnestPointerCursorFuncs); /* init SW rendering */ - PointPriv = dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey); - xnestCursorFuncs.spriteFuncs = PointPriv->spriteFuncs; - dixSetPrivate(&pScreen->devPrivates, xnestCursorScreenKey, &xnestCursorFuncs); - PointPriv->spriteFuncs = &xnestPointerSpriteFuncs; - - pScreen->mmWidth = xnestWidth * DisplayWidthMM(xnestDisplay, - DefaultScreen(xnestDisplay)) / - DisplayWidth(xnestDisplay, - DefaultScreen(xnestDisplay)); - pScreen->mmHeight = xnestHeight * DisplayHeightMM(xnestDisplay, - DefaultScreen(xnestDisplay)) / - DisplayHeight(xnestDisplay, - DefaultScreen(xnestDisplay)); - - /* overwrite miCloseScreen with our own */ - pScreen->CloseScreen = xnestCloseScreen; - - if (!miScreenDevPrivateInit(pScreen, xnestWidth, NULL)) - return FALSE; - - /* overwrite miSetShape with our own */ - pScreen->SetShape = xnestSetShape; - - /* devPrivates */ + + /* myNum */ + /* id */ + miScreenInit(pScreen, NULL, xnestWidth, xnestHeight, 1, 1, xnestWidth, rootDepth, numDepths, depths, defaultVisual, /* root visual */ + numVisuals, visuals); + + pScreen->defColormap = (Colormap) FakeClientID(0); + pScreen->minInstalledCmaps = MINCMAPS; + pScreen->maxInstalledCmaps = MAXCMAPS; + pScreen->backingStoreSupport = NotUseful; + pScreen->saveUnderSupport = NotUseful; + pScreen->whitePixel = xnestWhitePixel; + pScreen->blackPixel = xnestBlackPixel; + /* GCperDepth */ + /* PixmapPerDepth */ + pScreen->devPrivate = NULL; + /* WindowPrivateLen */ + /* WindowPrivateSizes */ + /* totalWindowSize */ + /* GCPrivateLen */ + /* GCPrivateSizes */ + /* totalGCSize */ + + /* Random screen procedures */ + + pScreen->QueryBestSize = xnestQueryBestSize; + pScreen->SaveScreen = xnestSaveScreen; + pScreen->GetImage = xnestGetImage; + pScreen->GetSpans = xnestGetSpans; + pScreen->SourceValidate = NULL; + + /* Window Procedures */ + + pScreen->CreateWindow = xnestCreateWindow; + pScreen->DestroyWindow = xnestDestroyWindow; + pScreen->PositionWindow = xnestPositionWindow; + pScreen->ChangeWindowAttributes = xnestChangeWindowAttributes; + pScreen->RealizeWindow = xnestRealizeWindow; + pScreen->UnrealizeWindow = xnestUnrealizeWindow; + pScreen->PostValidateTree = NULL; + pScreen->WindowExposures = xnestWindowExposures; + pScreen->CopyWindow = xnestCopyWindow; + pScreen->ClipNotify = xnestClipNotify; + + /* Pixmap procedures */ + + pScreen->CreatePixmap = xnestCreatePixmap; + pScreen->DestroyPixmap = xnestDestroyPixmap; + + /* Font procedures */ + + pScreen->RealizeFont = xnestRealizeFont; + pScreen->UnrealizeFont = xnestUnrealizeFont; + + /* GC procedures */ + + pScreen->CreateGC = xnestCreateGC; + + /* Colormap procedures */ + + pScreen->CreateColormap = xnestCreateColormap; + pScreen->DestroyColormap = xnestDestroyColormap; + pScreen->InstallColormap = xnestInstallColormap; + pScreen->UninstallColormap = xnestUninstallColormap; + pScreen->ListInstalledColormaps = xnestListInstalledColormaps; + pScreen->StoreColors = xnestStoreColors; + pScreen->ResolveColor = xnestResolveColor; + + pScreen->BitmapToRegion = xnestPixmapToRegion; + + /* OS layer procedures */ + + pScreen->BlockHandler = (ScreenBlockHandlerProcPtr) NoopDDA; + pScreen->WakeupHandler = (ScreenWakeupHandlerProcPtr) NoopDDA; + pScreen->blockData = NULL; + pScreen->wakeupData = NULL; + + miDCInitialize(pScreen, &xnestPointerCursorFuncs); /* init SW rendering */ + PointPriv = dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey); + xnestCursorFuncs.spriteFuncs = PointPriv->spriteFuncs; + dixSetPrivate(&pScreen->devPrivates, xnestCursorScreenKey, + &xnestCursorFuncs); + PointPriv->spriteFuncs = &xnestPointerSpriteFuncs; + + pScreen->mmWidth = xnestWidth * DisplayWidthMM(xnestDisplay, + DefaultScreen(xnestDisplay)) + / DisplayWidth(xnestDisplay, DefaultScreen(xnestDisplay)); + pScreen->mmHeight = + xnestHeight * DisplayHeightMM(xnestDisplay, + DefaultScreen(xnestDisplay)) / + DisplayHeight(xnestDisplay, DefaultScreen(xnestDisplay)); + + /* overwrite miCloseScreen with our own */ + pScreen->CloseScreen = xnestCloseScreen; + + if (!miScreenDevPrivateInit(pScreen, xnestWidth, NULL)) + return FALSE; + + /* overwrite miSetShape with our own */ + pScreen->SetShape = xnestSetShape; + + /* devPrivates */ #define POSITION_OFFSET (pScreen->myNum * (xnestWidth + xnestHeight) / 32) - - if (xnestDoFullGeneration) { - - valuemask = CWBackPixel | CWEventMask | CWColormap; - attributes.background_pixel = xnestWhitePixel; - attributes.event_mask = xnestEventMask; - attributes.colormap = xnestDefaultVisualColormap(xnestDefaultVisual(pScreen)); - - if (xnestParentWindow != 0) { - xnestDefaultWindows[pScreen->myNum] = xnestParentWindow; - XSelectInput (xnestDisplay, xnestDefaultWindows[pScreen->myNum], - xnestEventMask); - } else - xnestDefaultWindows[pScreen->myNum] = - XCreateWindow(xnestDisplay, - DefaultRootWindow(xnestDisplay), - xnestX + POSITION_OFFSET, - xnestY + POSITION_OFFSET, - xnestWidth, xnestHeight, - xnestBorderWidth, - pScreen->rootDepth, - InputOutput, - xnestDefaultVisual(pScreen), - valuemask, &attributes); - - if (!xnestWindowName) - xnestWindowName = argv[0]; - - sizeHints.flags = PPosition | PSize | PMaxSize; - sizeHints.x = xnestX + POSITION_OFFSET; - sizeHints.y = xnestY + POSITION_OFFSET; - sizeHints.width = sizeHints.max_width = xnestWidth; - sizeHints.height = sizeHints.max_height = xnestHeight; - if (xnestUserGeometry & XValue || xnestUserGeometry & YValue) - sizeHints.flags |= USPosition; - if (xnestUserGeometry & WidthValue || xnestUserGeometry & HeightValue) - sizeHints.flags |= USSize; - XSetStandardProperties(xnestDisplay, - xnestDefaultWindows[pScreen->myNum], - xnestWindowName, - xnestWindowName, - xnestIconBitmap, - argv, argc, &sizeHints); - - XMapWindow(xnestDisplay, xnestDefaultWindows[pScreen->myNum]); - - valuemask = CWBackPixmap | CWColormap; - attributes.background_pixmap = xnestScreenSaverPixmap; - attributes.colormap = - DefaultColormap(xnestDisplay, DefaultScreen(xnestDisplay)); - xnestScreenSaverWindows[pScreen->myNum] = - XCreateWindow(xnestDisplay, - xnestDefaultWindows[pScreen->myNum], - 0, 0, xnestWidth, xnestHeight, 0, - DefaultDepth(xnestDisplay, DefaultScreen(xnestDisplay)), - InputOutput, - DefaultVisual(xnestDisplay, DefaultScreen(xnestDisplay)), - valuemask, &attributes); - } - - if (!xnestCreateDefaultColormap(pScreen)) return False; - - return True; + + if (xnestDoFullGeneration) { + + valuemask = CWBackPixel | CWEventMask | CWColormap; + attributes.background_pixel = xnestWhitePixel; + attributes.event_mask = xnestEventMask; + attributes.colormap = + xnestDefaultVisualColormap(xnestDefaultVisual(pScreen)); + + if (xnestParentWindow != 0) { + xnestDefaultWindows[pScreen->myNum] = xnestParentWindow; + XSelectInput(xnestDisplay, xnestDefaultWindows[pScreen->myNum], + xnestEventMask); + } + else + xnestDefaultWindows[pScreen->myNum] = + XCreateWindow(xnestDisplay, + DefaultRootWindow(xnestDisplay), + xnestX + POSITION_OFFSET, + xnestY + POSITION_OFFSET, + xnestWidth, xnestHeight, + xnestBorderWidth, + pScreen->rootDepth, + InputOutput, + xnestDefaultVisual(pScreen), + valuemask, &attributes); + + if (!xnestWindowName) + xnestWindowName = argv[0]; + + sizeHints.flags = PPosition | PSize | PMaxSize; + sizeHints.x = xnestX + POSITION_OFFSET; + sizeHints.y = xnestY + POSITION_OFFSET; + sizeHints.width = sizeHints.max_width = xnestWidth; + sizeHints.height = sizeHints.max_height = xnestHeight; + if (xnestUserGeometry & XValue || xnestUserGeometry & YValue) + sizeHints.flags |= USPosition; + if (xnestUserGeometry & WidthValue || xnestUserGeometry & HeightValue) + sizeHints.flags |= USSize; + XSetStandardProperties(xnestDisplay, + xnestDefaultWindows[pScreen->myNum], + xnestWindowName, + xnestWindowName, + xnestIconBitmap, argv, argc, &sizeHints); + + XMapWindow(xnestDisplay, xnestDefaultWindows[pScreen->myNum]); + + valuemask = CWBackPixmap | CWColormap; + attributes.background_pixmap = xnestScreenSaverPixmap; + attributes.colormap = + DefaultColormap(xnestDisplay, DefaultScreen(xnestDisplay)); + xnestScreenSaverWindows[pScreen->myNum] = + XCreateWindow(xnestDisplay, + xnestDefaultWindows[pScreen->myNum], + 0, 0, xnestWidth, xnestHeight, 0, + DefaultDepth(xnestDisplay, + DefaultScreen(xnestDisplay)), + InputOutput, DefaultVisual(xnestDisplay, + DefaultScreen + (xnestDisplay)), valuemask, + &attributes); + } + + if (!xnestCreateDefaultColormap(pScreen)) + return False; + + return True; } Bool xnestCloseScreen(int index, ScreenPtr pScreen) { - int i; - - for (i = 0; i < pScreen->numDepths; i++) - free(pScreen->allowedDepths[i].vids); - free(pScreen->allowedDepths); - free(pScreen->visuals); - free(pScreen->devPrivate); - - /* - If xnestDoFullGeneration all x resources will be destroyed upon closing - the display connection. There is no need to generate extra protocol. - */ - - return True; + int i; + + for (i = 0; i < pScreen->numDepths; i++) + free(pScreen->allowedDepths[i].vids); + free(pScreen->allowedDepths); + free(pScreen->visuals); + free(pScreen->devPrivate); + + /* + If xnestDoFullGeneration all x resources will be destroyed upon closing + the display connection. There is no need to generate extra protocol. + */ + + return True; } diff --git a/hw/xnest/Screen.h b/hw/xnest/Screen.h index b113c6460..1d255d79b 100644 --- a/hw/xnest/Screen.h +++ b/hw/xnest/Screen.h @@ -22,4 +22,4 @@ ScreenPtr xnestScreen(Window window); Bool xnestOpenScreen(int index, ScreenPtr pScreen, int argc, char *argv[]); Bool xnestCloseScreen(int index, ScreenPtr pScreen); -#endif /* XNESTSCREEN_H */ +#endif /* XNESTSCREEN_H */ diff --git a/hw/xnest/Visual.c b/hw/xnest/Visual.c index da1d63c10..63198ba4f 100644 --- a/hw/xnest/Visual.c +++ b/hw/xnest/Visual.c @@ -30,41 +30,41 @@ is" without express or implied warranty. Visual * xnestVisual(VisualPtr pVisual) { - int i; + int i; - for (i = 0; i < xnestNumVisuals; i++) - if (pVisual->class == xnestVisuals[i].class && - pVisual->bitsPerRGBValue == xnestVisuals[i].bits_per_rgb && - pVisual->ColormapEntries == xnestVisuals[i].colormap_size && - pVisual->nplanes == xnestVisuals[i].depth && - pVisual->redMask == xnestVisuals[i].red_mask && - pVisual->greenMask == xnestVisuals[i].green_mask && - pVisual->blueMask == xnestVisuals[i].blue_mask) - return xnestVisuals[i].visual; + for (i = 0; i < xnestNumVisuals; i++) + if (pVisual->class == xnestVisuals[i].class && + pVisual->bitsPerRGBValue == xnestVisuals[i].bits_per_rgb && + pVisual->ColormapEntries == xnestVisuals[i].colormap_size && + pVisual->nplanes == xnestVisuals[i].depth && + pVisual->redMask == xnestVisuals[i].red_mask && + pVisual->greenMask == xnestVisuals[i].green_mask && + pVisual->blueMask == xnestVisuals[i].blue_mask) + return xnestVisuals[i].visual; - return NULL; + return NULL; } Visual * xnestVisualFromID(ScreenPtr pScreen, VisualID visual) { - int i; - - for (i = 0; i < pScreen->numVisuals; i++) - if (pScreen->visuals[i].vid == visual) - return xnestVisual(&pScreen->visuals[i]); + int i; - return NULL; + for (i = 0; i < pScreen->numVisuals; i++) + if (pScreen->visuals[i].vid == visual) + return xnestVisual(&pScreen->visuals[i]); + + return NULL; } Colormap -xnestDefaultVisualColormap(Visual *visual) +xnestDefaultVisualColormap(Visual * visual) { - int i; - - for (i = 0; i < xnestNumVisuals; i++) - if (xnestVisuals[i].visual == visual) - return xnestDefaultColormaps[i]; - - return None; + int i; + + for (i = 0; i < xnestNumVisuals; i++) + if (xnestVisuals[i].visual == visual) + return xnestDefaultColormaps[i]; + + return None; } diff --git a/hw/xnest/Visual.h b/hw/xnest/Visual.h index 1bd203709..c3ae8a19f 100644 --- a/hw/xnest/Visual.h +++ b/hw/xnest/Visual.h @@ -17,9 +17,9 @@ is" without express or implied warranty. Visual *xnestVisual(VisualPtr pVisual); Visual *xnestVisualFromID(ScreenPtr pScreen, VisualID visual); -Colormap xnestDefaultVisualColormap(Visual *visual); +Colormap xnestDefaultVisualColormap(Visual * visual); #define xnestDefaultVisual(pScreen) \ xnestVisualFromID((pScreen), (pScreen)->rootVisual) -#endif /* XNESTVISUAL_H */ +#endif /* XNESTVISUAL_H */ diff --git a/hw/xnest/Window.c b/hw/xnest/Window.c index 9ed69ed74..e2b21b58e 100644 --- a/hw/xnest/Window.c +++ b/hw/xnest/Window.c @@ -44,333 +44,327 @@ DevPrivateKeyRec xnestWindowPrivateKeyRec; static int xnestFindWindowMatch(WindowPtr pWin, pointer ptr) { - xnestWindowMatch *wm = (xnestWindowMatch *)ptr; - if (wm->window == xnestWindow(pWin)) { - wm->pWin = pWin; - return WT_STOPWALKING; - } - else - return WT_WALKCHILDREN; + xnestWindowMatch *wm = (xnestWindowMatch *) ptr; + + if (wm->window == xnestWindow(pWin)) { + wm->pWin = pWin; + return WT_STOPWALKING; + } + else + return WT_WALKCHILDREN; } WindowPtr xnestWindowPtr(Window window) { - xnestWindowMatch wm; - int i; - - wm.pWin = NullWindow; - wm.window = window; - - for (i = 0; i < xnestNumScreens; i++) { - WalkTree(screenInfo.screens[i], xnestFindWindowMatch, (pointer) &wm); - if (wm.pWin) break; - } - - return wm.pWin; + xnestWindowMatch wm; + int i; + + wm.pWin = NullWindow; + wm.window = window; + + for (i = 0; i < xnestNumScreens; i++) { + WalkTree(screenInfo.screens[i], xnestFindWindowMatch, (pointer) &wm); + if (wm.pWin) + break; + } + + return wm.pWin; } - + Bool xnestCreateWindow(WindowPtr pWin) { - unsigned long mask; - XSetWindowAttributes attributes; - Visual *visual; - ColormapPtr pCmap; - - if (pWin->drawable.class == InputOnly) { - mask = 0L; - visual = CopyFromParent; - } - else { - mask = CWEventMask | CWBackingStore; - attributes.event_mask = ExposureMask; - attributes.backing_store = NotUseful; - - if (pWin->parent) { - if (pWin->optional && pWin->optional->visual != wVisual(pWin->parent)) { - visual = xnestVisualFromID(pWin->drawable.pScreen, wVisual(pWin)); - mask |= CWColormap; - if (pWin->optional->colormap) { - dixLookupResourceByType((pointer *)&pCmap, wColormap(pWin), - RT_COLORMAP, serverClient, DixUseAccess); - attributes.colormap = xnestColormap(pCmap); - } - else - attributes.colormap = xnestDefaultVisualColormap(visual); - } - else - visual = CopyFromParent; + unsigned long mask; + XSetWindowAttributes attributes; + Visual *visual; + ColormapPtr pCmap; + + if (pWin->drawable.class == InputOnly) { + mask = 0L; + visual = CopyFromParent; } - else { /* root windows have their own colormaps at creation time */ - visual = xnestVisualFromID(pWin->drawable.pScreen, wVisual(pWin)); - dixLookupResourceByType((pointer *)&pCmap, wColormap(pWin), - RT_COLORMAP, serverClient, DixUseAccess); - mask |= CWColormap; - attributes.colormap = xnestColormap(pCmap); + else { + mask = CWEventMask | CWBackingStore; + attributes.event_mask = ExposureMask; + attributes.backing_store = NotUseful; + + if (pWin->parent) { + if (pWin->optional && + pWin->optional->visual != wVisual(pWin->parent)) { + visual = + xnestVisualFromID(pWin->drawable.pScreen, wVisual(pWin)); + mask |= CWColormap; + if (pWin->optional->colormap) { + dixLookupResourceByType((pointer *) &pCmap, wColormap(pWin), + RT_COLORMAP, serverClient, + DixUseAccess); + attributes.colormap = xnestColormap(pCmap); + } + else + attributes.colormap = xnestDefaultVisualColormap(visual); + } + else + visual = CopyFromParent; + } + else { /* root windows have their own colormaps at creation time */ + visual = xnestVisualFromID(pWin->drawable.pScreen, wVisual(pWin)); + dixLookupResourceByType((pointer *) &pCmap, wColormap(pWin), + RT_COLORMAP, serverClient, DixUseAccess); + mask |= CWColormap; + attributes.colormap = xnestColormap(pCmap); + } } - } - - xnestWindowPriv(pWin)->window = XCreateWindow(xnestDisplay, - xnestWindowParent(pWin), - pWin->origin.x - - wBorderWidth(pWin), - pWin->origin.y - - wBorderWidth(pWin), - pWin->drawable.width, - pWin->drawable.height, - pWin->borderWidth, - pWin->drawable.depth, - pWin->drawable.class, - visual, - mask, &attributes); - xnestWindowPriv(pWin)->parent = xnestWindowParent(pWin); - xnestWindowPriv(pWin)->x = pWin->origin.x - wBorderWidth(pWin); - xnestWindowPriv(pWin)->y = pWin->origin.y - wBorderWidth(pWin); - xnestWindowPriv(pWin)->width = pWin->drawable.width; - xnestWindowPriv(pWin)->height = pWin->drawable.height; - xnestWindowPriv(pWin)->border_width = pWin->borderWidth; - xnestWindowPriv(pWin)->sibling_above = None; - if (pWin->nextSib) - xnestWindowPriv(pWin->nextSib)->sibling_above = xnestWindow(pWin); - xnestWindowPriv(pWin)->bounding_shape = - RegionCreate(NULL, 1); - xnestWindowPriv(pWin)->clip_shape = - RegionCreate(NULL, 1); - - if (!pWin->parent) /* only the root window will have the right colormap */ - xnestSetInstalledColormapWindows(pWin->drawable.pScreen); - - return True; + + xnestWindowPriv(pWin)->window = XCreateWindow(xnestDisplay, + xnestWindowParent(pWin), + pWin->origin.x - + wBorderWidth(pWin), + pWin->origin.y - + wBorderWidth(pWin), + pWin->drawable.width, + pWin->drawable.height, + pWin->borderWidth, + pWin->drawable.depth, + pWin->drawable.class, + visual, mask, &attributes); + xnestWindowPriv(pWin)->parent = xnestWindowParent(pWin); + xnestWindowPriv(pWin)->x = pWin->origin.x - wBorderWidth(pWin); + xnestWindowPriv(pWin)->y = pWin->origin.y - wBorderWidth(pWin); + xnestWindowPriv(pWin)->width = pWin->drawable.width; + xnestWindowPriv(pWin)->height = pWin->drawable.height; + xnestWindowPriv(pWin)->border_width = pWin->borderWidth; + xnestWindowPriv(pWin)->sibling_above = None; + if (pWin->nextSib) + xnestWindowPriv(pWin->nextSib)->sibling_above = xnestWindow(pWin); + xnestWindowPriv(pWin)->bounding_shape = RegionCreate(NULL, 1); + xnestWindowPriv(pWin)->clip_shape = RegionCreate(NULL, 1); + + if (!pWin->parent) /* only the root window will have the right colormap */ + xnestSetInstalledColormapWindows(pWin->drawable.pScreen); + + return True; } Bool xnestDestroyWindow(WindowPtr pWin) { - if (pWin->nextSib) - xnestWindowPriv(pWin->nextSib)->sibling_above = - xnestWindowPriv(pWin)->sibling_above; - RegionDestroy(xnestWindowPriv(pWin)->bounding_shape); - RegionDestroy(xnestWindowPriv(pWin)->clip_shape); - XDestroyWindow(xnestDisplay, xnestWindow(pWin)); - xnestWindowPriv(pWin)->window = None; - - if (pWin->optional && pWin->optional->colormap && pWin->parent) - xnestSetInstalledColormapWindows(pWin->drawable.pScreen); - - return True; + if (pWin->nextSib) + xnestWindowPriv(pWin->nextSib)->sibling_above = + xnestWindowPriv(pWin)->sibling_above; + RegionDestroy(xnestWindowPriv(pWin)->bounding_shape); + RegionDestroy(xnestWindowPriv(pWin)->clip_shape); + XDestroyWindow(xnestDisplay, xnestWindow(pWin)); + xnestWindowPriv(pWin)->window = None; + + if (pWin->optional && pWin->optional->colormap && pWin->parent) + xnestSetInstalledColormapWindows(pWin->drawable.pScreen); + + return True; } Bool xnestPositionWindow(WindowPtr pWin, int x, int y) { - xnestConfigureWindow(pWin, - CWParent | - CWX | CWY | - CWWidth | CWHeight | - CWBorderWidth); - - return True; + xnestConfigureWindow(pWin, + CWParent | + CWX | CWY | CWWidth | CWHeight | CWBorderWidth); + + return True; } void xnestConfigureWindow(WindowPtr pWin, unsigned int mask) { - unsigned int valuemask; - XWindowChanges values; - - if (mask & CWParent && - xnestWindowPriv(pWin)->parent != xnestWindowParent(pWin)) { - XReparentWindow(xnestDisplay, xnestWindow(pWin), - xnestWindowParent(pWin), - pWin->origin.x - wBorderWidth(pWin), - pWin->origin.y - wBorderWidth(pWin)); - xnestWindowPriv(pWin)->parent = xnestWindowParent(pWin); - xnestWindowPriv(pWin)->x = pWin->origin.x - wBorderWidth(pWin); - xnestWindowPriv(pWin)->y = pWin->origin.y - wBorderWidth(pWin); - xnestWindowPriv(pWin)->sibling_above = None; - if (pWin->nextSib) - xnestWindowPriv(pWin->nextSib)->sibling_above = xnestWindow(pWin); - } - - valuemask = 0; - - if (mask & CWX && - xnestWindowPriv(pWin)->x != pWin->origin.x - wBorderWidth(pWin)) { - valuemask |= CWX; - values.x = - xnestWindowPriv(pWin)->x = - pWin->origin.x - wBorderWidth(pWin); - } - - if (mask & CWY && - xnestWindowPriv(pWin)->y != pWin->origin.y - wBorderWidth(pWin)) { - valuemask |= CWY; - values.y = - xnestWindowPriv(pWin)->y = - pWin->origin.y - wBorderWidth(pWin); - } - - if (mask & CWWidth && - xnestWindowPriv(pWin)->width != pWin->drawable.width) { - valuemask |= CWWidth; - values.width = - xnestWindowPriv(pWin)->width = - pWin->drawable.width; - } - - if (mask & CWHeight && - xnestWindowPriv(pWin)->height != pWin->drawable.height) { - valuemask |= CWHeight; - values.height = - xnestWindowPriv(pWin)->height = - pWin->drawable.height; - } - - if (mask & CWBorderWidth && - xnestWindowPriv(pWin)->border_width != pWin->borderWidth) { - valuemask |= CWBorderWidth; - values.border_width = - xnestWindowPriv(pWin)->border_width = - pWin->borderWidth; - } - - if (valuemask) - XConfigureWindow(xnestDisplay, xnestWindow(pWin), valuemask, &values); - - if (mask & CWStackingOrder && - xnestWindowPriv(pWin)->sibling_above != xnestWindowSiblingAbove(pWin)) { - WindowPtr pSib; - - /* find the top sibling */ - for (pSib = pWin; pSib->prevSib != NullWindow; pSib = pSib->prevSib); - - /* the top sibling */ - valuemask = CWStackMode; - values.stack_mode = Above; - XConfigureWindow(xnestDisplay, xnestWindow(pSib), valuemask, &values); - xnestWindowPriv(pSib)->sibling_above = None; - - /* the rest of siblings */ - for (pSib = pSib->nextSib; pSib != NullWindow; pSib = pSib->nextSib) { - valuemask = CWSibling | CWStackMode; - values.sibling = xnestWindowSiblingAbove(pSib); - values.stack_mode = Below; - XConfigureWindow(xnestDisplay, xnestWindow(pSib), valuemask, &values); - xnestWindowPriv(pSib)->sibling_above = xnestWindowSiblingAbove(pSib); + unsigned int valuemask; + XWindowChanges values; + + if (mask & CWParent && + xnestWindowPriv(pWin)->parent != xnestWindowParent(pWin)) { + XReparentWindow(xnestDisplay, xnestWindow(pWin), + xnestWindowParent(pWin), + pWin->origin.x - wBorderWidth(pWin), + pWin->origin.y - wBorderWidth(pWin)); + xnestWindowPriv(pWin)->parent = xnestWindowParent(pWin); + xnestWindowPriv(pWin)->x = pWin->origin.x - wBorderWidth(pWin); + xnestWindowPriv(pWin)->y = pWin->origin.y - wBorderWidth(pWin); + xnestWindowPriv(pWin)->sibling_above = None; + if (pWin->nextSib) + xnestWindowPriv(pWin->nextSib)->sibling_above = xnestWindow(pWin); + } + + valuemask = 0; + + if (mask & CWX && + xnestWindowPriv(pWin)->x != pWin->origin.x - wBorderWidth(pWin)) { + valuemask |= CWX; + values.x = + xnestWindowPriv(pWin)->x = pWin->origin.x - wBorderWidth(pWin); + } + + if (mask & CWY && + xnestWindowPriv(pWin)->y != pWin->origin.y - wBorderWidth(pWin)) { + valuemask |= CWY; + values.y = + xnestWindowPriv(pWin)->y = pWin->origin.y - wBorderWidth(pWin); + } + + if (mask & CWWidth && xnestWindowPriv(pWin)->width != pWin->drawable.width) { + valuemask |= CWWidth; + values.width = xnestWindowPriv(pWin)->width = pWin->drawable.width; + } + + if (mask & CWHeight && + xnestWindowPriv(pWin)->height != pWin->drawable.height) { + valuemask |= CWHeight; + values.height = xnestWindowPriv(pWin)->height = pWin->drawable.height; + } + + if (mask & CWBorderWidth && + xnestWindowPriv(pWin)->border_width != pWin->borderWidth) { + valuemask |= CWBorderWidth; + values.border_width = + xnestWindowPriv(pWin)->border_width = pWin->borderWidth; + } + + if (valuemask) + XConfigureWindow(xnestDisplay, xnestWindow(pWin), valuemask, &values); + + if (mask & CWStackingOrder && + xnestWindowPriv(pWin)->sibling_above != xnestWindowSiblingAbove(pWin)) { + WindowPtr pSib; + + /* find the top sibling */ + for (pSib = pWin; pSib->prevSib != NullWindow; pSib = pSib->prevSib); + + /* the top sibling */ + valuemask = CWStackMode; + values.stack_mode = Above; + XConfigureWindow(xnestDisplay, xnestWindow(pSib), valuemask, &values); + xnestWindowPriv(pSib)->sibling_above = None; + + /* the rest of siblings */ + for (pSib = pSib->nextSib; pSib != NullWindow; pSib = pSib->nextSib) { + valuemask = CWSibling | CWStackMode; + values.sibling = xnestWindowSiblingAbove(pSib); + values.stack_mode = Below; + XConfigureWindow(xnestDisplay, xnestWindow(pSib), valuemask, + &values); + xnestWindowPriv(pSib)->sibling_above = + xnestWindowSiblingAbove(pSib); + } } - } } Bool xnestChangeWindowAttributes(WindowPtr pWin, unsigned long mask) { - XSetWindowAttributes attributes; - - if (mask & CWBackPixmap) - switch (pWin->backgroundState) { - case None: - attributes.background_pixmap = None; - break; - - case ParentRelative: - attributes.background_pixmap = ParentRelative; - break; - - case BackgroundPixmap: - attributes.background_pixmap = xnestPixmap(pWin->background.pixmap); - break; - - case BackgroundPixel: - mask &= ~CWBackPixmap; - break; + XSetWindowAttributes attributes; + + if (mask & CWBackPixmap) + switch (pWin->backgroundState) { + case None: + attributes.background_pixmap = None; + break; + + case ParentRelative: + attributes.background_pixmap = ParentRelative; + break; + + case BackgroundPixmap: + attributes.background_pixmap = xnestPixmap(pWin->background.pixmap); + break; + + case BackgroundPixel: + mask &= ~CWBackPixmap; + break; + } + + if (mask & CWBackPixel) { + if (pWin->backgroundState == BackgroundPixel) + attributes.background_pixel = xnestPixel(pWin->background.pixel); + else + mask &= ~CWBackPixel; } - if (mask & CWBackPixel) { - if (pWin->backgroundState == BackgroundPixel) - attributes.background_pixel = xnestPixel(pWin->background.pixel); - else - mask &= ~CWBackPixel; - } - - if (mask & CWBorderPixmap) { - if (pWin->borderIsPixel) - mask &= ~CWBorderPixmap; - else - attributes.border_pixmap = xnestPixmap(pWin->border.pixmap); - } - - if (mask & CWBorderPixel) { - if (pWin->borderIsPixel) - attributes.border_pixel = xnestPixel(pWin->border.pixel); - else - mask &= ~CWBorderPixel; - } - - if (mask & CWBitGravity) - attributes.bit_gravity = pWin->bitGravity; - - if (mask & CWWinGravity) /* dix does this for us */ - mask &= ~CWWinGravity; + if (mask & CWBorderPixmap) { + if (pWin->borderIsPixel) + mask &= ~CWBorderPixmap; + else + attributes.border_pixmap = xnestPixmap(pWin->border.pixmap); + } - if (mask & CWBackingStore) /* this is really not useful */ - mask &= ~CWBackingStore; + if (mask & CWBorderPixel) { + if (pWin->borderIsPixel) + attributes.border_pixel = xnestPixel(pWin->border.pixel); + else + mask &= ~CWBorderPixel; + } - if (mask & CWBackingPlanes) /* this is really not useful */ - mask &= ~CWBackingPlanes; + if (mask & CWBitGravity) + attributes.bit_gravity = pWin->bitGravity; - if (mask & CWBackingPixel) /* this is really not useful */ - mask &= ~CWBackingPixel; + if (mask & CWWinGravity) /* dix does this for us */ + mask &= ~CWWinGravity; - if (mask & CWOverrideRedirect) - attributes.override_redirect = pWin->overrideRedirect; + if (mask & CWBackingStore) /* this is really not useful */ + mask &= ~CWBackingStore; - if (mask & CWSaveUnder) /* this is really not useful */ - mask &= ~CWSaveUnder; + if (mask & CWBackingPlanes) /* this is really not useful */ + mask &= ~CWBackingPlanes; - if (mask & CWEventMask) /* events are handled elsewhere */ - mask &= ~CWEventMask; + if (mask & CWBackingPixel) /* this is really not useful */ + mask &= ~CWBackingPixel; - if (mask & CWDontPropagate) /* events are handled elsewhere */ - mask &= ~CWDontPropagate; + if (mask & CWOverrideRedirect) + attributes.override_redirect = pWin->overrideRedirect; - if (mask & CWColormap) { - ColormapPtr pCmap; - - dixLookupResourceByType((pointer *)&pCmap, wColormap(pWin), RT_COLORMAP, - serverClient, DixUseAccess); + if (mask & CWSaveUnder) /* this is really not useful */ + mask &= ~CWSaveUnder; - attributes.colormap = xnestColormap(pCmap); + if (mask & CWEventMask) /* events are handled elsewhere */ + mask &= ~CWEventMask; - xnestSetInstalledColormapWindows(pWin->drawable.pScreen); - } + if (mask & CWDontPropagate) /* events are handled elsewhere */ + mask &= ~CWDontPropagate; - if (mask & CWCursor) /* this is handeled in cursor code */ - mask &= ~CWCursor; + if (mask & CWColormap) { + ColormapPtr pCmap; + + dixLookupResourceByType((pointer *) &pCmap, wColormap(pWin), + RT_COLORMAP, serverClient, DixUseAccess); + + attributes.colormap = xnestColormap(pCmap); + + xnestSetInstalledColormapWindows(pWin->drawable.pScreen); + } - if (mask) - XChangeWindowAttributes(xnestDisplay, xnestWindow(pWin), - mask, &attributes); - - return True; -} + if (mask & CWCursor) /* this is handeled in cursor code */ + mask &= ~CWCursor; + + if (mask) + XChangeWindowAttributes(xnestDisplay, xnestWindow(pWin), + mask, &attributes); + + return True; +} Bool xnestRealizeWindow(WindowPtr pWin) { - xnestConfigureWindow(pWin, CWStackingOrder); - xnestShapeWindow(pWin); - XMapWindow(xnestDisplay, xnestWindow(pWin)); + xnestConfigureWindow(pWin, CWStackingOrder); + xnestShapeWindow(pWin); + XMapWindow(xnestDisplay, xnestWindow(pWin)); - return True; + return True; } Bool xnestUnrealizeWindow(WindowPtr pWin) { - XUnmapWindow(xnestDisplay, xnestWindow(pWin)); + XUnmapWindow(xnestDisplay, xnestWindow(pWin)); - return True; + return True; } void @@ -381,139 +375,143 @@ xnestCopyWindow(WindowPtr pWin, xPoint oldOrigin, RegionPtr oldRegion) void xnestClipNotify(WindowPtr pWin, int dx, int dy) { - xnestConfigureWindow(pWin, CWStackingOrder); - xnestShapeWindow(pWin); + xnestConfigureWindow(pWin, CWStackingOrder); + xnestShapeWindow(pWin); } static Bool -xnestWindowExposurePredicate(Display *display, XEvent *event, XPointer ptr) +xnestWindowExposurePredicate(Display * display, XEvent * event, XPointer ptr) { - return (event->type == Expose && event->xexpose.window == *(Window *)ptr); + return (event->type == Expose && event->xexpose.window == *(Window *) ptr); } void xnestWindowExposures(WindowPtr pWin, RegionPtr pRgn, RegionPtr other_exposed) { - XEvent event; - Window window; - BoxRec Box; - - XSync(xnestDisplay, False); - - window = xnestWindow(pWin); - - while (XCheckIfEvent(xnestDisplay, &event, - xnestWindowExposurePredicate, (char *)&window)) { - - Box.x1 = pWin->drawable.x + wBorderWidth(pWin) + event.xexpose.x; - Box.y1 = pWin->drawable.y + wBorderWidth(pWin) + event.xexpose.y; - Box.x2 = Box.x1 + event.xexpose.width; - Box.y2 = Box.y1 + event.xexpose.height; - - event.xexpose.type = ProcessedExpose; - - if (RegionContainsRect(pRgn, &Box) != rgnIN) - XPutBackEvent(xnestDisplay, &event); - } - - miWindowExposures(pWin, pRgn, other_exposed); + XEvent event; + Window window; + BoxRec Box; + + XSync(xnestDisplay, False); + + window = xnestWindow(pWin); + + while (XCheckIfEvent(xnestDisplay, &event, + xnestWindowExposurePredicate, (char *) &window)) { + + Box.x1 = pWin->drawable.x + wBorderWidth(pWin) + event.xexpose.x; + Box.y1 = pWin->drawable.y + wBorderWidth(pWin) + event.xexpose.y; + Box.x2 = Box.x1 + event.xexpose.width; + Box.y2 = Box.y1 + event.xexpose.height; + + event.xexpose.type = ProcessedExpose; + + if (RegionContainsRect(pRgn, &Box) != rgnIN) + XPutBackEvent(xnestDisplay, &event); + } + + miWindowExposures(pWin, pRgn, other_exposed); } void xnestSetShape(WindowPtr pWin, int kind) { - xnestShapeWindow(pWin); - miSetShape(pWin, kind); + xnestShapeWindow(pWin); + miSetShape(pWin, kind); } static Bool xnestRegionEqual(RegionPtr pReg1, RegionPtr pReg2) { - BoxPtr pBox1, pBox2; - unsigned int n1, n2; + BoxPtr pBox1, pBox2; + unsigned int n1, n2; - if (pReg1 == pReg2) return True; + if (pReg1 == pReg2) + return True; - if (pReg1 == NullRegion || pReg2 == NullRegion) return False; + if (pReg1 == NullRegion || pReg2 == NullRegion) + return False; - pBox1 = RegionRects(pReg1); - n1 = RegionNumRects(pReg1); + pBox1 = RegionRects(pReg1); + n1 = RegionNumRects(pReg1); - pBox2 = RegionRects(pReg2); - n2 = RegionNumRects(pReg2); + pBox2 = RegionRects(pReg2); + n2 = RegionNumRects(pReg2); - if (n1 != n2) return False; + if (n1 != n2) + return False; - if (pBox1 == pBox2) return True; + if (pBox1 == pBox2) + return True; - if (memcmp(pBox1, pBox2, n1 * sizeof(BoxRec))) return False; + if (memcmp(pBox1, pBox2, n1 * sizeof(BoxRec))) + return False; - return True; + return True; } void xnestShapeWindow(WindowPtr pWin) { - Region reg; - BoxPtr pBox; - XRectangle rect; - int i; - - if (!xnestRegionEqual(xnestWindowPriv(pWin)->bounding_shape, - wBoundingShape(pWin))) { - - if (wBoundingShape(pWin)) { - RegionCopy(xnestWindowPriv(pWin)->bounding_shape, wBoundingShape(pWin)); - - reg = XCreateRegion(); - pBox = RegionRects(xnestWindowPriv(pWin)->bounding_shape); - for (i = 0; - i < RegionNumRects(xnestWindowPriv(pWin)->bounding_shape); - i++) { - rect.x = pBox[i].x1; - rect.y = pBox[i].y1; - rect.width = pBox[i].x2 - pBox[i].x1; - rect.height = pBox[i].y2 - pBox[i].y1; - XUnionRectWithRegion(&rect, reg, reg); - } - XShapeCombineRegion(xnestDisplay, xnestWindow(pWin), - ShapeBounding, 0, 0, reg, ShapeSet); - XDestroyRegion(reg); - } - else { - RegionEmpty(xnestWindowPriv(pWin)->bounding_shape); - - XShapeCombineMask(xnestDisplay, xnestWindow(pWin), - ShapeBounding, 0, 0, None, ShapeSet); - } - } - - if (!xnestRegionEqual(xnestWindowPriv(pWin)->clip_shape, - wClipShape(pWin))) { - - if (wClipShape(pWin)) { - RegionCopy(xnestWindowPriv(pWin)->clip_shape, wClipShape(pWin)); - - reg = XCreateRegion(); - pBox = RegionRects(xnestWindowPriv(pWin)->clip_shape); - for (i = 0; - i < RegionNumRects(xnestWindowPriv(pWin)->clip_shape); - i++) { - rect.x = pBox[i].x1; - rect.y = pBox[i].y1; - rect.width = pBox[i].x2 - pBox[i].x1; - rect.height = pBox[i].y2 - pBox[i].y1; - XUnionRectWithRegion(&rect, reg, reg); - } - XShapeCombineRegion(xnestDisplay, xnestWindow(pWin), - ShapeClip, 0, 0, reg, ShapeSet); - XDestroyRegion(reg); + Region reg; + BoxPtr pBox; + XRectangle rect; + int i; + + if (!xnestRegionEqual(xnestWindowPriv(pWin)->bounding_shape, + wBoundingShape(pWin))) { + + if (wBoundingShape(pWin)) { + RegionCopy(xnestWindowPriv(pWin)->bounding_shape, + wBoundingShape(pWin)); + + reg = XCreateRegion(); + pBox = RegionRects(xnestWindowPriv(pWin)->bounding_shape); + for (i = 0; + i < RegionNumRects(xnestWindowPriv(pWin)->bounding_shape); + i++) { + rect.x = pBox[i].x1; + rect.y = pBox[i].y1; + rect.width = pBox[i].x2 - pBox[i].x1; + rect.height = pBox[i].y2 - pBox[i].y1; + XUnionRectWithRegion(&rect, reg, reg); + } + XShapeCombineRegion(xnestDisplay, xnestWindow(pWin), + ShapeBounding, 0, 0, reg, ShapeSet); + XDestroyRegion(reg); + } + else { + RegionEmpty(xnestWindowPriv(pWin)->bounding_shape); + + XShapeCombineMask(xnestDisplay, xnestWindow(pWin), + ShapeBounding, 0, 0, None, ShapeSet); + } } - else { - RegionEmpty(xnestWindowPriv(pWin)->clip_shape); - - XShapeCombineMask(xnestDisplay, xnestWindow(pWin), - ShapeClip, 0, 0, None, ShapeSet); + + if (!xnestRegionEqual(xnestWindowPriv(pWin)->clip_shape, wClipShape(pWin))) { + + if (wClipShape(pWin)) { + RegionCopy(xnestWindowPriv(pWin)->clip_shape, wClipShape(pWin)); + + reg = XCreateRegion(); + pBox = RegionRects(xnestWindowPriv(pWin)->clip_shape); + for (i = 0; + i < RegionNumRects(xnestWindowPriv(pWin)->clip_shape); i++) { + rect.x = pBox[i].x1; + rect.y = pBox[i].y1; + rect.width = pBox[i].x2 - pBox[i].x1; + rect.height = pBox[i].y2 - pBox[i].y1; + XUnionRectWithRegion(&rect, reg, reg); + } + XShapeCombineRegion(xnestDisplay, xnestWindow(pWin), + ShapeClip, 0, 0, reg, ShapeSet); + XDestroyRegion(reg); + } + else { + RegionEmpty(xnestWindowPriv(pWin)->clip_shape); + + XShapeCombineMask(xnestDisplay, xnestWindow(pWin), + ShapeClip, 0, 0, None, ShapeSet); + } } - } } diff --git a/hw/xnest/XNCursor.h b/hw/xnest/XNCursor.h index 473b2017f..1a3c6f44e 100644 --- a/hw/xnest/XNCursor.h +++ b/hw/xnest/XNCursor.h @@ -22,11 +22,12 @@ typedef struct { } xnestCursorFuncRec, *xnestCursorFuncPtr; extern DevPrivateKeyRec xnestCursorScreenKeyRec; + #define xnestCursorScreenKey (&xnestCursorScreenKeyRec) extern xnestCursorFuncRec xnestCursorFuncs; typedef struct { - Cursor cursor; + Cursor cursor; } xnestPrivCursor; #define xnestGetCursorPriv(pCursor, pScreen) ((xnestPrivCursor *) \ @@ -39,21 +40,13 @@ typedef struct { (xnestGetCursorPriv(pCursor, pScreen)->cursor) Bool xnestRealizeCursor(DeviceIntPtr pDev, - ScreenPtr pScreen, - CursorPtr pCursor); + ScreenPtr pScreen, CursorPtr pCursor); Bool xnestUnrealizeCursor(DeviceIntPtr pDev, - ScreenPtr pScreen, - CursorPtr pCursor); -void xnestRecolorCursor(ScreenPtr pScreen, - CursorPtr pCursor, - Bool displayed); -void xnestSetCursor (DeviceIntPtr pDev, - ScreenPtr pScreen, - CursorPtr pCursor, - int x, int y); -void xnestMoveCursor (DeviceIntPtr pDev, - ScreenPtr pScreen, - int x, int y); + ScreenPtr pScreen, CursorPtr pCursor); +void xnestRecolorCursor(ScreenPtr pScreen, CursorPtr pCursor, Bool displayed); +void xnestSetCursor(DeviceIntPtr pDev, + ScreenPtr pScreen, CursorPtr pCursor, int x, int y); +void xnestMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y); Bool xnestDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScreen); void xnestDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScreen); -#endif /* XNESTCURSOR_H */ +#endif /* XNESTCURSOR_H */ diff --git a/hw/xnest/XNFont.h b/hw/xnest/XNFont.h index 92c112f36..a210b1790 100644 --- a/hw/xnest/XNFont.h +++ b/hw/xnest/XNFont.h @@ -16,7 +16,7 @@ is" without express or implied warranty. #define XNESTFONT_H typedef struct { - XFontStruct *font_struct; + XFontStruct *font_struct; } xnestPrivFont; extern int xnestFontPrivateIndex; @@ -31,4 +31,4 @@ extern int xnestFontPrivateIndex; Bool xnestRealizeFont(ScreenPtr pScreen, FontPtr pFont); Bool xnestUnrealizeFont(ScreenPtr pScreen, FontPtr pFont); -#endif /* XNESTFONT_H */ +#endif /* XNESTFONT_H */ diff --git a/hw/xnest/XNGC.h b/hw/xnest/XNGC.h index c4a6cef77..c7c25e426 100644 --- a/hw/xnest/XNGC.h +++ b/hw/xnest/XNGC.h @@ -18,10 +18,11 @@ is" without express or implied warranty. /* This file uses the GC definition form Xlib.h as XlibGC. */ typedef struct { - XlibGC gc; + XlibGC gc; } xnestPrivGC; extern DevPrivateKeyRec xnestGCPrivateKeyRec; + #define xnestGCPrivateKey (&xnestGCPrivateKeyRec) #define xnestGCPriv(pGC) ((xnestPrivGC *) \ @@ -39,4 +40,4 @@ void xnestDestroyClip(GCPtr pGC); void xnestDestroyClipHelper(GCPtr pGC); void xnestCopyClip(GCPtr pGCDst, GCPtr pGCSrc); -#endif /* XNESTGC_H */ +#endif /* XNESTGC_H */ diff --git a/hw/xnest/XNPixmap.h b/hw/xnest/XNPixmap.h index aa671ed1f..268ba1e8b 100644 --- a/hw/xnest/XNPixmap.h +++ b/hw/xnest/XNPixmap.h @@ -16,10 +16,11 @@ is" without express or implied warranty. #define XNESTPIXMAP_H extern DevPrivateKeyRec xnestPixmapPrivateKeyRec; + #define xnestPixmapPrivateKey (&xnestPixmapPrivateKeyRec) typedef struct { - Pixmap pixmap; + Pixmap pixmap; } xnestPrivPixmap; #define xnestPixmapPriv(pPixmap) ((xnestPrivPixmap *) \ @@ -30,8 +31,8 @@ typedef struct { #define xnestSharePixmap(pPixmap) ((pPixmap)->refcnt++) PixmapPtr xnestCreatePixmap(ScreenPtr pScreen, int width, int height, - int depth, unsigned usage_hint); + int depth, unsigned usage_hint); Bool xnestDestroyPixmap(PixmapPtr pPixmap); RegionPtr xnestPixmapToRegion(PixmapPtr pPixmap); -#endif /* XNESTPIXMAP_H */ +#endif /* XNESTPIXMAP_H */ diff --git a/hw/xnest/XNWindow.h b/hw/xnest/XNWindow.h index f4d8fc7d6..02b0f3f36 100644 --- a/hw/xnest/XNWindow.h +++ b/hw/xnest/XNWindow.h @@ -16,24 +16,25 @@ is" without express or implied warranty. #define XNESTWINDOW_H typedef struct { - Window window; - Window parent; - int x; - int y; - unsigned int width; - unsigned int height; - unsigned int border_width; - Window sibling_above; - RegionPtr bounding_shape; - RegionPtr clip_shape; + Window window; + Window parent; + int x; + int y; + unsigned int width; + unsigned int height; + unsigned int border_width; + Window sibling_above; + RegionPtr bounding_shape; + RegionPtr clip_shape; } xnestPrivWin; typedef struct { - WindowPtr pWin; - Window window; + WindowPtr pWin; + Window window; } xnestWindowMatch; extern DevPrivateKeyRec xnestWindowPrivateKeyRec; + #define xnestWindowPrivateKey (&xnestWindowPrivateKeyRec) #define xnestWindowPriv(pWin) ((xnestPrivWin *) \ @@ -66,8 +67,8 @@ Bool xnestUnrealizeWindow(WindowPtr pWin); void xnestCopyWindow(WindowPtr pWin, xPoint oldOrigin, RegionPtr oldRegion); void xnestClipNotify(WindowPtr pWin, int dx, int dy); void xnestWindowExposures(WindowPtr pWin, RegionPtr pRgn, - RegionPtr other_exposed); + RegionPtr other_exposed); void xnestSetShape(WindowPtr pWin, int kind); void xnestShapeWindow(WindowPtr pWin); -#endif /* XNESTWINDOW_H */ +#endif /* XNESTWINDOW_H */ diff --git a/hw/xnest/Xnest.h b/hw/xnest/Xnest.h index 827030c8f..adb9daf8b 100644 --- a/hw/xnest/Xnest.h +++ b/hw/xnest/Xnest.h @@ -40,6 +40,7 @@ typedef unsigned long Mask64; typedef unsigned long Atom64; typedef unsigned long VisualID64; typedef unsigned long Time64; + #define XID XID64 #define Mask Mask64 #define Atom Atom64 @@ -53,6 +54,7 @@ typedef XID Cursor64; typedef XID Colormap64; typedef XID GContext64; typedef XID KeySym64; + #define Window Window64 #define Drawable Drawable64 #define Font Font64 @@ -86,9 +88,3 @@ typedef XID KeySym64; #undef GContext #undef KeySym #endif /*_XSERVER64_tmp*/ - - - - - - diff --git a/hw/xnest/xnest-config.h b/hw/xnest/xnest-config.h index 4889f1fdd..ef48c580f 100644 --- a/hw/xnest/xnest-config.h +++ b/hw/xnest/xnest-config.h @@ -33,4 +33,4 @@ #undef MITSHM -#endif /* XNEST_CONFIG_H */ +#endif /* XNEST_CONFIG_H */ |