From 43bfc0971f9240b74e6d6318ae2f6dafab499617 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Sun, 11 Jul 2021 19:41:34 +0200 Subject: [PATCH] Apply Xorg coding style to xvnc.c Makes it easier to compare with upstream files as the formatting will be the same. --- unix/xserver/hw/vnc/xvnc.c | 1127 ++++++++++++++++++------------------ 1 file changed, 567 insertions(+), 560 deletions(-) diff --git a/unix/xserver/hw/vnc/xvnc.c b/unix/xserver/hw/vnc/xvnc.c index 04cbc386..e9ca3b70 100644 --- a/unix/xserver/hw/vnc/xvnc.c +++ b/unix/xserver/hw/vnc/xvnc.c @@ -66,7 +66,7 @@ from the X Consortium. #ifdef HAS_SHM #include #include -#endif /* HAS_SHM */ +#endif /* HAS_SHM */ #include "dix.h" #include "os.h" #include "miline.h" @@ -76,7 +76,8 @@ from the X Consortium. #include "dpmsproc.h" #endif #include - extern char buildtime[]; +extern char buildtime[]; + #undef VENDOR_RELEASE #undef VENDOR_STRING #include "version-config.h" @@ -94,8 +95,7 @@ from the X Consortium. #define VFB_DEFAULT_LINEBIAS 0 #define XWD_WINDOW_NAME_LEN 60 -typedef struct -{ +typedef struct { int width; int height; @@ -119,8 +119,7 @@ typedef struct #endif } vfbFramebufferInfo, *vfbFramebufferInfoPtr; -typedef struct -{ +typedef struct { int scrnum; Pixel blackPixel; @@ -150,7 +149,6 @@ static char displayNumStr[16]; static int vncVerbose = DEFAULT_LOG_VERBOSITY; - static void vncPrintBanner(void) { @@ -163,9 +161,10 @@ static void vfbInitializePixmapDepths(void) { int i; - vfbPixmapDepths[1] = TRUE; /* always need bitmaps */ + + vfbPixmapDepths[1] = TRUE; /* always need bitmaps */ for (i = 2; i <= 32; i++) - vfbPixmapDepths[i] = FALSE; + vfbPixmapDepths[i] = FALSE; } static void @@ -173,17 +172,16 @@ vfbInitializeDefaultScreens(void) { int i; - for (i = 0; i < MAXSCREENS; i++) - { - vfbScreens[i].scrnum = i; - vfbScreens[i].blackPixel = VFB_DEFAULT_BLACKPIXEL; - vfbScreens[i].whitePixel = VFB_DEFAULT_WHITEPIXEL; - vfbScreens[i].lineBias = VFB_DEFAULT_LINEBIAS; - vfbScreens[i].fb.width = VFB_DEFAULT_WIDTH; - vfbScreens[i].fb.height = VFB_DEFAULT_HEIGHT; - vfbScreens[i].fb.pfbMemory = NULL; - vfbScreens[i].fb.depth = VFB_DEFAULT_DEPTH; - vfbScreens[i].pixelFormatDefined = FALSE; + for (i = 0; i < MAXSCREENS; i++) { + vfbScreens[i].scrnum = i; + vfbScreens[i].blackPixel = VFB_DEFAULT_BLACKPIXEL; + vfbScreens[i].whitePixel = VFB_DEFAULT_WHITEPIXEL; + vfbScreens[i].lineBias = VFB_DEFAULT_LINEBIAS; + vfbScreens[i].fb.width = VFB_DEFAULT_WIDTH; + vfbScreens[i].fb.height = VFB_DEFAULT_HEIGHT; + vfbScreens[i].fb.pfbMemory = NULL; + vfbScreens[i].fb.depth = VFB_DEFAULT_DEPTH; + vfbScreens[i].pixelFormatDefined = FALSE; } vfbNumScreens = 1; } @@ -191,10 +189,14 @@ vfbInitializeDefaultScreens(void) static int vfbBitsPerPixel(int depth) { - if (depth == 1) return 1; - else if (depth <= 8) return 8; - else if (depth <= 16) return 16; - else return 32; + if (depth == 1) + return 1; + else if (depth <= 8) + return 8; + else if (depth <= 16) + return 16; + else + return 32; } static void vfbFreeFramebufferMemory(vfbFramebufferInfoPtr pfb); @@ -205,12 +207,14 @@ static void vfbFreeFramebufferMemory(vfbFramebufferInfoPtr pfb); such as Unity 2D on Ubuntu 11.10 crashes if DPMS is not available. (DPMSSet is called by dpms.c, but the return value is ignored.) */ -int DPMSSet(ClientPtr client, int level) +int +DPMSSet(ClientPtr client, int level) { return Success; } -Bool DPMSSupported(void) +Bool +DPMSSupported(void) { /* Causes DPMSCapable to return false, meaning no devices are DPMS capable */ @@ -219,7 +223,8 @@ Bool DPMSSupported(void) #endif #endif -void ddxGiveUp(enum ExitCode error) +void +ddxGiveUp(enum ExitCode error) { int i; @@ -250,8 +255,7 @@ DarwinGlxExtensionInit() } void -DarwinGlxWrapInitVisuals( - void *procPtr) +DarwinGlxWrapInitVisuals(void *procPtr) { GlxWrapInitVisuals(procPtr); } @@ -268,7 +272,8 @@ OsVendorFatalError(const char *f, va_list args) } #ifdef DDXBEFORERESET -void ddxBeforeReset(void) +void +ddxBeforeReset(void) { return; } @@ -283,14 +288,15 @@ ddxInputThreadInit(void) } #endif -void ddxUseMsg(void) +void +ddxUseMsg(void) { vncPrintBanner(); ErrorF("-screen scrn WxHxD set screen's width, height, depth\n"); ErrorF("-pixdepths list-of-int support given pixmap depths\n"); ErrorF("+/-render turn on/off RENDER extension support" - "(default on)\n"); + "(default on)\n"); ErrorF("-linebias n adjust thin line pixelization\n"); ErrorF("-blackpixel n pixel value for black\n"); ErrorF("-whitepixel n pixel value for white\n"); @@ -303,13 +309,14 @@ void ddxUseMsg(void) ErrorF("-depth D set screen 0's depth\n"); ErrorF("-pixelformat fmt set pixel format (rgbNNN or bgrNNN)\n"); ErrorF("-inetd has been launched from inetd\n"); - ErrorF("-noclipboard disable clipboard settings modification via vncconfig utility\n"); + ErrorF + ("-noclipboard disable clipboard settings modification via vncconfig utility\n"); ErrorF("-verbose [n] verbose startup messages\n"); ErrorF("-quiet minimal startup messages\n"); ErrorF("-version show the server version\n"); ErrorF("\nVNC parameters:\n"); - fprintf(stderr,"\n" + fprintf(stderr, "\n" "Parameters can be turned on with - or off with -=0\n" "Parameters which take a value can be specified as " "- \n" @@ -319,11 +326,12 @@ void ddxUseMsg(void) vncListParams(79, 14); } -static -Bool displayNumFree(int num) +static Bool +displayNumFree(int num) { char file[256]; - if (vncIsTCPPortUsed(6000+num)) + + if (vncIsTCPPortUsed(6000 + num)) return FALSE; sprintf(file, "/tmp/.X%d-lock", num); if (access(file, F_OK) == 0) @@ -344,187 +352,170 @@ Bool displayNumFree(int num) return 0; \ } -int +int ddxProcessArgument(int argc, char *argv[], int i) { static Bool firstTime = TRUE; - if (firstTime) - { + if (firstTime) { /* Force -noreset as default until we properly handle resets */ - dispatchExceptionAtReset = 0; + dispatchExceptionAtReset = 0; vfbInitializeDefaultScreens(); - vfbInitializePixmapDepths(); - firstTime = FALSE; - vncInitRFB(); + vfbInitializePixmapDepths(); + firstTime = FALSE; + vncInitRFB(); } - if (argv[i][0] == ':') + if (argv[i][0] == ':') displaySpecified = TRUE; - if (strcmp (argv[i], "-screen") == 0) /* -screen n WxHxD */ - { - int screenNum; - fail_unless_args(argc, i, 2); - screenNum = atoi(argv[i+1]); - if (screenNum < 0 || screenNum >= MAXSCREENS) - { - ErrorF("Invalid screen number %d\n", screenNum); - UseMsg(); - return 0; - } - if (3 != sscanf(argv[i+2], "%dx%dx%d", - &vfbScreens[screenNum].fb.width, - &vfbScreens[screenNum].fb.height, - &vfbScreens[screenNum].fb.depth)) - { - ErrorF("Invalid screen configuration %s\n", argv[i+2]); - UseMsg(); - return 0; - } - - if (screenNum >= vfbNumScreens) - vfbNumScreens = screenNum + 1; - lastScreen = screenNum; - return 3; + if (strcmp(argv[i], "-screen") == 0) { /* -screen n WxHxD */ + int screenNum; + + fail_unless_args(argc, i, 2); + screenNum = atoi(argv[i + 1]); + if (screenNum < 0 || screenNum >= MAXSCREENS) { + ErrorF("Invalid screen number %d\n", screenNum); + UseMsg(); + return 0; + } + if (3 != sscanf(argv[i + 2], "%dx%dx%d", + &vfbScreens[screenNum].fb.width, + &vfbScreens[screenNum].fb.height, + &vfbScreens[screenNum].fb.depth)) { + ErrorF("Invalid screen configuration %s\n", argv[i + 2]); + UseMsg(); + return 0; + } + + if (screenNum >= vfbNumScreens) + vfbNumScreens = screenNum + 1; + lastScreen = screenNum; + return 3; } - if (strcmp (argv[i], "-pixdepths") == 0) /* -pixdepths list-of-depth */ - { - int depth, ret = 1; - - fail_unless_args(argc, i, 1); - ++i; - while ((i < argc) && (depth = atoi(argv[i++])) != 0) - { - if (depth < 0 || depth > 32) - { - ErrorF("Invalid pixmap depth %d\n", depth); - UseMsg(); - return 0; - } - vfbPixmapDepths[depth] = TRUE; - ret++; - } - return ret; + if (strcmp(argv[i], "-pixdepths") == 0) { /* -pixdepths list-of-depth */ + int depth, ret = 1; + + fail_unless_args(argc, i, 1); + ++i; + while ((i < argc) && (depth = atoi(argv[i++])) != 0) { + if (depth < 0 || depth > 32) { + ErrorF("Invalid pixmap depth %d\n", depth); + UseMsg(); + return 0; + } + vfbPixmapDepths[depth] = TRUE; + ret++; + } + return ret; } - - if (strcmp (argv[i], "+render") == 0) /* +render */ - { - Render = TRUE; - return 1; + + if (strcmp(argv[i], "+render") == 0) { /* +render */ + Render = TRUE; + return 1; } - - if (strcmp (argv[i], "-render") == 0) /* -render */ - { - Render = FALSE; - return 1; + + if (strcmp(argv[i], "-render") == 0) { /* -render */ + Render = FALSE; + return 1; } - if (strcmp (argv[i], "-blackpixel") == 0) /* -blackpixel n */ - { - Pixel pix; - fail_unless_args(argc, i, 1); - ++i; - pix = atoi(argv[i]); - if (-1 == lastScreen) - { - int j; - for (j = 0; j < MAXSCREENS; j++) - { - vfbScreens[j].blackPixel = pix; - } - } - else - { - vfbScreens[lastScreen].blackPixel = pix; - } - return 2; + if (strcmp(argv[i], "-blackpixel") == 0) { /* -blackpixel n */ + Pixel pix; + + fail_unless_args(argc, i, 1); + ++i; + pix = atoi(argv[i]); + if (-1 == lastScreen) { + int j; + + for (j = 0; j < MAXSCREENS; j++) { + vfbScreens[j].blackPixel = pix; + } + } + else { + vfbScreens[lastScreen].blackPixel = pix; + } + return 2; } - if (strcmp (argv[i], "-whitepixel") == 0) /* -whitepixel n */ - { - Pixel pix; - fail_unless_args(argc, i, 1); - ++i; - pix = atoi(argv[i]); - if (-1 == lastScreen) - { - int j; - for (j = 0; j < MAXSCREENS; j++) - { - vfbScreens[j].whitePixel = pix; - } - } - else - { - vfbScreens[lastScreen].whitePixel = pix; - } - return 2; + if (strcmp(argv[i], "-whitepixel") == 0) { /* -whitepixel n */ + Pixel pix; + + fail_unless_args(argc, i, 1); + ++i; + pix = atoi(argv[i]); + if (-1 == lastScreen) { + int j; + + for (j = 0; j < MAXSCREENS; j++) { + vfbScreens[j].whitePixel = pix; + } + } + else { + vfbScreens[lastScreen].whitePixel = pix; + } + return 2; } - - if (strcmp (argv[i], "-linebias") == 0) /* -linebias n */ - { - unsigned int linebias; - fail_unless_args(argc, i, 1); - ++i; - linebias = atoi(argv[i]); - if (-1 == lastScreen) - { - int j; - for (j = 0; j < MAXSCREENS; j++) - { - vfbScreens[j].lineBias = linebias; - } - } - else - { - vfbScreens[lastScreen].lineBias = linebias; - } - return 2; + + if (strcmp(argv[i], "-linebias") == 0) { /* -linebias n */ + unsigned int linebias; + + fail_unless_args(argc, i, 1); + ++i; + linebias = atoi(argv[i]); + if (-1 == lastScreen) { + int j; + + for (j = 0; j < MAXSCREENS; j++) { + vfbScreens[j].lineBias = linebias; + } + } + else { + vfbScreens[lastScreen].lineBias = linebias; + } + return 2; } #ifdef HAS_SHM - if (strcmp (argv[i], "-shmem") == 0) /* -shmem */ - { - fbmemtype = SHARED_MEMORY_FB; - return 1; + if (strcmp(argv[i], "-shmem") == 0) { /* -shmem */ + fbmemtype = SHARED_MEMORY_FB; + return 1; } #endif - - if (strcmp(argv[i], "-geometry") == 0) - { - fail_unless_args(argc, i, 1); - ++i; - if (sscanf(argv[i],"%dx%d",&vfbScreens[0].fb.width, - &vfbScreens[0].fb.height) != 2) { - ErrorF("Invalid geometry %s\n", argv[i]); - UseMsg(); - return 0; - } - return 2; + + if (strcmp(argv[i], "-geometry") == 0) { + fail_unless_args(argc, i, 1); + ++i; + if (sscanf(argv[i], "%dx%d", &vfbScreens[0].fb.width, + &vfbScreens[0].fb.height) != 2) { + ErrorF("Invalid geometry %s\n", argv[i]); + UseMsg(); + return 0; + } + return 2; } - - if (strcmp(argv[i], "-depth") == 0) - { - fail_unless_args(argc, i, 1); - ++i; - vfbScreens[0].fb.depth = atoi(argv[i]); - return 2; + + if (strcmp(argv[i], "-depth") == 0) { + fail_unless_args(argc, i, 1); + ++i; + vfbScreens[0].fb.depth = atoi(argv[i]); + return 2; } - if (strcmp(argv[i], "-pixelformat") == 0) - { - char rgbbgr[4]; - int bits1, bits2, bits3; - fail_unless_args(argc, i, 1); - ++i; - if (sscanf(argv[i], "%3s%1d%1d%1d", rgbbgr,&bits1,&bits2,&bits3) < 4) { - ErrorF("Invalid pixel format %s\n", argv[i]); - UseMsg(); - return 0; - } + if (strcmp(argv[i], "-pixelformat") == 0) { + char rgbbgr[4]; + int bits1, bits2, bits3; + + fail_unless_args(argc, i, 1); + ++i; + if (sscanf(argv[i], "%3s%1d%1d%1d", rgbbgr, &bits1, &bits2, &bits3) < 4) { + ErrorF("Invalid pixel format %s\n", argv[i]); + UseMsg(); + return 0; + } #define SET_PIXEL_FORMAT(vfbScreen) \ (vfbScreen).pixelFormatDefined = TRUE; \ @@ -544,57 +535,58 @@ ddxProcessArgument(int argc, char *argv[], int i) return 0; \ } - if (-1 == lastScreen) - { - int j; - for (j = 0; j < MAXSCREENS; j++) - { - SET_PIXEL_FORMAT(vfbScreens[j]); - } - } - else - { - SET_PIXEL_FORMAT(vfbScreens[lastScreen]); - } - - return 2; + if (-1 == lastScreen) { + int j; + + for (j = 0; j < MAXSCREENS; j++) { + SET_PIXEL_FORMAT(vfbScreens[j]); + } + } + else { + SET_PIXEL_FORMAT(vfbScreens[lastScreen]); + } + + return 2; } - if (strcmp(argv[i], "-inetd") == 0) - { - int nullfd; - - dup2(0,3); - vncInetdSock = 3; - - /* Avoid xserver >= 1.19's epoll-fd becoming fd 2 / stderr only to be - replaced by /dev/null by OsInit() because the pollfd is not - writable, breaking ospoll_wait(). */ - nullfd = open("/dev/null", O_WRONLY); - dup2(nullfd, 2); - close(nullfd); - - if (!displaySpecified) { - int port = vncGetSocketPort(vncInetdSock); - int displayNum = port - 5900; - if (displayNum < 0 || displayNum > 99 || !displayNumFree(displayNum)) { - for (displayNum = 1; displayNum < 100; displayNum++) - if (displayNumFree(displayNum)) break; - - if (displayNum == 100) - FatalError("Xvnc error: no free display number for -inetd\n"); - } - - display = displayNumStr; - sprintf(displayNumStr, "%d", displayNum); - } - - return 1; + if (strcmp(argv[i], "-inetd") == 0) { + int nullfd; + + dup2(0, 3); + vncInetdSock = 3; + + /* Avoid xserver >= 1.19's epoll-fd becoming fd 2 / stderr only to be + replaced by /dev/null by OsInit() because the pollfd is not + writable, breaking ospoll_wait(). */ + nullfd = open("/dev/null", O_WRONLY); + dup2(nullfd, 2); + close(nullfd); + + if (!displaySpecified) { + int port = vncGetSocketPort(vncInetdSock); + int displayNum = port - 5900; + + if (displayNum < 0 || displayNum > 99 || + !displayNumFree(displayNum)) { + for (displayNum = 1; displayNum < 100; displayNum++) + if (displayNumFree(displayNum)) + break; + + if (displayNum == 100) + FatalError + ("Xvnc error: no free display number for -inetd\n"); + } + + display = displayNumStr; + sprintf(displayNumStr, "%d", displayNum); + } + + return 1; } if (strcmp(argv[i], "-noclipboard") == 0) { - vncNoClipboard = 1; - return 1; + vncNoClipboard = 1; + return 1; } if (!strcmp(argv[i], "-verbose")) { @@ -626,48 +618,48 @@ ddxProcessArgument(int argc, char *argv[], int i) } /* We need to resolve an ambiguity for booleans */ - if (argv[i][0] == '-' && i+1 < argc && - vncIsParamBool(&argv[i][1])) { - if ((strcasecmp(argv[i+1], "0") == 0) || - (strcasecmp(argv[i+1], "1") == 0) || - (strcasecmp(argv[i+1], "true") == 0) || - (strcasecmp(argv[i+1], "false") == 0) || - (strcasecmp(argv[i+1], "yes") == 0) || - (strcasecmp(argv[i+1], "no") == 0)) { - vncSetParam(&argv[i][1], argv[i+1]); + if (argv[i][0] == '-' && i + 1 < argc && vncIsParamBool(&argv[i][1])) { + if ((strcasecmp(argv[i + 1], "0") == 0) || + (strcasecmp(argv[i + 1], "1") == 0) || + (strcasecmp(argv[i + 1], "true") == 0) || + (strcasecmp(argv[i + 1], "false") == 0) || + (strcasecmp(argv[i + 1], "yes") == 0) || + (strcasecmp(argv[i + 1], "no") == 0)) { + vncSetParam(&argv[i][1], argv[i + 1]); return 2; } } if (vncSetParamSimple(argv[i])) - return 1; - - if (argv[i][0] == '-' && i+1 < argc) { - if (vncSetParam(&argv[i][1], argv[i+1])) - return 2; + return 1; + + if (argv[i][0] == '-' && i + 1 < argc) { + if (vncSetParam(&argv[i][1], argv[i + 1])) + return 2; } - + return 0; } -#ifdef DDXTIME /* from ServerOSDefines */ +#ifdef DDXTIME /* from ServerOSDefines */ CARD32 GetTimeInMillis() { - struct timeval tp; + struct timeval tp; X_GETTIMEOFDAY(&tp); - return(tp.tv_sec * 1000) + (tp.tv_usec / 1000); + return (tp.tv_sec * 1000) + (tp.tv_usec / 1000); } #endif static DevPrivateKeyRec cmapScrPrivateKeyRec; + #define cmapScrPrivateKey (&cmapScrPrivateKeyRec) #define GetInstalledColormap(s) ((ColormapPtr) dixLookupPrivate(&(s)->devPrivates, cmapScrPrivateKey)) #define SetInstalledColormap(s,c) (dixSetPrivate(&(s)->devPrivates, cmapScrPrivateKey, c)) -static int -vfbListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps) +static int +vfbListInstalledColormaps(ScreenPtr pScreen, Colormap * pmaps) { /* By the time we are processing requests, we can guarantee that there * is always a colormap installed */ @@ -675,54 +667,53 @@ vfbListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps) return (1); } - -static void +static void vfbInstallColormap(ColormapPtr pmap) { ColormapPtr oldpmap; oldpmap = GetInstalledColormap(pmap->pScreen); - if (pmap != oldpmap) - { - int entries; - VisualPtr pVisual; - Pixel * ppix; - xrgb * prgb; - xColorItem *defs; - int i; - - if(oldpmap != (ColormapPtr)None) - WalkTree(pmap->pScreen, TellLostMap, (char *)&oldpmap->mid); - /* Install pmap */ - SetInstalledColormap(pmap->pScreen, pmap); - WalkTree(pmap->pScreen, TellGainedMap, (char *)&pmap->mid); - - entries = pmap->pVisual->ColormapEntries; - pVisual = pmap->pVisual; - - ppix = (Pixel *)calloc(entries, sizeof(Pixel)); - prgb = (xrgb *)calloc(entries, sizeof(xrgb)); - defs = (xColorItem *)calloc(entries, sizeof(xColorItem)); - if (!ppix || !prgb || !defs) - FatalError ("Not enough memory for color map\n"); - - for (i = 0; i < entries; i++) ppix[i] = i; - /* XXX truecolor */ - QueryColors(pmap, entries, ppix, prgb, serverClient); - - for (i = 0; i < entries; i++) { /* convert xrgbs to xColorItems */ - defs[i].pixel = ppix[i] & 0xff; /* change pixel to index */ - defs[i].red = prgb[i].red; - defs[i].green = prgb[i].green; - defs[i].blue = prgb[i].blue; - defs[i].flags = DoRed|DoGreen|DoBlue; - } - (*pmap->pScreen->StoreColors)(pmap, entries, defs); - - free(ppix); - free(prgb); - free(defs); + if (pmap != oldpmap) { + int entries; + VisualPtr pVisual; + Pixel *ppix; + xrgb *prgb; + xColorItem *defs; + int i; + + if (oldpmap != (ColormapPtr) None) + WalkTree(pmap->pScreen, TellLostMap, (char *) &oldpmap->mid); + /* Install pmap */ + SetInstalledColormap(pmap->pScreen, pmap); + WalkTree(pmap->pScreen, TellGainedMap, (char *) &pmap->mid); + + entries = pmap->pVisual->ColormapEntries; + pVisual = pmap->pVisual; + + ppix = (Pixel *) calloc(entries, sizeof(Pixel)); + prgb = (xrgb *) calloc(entries, sizeof(xrgb)); + defs = (xColorItem *) calloc(entries, sizeof(xColorItem)); + if (!ppix || !prgb || !defs) + FatalError("Not enough memory for color map\n"); + + for (i = 0; i < entries; i++) + ppix[i] = i; + /* XXX truecolor */ + QueryColors(pmap, entries, ppix, prgb, serverClient); + + for (i = 0; i < entries; i++) { /* convert xrgbs to xColorItems */ + defs[i].pixel = ppix[i] & 0xff; /* change pixel to index */ + defs[i].red = prgb[i].red; + defs[i].green = prgb[i].green; + defs[i].blue = prgb[i].blue; + defs[i].flags = DoRed | DoGreen | DoBlue; + } + (*pmap->pScreen->StoreColors) (pmap, entries, defs); + + free(ppix); + free(prgb); + free(defs); } } @@ -731,17 +722,18 @@ vfbUninstallColormap(ColormapPtr pmap) { ColormapPtr curpmap = GetInstalledColormap(pmap->pScreen); - if(pmap == curpmap) - { - if (pmap->mid != pmap->pScreen->defColormap) - { - int rc = dixLookupResourceByType((void * *) &curpmap, pmap->pScreen->defColormap, - RT_COLORMAP, serverClient, DixUnknownAccess); - if (rc != Success) - ErrorF("Failed to uninstall color map\n"); - else - (*pmap->pScreen->InstallColormap)(curpmap); - } + if (pmap == curpmap) { + if (pmap->mid != pmap->pScreen->defColormap) { + int rc = + dixLookupResourceByType((void * *) &curpmap, + pmap->pScreen->defColormap, + RT_COLORMAP, serverClient, + DixUnknownAccess); + if (rc != Success) + ErrorF("Failed to uninstall color map\n"); + else + (*pmap->pScreen->InstallColormap) (curpmap); + } } } @@ -757,7 +749,7 @@ vfbAllocateSharedMemoryFramebuffer(vfbFramebufferInfoPtr pfb) { /* create the shared memory segment */ - pfb->shmid = shmget(IPC_PRIVATE, pfb->sizeInBytes, IPC_CREAT|0777); + pfb->shmid = shmget(IPC_PRIVATE, pfb->sizeInBytes, IPC_CREAT | 0777); if (pfb->shmid < 0) { perror("shmget"); ErrorF("shmget %d bytes failed, errno %d", pfb->sizeInBytes, errno); @@ -767,21 +759,20 @@ vfbAllocateSharedMemoryFramebuffer(vfbFramebufferInfoPtr pfb) /* try to attach it */ pfb->pfbMemory = shmat(pfb->shmid, 0, 0); - if (-1 == (long)pfb->pfbMemory) { + if (-1 == (long) pfb->pfbMemory) { perror("shmat"); ErrorF("shmat failed, errno %d", errno); - pfb->pfbMemory = NULL; + pfb->pfbMemory = NULL; return; } } -#endif /* HAS_SHM */ - +#endif /* HAS_SHM */ static void * vfbAllocateFramebufferMemory(vfbFramebufferInfoPtr pfb) { if (pfb->pfbMemory != NULL) - return pfb->pfbMemory; /* already done */ + return pfb->pfbMemory; /* already done */ /* Compute memory layout */ pfb->paddedBytesWidth = PixmapBytePad(pfb->width, pfb->depth); @@ -822,10 +813,10 @@ vfbFreeFramebufferMemory(vfbFramebufferInfoPtr pfb) ErrorF("shmdt failed, errno %d", errno); } break; -#else /* HAS_SHM */ +#else /* HAS_SHM */ case SHARED_MEMORY_FB: break; -#endif /* HAS_SHM */ +#endif /* HAS_SHM */ case NORMAL_MEMORY_FB: free(pfb->pfbMemory); break; @@ -835,7 +826,7 @@ vfbFreeFramebufferMemory(vfbFramebufferInfoPtr pfb) } static Bool -vfbCursorOffScreen (ScreenPtr *ppScreen, int *x, int *y) +vfbCursorOffScreen(ScreenPtr *ppScreen, int *x, int *y) { int absX, absY; int i; @@ -850,7 +841,7 @@ vfbCursorOffScreen (ScreenPtr *ppScreen, int *x, int *y) absX = *x + (*ppScreen)->x; absY = *y + (*ppScreen)->y; - for (i = 0;i < screenInfo.numScreens;i++) { + for (i = 0; i < screenInfo.numScreens; i++) { ScreenPtr newScreen; newScreen = screenInfo.screens[i]; @@ -875,41 +866,42 @@ vfbCursorOffScreen (ScreenPtr *ppScreen, int *x, int *y) } static void -vfbCrossScreen (ScreenPtr pScreen, Bool entering) +vfbCrossScreen(ScreenPtr pScreen, Bool entering) { } -static Bool vfbRealizeCursor(DeviceIntPtr pDev, - ScreenPtr pScreen, CursorPtr pCursor) +static Bool +vfbRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor) { return TRUE; } -static Bool vfbUnrealizeCursor(DeviceIntPtr pDev, - ScreenPtr pScreen, CursorPtr pCursor) +static Bool +vfbUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor) { return TRUE; } -static void vfbSetCursor(DeviceIntPtr pDev, - ScreenPtr pScreen, CursorPtr pCursor, int x, int y) +static void +vfbSetCursor(DeviceIntPtr pDev, + ScreenPtr pScreen, CursorPtr pCursor, int x, int y) { } -static void vfbMoveCursor(DeviceIntPtr pDev, - ScreenPtr pScreen, int x, int y) +static void +vfbMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y) { } static Bool vfbDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScreen) -{ +{ return TRUE; } static void vfbDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScreen) -{ +{ } static miPointerSpriteFuncRec vfbPointerSpriteFuncs = { @@ -927,119 +919,109 @@ static miPointerScreenFuncRec vfbPointerCursorFuncs = { miPointerWarpCursor }; - -static Bool vncRandRGetInfo (ScreenPtr pScreen, Rotation *rotations) +static Bool +vncRandRGetInfo(ScreenPtr pScreen, Rotation * rotations) { - // We update all information right away, so there is nothing to - // do here. - return TRUE; + // We update all information right away, so there is nothing to + // do here. + return TRUE; } /* from hw/xfree86/common/xf86Helper.c */ #include "mivalidate.h" static void -xf86SetRootClip (ScreenPtr pScreen, Bool enable) +xf86SetRootClip(ScreenPtr pScreen, Bool enable) { - WindowPtr pWin = pScreen->root; - WindowPtr pChild; - Bool WasViewable = (Bool)(pWin->viewable); - Bool anyMarked = FALSE; - WindowPtr pLayerWin; - BoxRec box; - - if (WasViewable) - { - for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib) - { - (void) (*pScreen->MarkOverlappedWindows)(pChild, - pChild, - &pLayerWin); - } - (*pScreen->MarkWindow) (pWin); - anyMarked = TRUE; - if (pWin->valdata) - { - if (HasBorder (pWin)) - { - RegionPtr borderVisible; - - borderVisible = RegionCreate(NullBox, 1); - RegionSubtract(borderVisible, - &pWin->borderClip, &pWin->winSize); - pWin->valdata->before.borderVisible = borderVisible; - } - pWin->valdata->before.resized = TRUE; - } + WindowPtr pWin = pScreen->root; + WindowPtr pChild; + Bool WasViewable = (Bool) (pWin->viewable); + Bool anyMarked = FALSE; + WindowPtr pLayerWin; + BoxRec box; + + if (WasViewable) { + for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib) { + (void) (*pScreen->MarkOverlappedWindows) (pChild, + pChild, &pLayerWin); + } + (*pScreen->MarkWindow) (pWin); + anyMarked = TRUE; + if (pWin->valdata) { + if (HasBorder(pWin)) { + RegionPtr borderVisible; + + borderVisible = RegionCreate(NullBox, 1); + RegionSubtract(borderVisible, + &pWin->borderClip, &pWin->winSize); + pWin->valdata->before.borderVisible = borderVisible; + } + pWin->valdata->before.resized = TRUE; + } } - + /* * Use RegionBreak to avoid optimizations in ValidateTree * that assume the root borderClip can't change well, normally * it doesn't...) */ - if (enable) - { - box.x1 = 0; - box.y1 = 0; - box.x2 = pScreen->width; - box.y2 = pScreen->height; - RegionInit(&pWin->winSize, &box, 1); - RegionInit(&pWin->borderSize, &box, 1); - if (WasViewable) - RegionReset(&pWin->borderClip, &box); - pWin->drawable.width = pScreen->width; - pWin->drawable.height = pScreen->height; + if (enable) { + box.x1 = 0; + box.y1 = 0; + box.x2 = pScreen->width; + box.y2 = pScreen->height; + RegionInit(&pWin->winSize, &box, 1); + RegionInit(&pWin->borderSize, &box, 1); + if (WasViewable) + RegionReset(&pWin->borderClip, &box); + pWin->drawable.width = pScreen->width; + pWin->drawable.height = pScreen->height; RegionBreak(&pWin->clipList); } - else - { - RegionEmpty(&pWin->borderClip); - RegionBreak(&pWin->clipList); + else { + RegionEmpty(&pWin->borderClip); + RegionBreak(&pWin->clipList); } - - ResizeChildrenWinSize (pWin, 0, 0, 0, 0); - - if (WasViewable) - { - - if (pWin->firstChild) - { - anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin->firstChild, - pWin->firstChild, - (WindowPtr *)NULL); - } - else - { - (*pScreen->MarkWindow) (pWin); - anyMarked = TRUE; - } - - if (anyMarked) - (*pScreen->ValidateTree)(pWin, NullWindow, VTOther); + + ResizeChildrenWinSize(pWin, 0, 0, 0, 0); + + if (WasViewable) { + + if (pWin->firstChild) { + anyMarked |= (*pScreen->MarkOverlappedWindows) (pWin->firstChild, + pWin->firstChild, + (WindowPtr *) NULL); + } + else { + (*pScreen->MarkWindow) (pWin); + anyMarked = TRUE; + } + + if (anyMarked) + (*pScreen->ValidateTree) (pWin, NullWindow, VTOther); } - if (WasViewable) - { - if (anyMarked) - (*pScreen->HandleExposures)(pWin); + if (WasViewable) { + if (anyMarked) + (*pScreen->HandleExposures) (pWin); - if (anyMarked && pScreen->PostValidateTree) - (*pScreen->PostValidateTree)(pWin, NullWindow, VTOther); + if (anyMarked && pScreen->PostValidateTree) + (*pScreen->PostValidateTree) (pWin, NullWindow, VTOther); } if (pWin->realized) - WindowsRestructured (); - FlushAllOutput (); + WindowsRestructured(); + FlushAllOutput(); } static Bool vncRandRCrtcSet(ScreenPtr pScreen, RRCrtcPtr crtc, RRModePtr mode, int x, int y, Rotation rotation, int num_outputs, - RROutputPtr *outputs); + RROutputPtr * outputs); static RRModePtr vncRandRModeGet(int width, int height); -static Bool vncRandRScreenSetSize(ScreenPtr pScreen, - CARD16 width, CARD16 height, - CARD32 mmWidth, CARD32 mmHeight) +static Bool +vncRandRScreenSetSize(ScreenPtr pScreen, + CARD16 width, CARD16 height, + CARD32 mmWidth, CARD32 mmHeight) { vfbScreenInfoPtr pvfb = &vfbScreens[pScreen->myNum]; vfbFramebufferInfo fb; @@ -1119,7 +1101,7 @@ static Bool vncRandRScreenSetSize(ScreenPtr pScreen, RRScreenSizeNotify(pScreen); /* Crop all CRTCs to the new screen */ - for (int i = 0;i < rp->numCrtcs;i++) { + for (int i = 0; i < rp->numCrtcs; i++) { RRCrtcPtr crtc; RRModePtr mode; @@ -1163,9 +1145,10 @@ static Bool vncRandRScreenSetSize(ScreenPtr pScreen, return TRUE; } -static Bool vncRandRCrtcSet(ScreenPtr pScreen, RRCrtcPtr crtc, RRModePtr mode, - int x, int y, Rotation rotation, int num_outputs, - RROutputPtr *outputs) +static Bool +vncRandRCrtcSet(ScreenPtr pScreen, RRCrtcPtr crtc, RRModePtr mode, + int x, int y, Rotation rotation, int num_outputs, + RROutputPtr * outputs) { Bool ret; int i; @@ -1174,10 +1157,10 @@ static Bool vncRandRCrtcSet(ScreenPtr pScreen, RRCrtcPtr crtc, RRModePtr mode, * Some applications get confused by a connected output without a * mode or CRTC, so we need to fiddle with the connection state as well. */ - for (i = 0;i < crtc->numOutputs;i++) + for (i = 0; i < crtc->numOutputs; i++) RROutputSetConnection(crtc->outputs[i], RR_Disconnected); - for (i = 0;i < num_outputs;i++) { + for (i = 0; i < num_outputs; i++) { if (mode != NULL) RROutputSetConnection(outputs[i], RR_Connected); else @@ -1192,37 +1175,42 @@ static Bool vncRandRCrtcSet(ScreenPtr pScreen, RRCrtcPtr crtc, RRModePtr mode, return TRUE; } -static Bool vncRandROutputValidateMode(ScreenPtr pScreen, - RROutputPtr output, RRModePtr mode) +static Bool +vncRandROutputValidateMode(ScreenPtr pScreen, + RROutputPtr output, RRModePtr mode) { /* We have no hardware so any mode works */ return TRUE; } -static void vncRandRModeDestroy(ScreenPtr pScreen, RRModePtr mode) +static void +vncRandRModeDestroy(ScreenPtr pScreen, RRModePtr mode) { /* We haven't allocated anything so nothing to destroy */ } -static const int vncRandRWidths[] = { 1920, 1920, 1600, 1680, 1400, 1360, 1280, 1280, 1280, 1280, 1024, 800, 640 }; -static const int vncRandRHeights[] = { 1200, 1080, 1200, 1050, 1050, 768, 1024, 960, 800, 720, 768, 600, 480 }; +static const int vncRandRWidths[] = + { 1920, 1920, 1600, 1680, 1400, 1360, 1280, 1280, 1280, 1280, 1024, 800, 640 }; +static const int vncRandRHeights[] = + { 1200, 1080, 1200, 1050, 1050, 768, 1024, 960, 800, 720, 768, 600, 480 }; static int vncRandRIndex = 0; -static RRModePtr vncRandRModeGet(int width, int height) +static RRModePtr +vncRandRModeGet(int width, int height) { - xRRModeInfo modeInfo; + xRRModeInfo modeInfo; char name[100]; RRModePtr mode; memset(&modeInfo, 0, sizeof(modeInfo)); sprintf(name, "%dx%d", width, height); - + modeInfo.width = width; modeInfo.height = height; modeInfo.hTotal = width; modeInfo.vTotal = height; - modeInfo.dotClock = ((CARD32)width * (CARD32)height * 60); + modeInfo.dotClock = ((CARD32) width * (CARD32) height * 60); modeInfo.nameLength = strlen(name); mode = RRModeGet(&modeInfo, name); if (mode == NULL) @@ -1231,14 +1219,15 @@ static RRModePtr vncRandRModeGet(int width, int height) return mode; } -static void vncRandRSetModes(RROutputPtr output, int pref_width, int pref_height) +static void +vncRandRSetModes(RROutputPtr output, int pref_width, int pref_height) { RRModePtr mode; RRModePtr *modes; int i, num_modes, num_pref; - num_modes = sizeof(vncRandRWidths)/sizeof(*vncRandRWidths) + 1; - modes = malloc(sizeof(RRModePtr)*num_modes); + num_modes = sizeof(vncRandRWidths) / sizeof(*vncRandRWidths) + 1; + modes = malloc(sizeof(RRModePtr) * num_modes); if (modes == NULL) return; @@ -1254,7 +1243,7 @@ static void vncRandRSetModes(RROutputPtr output, int pref_width, int pref_height } } - for (i = 0;i < sizeof(vncRandRWidths)/sizeof(*vncRandRWidths);i++) { + for (i = 0; i < sizeof(vncRandRWidths) / sizeof(*vncRandRWidths); i++) { if ((vncRandRWidths[i] == pref_width) && (vncRandRHeights[i] == pref_height)) continue; @@ -1270,7 +1259,8 @@ static void vncRandRSetModes(RROutputPtr output, int pref_width, int pref_height free(modes); } -static RRCrtcPtr vncRandRCrtcCreate(ScreenPtr pScreen) +static RRCrtcPtr +vncRandRCrtcCreate(ScreenPtr pScreen) { RRCrtcPtr crtc; RROutputPtr output; @@ -1280,7 +1270,7 @@ static RRCrtcPtr vncRandRCrtcCreate(ScreenPtr pScreen) crtc = RRCrtcCreate(pScreen, NULL); /* We don't actually support gamma, but xrandr complains when it is missing */ - RRCrtcGammaSetSize (crtc, 256); + RRCrtcGammaSetSize(crtc, 256); /* Then we create a dummy output for it... */ sprintf(name, "VNC-%d", vncRandRIndex); @@ -1302,12 +1292,14 @@ static RRCrtcPtr vncRandRCrtcCreate(ScreenPtr pScreen) /* Used from XserverDesktop when it needs more outputs... */ -int vncRandRCanCreateScreenOutputs(int scrIdx, int extraOutputs) +int +vncRandRCanCreateScreenOutputs(int scrIdx, int extraOutputs) { return 1; } -int vncRandRCreateScreenOutputs(int scrIdx, int extraOutputs) +int +vncRandRCreateScreenOutputs(int scrIdx, int extraOutputs) { RRCrtcPtr crtc; @@ -1323,12 +1315,14 @@ int vncRandRCreateScreenOutputs(int scrIdx, int extraOutputs) /* Creating and modifying modes, used by XserverDesktop and init here */ -int vncRandRCanCreateModes() +int +vncRandRCanCreateModes() { return 1; } -void* vncRandRCreateMode(void* out, int width, int height) +void * +vncRandRCreateMode(void *out, int width, int height) { RROutputPtr output; @@ -1355,7 +1349,8 @@ void* vncRandRCreateMode(void* out, int width, int height) return NULL; } -void* vncRandRSetPreferredMode(void* out, void* m) +void * +vncRandRSetPreferredMode(void *out, void *m) { RRModePtr mode; RROutputPtr output; @@ -1385,7 +1380,8 @@ void* vncRandRSetPreferredMode(void* out, void* m) return NULL; } -static Bool vncRandRInit(ScreenPtr pScreen) +static Bool +vncRandRInit(ScreenPtr pScreen) { RRCrtcPtr crtc; RRModePtr mode; @@ -1420,13 +1416,12 @@ static Bool vncRandRInit(ScreenPtr pScreen) return TRUE; } - static Bool vfbCloseScreen(ScreenPtr pScreen) { vfbScreenInfoPtr pvfb = &vfbScreens[pScreen->myNum]; int i; - + pScreen->CloseScreen = pvfb->closeScreen; /* @@ -1434,7 +1429,7 @@ vfbCloseScreen(ScreenPtr pScreen) * clear installed colormaps so that server reset works correctly. */ for (i = 0; i < screenInfo.numScreens; i++) - SetInstalledColormap(screenInfo.screens[i], NULL); + SetInstalledColormap(screenInfo.screens[i], NULL); /* * fb overwrites miCloseScreen, so do this here @@ -1458,7 +1453,7 @@ vfbScreenInit(ScreenPtr pScreen, int argc, char **argv) rrScrPrivPtr rp; if (!dixRegisterPrivateKey(&cmapScrPrivateKeyRec, PRIVATE_SCREEN, 0)) - return FALSE; + return FALSE; /* 96 is the default used by most other systems */ dpi = 96; @@ -1466,7 +1461,8 @@ vfbScreenInit(ScreenPtr pScreen, int argc, char **argv) dpi = monitorResolution; pbits = vfbAllocateFramebufferMemory(&pvfb->fb); - if (!pbits) return FALSE; + if (!pbits) + return FALSE; vncFbptr[index] = pbits; vncFbstride[index] = pvfb->fb.paddedWidth; @@ -1474,40 +1470,43 @@ vfbScreenInit(ScreenPtr pScreen, int argc, char **argv) switch (pvfb->fb.depth) { case 16: - miSetVisualTypesAndMasks (16, - ((1 << TrueColor) | - (1 << DirectColor)), - 8, TrueColor, 0xf800, 0x07e0, 0x001f); - break; + miSetVisualTypesAndMasks(16, + ((1 << TrueColor) | + (1 << DirectColor)), + 8, TrueColor, 0xf800, 0x07e0, 0x001f); + break; case 24: - miSetVisualTypesAndMasks (24, - ((1 << TrueColor) | - (1 << DirectColor)), - 8, TrueColor, 0xff0000, 0x00ff00, 0x0000ff); - break; + miSetVisualTypesAndMasks(24, + ((1 << TrueColor) | + (1 << DirectColor)), + 8, TrueColor, 0xff0000, 0x00ff00, 0x0000ff); + break; case 32: - miSetVisualTypesAndMasks (32, - ((1 << TrueColor) | - (1 << DirectColor)), - 8, TrueColor, 0xff000000, 0x00ff0000, 0x0000ff00); - break; + miSetVisualTypesAndMasks(32, + ((1 << TrueColor) | + (1 << DirectColor)), + 8, TrueColor, 0xff000000, 0x00ff0000, + 0x0000ff00); + break; default: - return FALSE; + return FALSE; } if (index > 0) { - ScreenPtr prevScreen = screenInfo.screens[index-1]; + ScreenPtr prevScreen = screenInfo.screens[index - 1]; + pScreen->x = prevScreen->x + prevScreen->width; pScreen->y = 0; } ret = fbScreenInit(pScreen, pbits, pvfb->fb.width, pvfb->fb.height, - dpi, dpi, pvfb->fb.paddedWidth, pvfb->fb.bitsPerPixel); - - if (ret && Render) - ret = fbPictureInit (pScreen, 0, 0); + dpi, dpi, pvfb->fb.paddedWidth, pvfb->fb.bitsPerPixel); + + if (ret && Render) + ret = fbPictureInit(pScreen, 0, 0); - if (!ret) return FALSE; + if (!ret) + return FALSE; /* * Circumvent the backing store that was just initialised. This amounts @@ -1519,54 +1518,59 @@ vfbScreenInit(ScreenPtr pScreen, int argc, char **argv) pScreen->ListInstalledColormaps = vfbListInstalledColormaps; pScreen->SaveScreen = vfbSaveScreen; - + miPointerInitialize(pScreen, &vfbPointerSpriteFuncs, &vfbPointerCursorFuncs, - FALSE); - + FALSE); + pScreen->blackPixel = pvfb->blackPixel; pScreen->whitePixel = pvfb->whitePixel; if (!pvfb->pixelFormatDefined) { - switch (pvfb->fb.depth) { - case 16: - pvfb->pixelFormatDefined = TRUE; - pvfb->rgbNotBgr = TRUE; - pvfb->blueBits = pvfb->redBits = 5; - pvfb->greenBits = 6; - break; - case 24: - case 32: - pvfb->pixelFormatDefined = TRUE; - pvfb->rgbNotBgr = TRUE; - pvfb->blueBits = pvfb->redBits = pvfb->greenBits = 8; - break; - } + switch (pvfb->fb.depth) { + case 16: + pvfb->pixelFormatDefined = TRUE; + pvfb->rgbNotBgr = TRUE; + pvfb->blueBits = pvfb->redBits = 5; + pvfb->greenBits = 6; + break; + case 24: + case 32: + pvfb->pixelFormatDefined = TRUE; + pvfb->rgbNotBgr = TRUE; + pvfb->blueBits = pvfb->redBits = pvfb->greenBits = 8; + break; + } } if (pvfb->pixelFormatDefined) { - VisualPtr vis = pScreen->visuals; - for (int i = 0; i < pScreen->numVisuals; i++) { - if (pvfb->rgbNotBgr) { - vis->offsetBlue = 0; - vis->blueMask = (1 << pvfb->blueBits) - 1; - vis->offsetGreen = pvfb->blueBits; - vis->greenMask = ((1 << pvfb->greenBits) - 1) << vis->offsetGreen; - vis->offsetRed = vis->offsetGreen + pvfb->greenBits; - vis->redMask = ((1 << pvfb->redBits) - 1) << vis->offsetRed; - } else { - vis->offsetRed = 0; - vis->redMask = (1 << pvfb->redBits) - 1; - vis->offsetGreen = pvfb->redBits; - vis->greenMask = ((1 << pvfb->greenBits) - 1) << vis->offsetGreen; - vis->offsetBlue = vis->offsetGreen + pvfb->greenBits; - vis->blueMask = ((1 << pvfb->blueBits) - 1) << vis->offsetBlue; - } - vis++; - } + VisualPtr vis = pScreen->visuals; + + for (int i = 0; i < pScreen->numVisuals; i++) { + if (pvfb->rgbNotBgr) { + vis->offsetBlue = 0; + vis->blueMask = (1 << pvfb->blueBits) - 1; + vis->offsetGreen = pvfb->blueBits; + vis->greenMask = + ((1 << pvfb->greenBits) - 1) << vis->offsetGreen; + vis->offsetRed = vis->offsetGreen + pvfb->greenBits; + vis->redMask = ((1 << pvfb->redBits) - 1) << vis->offsetRed; + } + else { + vis->offsetRed = 0; + vis->redMask = (1 << pvfb->redBits) - 1; + vis->offsetGreen = pvfb->redBits; + vis->greenMask = + ((1 << pvfb->greenBits) - 1) << vis->offsetGreen; + vis->offsetBlue = vis->offsetGreen + pvfb->greenBits; + vis->blueMask = ((1 << pvfb->blueBits) - 1) << vis->offsetBlue; + } + vis++; + } } - + ret = fbCreateDefColormap(pScreen); - if (!ret) return FALSE; + if (!ret) + return FALSE; miSetZeroLineBias(pScreen, pvfb->lineBias); @@ -1574,7 +1578,8 @@ vfbScreenInit(ScreenPtr pScreen, int argc, char **argv) pScreen->CloseScreen = vfbCloseScreen; ret = RRScreenInit(pScreen); - if (!ret) return FALSE; + if (!ret) + return FALSE; rp = rrGetScrPriv(pScreen); @@ -1586,15 +1591,16 @@ vfbScreenInit(ScreenPtr pScreen, int argc, char **argv) rp->rrModeDestroy = vncRandRModeDestroy; ret = vncRandRInit(pScreen); - if (!ret) return FALSE; - - - return TRUE; + if (!ret) + return FALSE; -} /* end vfbScreenInit */ + return TRUE; +} /* end vfbScreenInit */ -static void vfbClientStateChange(CallbackListPtr *a, void *b, void *c) { +static void +vfbClientStateChange(CallbackListPtr *a, void *b, void *c) +{ if (dispatchException & DE_RESET) { ErrorF("Warning: VNC extension does not support -reset, terminating instead. Use -noreset to prevent termination.\n"); @@ -1602,7 +1608,7 @@ static void vfbClientStateChange(CallbackListPtr *a, void *b, void *c) { dispatchException &= ~DE_RESET; } } - + #ifdef GLXEXT extern void GlxExtensionInit(void); @@ -1614,7 +1620,7 @@ static ExtensionModule glxExt = { #endif void -InitOutput(ScreenInfo *scrInfo, int argc, char **argv) +InitOutput(ScreenInfo * scrInfo, int argc, char **argv) { int i; int NumFormats = 0; @@ -1635,33 +1641,30 @@ InitOutput(ScreenInfo *scrInfo, int argc, char **argv) /* initialize pixmap formats */ /* must have a pixmap depth to match every screen depth */ - for (i = 0; i < vfbNumScreens; i++) - { - vfbPixmapDepths[vfbScreens[i].fb.depth] = TRUE; + for (i = 0; i < vfbNumScreens; i++) { + vfbPixmapDepths[vfbScreens[i].fb.depth] = TRUE; } /* RENDER needs a good set of pixmaps. */ if (Render) { - vfbPixmapDepths[1] = TRUE; - vfbPixmapDepths[4] = TRUE; - vfbPixmapDepths[8] = TRUE; + vfbPixmapDepths[1] = TRUE; + vfbPixmapDepths[4] = TRUE; + vfbPixmapDepths[8] = TRUE; /* vfbPixmapDepths[15] = TRUE; */ - vfbPixmapDepths[16] = TRUE; - vfbPixmapDepths[24] = TRUE; - vfbPixmapDepths[32] = TRUE; + vfbPixmapDepths[16] = TRUE; + vfbPixmapDepths[24] = TRUE; + vfbPixmapDepths[32] = TRUE; } - for (i = 1; i <= 32; i++) - { - if (vfbPixmapDepths[i]) - { - if (NumFormats >= MAXFORMATS) - FatalError ("MAXFORMATS is too small for this server\n"); - scrInfo->formats[NumFormats].depth = i; - scrInfo->formats[NumFormats].bitsPerPixel = vfbBitsPerPixel(i); - scrInfo->formats[NumFormats].scanlinePad = BITMAP_SCANLINE_PAD; - NumFormats++; - } + for (i = 1; i <= 32; i++) { + if (vfbPixmapDepths[i]) { + if (NumFormats >= MAXFORMATS) + FatalError("MAXFORMATS is too small for this server\n"); + scrInfo->formats[NumFormats].depth = i; + scrInfo->formats[NumFormats].bitsPerPixel = vfbBitsPerPixel(i); + scrInfo->formats[NumFormats].scanlinePad = BITMAP_SCANLINE_PAD; + NumFormats++; + } } scrInfo->imageByteOrder = IMAGE_BYTE_ORDER; @@ -1672,53 +1675,57 @@ InitOutput(ScreenInfo *scrInfo, int argc, char **argv) /* initialize screens */ - for (i = 0; i < vfbNumScreens; i++) - { - if (-1 == AddScreen(vfbScreenInit, argc, argv)) - { - FatalError("Couldn't add screen %d\n", i); - } + for (i = 0; i < vfbNumScreens; i++) { + if (-1 == AddScreen(vfbScreenInit, argc, argv)) { + FatalError("Couldn't add screen %d\n", i); + } } if (!AddCallback(&ClientStateCallback, vfbClientStateChange, 0)) { - FatalError("AddCallback failed\n"); + FatalError("AddCallback failed\n"); } -} /* end InitOutput */ +} /* end InitOutput */ /* this is just to get the server to link on AIX */ #ifdef AIXV3 -int SelectWaitTime = 10000; /* usec */ +int SelectWaitTime = 10000; /* usec */ #endif -void DDXRingBell(int percent, int pitch, int duration) +void +DDXRingBell(int percent, int pitch, int duration) { - if (percent > 0) - vncBell(); + if (percent > 0) + vncBell(); } -Bool LegalModifier(unsigned int key, DeviceIntPtr pDev) +Bool +LegalModifier(unsigned int key, DeviceIntPtr pDev) { - return TRUE; + return TRUE; } -void ProcessInputEvents(void) +void +ProcessInputEvents(void) { - mieqProcessInputEvents(); + mieqProcessInputEvents(); } -void InitInput(int argc, char *argv[]) +void +InitInput(int argc, char *argv[]) { - mieqInit (); + mieqInit(); } -void CloseInput(void) +void +CloseInput(void) { } -void vncClientGone(int fd) +void +vncClientGone(int fd) { - if (fd == vncInetdSock) { - ErrorF("inetdSock client gone\n"); - GiveUp(0); - } + if (fd == vncInetdSock) { + ErrorF("inetdSock client gone\n"); + GiveUp(0); + } } -- 2.39.5