--- xc/config/cf/X11.tmpl.orig Sat Apr 21 12:43:26 2001 +++ xc/config/cf/X11.tmpl Mon Apr 23 19:30:15 2001 @@ -583,6 +583,19 @@ #define XineramaDefines /**/ #endif #endif +#ifndef ServerCursorDefines +#if EnableEnlargeCursor +#define EnlargeCursorDefines -DENLARGE_CURSOR +#else +define EnlargeCursorDefines /**/ +#endif +#if EnableMangleCursorColors +#define MangleCursorColorsDefines -DTOUCH_CURSOR_COLORS +#else +define MangleCursorColorsDefines /**/ +#endif +#define ServerCursorDefines EnlargeCursorDefines MangleCursorColorsDefines +#endif #ifndef XieDefines #if BuildXIE #define XieDefines -DXIE @@ -831,7 +844,7 @@ #define ServerAssertDefines -DNDEBUG #endif #ifndef ServerDefines -#define ServerDefines StandardDefines PervasiveExtensionDefines ServerExtraDefines ServerAssertDefines +#define ServerDefines StandardDefines PervasiveExtensionDefines ServerExtraDefines ServerAssertDefines ServerCursorDefines #endif #ifndef PexDipexDefines #define PexDipexDefines /**/ --- xc/config/cf/xf86site.def.orig Sat Apr 21 12:43:26 2001 +++ xc/config/cf/xf86site.def Mon Apr 23 18:53:27 2001 @@ -501,6 +501,18 @@ #define BuildXinerama NO */ +/* + * If you don't want to enable cursor doubling, uncomment this. + * +#define EnableEnlargeCursor NO + */ + +/* + * If you don't want to enable changing default cursor colors, uncomment this. + * +#define EnableMangleCursorColors NO + */ + /* * If you don't want to build support for an external GLX server module or * library, uncomment this. --- xc/config/cf/xfree86.cf.orig Sat Apr 21 12:43:26 2001 +++ xc/config/cf/xfree86.cf Mon Apr 23 19:19:06 2001 @@ -785,6 +785,16 @@ # define BuildXinerama YES #endif +/* Compile in cursor doubling code */ +#ifndef EnableEnlargeCursor +# define EnableEnlargeCursor YES +#endif + +/* Compile in default cursor recoloring support */ +#ifndef EnableMangleCursorColors +# define EnableMangleCursorColors YES +#endif + /* Build Render extension */ #ifndef BuildRender # define BuildRender YES --- xc/programs/Xserver/dix/cursor.c.orig Sun Oct 4 16:38:02 1998 +++ xc/programs/Xserver/dix/cursor.c Wed May 9 11:39:24 2001 @@ -318,6 +318,9 @@ xfree(srcbits); return BadAlloc; } +#ifdef ENLARGE_CURSOR + if (enlargeCursor) EnlargeCursorBitmapInPlace(&cm, srcbits, mskbits); +#endif bits->source = srcbits; bits->mask = mskbits; bits->width = cm.width; @@ -397,6 +400,7 @@ FontPtr cursorfont; int err; XID fontID; + int foreRed, foreGreen, foreBlue, backRed, backGreen, backBlue; fontID = FakeClientID(0); err = OpenFont(serverClient, fontID, FontLoadAll | FontOpenSync, @@ -407,8 +411,12 @@ cursorfont = (FontPtr)LookupIDByType(fontID, RT_FONT); if (!cursorfont) return NullCursor; + GetPreferredCursorColors(0, 0, 0, ~0, ~0, ~0, + &foreRed, &foreGreen, &foreBlue, + &backRed, &backGreen, &backBlue); if (AllocGlyphCursor(fontID, glyph, fontID, glyph + 1, - 0, 0, 0, ~0, ~0, ~0, &curs, serverClient) != Success) + foreRed, foreGreen, foreBlue, backRed, backGreen, backBlue, + &curs, serverClient) != Success) return NullCursor; if (!AddResource(FakeClientID(0), RT_CURSOR, (pointer)curs)) @@ -416,3 +424,149 @@ return curs; } + +/*********************************************************** + * GetPreferredCursorColors + *************************************************************/ + +void +GetPreferredCursorColors(clnForeRed, clnForeGreen, clnForeBlue, + clnBackRed, clnBackGreen, clnBackBlue, + retForeRed, retForeGreen, retForeBlue, + retBackRed, retBackGreen, retBackBlue) + int clnForeRed; + int clnForeGreen; + int clnForeBlue; + int clnBackRed; + int clnBackGreen; + int clnBackBlue; + int * retForeRed; + int * retForeGreen; + int * retForeBlue; + int * retBackRed; + int * retBackGreen; + int * retBackBlue; +{ + /* + * fill in client-supplied values first + */ + *retForeRed = clnForeRed; + *retForeGreen = clnForeGreen; + *retForeBlue = clnForeBlue; + *retBackRed = clnBackRed; + *retBackGreen = clnBackGreen; + *retBackBlue = clnBackBlue; + +#ifdef TOUCH_CURSOR_COLORS + /* + * detect the XCreateFontCursor()'s hardcoded "black&white" behaviour + * (the 0xFF00 checks are for simple-minded clients which do 24bit->48bit + * color expansion by <<8, so that #FFFFFF converts to #FF00FF00FF00) + */ + if ( (clnForeRed | clnForeGreen | clnForeBlue) == 0 && + ((clnBackRed & clnBackGreen & clnBackBlue & 65535) == 65535 || + (clnBackRed == 0xFF00 && clnBackGreen == 0xFF00 && clnBackBlue == 0xFF00))) + { + if (touchCursorFore) + { + *retForeRed = curForeRed; + *retForeGreen = curForeGreen; + *retForeBlue = curForeBlue; + } + if (touchCursorBack) + { + *retBackRed = curBackRed; + *retBackGreen = curBackGreen; + *retBackBlue = curBackBlue; + } + } +#endif +} + +#ifdef TOUCH_CURSOR_COLORS +void +RememberCursorForeName(name) + char *name; +{ + if (curForeName) xfree(curForeName); + curForeName = xalloc(strlen(name) + 1); + if (!curForeName) + FatalError("Out of Memory\n"); + strcpy(curForeName, name); +} + +void +RememberCursorBackName(name) + char *name; +{ + if (curBackName) xfree(curBackName); + curBackName = xalloc(strlen(name) + 1); + if (!curBackName) + FatalError("Out of Memory\n"); + strcpy(curBackName, name); +} +#endif + +#ifdef ENLARGE_CURSOR +/*********************************************************** + * EnlargeCursorBitmapInPlace + * + * The "cm_p" parameter should be "CursorMetricRec*", but that + * is defined in cursorstr.h, which #includes cursor.h, so in + * order to prevent loop includes we use "void*" and casting. + *************************************************************/ + +#define CM_P ((CursorMetricRec*)cm_p) + +void +EnlargeCursorBitmapInPlace(cm_p, srcbits, mskbits) + void *cm_p; + unsigned char *srcbits; + unsigned char *mskbits; +{ + long s_bpl = BitmapBytePad(CM_P->width); + long e_bpl = BitmapBytePad(CM_P->width * 2); + int src_or_msk; + unsigned char *s_p; + unsigned char *e_p; + int y; + long e_counter; + int byte_value; + + static unsigned char doubledbits[16] = + { + 0x00, 0x03, 0x0c, 0x0f, 0x30, 0x33, 0x3c, 0x3f, + 0xc0, 0xc3, 0xcc, 0xcf, 0xf0, 0xf3, 0xfc, 0xff, + }; + + for (src_or_msk = 0, s_p = srcbits, e_p = srcbits; + src_or_msk <= 1; + src_or_msk++, s_p = mskbits, e_p = mskbits) + { + /* Advance pointers to ends of bitmaps */ + s_p += s_bpl*(CM_P->height) - s_bpl + e_bpl/2; + e_p += e_bpl*(CM_P->height)*2; + + for (y = CM_P->height; --y >= 0;) + { + for (e_counter = e_bpl/2; --e_counter >= 0;) + { + byte_value = *--s_p; + --e_p; + *e_p = *(e_p - e_bpl) = doubledbits[byte_value>>4]; + --e_p; + *e_p = *(e_p - e_bpl) = doubledbits[byte_value&0xF]; + } + + /* Move pointers to ends of previous lines */ + s_p -= s_bpl - e_bpl/2; + e_p -= e_bpl; + } + } + + CM_P->width *= 2; + CM_P->height *= 2; + CM_P->xhot *= 2; + CM_P->yhot *= 2; +} +#endif --- xc/programs/Xserver/dix/dispatch.c.orig Sat Oct 28 08:20:37 2000 +++ xc/programs/Xserver/dix/dispatch.c Wed May 9 11:39:24 2001 @@ -3092,6 +3092,7 @@ unsigned short width, height; long n; CursorMetricRec cm; + int foreRed, foreGreen, foreBlue, backRed, backGreen, backBlue; REQUEST(xCreateCursorReq); @@ -3129,6 +3130,11 @@ || stuff->y > height ) return (BadMatch); +#ifdef ENLARGE_CURSOR + if (enlargeCursor) + n = BitmapBytePad(width*2)*height*2; + else +#endif n = BitmapBytePad(width)*height; srcbits = (unsigned char *)xalloc(n); if (!srcbits) @@ -3161,9 +3167,16 @@ cm.height = height; cm.xhot = stuff->x; cm.yhot = stuff->y; +#if ENLARGE_CURSOR + if (enlargeCursor) EnlargeCursorBitmapInPlace(&cm, srcbits, mskbits); +#endif + GetPreferredCursorColors(stuff->foreRed, stuff->foreGreen, stuff->foreBlue, + stuff->backRed, stuff->backGreen, stuff->backBlue, + &foreRed, &foreGreen, &foreBlue, + &backRed, &backGreen, &backBlue); pCursor = AllocCursor( srcbits, mskbits, &cm, - stuff->foreRed, stuff->foreGreen, stuff->foreBlue, - stuff->backRed, stuff->backGreen, stuff->backBlue); + foreRed, foreGreen, foreBlue, + backRed, backGreen, backBlue); if (pCursor && AddResource(stuff->cid, RT_CURSOR, (pointer)pCursor)) return (client->noClientException); @@ -3176,16 +3189,21 @@ { CursorPtr pCursor; int res; + int foreRed, foreGreen, foreBlue, backRed, backGreen, backBlue; REQUEST(xCreateGlyphCursorReq); REQUEST_SIZE_MATCH(xCreateGlyphCursorReq); LEGAL_NEW_RESOURCE(stuff->cid, client); + GetPreferredCursorColors(stuff->foreRed, stuff->foreGreen, stuff->foreBlue, + stuff->backRed, stuff->backGreen, stuff->backBlue, + &foreRed, &foreGreen, &foreBlue, + &backRed, &backGreen, &backBlue); res = AllocGlyphCursor(stuff->source, stuff->sourceChar, stuff->mask, stuff->maskChar, - stuff->foreRed, stuff->foreGreen, stuff->foreBlue, - stuff->backRed, stuff->backGreen, stuff->backBlue, + foreRed, foreGreen, foreBlue, + backRed, backGreen, backBlue, &pCursor, client); if (res != Success) return res; --- xc/programs/Xserver/dix/globals.c.orig Sat Sep 25 21:36:51 1999 +++ xc/programs/Xserver/dix/globals.c Wed May 9 11:39:24 2001 @@ -141,3 +141,17 @@ char **argvGlobal; DDXPointRec dixScreenOrigins[MAXSCREENS]; + +#ifdef ENLARGE_CURSOR +Bool enlargeCursor = FALSE; +Bool enlargeCursorSpecified = FALSE; +#endif + +#ifdef TOUCH_CURSOR_COLORS +Bool touchCursorFore = FALSE; +Bool touchCursorBack = FALSE; +char *curForeName = NULL; +char *curBackName = NULL; +unsigned short curForeRed, curForeGreen, curForeBlue; +unsigned short curBackRed, curBackGreen, curBackBlue; +#endif --- xc/programs/Xserver/dix/glyphcurs.c.orig Sun Sep 27 15:03:21 1998 +++ xc/programs/Xserver/dix/glyphcurs.c Wed May 9 11:39:24 2001 @@ -87,6 +87,11 @@ char2b[1] = (unsigned char)(ch & 0xff); pScreen = screenInfo.screens[0]; +#ifdef ENLARGE_CURSOR + if (enlargeCursor) + nby = BitmapBytePad(cm->width * 2) * (long)cm->height * 2; + else +#endif nby = BitmapBytePad(cm->width) * (long)cm->height; pbits = (char *)xalloc(nby); if (!pbits) --- xc/programs/Xserver/hw/xfree86/common/xf86Config.c.orig Sat Dec 9 09:58:35 2000 +++ xc/programs/Xserver/hw/xfree86/common/xf86Config.c Wed May 9 12:32:56 2001 @@ -693,7 +693,10 @@ FLAG_PC98, FLAG_ESTIMATE_SIZES_AGGRESSIVELY, FLAG_NOPM, - FLAG_XINERAMA + FLAG_XINERAMA, + FLAG_ENLARGE_CURSOR, + FLAG_CURSOR_FG, + FLAG_CURSOR_BG } FlagValues; static OptionInfoRec FlagOptions[] = { @@ -745,6 +748,12 @@ {0}, FALSE }, { FLAG_XINERAMA, "Xinerama", OPTV_BOOLEAN, {0}, FALSE }, + { FLAG_ENLARGE_CURSOR, "EnlargeCursor", OPTV_BOOLEAN, + {0}, FALSE }, + { FLAG_CURSOR_FG, "CursorFg", OPTV_STRING, + {0}, FALSE }, + { FLAG_CURSOR_BG, "CursorBg", OPTV_STRING, + {0}, FALSE }, { -1, NULL, OPTV_NONE, {0}, FALSE } }; @@ -774,6 +783,7 @@ Pix24Flags pix24 = Pix24DontCare; Bool value; MessageType from; + char *str_value; if(flagsconf == NULL) return TRUE; @@ -926,6 +936,41 @@ } if (!noPanoramiXExtension) xf86Msg(from, "Xinerama: enabled\n"); +#endif + +#ifdef ENLARGE_CURSOR + from = X_DEFAULT; + if (enlargeCursorSpecified) from = X_CMDLINE; + if (xf86GetOptValBool(FlagOptions, FLAG_ENLARGE_CURSOR, &value) && from == X_DEFAULT) { + enlargeCursor = value; + from = X_CONFIG; + } + if (from != X_DEFAULT) + xf86Msg(from, "EnlargeCursor: %s\n", enlargeCursor? "enabled":"disabled"); +#endif + +#ifdef TOUCH_CURSOR_COLORS + from = X_DEFAULT; + if (curForeName) + from = X_CMDLINE; + else if ((str_value = xf86GetOptValString(FlagOptions, FLAG_CURSOR_FG))) + { + RememberCursorForeName(str_value); + from = X_CONFIG; + } + if (curForeName) + xf86Msg(from, "CursorFg: %s\n", curForeName); + + from = X_DEFAULT; + if (curBackName) + from = X_CMDLINE; + else if ((str_value = xf86GetOptValString(FlagOptions, FLAG_CURSOR_BG))) + { + RememberCursorBackName(str_value); + from = X_CONFIG; + } + if (curBackName) + xf86Msg(from, "CursorBg: %s\n", curBackName); #endif return TRUE; --- xc/programs/Xserver/hw/xfree86/common/xf86Init.c.orig Tue Dec 5 06:54:54 2000 +++ xc/programs/Xserver/hw/xfree86/common/xf86Init.c Wed May 9 11:39:24 2001 @@ -190,6 +190,59 @@ return (ret); } +#ifdef TOUCH_CURSOR_COLORS +/* + * The code is almost verbatim copy of hw/dec/ws/cfbinit.c::colorNameToColor() + */ +static Bool +ConvertColorName(name, red_v, green_v, blue_v, whichone) + char *name; + unsigned short *red_v; + unsigned short *green_v; + unsigned short *blue_v; + char *whichone; +{ + if ( *name == '#' && strlen(name) == 7) + { + name++; /* skip over # */ + sscanf( name, "%2hx", red_v); + *red_v *= 0x101; + + name += 2; + sscanf( name, "%2hx", green_v); + *green_v *= 0x101; + + name += 2; + sscanf( name, "%2hx", blue_v); + *blue_v *= 0x101; + } + else /* named color */ + { + if (!OsLookupColor( 0 /*"screen", not used*/, name, strlen( name), + red_v, green_v, blue_v)) + { + xf86Msg(X_NOTICE, "Cursor %s color name \"%s\" is not defined\n", + whichone, name); + return FALSE; + } + } + + xf86Msg(X_INFO, "Using (0x%04x,0x%04x,0x%04x) for cursor %s color\n", + *red_v, *green_v, *blue_v, whichone); + + return TRUE; +} + +static void +ConvertCursorColorNames(void) +{ + if (curForeName) touchCursorFore = + ConvertColorName(curForeName, &curForeRed, &curForeGreen, &curForeBlue, "foreground"); + if (curBackName) touchCursorBack = + ConvertColorName(curBackName, &curBackRed, &curBackGreen, &curBackBlue, "background"); +} +#endif + /* * InitOutput -- @@ -292,6 +345,11 @@ /* Do this after XF86Config is read (it's normally in OsInit()) */ OsInitColors(); + +#ifdef TOUCH_CURSOR_COLORS + /* This has to be done after OsInitColors() */ + ConvertCursorColorNames(); +#endif /* Enable full I/O access */ xf86EnableIO(); --- xc/programs/Xserver/hw/xfree86/XF86Config.cpp.orig Sat Apr 21 12:43:26 2001 +++ xc/programs/Xserver/hw/xfree86/XF86Config.cpp Wed May 2 16:17:23 2001 @@ -519,6 +519,15 @@ .TP 7 .BI "Option \*qXinerama\*q \*q" boolean \*q enable or disable XINERAMA extension. Default is disabled. +.TP 7 +.BI "Option \*qEnlargeCursor\*q \*q" boolean \*q +enable or disable large mouse cursor. Default is disabled. +.TP 7 +.BI "Option \*qCursorFG\*q \*q" color \*q +change mouse cursor foreground. Default is black. +.TP 7 +.BI "Option \*qCursorBG\*q \*q" color \*q +change mouse cursor background. Default is white. .SH MODULE SECTION The .B Module --- xc/programs/Xserver/include/cursor.h.orig Sun Sep 27 15:02:46 1998 +++ xc/programs/Xserver/include/cursor.h Tue May 8 17:11:58 2001 @@ -144,4 +144,43 @@ #endif ); +extern void GetPreferredCursorColors( +#if NeedFunctionPrototypes + int /*clnForeRed*/, + int /*clnForeGreen*/, + int /*clnForeBlue*/, + int /*clnBackRed*/, + int /*clnBackGreen*/, + int /*clnBackBlue*/, + int * /*retForeRed*/, + int * /*retForeGreen*/, + int * /*retForeBlue*/, + int * /*retBackRed*/, + int * /*retBackGreen*/, + int * /*retBackBlue*/ +#endif +); + +#ifdef TOUCH_CURSOR_COLORS +extern void RememberCursorForeName( +#if NeedFunctionPrototypes + char * /*name*/ +#endif +); + +extern void RememberCursorBackName( +#if NeedFunctionPrototypes + char * /*name*/ +#endif +); +#endif + +extern void EnlargeCursorBitmapInPlace( +#if NeedFunctionPrototypes + void * /*cm_p, in fact a "CursorMetricRec*"*/, + unsigned char * /*srcbits_p*/, + unsigned char * /*mskbits_p*/ +#endif +); + #endif /* CURSOR_H */ --- xc/programs/Xserver/include/globals.h.orig Sat Jul 1 06:41:07 2000 +++ xc/programs/Xserver/include/globals.h Wed May 9 11:22:30 2001 @@ -48,5 +48,19 @@ extern Bool PanoramiXOneExposeRequest; #endif +#ifdef ENLARGE_CURSOR +extern Bool enlargeCursor; +extern Bool enlargeCursorSpecified; /* To distinguish "FALSE" and "unset" */ +#endif + +#ifdef TOUCH_CURSOR_COLORS +extern Bool touchCursorFore; +extern Bool touchCursorBack; +extern char *curForeName; +extern char *curBackName; +extern unsigned short curForeRed, curForeGreen, curForeBlue; +extern unsigned short curBackRed, curBackGreen, curBackBlue; +#endif + #endif /* _XSERV_GLOBAL_H_ */ --- xc/programs/Xserver/os/utils.c.orig Tue Dec 5 06:59:14 2000 +++ xc/programs/Xserver/os/utils.c Wed May 9 11:39:24 2001 @@ -590,6 +590,14 @@ ErrorF("+xinerama Enable XINERAMA extension\n"); ErrorF("-xinerama Disable XINERAMA extension\n"); #endif +#ifdef ENLARGE_CURSOR + ErrorF("+enlargecursor enable large mouse cursor\n"); + ErrorF("-enlargecursor disable large mouse cursor\n"); +#endif +#ifdef TOUCH_CURSOR_COLORS + ErrorF("-cursorfg color set default foreground for all mouse cursors\n"); + ErrorF("-cursorbg color set default background for all mouse cursors\n"); +#endif #ifdef XDMCP XdmcpUseMsg(); #endif @@ -941,6 +949,28 @@ } else if ( strcmp( argv[i], "-xinerama") == 0){ noPanoramiXExtension = TRUE; + } +#endif +#ifdef ENLARGE_CURSOR + else if ( strcmp( argv[i], "+enlargecursor") == 0){ + enlargeCursor = TRUE; + enlargeCursorSpecified = TRUE; + } + else if ( strcmp( argv[i], "-enlargecursor") == 0){ + enlargeCursor = FALSE; + enlargeCursorSpecified = TRUE; + } +#endif +#ifdef TOUCH_CURSOR_COLORS + else if ( strcmp( argv[i], "-cursorfg") == 0){ + if(++i >= argc) + UseMsg(); + RememberCursorForeName(argv[i]); + } + else if ( strcmp( argv[i], "-cursorbg") == 0){ + if(++i >= argc) + UseMsg(); + RememberCursorBackName(argv[i]); } #endif else if ( strcmp( argv[i], "-x") == 0) --- xc/programs/Xserver/Xserver.cpp.orig Tue Dec 12 02:29:32 2000 +++ xc/programs/Xserver/Xserver.cpp Wed May 2 18:26:31 2001 @@ -226,6 +226,15 @@ .TP 8 .B [+-]xinerama enable(+) or disable(-) XINERAMA extension. Default is disabled. +.TP 8 +.B [+-]enlargecursor +enable(+) or disable(-) large cursor. Default is disabled. +.TP 8 +.B \-cursorfg \fIcolor\fP +sets default foreground color for all cursors. +.TP 8 +.B \-cursorbg \fIcolor\fP +sets default background color for all cursors. .SH SERVER DEPENDENT OPTIONS Some X servers accept the following options: .TP 8