diff options
Diffstat (limited to 'nx-X11/programs/Xserver/hw')
-rw-r--r-- | nx-X11/programs/Xserver/hw/nxagent/Screen.c | 436 |
1 files changed, 201 insertions, 235 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index b3f4ccbc6..01579581f 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -268,8 +268,6 @@ void nxagentSetScreenInfo(ScreenInfo *screenInfo) void nxagentSetPixmapFormats(ScreenInfo *screenInfo) { - int i; - /* * Formats are created with no care of which are supported * on the real display. Creating only formats supported @@ -279,7 +277,7 @@ void nxagentSetPixmapFormats(ScreenInfo *screenInfo) screenInfo -> numPixmapFormats = nxagentNumPixmapFormats; - for (i = 0; i < nxagentNumPixmapFormats; i++) + for (int i = 0; i < nxagentNumPixmapFormats; i++) { screenInfo -> formats[i].depth = nxagentPixmapFormats[i].depth; screenInfo -> formats[i].bitsPerPixel = nxagentPixmapFormats[i].bits_per_pixel; @@ -651,14 +649,12 @@ FIXME: Do we need to check the key grab if the Bool nxagentCreateScreenResources(ScreenPtr pScreen) { - Bool ret; - CreatePixmapProcPtr savedCreatePixmap = pScreen->CreatePixmap; ModifyPixmapHeaderProcPtr savedModifyPixmapHeader = pScreen->ModifyPixmapHeader; pScreen->CreatePixmap = fbCreatePixmap; pScreen->ModifyPixmapHeader = miModifyPixmapHeader; - ret = miCreateScreenResources(pScreen); + Bool ret = miCreateScreenResources(pScreen); pScreen->CreatePixmap = savedCreatePixmap; pScreen->ModifyPixmapHeader = savedModifyPixmapHeader; @@ -688,7 +684,6 @@ void nxagentInitViewportFrame(ScreenPtr pScreen, WindowPtr pRootWin) { int error = Success; VisualID visual = 0; - int i; XID xid; if (nxagentOption(Rootless)) @@ -696,7 +691,7 @@ void nxagentInitViewportFrame(ScreenPtr pScreen, WindowPtr pRootWin) return; } - for (i = 0; i < pScreen -> numDepths; i++) + for (int i = 0; i < pScreen -> numDepths; i++) { if (pScreen -> allowedDepths[i].depth == pRootWin -> drawable.depth) { @@ -2714,37 +2709,31 @@ int nxagentShadowInit(ScreenPtr pScreen, WindowPtr pWin) case StaticGray: { className = "StaticGray"; - break; } case StaticColor: { className = "StaticColor"; - break; } case PseudoColor: { className = "PseudoColor"; - break; } case DirectColor: { className = "DirectColor"; - break; } case GrayScale: { className = "GrayScale"; - break; } default: { className = ""; - break; } } @@ -3222,29 +3211,14 @@ int nxagentShadowPoll(PixmapPtr nxagentShadowPixmapPtr, GCPtr nxagentShadowGCPtr void nxagentShadowAdaptDepth(unsigned int width, unsigned int height, unsigned int lineMaster, char **buffer) { - unsigned char red; - unsigned char green; - unsigned char blue; - unsigned short color16 = 0; - unsigned char * icBuffer; - unsigned char * cBuffer = NULL; unsigned char * tBuffer = (unsigned char *) *buffer; - unsigned int lineShadow; - unsigned int length; - unsigned int c; - unsigned int pad; - unsigned int color32 = 0; - unsigned long redMask; - unsigned long greenMask; - unsigned long blueMask; - Visual *pVisual; - length = nxagentImageLength(width, height, ZPixmap, 0, nxagentShadowDepth); + unsigned int length = nxagentImageLength(width, height, ZPixmap, 0, nxagentShadowDepth); - cBuffer = malloc(length); - icBuffer = cBuffer; + unsigned char *cBuffer = malloc(length); + unsigned char *icBuffer = cBuffer; - pVisual = nxagentImageVisual((DrawablePtr) nxagentShadowPixmapPtr, nxagentShadowDepth); + Visual *pVisual = nxagentImageVisual((DrawablePtr) nxagentShadowPixmapPtr, nxagentShadowDepth); if (pVisual == NULL) { @@ -3260,9 +3234,9 @@ void nxagentShadowAdaptDepth(unsigned int width, unsigned int height, pVisual -> red_mask, pVisual -> green_mask, pVisual -> blue_mask); #endif - redMask = nxagentShadowDisplay -> screens[0].root_visual[0].red_mask; - greenMask = nxagentShadowDisplay -> screens[0].root_visual[0].green_mask; - blueMask = nxagentShadowDisplay -> screens[0].root_visual[0].blue_mask; + unsigned long redMask = nxagentShadowDisplay -> screens[0].root_visual[0].red_mask; + unsigned long greenMask = nxagentShadowDisplay -> screens[0].root_visual[0].green_mask; + unsigned long blueMask = nxagentShadowDisplay -> screens[0].root_visual[0].blue_mask; #ifdef TEST fprintf(stderr, "nxagentCorrectDepthShadow: Master redMask [%lu] greenMask[%lu] blueMask[%lu].\n", @@ -3276,7 +3250,7 @@ void nxagentShadowAdaptDepth(unsigned int width, unsigned int height, */ case 16: { - pad = lineMaster - nxagentBppMaster * width; + unsigned int pad = lineMaster - nxagentBppMaster * width; #ifdef TEST fprintf(stderr, "nxagentCorrectDepthShadow: line [%d] width[%d] pad[%d].\n", lineMaster, width, pad); @@ -3284,8 +3258,13 @@ void nxagentShadowAdaptDepth(unsigned int width, unsigned int height, while (height > 0) { - for (c = 0; c < width ; c++) + for (unsigned int c = 0; c < width ; c++) { + unsigned char red; + unsigned char green; + unsigned char blue; + unsigned short color16; + if (imageByteOrder == LSBFirst) { color16 = *tBuffer++; @@ -3353,9 +3332,8 @@ void nxagentShadowAdaptDepth(unsigned int width, unsigned int height, */ case 24: { - lineShadow = PixmapBytePad(width, nxagentShadowDepth); - - pad = lineShadow - nxagentBppShadow * width; + unsigned int lineShadow = PixmapBytePad(width, nxagentShadowDepth); + unsigned int pad = lineShadow - nxagentBppShadow * width; #ifdef TEST fprintf(stderr, "nxagentCorrectDepthShadow: line [%d] width[%d] pad[%d].\n", lineShadow, width, pad); @@ -3363,8 +3341,11 @@ void nxagentShadowAdaptDepth(unsigned int width, unsigned int height, while (height > 0) { - for (c = 0; c < width; c++) + for (unsigned int c = 0; c < width; c++) { + unsigned short color16; + unsigned int color32; + if (imageByteOrder == LSBFirst) { color32 = *tBuffer++; @@ -3479,8 +3460,6 @@ FIXME: The port information is not used at the moment and produces a if (iReturn == Success && atomReturnType != None && ulReturnItems > 0 && pszReturnData != NULL) { - char *local_buf; - #ifdef TEST fprintf(stderr, "nxagentPropagateArtsdProperties: Got [%ld] elements of format [%d] with [%ld] bytes left.\n", ulReturnItems, iReturnFormat, ulReturnBytesLeft); @@ -3495,7 +3474,7 @@ FIXME: The port information is not used at the moment and produces a #endif - local_buf = (char *) malloc(strlen((char*)pszReturnData) + 100); + char *local_buf = (char *) malloc(strlen((char*)pszReturnData) + 100); if (local_buf) { @@ -3611,9 +3590,7 @@ FIXME: The port information is not used at the moment and produces a Bool nxagentReconnectScreen(void *p0) { - CARD16 w, h; PixmapPtr pPixmap = (PixmapPtr)nxagentDefaultScreen->devPrivate; - Mask mask; #if defined(NXAGENT_RECONNECT_DEBUG) || defined(NXAGENT_RECONNECT_SCREEN_DEBUG) fprintf(stderr, "nxagentReconnectScreen\n"); @@ -3634,8 +3611,8 @@ Bool nxagentReconnectScreen(void *p0) pPixmap, nxagentPixmap( pPixmap )); #endif - w = 16; - h = 16; + CARD16 w = 16; + CARD16 h = 16; (*nxagentDefaultScreen->QueryBestSize)(StippleShape, &w, &h, nxagentDefaultScreen); if (!(nxagentPixmap(nxagentDefaultScreen->PixmapPerDepth[0]) = XCreatePixmap(nxagentDisplay, @@ -3644,7 +3621,7 @@ Bool nxagentReconnectScreen(void *p0) h, 1))); - mask = nxagentGetDefaultEventMask(); + Mask mask = nxagentGetDefaultEventMask(); mask |= NXAGENT_KEYBOARD_EVENT_MASK | NXAGENT_POINTER_EVENT_MASK; nxagentSetDefaultEventMask(mask); XSelectInput(nxagentDisplay, nxagentDefaultWindows[0], mask); @@ -3663,8 +3640,8 @@ Bool nxagentReconnectScreen(void *p0) /* intersect two rectangles */ Bool intersect(int ax1, int ay1, unsigned int aw, unsigned int ah, - int bx1, int by1, unsigned int bw, unsigned int bh, - int *x, int *y, unsigned int *w, unsigned int *h) + int bx1, int by1, unsigned int bw, unsigned int bh, + int *x, int *y, unsigned int *w, unsigned int *h) { int tx1, ty1, tx2, ty2, ix, iy; unsigned int iw, ih; @@ -3721,9 +3698,9 @@ Bool intersect(int ax1, int ay1, unsigned int aw, unsigned int ah, /* intersect two rectangles, return aw/ah for w/h if resulting rectangle is (partly) outside of bounding box */ Bool intersect_bb(int ax1, int ay1, unsigned int aw, unsigned int ah, - int bx1, int by1, unsigned int bw, unsigned int bh, - int bbx1, int bby1, int bbx2, int bby2, - int *x, int *y, unsigned int *w, unsigned int *h) + int bx1, int by1, unsigned int bw, unsigned int bh, + int bbx1, int bby1, int bbx2, int bby2, + int *x, int *y, unsigned int *w, unsigned int *h) { #ifdef DEBUG @@ -3877,9 +3854,6 @@ void nxagentAdjustCustomMode(ScreenPtr pScreen) int nxagentChangeScreenConfig(int screen, int width, int height) { - ScreenPtr pScreen; - int r; - #ifdef DEBUG fprintf(stderr, "nxagentChangeScreenConfig: called for screen [%d], width [%d] height [%d]\n", screen, width, height); #endif @@ -3923,13 +3897,13 @@ int nxagentChangeScreenConfig(int screen, int width, int height) return 0; } - pScreen = screenInfo.screens[screen] -> root -> drawable.pScreen; + ScreenPtr pScreen = screenInfo.screens[screen] -> root -> drawable.pScreen; #ifdef TEST fprintf(stderr, "nxagentChangeScreenConfig: Changing config to %d x %d\n", width, height); #endif - r = nxagentResizeScreen(pScreen, width, height, 0, 0); + int r = nxagentResizeScreen(pScreen, width, height, 0, 0); if (r != 0) { @@ -3958,21 +3932,25 @@ int nxagentChangeScreenConfig(int screen, int width, int height) /* Destroy an output after removing it from any crtc that might reference it */ -void nxagentDropOutput(RROutputPtr o) { +void nxagentDropOutput(RROutputPtr o) +{ RRCrtcPtr c = o->crtc; - if (c) { - for (int i = 0; i < c->numOutputs; i++) { - if (c->outputs[i] == o) { -#ifdef DEBUG - fprintf(stderr, "nxagentDropOutput: output [%s] is in use by crtc [%p], removing it from there\n", o->name, c); -#endif - RRCrtcSet(c, NULL, 0, 0, RR_Rotate_0, 0, NULL); + if (c) + { + for (int i = 0; i < c->numOutputs; i++) + { + if (c->outputs[i] == o) + { + #ifdef DEBUG + fprintf(stderr, "nxagentDropOutput: output [%s] is in use by crtc [%p], removing it from there\n", o->name, c); + #endif + RRCrtcSet(c, NULL, 0, 0, RR_Rotate_0, 0, NULL); } } } -#ifdef DEBUG + #ifdef DEBUG fprintf(stderr, "nxagentDropOutput: destroying output [%s]\n", o->name); -#endif + #endif RROutputDestroy(o); } @@ -3993,23 +3971,22 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) int i; int number = 0; - XineramaScreenInfo *screeninfo = NULL; + XineramaScreenInfo *screeninfo = XineramaQueryScreens(nxagentDisplay, &number); - screeninfo = XineramaQueryScreens(nxagentDisplay, &number); if (number) { -#ifdef DEBUG + #ifdef DEBUG fprintf(stderr, "nxagentAdjustRandRXinerama: XineramaQueryScreens() returned [%d] screens:\n", number); for (int i=0; i < number; i++) { - fprintf(stderr, "nxagentAdjustRandRXinerama: screen_number [%d] x_org [%d] y_org [%d] width [%d] height [%d]\n", screeninfo[i].screen_number, screeninfo[i].x_org, screeninfo[i].y_org, screeninfo[i].width, screeninfo[i].height); + fprintf(stderr, "nxagentAdjustRandRXinerama: screen_number [%d] x_org [%d] y_org [%d] width [%d] height [%d]\n", screeninfo[i].screen_number, screeninfo[i].x_org, screeninfo[i].y_org, screeninfo[i].width, screeninfo[i].height); } -#endif + #endif } else { -#ifdef DEBUG + #ifdef DEBUG fprintf(stderr, "nxagentAdjustRandRXinerama: XineramaQueryScreens() failed - continuing without Xinerama\n"); -#endif + #endif } /* @@ -4020,7 +3997,8 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) * behaved. The single PanoramiX/Xinerama extension however * disables xinerama if only one screen exists. */ - if (number == 0) { + if (number == 0) + { #ifdef DEBUG fprintf(stderr, "nxagentAdjustRandRXinerama: faking xinerama\n"); #endif @@ -4028,8 +4006,9 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) SAFE_free(screeninfo); - if (!(screeninfo = malloc(sizeof(XineramaScreenInfo)))) { - return FALSE; + if (!(screeninfo = malloc(sizeof(XineramaScreenInfo)))) + { + return FALSE; } /* fake a xinerama screeninfo that covers the whole screen */ @@ -4066,7 +4045,8 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) bbx2 = bby2 = 0; bbx1 = bby1 = INT_MAX; - for (i = 0; i < number; i++) { + for (i = 0; i < number; i++) + { bbx2 = max(bbx2, screeninfo[i].x_org + screeninfo[i].width); bby2 = max(bby2, screeninfo[i].y_org + screeninfo[i].height); bbx1 = min(bbx1, screeninfo[i].x_org); @@ -4083,8 +4063,10 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) /* adjust the number of CRTCs to match the number of reported xinerama screens on the real server */ - while (number != pScrPriv->numCrtcs) { - if (number < pScrPriv->numCrtcs) { + while (number != pScrPriv->numCrtcs) + { + if (number < pScrPriv->numCrtcs) + { #ifdef DEBUG fprintf(stderr, "nxagentAdjustRandRXinerama: destroying crtc\n"); #endif @@ -4108,12 +4090,14 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) /* set gamma. Currently the only reason for doing this is preventing the xrandr command from complaining about missing gamma. */ - for (i = 0; i < pScrPriv->numCrtcs; i++) { - if (pScrPriv->crtcs[i]->gammaSize == 0) { - CARD16 gamma = 0; - RRCrtcGammaSetSize(pScrPriv->crtcs[i], 1); - RRCrtcGammaSet(pScrPriv->crtcs[i], &gamma, &gamma, &gamma); - RRCrtcGammaNotify(pScrPriv->crtcs[i]); + for (i = 0; i < pScrPriv->numCrtcs; i++) + { + if (pScrPriv->crtcs[i]->gammaSize == 0) + { + CARD16 gamma = 0; + RRCrtcGammaSetSize(pScrPriv->crtcs[i], 1); + RRCrtcGammaSet(pScrPriv->crtcs[i], &gamma, &gamma, &gamma); + RRCrtcGammaNotify(pScrPriv->crtcs[i]); } } @@ -4127,13 +4111,15 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) nxagentDropOutput(pScrPriv->outputs[i]); /* add and init outputs */ - for (i = 0; i < number; i++) { - if (i >= pScrPriv->numOutputs) { + for (i = 0; i < number; i++) + { + if (i >= pScrPriv->numOutputs) + { sprintf(name, "NX%d", i+1); output = RROutputCreate(pScreen, name, strlen(name), NULL); - /* will be done later - RROutputSetConnection(output, RR_Disconnected); - */ + /* will be done later + RROutputSetConnection(output, RR_Disconnected); + */ #ifdef DEBUG fprintf(stderr, "nxagentAdjustRandRXinerama: created new output [%s]\n", name); #endif @@ -4154,7 +4140,8 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) RROutputSetPhysicalSize(output, 0, 0); } - for (i = 0; i < pScrPriv->numOutputs; i++) { + for (i = 0; i < pScrPriv->numOutputs; i++) + { Bool disable_output = FALSE; RRModePtr mymode = NULL, prevmode = NULL; int new_x = 0; @@ -4174,23 +4161,27 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) width, height, screeninfo[i].x_org, screeninfo[i].y_org, screeninfo[i].width, screeninfo[i].height, - bbx1, bby1, bbx2, bby2, + bbx1, bby1, bbx2, bby2, &new_x, &new_y, &new_w, &new_h); #endif /* save previous mode */ prevmode = pScrPriv->crtcs[i]->mode; #ifdef DEBUG - if (prevmode) { + if (prevmode) + { fprintf(stderr, "nxagentAdjustRandRXinerama: output [%d] name [%s]: prevmode [%s] ([%p]) refcnt [%d]\n", i, pScrPriv->outputs[i]->name, prevmode->name, (void *)prevmode, prevmode->refcnt); - } else { + } + else + { fprintf(stderr, "nxagentAdjustRandRXinerama: output [%d] name [%s]: no prevmode\n", i, pScrPriv->outputs[i]->name); } #endif RROutputSetCrtcs(pScrPriv->outputs[i], &(pScrPriv->crtcs[i]), 1); - if (disable_output) { + if (disable_output) + { #ifdef DEBUG fprintf(stderr, "nxagentAdjustRandRXinerama: output [%d] name [%s]: no (valid) intersection - disconnecting\n", i, pScrPriv->outputs[i]->name); #endif @@ -4205,7 +4196,8 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) * mode of the output's crtc. This also leads to xinerama not * showing the disconnected head anymore. */ - if (prevmode) { + if (prevmode) + { #ifdef DEBUG fprintf(stderr, "nxagentAdjustRandRXinerama: removing mode from output [%d] name [%s]\n", i, pScrPriv->outputs[i]->name); #endif @@ -4247,27 +4239,29 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) mymode = RRModeGet(&modeInfo, name); #ifdef DEBUG - if (mymode) { + if (mymode) + { fprintf(stderr, "nxagentAdjustRandRXinerama: output [%d] name [%s]: mode [%s] ([%p]) created/received, refcnt [%d]\n", i, pScrPriv->outputs[i]->name, name, (void *) mymode, mymode->refcnt); } else { - /* FIXME: what is the correct behaviour in this case? */ + /* FIXME: what is the correct behaviour in this case? */ fprintf(stderr, "nxagentAdjustRandRXinerama: output [%d] name [%s]: mode [%s] creation failed!\n", i, pScrPriv->outputs[i]->name, name); } #endif - if (prevmode && mymode == prevmode) { + if (prevmode && mymode == prevmode) + { #ifdef DEBUG fprintf(stderr, "nxagentAdjustRandRXinerama: mymode [%s] ([%p]) == prevmode [%s] ([%p])\n", mymode->name, (void *) mymode, prevmode->name, (void *)prevmode); #endif /* if they are the same RRModeGet() has increased the - refcnt by 1. We decrease it again by calling only - RRModeDestroy() and forget about prevmode */ - RRModeDestroy(mymode); + refcnt by 1. We decrease it again by calling only + RRModeDestroy() and forget about prevmode */ + RRModeDestroy(mymode); } else - { + { #ifdef DEBUG fprintf(stderr, "nxagentAdjustRandRXinerama: setting mode [%s] ([%p]) refcnt [%d] for output %d [%s]\n", mymode->name, (void *) mymode, mymode->refcnt, i, pScrPriv->outputs[i]->name); #endif @@ -4283,11 +4277,12 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) /* throw away the mode if otherwise unused. We do not need it anymore. We call FreeResource() to ensure the system will not try to free it again on shutdown */ - if (prevmode && prevmode->refcnt == 1) { + if (prevmode && prevmode->refcnt == 1) + { #ifdef DEBUG fprintf(stderr, "nxagentAdjustRandRXinerama: destroying prevmode [%s]\n", prevmode->name); #endif - FreeResource(prevmode->mode.id, 0); + FreeResource(prevmode->mode.id, 0); } RROutputChanged(pScrPriv->outputs[i], TRUE); @@ -4298,19 +4293,20 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) SAFE_free(screeninfo); #ifdef DEBUG - for (i = 0; i < pScrPriv->numCrtcs; i++) { + for (i = 0; i < pScrPriv->numCrtcs; i++) + { RRModePtr mode = pScrPriv->crtcs[i]->mode; if (mode) { - fprintf(stderr, "nxagentAdjustRandRXinerama: crtc [%d] ([%p]) has mode [%s] ([%p]), refcnt [%d] and [%d] outputs:\n", i, (void *) pScrPriv->crtcs[i], pScrPriv->crtcs[i]->mode->name, (void *)pScrPriv->crtcs[i]->mode, pScrPriv->crtcs[i]->mode->refcnt, pScrPriv->crtcs[i]->numOutputs); + fprintf(stderr, "nxagentAdjustRandRXinerama: crtc [%d] ([%p]) has mode [%s] ([%p]), refcnt [%d] and [%d] outputs:\n", i, (void *) pScrPriv->crtcs[i], pScrPriv->crtcs[i]->mode->name, (void *)pScrPriv->crtcs[i]->mode, pScrPriv->crtcs[i]->mode->refcnt, pScrPriv->crtcs[i]->numOutputs); } else { - fprintf(stderr, "nxagentAdjustRandRXinerama: crtc [%d] ([%p]) has no mode and [%d] outputs:\n", i, (void *) pScrPriv->crtcs[i], pScrPriv->crtcs[i]->numOutputs); + fprintf(stderr, "nxagentAdjustRandRXinerama: crtc [%d] ([%p]) has no mode and [%d] outputs:\n", i, (void *) pScrPriv->crtcs[i], pScrPriv->crtcs[i]->numOutputs); } if (pScrPriv->crtcs[i]->numOutputs > 0) for (int j=0; j < pScrPriv->crtcs[i]->numOutputs; j++) - fprintf(stderr, "nxagentAdjustRandRXinerama: output [%d] name [%s]->crtc=[%p]\n", j, pScrPriv->crtcs[i]->outputs[j]->name, (void *)pScrPriv->crtcs[i]->outputs[j]->crtc); + fprintf(stderr, "nxagentAdjustRandRXinerama: output [%d] name [%s]->crtc=[%p]\n", j, pScrPriv->crtcs[i]->outputs[j]->name, (void *)pScrPriv->crtcs[i]->outputs[j]->crtc); } #endif @@ -4338,24 +4334,13 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) void nxagentSaveAreas(PixmapPtr pPixmap, RegionPtr prgnSave, int xorg, int yorg, WindowPtr pWin) { - PixmapPtr pVirtualPixmap; - nxagentPrivPixmapPtr pPrivPixmap; - XlibGC gc; - XGCValues values; - int i; - int xSrc, ySrc, xDst, yDst, w, h; - int nRects; - int size; - BoxPtr pBox; - XRectangle *pRects; - BoxRec extents; - RegionRec cleanRegion; + XGCValues values = {0}; miBSWindowPtr pBackingStore = (miBSWindowPtr) pWin -> backStorage; - pVirtualPixmap = nxagentVirtualPixmap(pPixmap); + PixmapPtr pVirtualPixmap = nxagentVirtualPixmap(pPixmap); - pPrivPixmap = nxagentPixmapPriv(pPixmap); + nxagentPrivPixmapPtr pPrivPixmap = nxagentPixmapPriv(pPixmap); pPrivPixmap -> isBackingPixmap = 1; @@ -4364,13 +4349,14 @@ void nxagentSaveAreas(PixmapPtr pPixmap, RegionPtr prgnSave, int xorg, int yorg, values.subwindow_mode = IncludeInferiors; - gc = XCreateGC(nxagentDisplay, nxagentWindow(screenInfo.screens[0]->root), GCSubwindowMode, &values); + XlibGC gc = XCreateGC(nxagentDisplay, nxagentWindow(screenInfo.screens[0]->root), GCSubwindowMode, &values); /* * Initialize to the corrupted region. * Coordinates are relative to the window. */ + RegionRec cleanRegion; RegionInit(&cleanRegion, NullBox, 1); RegionCopy(&cleanRegion, nxagentCorruptedRegion((DrawablePtr) pWin)); @@ -4395,12 +4381,12 @@ void nxagentSaveAreas(PixmapPtr pPixmap, RegionPtr prgnSave, int xorg, int yorg, RegionSubtract(&cleanRegion, prgnSave, &cleanRegion); - nRects = RegionNumRects(&cleanRegion); - size = nRects * sizeof(*pRects); - pRects = (XRectangle *) malloc(size); - pBox = RegionRects(&cleanRegion); + int nRects = RegionNumRects(&cleanRegion); + int size = nRects * sizeof(XRectangle); + XRectangle *pRects = (XRectangle *) malloc(size); + BoxPtr pBox = RegionRects(&cleanRegion); - for (i = nRects; i-- > 0;) + for (int i = nRects; i-- > 0;) { pRects[i].x = pBox[i].x1; pRects[i].y = pBox[i].y1; @@ -4412,12 +4398,12 @@ void nxagentSaveAreas(PixmapPtr pPixmap, RegionPtr prgnSave, int xorg, int yorg, SAFE_free(pRects); - extents = *RegionExtents(&cleanRegion); + BoxRec extents = *RegionExtents(&cleanRegion); RegionUninit(&cleanRegion); - xDst = extents.x1; - yDst = extents.y1; + int xDst = extents.x1; + int yDst = extents.y1; /* * Left here the wrong solution. The window could be not @@ -4430,11 +4416,11 @@ void nxagentSaveAreas(PixmapPtr pPixmap, RegionPtr prgnSave, int xorg, int yorg, * ySrc = yDst + yorg - pWin -> drawable.y; */ - xSrc = xDst + pBackingStore -> x; - ySrc = yDst + pBackingStore -> y; + int xSrc = xDst + pBackingStore -> x; + int ySrc = yDst + pBackingStore -> y; - w = extents.x2 - extents.x1; - h = extents.y2 - extents.y1; + int w = extents.x2 - extents.x1; + int h = extents.y2 - extents.y1; XCopyArea(nxagentDisplay, nxagentWindow(pWin), nxagentPixmap(pPixmap), gc, xSrc, ySrc, w, h, xDst, yDst); @@ -4455,18 +4441,7 @@ void nxagentSaveAreas(PixmapPtr pPixmap, RegionPtr prgnSave, int xorg, int yorg, void nxagentRestoreAreas(PixmapPtr pPixmap, RegionPtr prgnRestore, int xorg, int yorg, WindowPtr pWin) { - PixmapPtr pVirtualPixmap; - RegionPtr clipRegion; - XlibGC gc; - XGCValues values; - int i; - int xSrc, ySrc, xDst, yDst, w, h; - int nRects; - int size; - BoxPtr pBox; - XRectangle *pRects; - BoxRec extents; - miBSWindowPtr pBackingStore; + XGCValues values = {0}; /* * Limit the area to restore to the @@ -4476,16 +4451,16 @@ void nxagentRestoreAreas(PixmapPtr pPixmap, RegionPtr prgnRestore, int xorg, RegionIntersect(prgnRestore, prgnRestore, &pWin -> drawable.pScreen -> root -> winSize); - pBackingStore = (miBSWindowPtr) pWin -> backStorage; + miBSWindowPtr pBackingStore = (miBSWindowPtr) pWin -> backStorage; - pVirtualPixmap = nxagentVirtualPixmap(pPixmap); + PixmapPtr pVirtualPixmap = nxagentVirtualPixmap(pPixmap); fbCopyWindowProc(&pVirtualPixmap -> drawable, &pWin -> drawable, 0, RegionRects(prgnRestore), RegionNumRects(prgnRestore), -xorg, -yorg, FALSE, FALSE, 0, 0); values.subwindow_mode = ClipByChildren; - gc = XCreateGC(nxagentDisplay, nxagentWindow(screenInfo.screens[0]->root), GCSubwindowMode, &values); + XlibGC gc = XCreateGC(nxagentDisplay, nxagentWindow(screenInfo.screens[0]->root), GCSubwindowMode, &values); /* * Translate the reference point to the origin of the window. @@ -4495,7 +4470,7 @@ void nxagentRestoreAreas(PixmapPtr pPixmap, RegionPtr prgnRestore, int xorg, -pWin -> drawable.x - pWin -> borderWidth, -pWin -> drawable.y - pWin -> borderWidth); - clipRegion = prgnRestore; + RegionPtr clipRegion = prgnRestore; if (nxagentDrawableStatus((DrawablePtr) pPixmap) == NotSynchronized) { @@ -4541,12 +4516,12 @@ void nxagentRestoreAreas(PixmapPtr pPixmap, RegionPtr prgnRestore, int xorg, RegionSubtract(clipRegion, prgnRestore, clipRegion); } - nRects = RegionNumRects(clipRegion); - size = nRects * sizeof(*pRects); - pRects = (XRectangle *) malloc(size); - pBox = RegionRects(clipRegion); + int nRects = RegionNumRects(clipRegion); + int size = nRects * sizeof(XRectangle); + XRectangle *pRects = (XRectangle *) malloc(size); + BoxPtr pBox = RegionRects(clipRegion); - for (i = nRects; i-- > 0;) + for (int i = nRects; i-- > 0;) { pRects[i].x = pBox[i].x1; pRects[i].y = pBox[i].y1; @@ -4558,16 +4533,16 @@ void nxagentRestoreAreas(PixmapPtr pPixmap, RegionPtr prgnRestore, int xorg, SAFE_free(pRects); - extents = *RegionExtents(clipRegion); + BoxRec extents = *RegionExtents(clipRegion); - xDst = extents.x1; - yDst = extents.y1; + int xDst = extents.x1; + int yDst = extents.y1; - xSrc = xDst - xorg + pWin -> drawable.x; - ySrc = yDst - yorg + pWin -> drawable.y; + int xSrc = xDst - xorg + pWin -> drawable.x; + int ySrc = yDst - yorg + pWin -> drawable.y; - w = extents.x2 - extents.x1; - h = extents.y2 - extents.y1; + int w = extents.x2 - extents.x1; + int h = extents.y2 - extents.y1; nxagentFlushConfigureWindow(); @@ -4661,11 +4636,7 @@ void nxagentSetWMNormalHintsMaxsize(ScreenPtr pScreen, int maxwidth, int maxheig void nxagentShadowAdaptToRatio(void) { - ScreenPtr pScreen; - RegionRec region; - BoxRec box; - - pScreen = screenInfo.screens[0]; + ScreenPtr pScreen = screenInfo.screens[0]; nxagentShadowSetRatio(nxagentOption(Width) * 1.0 / nxagentShadowWidth, nxagentOption(Height) * 1.0 / nxagentShadowHeight); @@ -4676,10 +4647,14 @@ void nxagentShadowAdaptToRatio(void) WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)), HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay))); - box.x1 = 0; - box.y1 = 0; - box.x2 = nxagentShadowPixmapPtr -> drawable.width; - box.y2 = nxagentShadowPixmapPtr -> drawable.height; + BoxRec box = { + .x1 = 0, + .y1 = 0, + .x2 = nxagentShadowPixmapPtr -> drawable.width, + .y2 = nxagentShadowPixmapPtr -> drawable.height + }; + + RegionRec region; RegionInit(®ion, &box, 1); @@ -4690,9 +4665,7 @@ void nxagentShadowAdaptToRatio(void) void nxagentPrintGeometry(void) { - int i; - - for (i = 0; i < screenInfo.numScreens; i++) + for (int i = 0; i < screenInfo.numScreens; i++) { if (nxagentPrintGeometryFlags & (1 << i)) { @@ -4711,21 +4684,15 @@ void nxagentPrintGeometry(void) void nxagentShowPixmap(PixmapPtr pPixmap, int x, int y, int width, int height) { static int init = 1; - static Display *shadow; - static Window win; + static Display *shadow = NULL; + static Window win = 0; - XlibGC gc; - XGCValues value; - XImage *image; - WindowPtr pWin = screenInfo.screens[0]->root; - unsigned int format; - int depth, pixmapWidth, pixmapHeight, length; - char *data; - - depth = pPixmap -> drawable.depth; - pixmapWidth = pPixmap -> drawable.width; - pixmapHeight = pPixmap -> drawable.height; - format = (depth == 1) ? XYPixmap : ZPixmap; + int depth = pPixmap -> drawable.depth; + /* + int pixmapWidth = pPixmap -> drawable.width; + int pixmapHeight = pPixmap -> drawable.height; + */ + unsigned int format = (depth == 1) ? XYPixmap : ZPixmap; if (init) { @@ -4770,9 +4737,9 @@ void nxagentShowPixmap(PixmapPtr pPixmap, int x, int y, int width, int height) XRaiseWindow(nxagentDisplay, win); } - length = nxagentImageLength(width, height, format, 0, depth); - - if ((data = malloc(length)) == NULL) + int length = nxagentImageLength(width, height, format, 0, depth); + char *data = malloc(length); + if (data == NULL) { #ifdef WARNING fprintf(stderr, "nxagentShowPixmap: malloc failed.\n"); @@ -4783,12 +4750,12 @@ void nxagentShowPixmap(PixmapPtr pPixmap, int x, int y, int width, int height) /* FIXME - image = XGetImage(nxagentDisplay, nxagentPixmap(pPixmap), x, y, - width, height, AllPlanes, format); + XImage *image = XGetImage(nxagentDisplay, nxagentPixmap(pPixmap), x, y, + width, height, AllPlanes, format); */ - image = XGetImage(nxagentDisplay, RootWindow(nxagentDisplay, 0), 0, 0, - width, height, AllPlanes, format); + XImage *image = XGetImage(nxagentDisplay, RootWindow(nxagentDisplay, 0), 0, 0, + width, height, AllPlanes, format); if (image == NULL) { @@ -4806,13 +4773,15 @@ FIXME memcpy(image -> data, data, length); - value.foreground = 0xffffff; - value.background = 0x000000; - value.plane_mask = 0xffffff; - value.fill_style = FillSolid; + XGCValues value = { + .foreground = 0xffffff, + .background = 0x000000, + .plane_mask = 0xffffff, + .fill_style = FillSolid + }; - gc = XCreateGC(shadow, win, GCBackground | - GCForeground | GCFillStyle | GCPlaneMask, &value); + XlibGC gc = XCreateGC(shadow, win, GCBackground | + GCForeground | GCFillStyle | GCPlaneMask, &value); XSync(shadow, 0); @@ -4843,26 +4812,19 @@ FIXME void nxagentFbRestoreArea(PixmapPtr pPixmap, WindowPtr pWin, int xSrc, int ySrc, int width, int height, int xDst, int yDst) { - Display *shadow; - - XlibGC gc; - XGCValues value; - XImage *image; - unsigned int format; - int depth, pixmapWidth, pixmapHeight, length; - char *data = NULL; - Visual *pVisual; - - depth = pPixmap -> drawable.depth; - pixmapWidth = pPixmap -> drawable.width; - pixmapHeight = pPixmap -> drawable.height; - format = (depth == 1) ? XYPixmap : ZPixmap; + Display *shadow = nxagentDisplay; - shadow = nxagentDisplay; + int depth = pPixmap -> drawable.depth; + /* + int pixmapWidth = pPixmap -> drawable.width; + int pixmapHeight = pPixmap -> drawable.height; + */ + unsigned int format = (depth == 1) ? XYPixmap : ZPixmap; - length = nxagentImageLength(width, height, format, 0, depth); + int length = nxagentImageLength(width, height, format, 0, depth); + char *data = malloc(length); - if ((data = malloc(length)) == NULL) + if (data == NULL) { #ifdef WARNING fprintf(stderr, "nxagentFbRestoreArea: malloc failed.\n"); @@ -4870,11 +4832,13 @@ void nxagentFbRestoreArea(PixmapPtr pPixmap, WindowPtr pWin, int xSrc, int ySrc, return; } + + XImage *image = NULL; /* - image = XGetImage(nxagentDisplay, nxagentPixmap(pPixmap), xSrc, ySrc, - width, height, AllPlanes, format); + XImage *image = XGetImage(nxagentDisplay, nxagentPixmap(pPixmap), xSrc, ySrc, + width, height, AllPlanes, format); */ - + if (image == NULL) { #ifdef WARNING @@ -4892,7 +4856,7 @@ void nxagentFbRestoreArea(PixmapPtr pPixmap, WindowPtr pWin, int xSrc, int ySrc, /* FIXME */ - pVisual = nxagentImageVisual((DrawablePtr) pPixmap, depth); + Visual *pVisual = nxagentImageVisual((DrawablePtr) pPixmap, depth); if (pVisual == NULL) { @@ -4914,14 +4878,16 @@ FIXME fprintf(stderr, "nxagentFbRestoreArea: Cleaning %d bytes of image.\n", length); - value.foreground = 0xffffff; - value.background = 0x000000; - value.plane_mask = 0xffffff; - value.fill_style = FillSolid; - value.function = GXcopy; + XGCValues value = { + .foreground = 0xffffff, + .background = 0x000000, + .plane_mask = 0xffffff, + .fill_style = FillSolid, + .function = GXcopy + }; - gc = XCreateGC(shadow, nxagentWindow(screenInfo.screens[0]->root), GCBackground | - GCForeground | GCFillStyle | GCPlaneMask | GCFunction, &value); + XlibGC gc = XCreateGC(shadow, nxagentWindow(screenInfo.screens[0]->root), GCBackground | + GCForeground | GCFillStyle | GCPlaneMask | GCFunction, &value); NXCleanImage(image); |