diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2019-06-22 11:32:42 +0200 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2019-06-22 11:32:42 +0200 |
commit | abf3741362f4c200945db6403fcd54df6754d4af (patch) | |
tree | ea7d12c03048fab6e0cbc7571b779c592d610512 /nx-X11/programs/Xserver/hw | |
parent | c0754a35755cdd4e25386abc6378e07605845948 (diff) | |
parent | c8a5e33fcdde322f486d6c69e7e16fa346793fc9 (diff) | |
download | nx-libs-abf3741362f4c200945db6403fcd54df6754d4af.tar.gz nx-libs-abf3741362f4c200945db6403fcd54df6754d4af.tar.bz2 nx-libs-abf3741362f4c200945db6403fcd54df6754d4af.zip |
Merge branch 'uli42-pr/various' into 3.6.x
Attributes GH PR #815: https://github.com/ArcticaProject/nx-libs/pull/815
Diffstat (limited to 'nx-X11/programs/Xserver/hw')
18 files changed, 335 insertions, 324 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c index 4bddbba3a..9d9f5d204 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Events.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c @@ -1964,14 +1964,14 @@ FIXME: Don't enqueue the KeyRelease event if the key was } case UnmapNotify: { - WindowPtr pWin; - #ifdef TEST fprintf(stderr, "nxagentDispatchEvents: Going to handle new UnmapNotify event.\n"); #endif if (nxagentOption(Rootless) == 1) { + WindowPtr pWin; + if ((pWin = nxagentRootlessTopLevelWindow(X.xunmap.window)) != NULL || ((pWin = nxagentWindowPtr(X.xunmap.window)) != NULL && nxagentWindowTopLevel(pWin) == 1)) @@ -1995,22 +1995,19 @@ FIXME: Don't enqueue the KeyRelease event if the key was } case MapNotify: { - WindowPtr pWin; - ClientPtr pClient; - #ifdef TEST fprintf(stderr, "nxagentDispatchEvents: Going to handle new MapNotify event.\n"); #endif if (nxagentOption(Rootless) == 1) { - Bool value = 1; + WindowPtr pWin; if ((pWin = nxagentRootlessTopLevelWindow(X.xmap.window)) != NULL || ((pWin = nxagentWindowPtr(X.xmap.window)) != NULL && nxagentWindowTopLevel(pWin) == 1)) { - pClient = wClient(pWin); + ClientPtr pClient = wClient(pWin); nxagentScreenTrap = 1; @@ -2021,6 +2018,8 @@ FIXME: Don't enqueue the KeyRelease event if the key was if (pWin != NULL) { + Bool value = 1; + TraverseTree(pWin, nxagentChangeMapPrivate, &value); } } @@ -2355,8 +2354,6 @@ int nxagentHandleKeyPress(XEvent *X, enum HandleEventResult *result) int nxagentHandlePropertyNotify(XEvent *X) { - int resource; - if (nxagentOption(Rootless) && !nxagentNotifyMatchChangeProperty((XPropertyEvent *) X)) { #ifdef TEST @@ -2366,7 +2363,7 @@ int nxagentHandlePropertyNotify(XEvent *X) if (nxagentWindowPtr(X -> xproperty.window) != NULL) { - resource = NXGetCollectPropertyResource(nxagentDisplay); + int resource = NXGetCollectPropertyResource(nxagentDisplay); if (resource == -1) { @@ -2643,8 +2640,6 @@ int nxagentHandleGraphicsExposeEvent(XEvent *X) int nxagentHandleClientMessageEvent(XEvent *X, enum HandleEventResult *result) { - WindowPtr pWin; - *result = doNothing; #ifdef TEST @@ -2680,7 +2675,7 @@ int nxagentHandleClientMessageEvent(XEvent *X, enum HandleEventResult *result) return 0; } - pWin = nxagentWindowPtr(X -> xclient.window); + WindowPtr pWin = nxagentWindowPtr(X -> xclient.window); if (pWin == NULL) { @@ -2886,7 +2881,6 @@ int nxagentHandleXkbKeyboardStateEvent(XEvent *X) int nxagentHandleXFixesSelectionNotify(XEvent *X) { - int i; Atom local; XFixesSelectionEvent *xfixesEvent = (XFixesSelectionEvent *) X; @@ -2915,7 +2909,7 @@ int nxagentHandleXFixesSelectionNotify(XEvent *X) if (SelectionCallback) { - i = 0; + int i = 0; while ((i < NumCurrentSelections) && CurrentSelections[i].selection != local) @@ -4011,21 +4005,23 @@ void nxagentDeactivatePointerGrab(void) if (grab) { - XButtonEvent X; - memset(&X, 0, sizeof(XButtonEvent)); - - X.type = ButtonRelease; - X.serial = 0; - X.send_event = FALSE; - X.time = currentTime.milliseconds; - X.display = nxagentDisplay; - X.window = nxagentWindow(grab -> window); - X.root = RootWindow(nxagentDisplay, 0); - X.subwindow = 0; - X.x = X.y = X.x_root = X.y_root = 0; - X.state = 0x100; - X.button = 1; - X.same_screen = TRUE; + XButtonEvent X = { + .type = ButtonRelease, + .serial = 0, + .send_event = FALSE, + .time = currentTime.milliseconds, + .display = nxagentDisplay, + .window = nxagentWindow(grab -> window), + .root = RootWindow(nxagentDisplay, 0), + .subwindow = 0, + .x = 0, + .y = 0, + .x_root = 0, + .y_root = 0, + .state = 0x100, + .button = 1, + .same_screen = TRUE, + }; XPutBackEvent(nxagentDisplay, (XEvent*)&X); } diff --git a/nx-X11/programs/Xserver/hw/nxagent/Extensions.c b/nx-X11/programs/Xserver/hw/nxagent/Extensions.c index 785724cea..239d84b85 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Extensions.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Extensions.c @@ -98,13 +98,12 @@ void nxagentInitGlxExtension(VisualPtr *visuals, DepthPtr *depths, int *numVisuals, int *numDepths, int *rootDepth, VisualID *defaultVisual) { - miInitVisualsProcPtr initVisuals; /* * Initialize the visuals to use the GLX extension. */ - initVisuals = NULL; + miInitVisualsProcPtr initVisuals = NULL; GlxWrapInitVisuals(&initVisuals); @@ -372,15 +371,13 @@ static int nxagentRandRInitSizes(ScreenPtr pScreen) int nxagentRandRSetConfig(ScreenPtr pScreen, Rotation rotation, int rate, RRScreenSizePtr pSize) { - int r; - UpdateCurrentTime(); /* * Whatever size is OK for us. */ - r = nxagentResizeScreen(pScreen, pSize -> width, pSize -> height, + int r = nxagentResizeScreen(pScreen, pSize -> width, pSize -> height, pSize -> mmWidth, pSize -> mmHeight); nxagentMoveViewport(pScreen, 0, 0); @@ -430,8 +427,6 @@ void nxagentRandRSetWindowsSize(int width, int height) int nxagentRandRScreenSetSize(ScreenPtr pScreen, CARD16 width, CARD16 height, CARD32 mmWidth, CARD32 mmHeight) { - int result; - UpdateCurrentTime(); if (nxagentOption(DesktopResize) == 1 && @@ -453,7 +448,7 @@ int nxagentRandRScreenSetSize(ScreenPtr pScreen, CARD16 width, CARD16 height, nxagentChangeOption(Height, height); } - result = nxagentResizeScreen(pScreen, width, height, mmWidth, mmHeight); + int result = nxagentResizeScreen(pScreen, width, height, mmWidth, mmHeight); if (result == 1 && nxagentOption(DesktopResize) == 1 && nxagentOption(Fullscreen) == 0 && nxagentOption(AllScreens) == 0) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Font.c b/nx-X11/programs/Xserver/hw/nxagent/Font.c index 8de50fdc3..fb441d431 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Font.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Font.c @@ -165,8 +165,6 @@ static struct _nxagentFailedToReconnectFonts void nxagentFreeFontCache(void) { - int i; - #ifdef NXAGENT_FONTCACHE_DEBUG fprintf(stderr, "Font: Freeing nxagent font cache\n"); #endif @@ -178,7 +176,7 @@ void nxagentFreeFontCache(void) fprintf(stderr, "Font: Freeing nxagent font cache, there are [%d] entries.\n", CACHE_INDEX); #endif - for (i = 0; i < CACHE_INDEX; i++) + for (int i = 0; i < CACHE_INDEX; i++) { #ifdef NXAGENT_FONTCACHE_DEBUG fprintf(stderr, "Font: Freeing nxagent font cache entry [%d] entry pointer is [%p], name [%s]\n", @@ -208,8 +206,6 @@ void nxagentFreeFontCache(void) void nxagentListRemoteFonts(const char *searchPattern, const int maxNames) { - int i, q, p; - char **xList; int xLen = 0; @@ -241,7 +237,7 @@ void nxagentListRemoteFonts(const char *searchPattern, const int maxNames) * other one will select the 'real' fonts. */ - for (p = 0; p < patternsQt; p++) + for (int p = 0; p < patternsQt; p++) { xList = XListFonts(nxagentDisplay, patterns[p], maxNames, &xLen); @@ -256,11 +252,9 @@ void nxagentListRemoteFonts(const char *searchPattern, const int maxNames) nxagentListRemoteAddName(searchPattern, maxNames); - for (i = 0; i < xLen; i++) + for (int i = 0; i < xLen; i++) { - q = 1; - - nxagentListRemoteAddName(xList[i], q); + nxagentListRemoteAddName(xList[i], 1); } XFreeFontNames(xList); @@ -270,7 +264,7 @@ void nxagentListRemoteFonts(const char *searchPattern, const int maxNames) fprintf(stderr, "nxagentListRemoteFonts: Printing remote font list.\n"); - for (i = 0; i < nxagentRemoteFontList.length; i++) + for (int i = 0; i < nxagentRemoteFontList.length; i++) { fprintf(stderr, "Font# %d, \"%s\"\n", i, nxagentRemoteFontList.list[i]->name); } @@ -353,9 +347,7 @@ void nxagentListRemoteAddName(const char *name, int status) static void nxagentFreeRemoteFontList(nxagentFontList *listRec) { - int l; - - for (l = 0; l < listRec -> length; l++) + for (int l = 0; l < listRec -> length; l++) { if (listRec -> list[l]) { @@ -377,18 +369,16 @@ static void nxagentFreeRemoteFontList(nxagentFontList *listRec) Bool nxagentFontFind(const char *name, int *pos) { - int low,high,res,iter,lpos; - if (!nxagentRemoteFontList.length) { *pos=0; return False; } - low = 0; - high = nxagentRemoteFontList.length - 1; - iter = 0; - res = 1; - lpos = nxagentRemoteFontList.length; + int low = 0; + int high = nxagentRemoteFontList.length - 1; + int iter = 0; + int res = 1; + int lpos = nxagentRemoteFontList.length; while (low <= high) { *pos = (high + low)/2; @@ -424,18 +414,15 @@ Bool nxagentFontFind(const char *name, int *pos) Bool nxagentFontLookUp(const char *name) { int i; - int result; - - char *scalable; if (name != NULL && strlen(name) == 0) { return 0; } - result = nxagentFontFind(name, &i); + int result = nxagentFontFind(name, &i); - scalable = NULL; + char *scalable = NULL; /* * Let's try with the scalable font description. @@ -443,9 +430,7 @@ Bool nxagentFontLookUp(const char *name) if (result == 0) { - scalable = nxagentMakeScalableFontName(name, 0); - - if (scalable != NULL) + if ((scalable = nxagentMakeScalableFontName(name, 0)) != NULL) { result = nxagentFontFind(scalable, &i); @@ -459,9 +444,7 @@ Bool nxagentFontLookUp(const char *name) if (result == 0) { - scalable = nxagentMakeScalableFontName(name, 1); - - if (scalable != NULL) + if ((scalable = nxagentMakeScalableFontName(name, 1)) != NULL) { result = nxagentFontFind(scalable, &i); @@ -857,7 +840,6 @@ static void nxagentFontDisconnect(FontPtr pFont, XID param1, void * param2) { nxagentPrivFont *privFont; Bool *pBool = (Bool*)param2; - int i; if (pFont == NULL || !*pBool) return; @@ -869,7 +851,7 @@ static void nxagentFontDisconnect(FontPtr pFont, XID param1, void * param2) (void *) pFont, privFont -> font_struct ? nxagentFont(pFont) : 0); #endif - for (i = 0; i < CACHE_INDEX; i++) + for (int i = 0; i < CACHE_INDEX; i++) { if (strcasecmp(CACHE_NAME(i), privFont -> fontName) == 0) { @@ -897,7 +879,6 @@ static void nxagentFontDisconnect(FontPtr pFont, XID param1, void * param2) static void nxagentCollectFailedFont(FontPtr fpt, XID id) { - if (nxagentFailedToReconnectFonts.font == NULL) { nxagentFailedToReconnectFonts.size = 8; @@ -1043,13 +1024,11 @@ static void nxagentFontReconnect(FontPtr pFont, XID param1, void * param2) static void nxagentFreeCacheBeforeReconnect(void) { - int i; - #ifdef NXAGENT_RECONNECT_FONT_DEBUG printFontCacheDump("nxagentFreeCacheBeforeReconnect"); #endif - for (i = 0; i < CACHE_INDEX; i++) + for (int i = 0; i < CACHE_INDEX; i++) { if (CACHE_FSTRUCT(i)) { @@ -1061,15 +1040,13 @@ static void nxagentFreeCacheBeforeReconnect(void) static void nxagentCleanCacheAfterReconnect(void) { - int i, j; int real_size = CACHE_INDEX; - nxCacheFontEntryRecPtr swapEntryPtr; #ifdef NXAGENT_RECONNECT_FONT_DEBUG printFontCacheDump("nxagentCleanCacheAfterReconnect"); #endif - for (i = 0; i < CACHE_INDEX; i++) + for (int i = 0; i < CACHE_INDEX; i++) { if(CACHE_FSTRUCT(i) == NULL) { @@ -1078,8 +1055,11 @@ static void nxagentCleanCacheAfterReconnect(void) } } - for (i = 0; i < real_size; i++) + for (int i = 0; i < real_size; i++) { + int j; + nxCacheFontEntryRecPtr swapEntryPtr; + /* Find - first bad occurrence if exist. */ while ((i < real_size) && CACHE_FSTRUCT(i)) i++; @@ -1108,11 +1088,9 @@ static void nxagentCleanCacheAfterReconnect(void) #ifdef NXAGENT_RECONNECT_FONT_DEBUG static void printFontCacheDump(char* msg) { - int i; - fprintf(stderr, "%s - begin -\n", msg); - for (i = 0; i < CACHE_INDEX; i++) + for (int i = 0; i < CACHE_INDEX; i++) { if (CACHE_FSTRUCT(i)) { @@ -1129,7 +1107,6 @@ static void printFontCacheDump(char* msg) Bool nxagentReconnectAllFonts(void *p0) { - int cid; Bool fontSuccess = True; reconnectFlexibility = *((int *) p0); @@ -1147,7 +1124,7 @@ Bool nxagentReconnectAllFonts(void *p0) FindClientResourcesByType(clients[serverClient -> index], RT_NX_FONT, (FindResType) nxagentFontReconnect, &fontSuccess); - for (cid = 0; cid < MAXCLIENTS; cid++) + for (int cid = 0; cid < MAXCLIENTS; cid++) { if (clients[cid]) { @@ -1258,7 +1235,6 @@ static void nxagentFreeFailedToReconnectFonts(void) Bool nxagentReconnectFailedFonts(void *p0) { - int i; int attempt = 1; const int maxAttempt = 5; @@ -1312,7 +1288,7 @@ Bool nxagentReconnectFailedFonts(void *p0) nxagentFreeRemoteFontList(&nxagentRemoteFontList); nxagentListRemoteFonts("*", nxagentMaxFontNames); - for(i = 0; i < nxagentFailedToReconnectFonts.index; i++) + for(int i = 0; i < nxagentFailedToReconnectFonts.index; i++) { fontSuccess = True; @@ -1365,7 +1341,6 @@ Bool nxagentReconnectFailedFonts(void *p0) Bool nxagentDisconnectAllFonts(void) { - int cid; Bool fontSuccess = True; #if defined(NXAGENT_RECONNECT_DEBUG) || defined(NXAGENT_RECONNECT_FONT_DEBUG) @@ -1384,7 +1359,7 @@ Bool nxagentDisconnectAllFonts(void) FindClientResourcesByType(clients[serverClient -> index], RT_NX_FONT, (FindResType) nxagentFontDisconnect, &fontSuccess); - for(cid = 0; cid < MAXCLIENTS; cid++) + for(int cid = 0; cid < MAXCLIENTS; cid++) { if( clients[cid] && fontSuccess ) { @@ -1647,7 +1622,6 @@ XFontStruct* nxagentLoadQueryFont(register Display *dpy, char *name, FontPtr pFo int nxagentFreeFont(XFontStruct *fs) { - if (fs -> per_char) { #ifdef USE_XF86BIGFONT diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c index 96b33ea7d..4952c0197 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c @@ -553,10 +553,11 @@ void nxagentChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl) value_mask = KBLed | KBLedMode; - for (int i = 1; i <= 32; i++) + for (int i = 1; i <= XkbNumIndicators; i++) { + unsigned int mask = (unsigned int)1 << (i - 1); values.led = i; - values.led_mode = (ctrl->leds & (1 << (i - 1))) ? LedModeOn : LedModeOff; + values.led_mode = (ctrl->leds & mask) ? LedModeOn : LedModeOff; XChangeKeyboardControl(nxagentDisplay, value_mask, &values); } @@ -945,6 +946,10 @@ XkbError: { NXShadowInitKeymap(&(pDev->key->curKeySyms)); } + + free(rules); + free(variant); + free(options); } if (xkb) @@ -1025,11 +1030,18 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio break; case DEVICE_CLOSE: - #ifdef TEST fprintf(stderr, "nxagentKeyboardProc: Called for [DEVICE_CLOSE].\n"); #endif + for (int i = 0; i < pDev->nPrivates; i++) + { + free(pDev->devPrivates[i].ptr); + pDev->devPrivates[i].ptr = NULL; + } + free(pDev->devPrivates); + pDev->devPrivates = NULL; + break; } @@ -1292,8 +1304,6 @@ static int nxagentRestoreKeyboardDeviceData(DeviceIntPtr devBackup, DeviceIntPtr static int nxagentFreeKeyboardDeviceData(DeviceIntPtr dev) { - KbdFeedbackPtr k, knext; - if (!dev) { #ifdef PANIC @@ -1327,14 +1337,18 @@ static int nxagentFreeKeyboardDeviceData(DeviceIntPtr dev) dev->focus = NULL; } - for (k = dev->kbdfeed; k; k = knext) + if (dev->kbdfeed) { - knext = k->next; - #ifdef XKB - if (k->xkb_sli) - XkbFreeSrvLedInfo(k->xkb_sli); - #endif - free(k); + for (KbdFeedbackPtr k = dev->kbdfeed, knext; k; k = knext) + { + knext = k->next; + #ifdef XKB + if (k->xkb_sli) + XkbFreeSrvLedInfo(k->xkb_sli); + #endif + free(k); + } + dev->kbdfeed = NULL; } #ifdef DEBUG @@ -1683,7 +1697,10 @@ static char* getKeyboardFilePath(void) free(sessionpath); FatalError("malloc for keyboard file path failed."); } - free(sessionpath); + else + { + free(sessionpath); + } } else { diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c b/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c index 50bf719c6..bfb208593 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c @@ -1216,7 +1216,7 @@ nxdoListFontsAndAliases(client, fss) if (c->savedName) { memcpy(tmp,c->savedName,c->savedNameLen>255?255:c->savedNameLen); - tmp[c->savedNameLen>255?256:c->savedNameLen]=0; + tmp[c->savedNameLen>255?255:c->savedNameLen]=0; if (nxagentFontLookUp(tmp)) break; else tmp[0]=0; @@ -1225,7 +1225,7 @@ nxdoListFontsAndAliases(client, fss) else { memcpy(tmp,name,namelen>255?255:namelen); - tmp[namelen>255?256:namelen]=0; + tmp[namelen>255?255:namelen]=0; if (nxagentFontLookUp(tmp)) break; else tmp[0]=0; diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXevents.c b/nx-X11/programs/Xserver/hw/nxagent/NXevents.c index 43dfe8613..78d74a0d5 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXevents.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXevents.c @@ -367,10 +367,8 @@ XYToWindow(int x, int y) if (spriteTraceGood >= spriteTraceSize) { spriteTraceSize += 10; - Must_have_memory = TRUE; /* XXX */ - spriteTrace = (WindowPtr *)realloc( + spriteTrace = realloc( spriteTrace, spriteTraceSize*sizeof(WindowPtr)); - Must_have_memory = FALSE; /* XXX */ } spriteTrace[spriteTraceGood++] = pWin; pWin = pWin->firstChild; diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXglyph.c b/nx-X11/programs/Xserver/hw/nxagent/NXglyph.c index 35dcbc132..72d8242bd 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXglyph.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXglyph.c @@ -59,6 +59,67 @@ #endif +GlyphRefPtr +FindGlyphRef (GlyphHashPtr hash, CARD32 signature, Bool match, GlyphPtr compare) +{ + CARD32 elt, step, s; + GlyphPtr glyph; + GlyphRefPtr table, gr, del; + CARD32 tableSize = hash->hashSet->size; + + table = hash->table; + elt = signature % tableSize; + step = 0; + del = 0; + for (;;) + { + gr = &table[elt]; + s = gr->signature; + glyph = gr->glyph; + if (!glyph) + { + if (del) + gr = del; + break; + } + if (glyph == DeletedGlyph) + { + if (!del) + del = gr; + else if (gr == del) + break; + } +#ifdef NXAGENT_SERVER + else if (s == signature && match && glyph->size != compare->size) + { + /* + * if the glyphsize is different there's no need to do a memcmp + * because it will surely report difference. And even worse: + * it will read beyond the end of glyph under some + * circumstances, which can be detected when compiling with + * -fsanitize=address. + */ + } +#endif + else if (s == signature && + (!match || + memcmp (&compare->info, &glyph->info, compare->size) == 0)) + { + break; + } + if (!step) + { + step = signature % hash->hashSet->rehash; + if (!step) + step = 1; + } + elt += step; + if (elt >= tableSize) + elt -= tableSize; + } + return gr; +} + void AddGlyph (GlyphSetPtr glyphSet, GlyphPtr glyph, Glyph id) { @@ -138,12 +199,6 @@ ResizeGlyphHash (GlyphHashPtr hash, CARD32 change, Bool global) int oldSize; CARD32 s; - #ifdef NXAGENT_SERVER - - CARD32 c; - - #endif - tableEntries = hash->tableEntries + change; hashSet = FindGlyphHashSet (tableEntries); if (hashSet == hash->hashSet) @@ -164,7 +219,7 @@ ResizeGlyphHash (GlyphHashPtr hash, CARD32 change, Bool global) #ifdef NXAGENT_SERVER - c = hash->table[i].corruptedGlyph; + CARD32 c = hash->table[i].corruptedGlyph; #endif diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c b/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c index 4ea7d2d73..491af5b30 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c @@ -303,33 +303,25 @@ CreateSolidPicture (Picture pid, xRenderColor *color, int *error) static PicturePtr createSourcePicture(void) { - PicturePtr pPicture; - extern int nxagentPicturePrivateIndex; - unsigned int totalPictureSize; - - DevUnion *ppriv; - - char *privPictureRecAddr; - - int i; - /* * Compute size of entire PictureRect, plus privates. */ - totalPictureSize = sizeof(PictureRec) + + unsigned int totalPictureSize = sizeof(PictureRec) + picturePrivateCount * sizeof(DevUnion) + sizeof(nxagentPrivPictureRec); - pPicture = (PicturePtr) calloc(1, totalPictureSize); + PicturePtr pPicture = (PicturePtr) calloc(1, totalPictureSize); + if (!pPicture) + return 0; if (pPicture != NULL) { - ppriv = (DevUnion *) (pPicture + 1); + DevUnion *ppriv = (DevUnion *) (pPicture + 1); - for (i = 0; i < picturePrivateCount; ++i) + for (int i = 0; i < picturePrivateCount; ++i) { /* * Other privates are inaccessible. @@ -338,7 +330,7 @@ static PicturePtr createSourcePicture(void) ppriv[i].ptr = NULL; } - privPictureRecAddr = (char *) &ppriv[picturePrivateCount]; + char *privPictureRecAddr = (char *) &ppriv[picturePrivateCount]; ppriv[nxagentPicturePrivateIndex].ptr = (void *) privPictureRecAddr; diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXrender.c b/nx-X11/programs/Xserver/hw/nxagent/NXrender.c index fd9c0be82..190f746a4 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXrender.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXrender.c @@ -1004,7 +1004,11 @@ ProcRenderCompositeGlyphs (ClientPtr client) elementsBase = malloc(nlist * sizeof(XGlyphElt8)); if (!elementsBase) - return BadAlloc; + { + free(glyphsBase); + free(listsBase); + return BadAlloc; + } buffer = (CARD8 *) (stuff + 1); glyphs = glyphsBase; diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXshm.c b/nx-X11/programs/Xserver/hw/nxagent/NXshm.c index 246d39355..9a314391c 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXshm.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXshm.c @@ -387,8 +387,8 @@ ProcShmPutImage(client) ((stuff->format != ZPixmap) && (stuff->srcX < screenInfo.bitmapScanlinePad) && ((stuff->format == XYBitmap) || - - ((stuff->srcY == 0) && - - (stuff->srcHeight == stuff->totalHeight))))) && + ((stuff->srcY == 0) && + (stuff->srcHeight == stuff->totalHeight))))) && ((stuff->srcX + stuff->srcWidth) == stuff->totalWidth)) (*pGC->ops->PutImage) (pDraw, pGC, stuff->depth, stuff->dstX, stuff->dstY, @@ -396,7 +396,7 @@ ProcShmPutImage(client) stuff->srcX, stuff->format, shmdesc->addr + stuff->offset + (stuff->srcY * length)); -- else + else #endif { #ifdef TEST diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c b/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c index 2fe37f79c..0851daf97 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c @@ -296,7 +296,7 @@ InitRootWindow(WindowPtr pWin) #ifdef NXAGENT_ARTSD { char artsd_port[10]; - int nPort; + short int nPort; extern void nxagentPropagateArtsdProperties(ScreenPtr pScreen, char *port); nPort = atoi(display) + 7000; sprintf(artsd_port,"%d", nPort); diff --git a/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c b/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c index be154f9c2..653426ebb 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c @@ -700,7 +700,6 @@ static void nxagentPixmapMatchID(void *p0, XID x1, void *p2) PixmapPtr nxagentPixmapPtr(Pixmap pixmap) { - int i; struct nxagentPixmapPair pair; if (pixmap == None) @@ -714,7 +713,7 @@ PixmapPtr nxagentPixmapPtr(Pixmap pixmap) FindClientResourcesByType(clients[serverClient -> index], RT_NX_PIXMAP, nxagentPixmapMatchID, &pair); - for (i = 0; (pair.pMap == NULL) && (i < MAXCLIENTS); i++) + for (int i = 0; (pair.pMap == NULL) && (i < MAXCLIENTS); i++) { if (clients[i]) { @@ -790,8 +789,8 @@ void nxagentDisconnectPixmap(void *p0, XID x1, void *p2) Bool nxagentDisconnectAllPixmaps(void) { - int r = 1; int i; + int r = 1; #ifdef TEST fprintf(stderr, "nxagentDisconnectAllPixmaps: Going to iterate through pixmap resources.\n"); @@ -958,8 +957,6 @@ Bool nxagentReconnectAllPixmaps(void *p0) { Bool result = 1; - int i; - #ifdef TEST fprintf(stderr, "nxagentReconnectAllPixmaps: Going to recreate all pixmaps.\n"); #endif @@ -991,7 +988,7 @@ Bool nxagentReconnectAllPixmaps(void *p0) #endif - for (i = 0, result = 1; i < MAXCLIENTS; result = 1, i++) + for (int i = 0, result = 1; i < MAXCLIENTS; result = 1, i++) { if (clients[i] != NULL) { @@ -1138,10 +1135,9 @@ Bool nxagentCheckPixmapIntegrity(PixmapPtr pPixmap) if (!integrity) { - int i; char *p, *q; - for (i = 0, p = image -> data, q = data; i < length; i++) + for (int i = 0, p = image -> data, q = data; i < length; i++) { if (p[i] != q[i]) { @@ -1187,7 +1183,6 @@ Bool nxagentCheckPixmapIntegrity(PixmapPtr pPixmap) Bool nxagentCheckAllPixmapIntegrity(void) { - int i; Bool imageIsGood = True; #ifdef TEST @@ -1197,7 +1192,7 @@ Bool nxagentCheckAllPixmapIntegrity(void) FindClientResourcesByType(clients[serverClient -> index], RT_NX_PIXMAP, nxagentCheckOnePixmapIntegrity, &imageIsGood); - for (i = 0; (i < MAXCLIENTS) && (imageIsGood); i++) + for (int i = 0; (i < MAXCLIENTS) && (imageIsGood); i++) { if (clients[i]) { @@ -1355,7 +1350,7 @@ Bool nxagentPixmapOnShadowDisplay(PixmapPtr pMap) /* FIXME: If the pixmap has a different depth from the window, the - XPutImage returns a BadMatch. For example this may happens if + XPutImage returns a BadMatch. For example this may happen if the Render extension is enabled. Can we fix this creating a new pixmap? */ @@ -1372,7 +1367,7 @@ FIXME: If the pixmap has a different depth from the window, the /* * If the framebuffer is updated continuously, the nxagent - * visualization become too much slow. + * visualization becomes much too slow. */ if ((GetTimeInMillis() - showTime) < 500) @@ -1630,11 +1625,10 @@ void nxagentPrintResourcePredicate(void *value, XID id, XID type, void *cdata) void nxagentPrintResources(void) { Bool result; - int i; nxagentPrintResourceTypes(); - for (i = 0; i < MAXCLIENTS; i++) + for (int i = 0; i < MAXCLIENTS; i++) { if (clients[i]) { diff --git a/nx-X11/programs/Xserver/hw/nxagent/Pointer.c b/nx-X11/programs/Xserver/hw/nxagent/Pointer.c index c59230724..85d286b96 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Pointer.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Pointer.c @@ -40,7 +40,7 @@ is" without express or implied warranty. #include "X.h" #include "Xproto.h" #include "screenint.h" -#include "input.h" +#include "inputstr.h" #include "misc.h" #include "scrnintstr.h" #include "servermd.h" @@ -162,11 +162,18 @@ int nxagentPointerProc(DeviceIntPtr pDev, int onoff) break; case DEVICE_CLOSE: - #ifdef TEST fprintf(stderr, "nxagentPointerProc: Called for [DEVICE_CLOSE].\n"); #endif + for (int i = 0; i < pDev->nPrivates; i++) + { + free(pDev->devPrivates[i].ptr); + pDev->devPrivates[i].ptr = NULL; + } + free(pDev->devPrivates); + pDev->devPrivates = NULL; + break; } diff --git a/nx-X11/programs/Xserver/hw/nxagent/Rootless.c b/nx-X11/programs/Xserver/hw/nxagent/Rootless.c index 82ec14fe9..c2611c194 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Rootless.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Rootless.c @@ -120,12 +120,10 @@ static void nxagentPrintRootlessTopLevelWindowMap(void); void nxagentPrintRootlessTopLevelWindowMap(void) { - int i; - fprintf(stderr, "nxagentPrintRootlessTopLevelWindowMap: Map size is [%d] num of entry [%d].\n", topLevelParentMap.size, topLevelParentMap.next); - for (i = 0; i < topLevelParentMap.next; i++) + for (int i = 0; i < topLevelParentMap.next; i++) { fprintf(stderr, "nxagentPrintRootlessTopLevelWindowMap: [%d] pWin at [%p] XID at [%ld].\n", i, (void *) topLevelParentMap.elt[i].pWin, (long int) topLevelParentMap.elt[i].xid); @@ -136,9 +134,7 @@ void nxagentPrintRootlessTopLevelWindowMap(void) void nxagentRootlessAddTopLevelWindow(WindowPtr pWin, Window w) { - int i; - - for (i = 0; i < topLevelParentMap.next; i++) + for (int i = 0; i < topLevelParentMap.next; i++) { if (topLevelParentMap.elt[i].pWin == pWin) { @@ -181,9 +177,7 @@ void nxagentRootlessAddTopLevelWindow(WindowPtr pWin, Window w) WindowPtr nxagentRootlessTopLevelWindow(Window w) { - int i; - - for (i = 0; i < topLevelParentMap.next; i++) + for (int i = 0; i < topLevelParentMap.next; i++) { if (w == topLevelParentMap.elt[i].xid) { @@ -196,9 +190,7 @@ WindowPtr nxagentRootlessTopLevelWindow(Window w) void nxagentRootlessDelTopLevelWindow(WindowPtr pWin) { - int i; - - for (i = 0; i < topLevelParentMap.next; i++) + for (int i = 0; i < topLevelParentMap.next; i++) { if (pWin == topLevelParentMap.elt[i].pWin) { @@ -485,7 +477,7 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value) { #ifdef TEST fprintf(stderr, "nxagentExportProperty: WARNING! Ignored ChangeProperty " - "on %swindow %lx property %s type %s nUnits %ld format %d\n", + "on %swindow [0x%lx] property [%s] type [%s] nUnits [%ld] format [%d]\n", nxagentWindowTopLevel(pWin) ? "toplevel " : "", nxagentWindow(pWin), validateString(propertyS), validateString(typeS), nUnits, format); #endif @@ -506,7 +498,6 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value) /* FIXME: is it okay here to ignore malloc fails? */ unsigned long *buffer = malloc(nUnits * sizeof(*buffer)); int *input = value; - int i; if (buffer) { @@ -514,7 +505,7 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value) export = True; output = (char*) buffer; - for (i = 0; i < nUnits; i++) + for (int i = 0; i < nUnits; i++) { buffer[i] = input[i]; } @@ -565,8 +556,8 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value) propHints.flags &= ~IconPixmapHint; #ifdef WARNING - fprintf(stderr, "nxagentExportProperty: WARNING! Failed to look up icon pixmap %x from hint " - "exporting property %s type %s on window %p.\n", + fprintf(stderr, "nxagentExportProperty: WARNING! Failed to look up icon pixmap [0x%x] from hint " + "exporting property [%s] type [%s] on window [%p].\n", (unsigned int) wmHints.icon_pixmap, propertyS, typeS, (void *) pWin); #endif @@ -587,8 +578,8 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value) propHints.flags &= ~IconWindowHint; #ifdef WARNING - fprintf(stderr, "nxagentExportProperty: WARNING! Failed to look up icon window %x from hint " - "exporting property %s type %s on window %p.\n", + fprintf(stderr, "nxagentExportProperty: WARNING! Failed to look up icon window [0x%x] from hint " + "exporting property [%s] type [%s] on window [%p].\n", (unsigned int) wmHints.icon_window, propertyS, typeS, (void *) pWin); #endif @@ -609,8 +600,8 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value) propHints.flags &= ~IconMaskHint; #ifdef WARNING - fprintf(stderr, "nxagentExportProperty: WARNING! Failed to look up icon mask %x from hint " - "exporting property %s type %s on window %p.\n", + fprintf(stderr, "nxagentExportProperty: WARNING! Failed to look up icon mask [0x%x] from hint " + "exporting property [%s] type [%s] on window [%p].\n", (unsigned int) wmHints.icon_mask, propertyS, typeS, (void *) pWin); #endif @@ -631,8 +622,8 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value) propHints.flags &= ~WindowGroupHint; #ifdef WARNING - fprintf(stderr, "nxagentExportProperty: WARNING! Failed to look up window group %x from hint " - "exporting property %s type %s on window %p.\n", + fprintf(stderr, "nxagentExportProperty: WARNING! Failed to look up window group [0x%x] from hint " + "exporting property [%s] type [%s] on window [%p].\n", (unsigned int) wmHints.window_group, propertyS, typeS, (void *) pWin); #endif @@ -644,13 +635,12 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value) XlibAtom *atoms = malloc(nUnits * sizeof(*atoms)); Atom *input = value; const char *atomName = NULL; - int i; int j = 0; if (!atoms) { #ifdef WARNING - fprintf(stderr, "nxagentExportProperty: WARNING! malloc() failed for '%s'- bailing out.\n", typeS); + fprintf(stderr, "nxagentExportProperty: WARNING! malloc() failed for '[%s]'- bailing out.\n", typeS); #endif return False; } @@ -659,7 +649,7 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value) export = True; output = (char *) atoms; - for (i = 0; i < nUnits; i++) + for (int i = 0; i < nUnits; i++) { /* * Exporting the _NET_WM_PING property could @@ -679,7 +669,7 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value) if (atoms[j] == None) { #ifdef WARNING - fprintf(stderr, "nxagentExportProperty: WARNING! Failed to convert local atom %ld [%s].\n", + fprintf(stderr, "nxagentExportProperty: WARNING! Failed to convert local atom [%ld] [%s].\n", (long int) input[i], validateString(atomName)); #endif } @@ -703,12 +693,11 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value) XlibWindow *wind = malloc(nUnits * sizeof(*wind)); ClientPtr pClient = wClient(pWin); WindowPtr pWindow; - int i; if (!wind) { #ifdef WARNING - fprintf(stderr, "nxagentExportProperty: WARNING! malloc() failed for '%s' - bailing out.\n", typeS); + fprintf(stderr, "nxagentExportProperty: WARNING! malloc() failed for '[%s]' - bailing out.\n", typeS); #endif return False; } @@ -717,7 +706,7 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value) export = True; output = (char*) wind; - for (i = 0; i < nUnits; i++) + for (int i = 0; i < nUnits; i++) { pWindow = (WindowPtr)SecurityLookupWindow(input[i], pClient, DixDestroyAccess); @@ -728,8 +717,8 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value) else { #ifdef WARNING - fprintf(stderr, "nxagentExportProperty: WARNING! Failed to look up window %ld " - "exporting property %s type %s on window %p.\n", + fprintf(stderr, "nxagentExportProperty: WARNING! Failed to look up window [%ld] " + "exporting property [%s] type [%s] on window [%p].\n", (long int) input[i], propertyS, typeS, (void *) pWin); #endif @@ -774,15 +763,14 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value) } else if (mode == PropModeReplace) { - int n; - char *data; + char * data = (char *) output; XDeleteProperty(nxagentDisplay, nxagentWindow(pWin), propertyX); - data = (char *) output; - while (nUnits > 0) { + int n; + if ((format >> 3) * nUnits + sizeof(xChangePropertyReq) < (MAX_REQUEST_SIZE << 2)) { @@ -819,7 +807,7 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value) { #ifdef TEST fprintf(stderr, "nxagentExportProperty: WARNING! Ignored ChangeProperty " - "on %swindow %x property %s type %s nUnits %ld format %d\n", + "on %swindow [0x%x] property [%s] type [%s] nUnits [%ld] format [%d]\n", nxagentWindowTopLevel(pWin) ? "toplevel " : "", nxagentWindow(pWin), validateString(propertyS), validateString(typeS), nUnits, format); @@ -866,7 +854,7 @@ void nxagentImportProperty(Window window, if (pWin == NULL) { #ifdef TEST - fprintf(stderr, "nxagentImportProperty: Failed to look up remote window %lx property [%ld] exiting.\n", + fprintf(stderr, "nxagentImportProperty: Failed to look up remote window [0x%lx] property [%ld] exiting.\n", window, property); #endif @@ -885,7 +873,7 @@ void nxagentImportProperty(Window window, } #ifdef TEST - fprintf(stderr, "nxagentImportProperty: Window %lx property [%ld]: %s\n", + fprintf(stderr, "nxagentImportProperty: Window [0x%lx] property [%ld]: [%s]\n", window, property, validateString(NameForAtom(propertyL))); #endif @@ -900,7 +888,7 @@ void nxagentImportProperty(Window window, if (buffer == NULL && (nitems > 0)) { #ifdef WARNING - fprintf(stderr, "nxagentImportProperty: Failed to retrieve remote property [%ld] %s on Window %ld\n", + fprintf(stderr, "nxagentImportProperty: Failed to retrieve remote property [%ld] [%s] on Window [%ld]\n", (long int) property, validateString(NameForAtom(propertyL)), (long int) window); #endif } @@ -956,8 +944,8 @@ void nxagentImportProperty(Window window, else if (wmState.icon) { #ifdef WARNING - fprintf(stderr, "nxagentImportProperty: WARNING! Failed to convert remote window %ld" - " importing property %ld of type WM_STATE", (long int) wmState.icon, + fprintf(stderr, "nxagentImportProperty: WARNING! Failed to convert remote window [%ld]" + " importing property [%ld] of type WM_STATE", (long int) wmState.icon, (long int) property); #endif } @@ -982,7 +970,7 @@ void nxagentImportProperty(Window window, #ifdef WARNING fprintf(stderr, "nxagentImportProperty: WARNING! Failed to look up remote icon " - "pixmap %d from hint importing property [%ld] type %s on window %p.\n", + "pixmap [%d] from hint importing property [%ld] type [%s] on window [%p].\n", (unsigned int) wmHints.icon_pixmap, (long int) property, typeS, (void *) pWin); #endif @@ -1003,7 +991,7 @@ void nxagentImportProperty(Window window, #ifdef WARNING fprintf(stderr, "nxagentImportProperty: WARNING! Failed to look up remote icon " - "window %x from hint importing property [%ld] type %s on window %p.\n", + "window [0x%x] from hint importing property [%ld] type [%s] on window [%p].\n", (unsigned int) wmHints.icon_window, (long int) property, typeS, (void *) pWin); #endif @@ -1024,7 +1012,7 @@ void nxagentImportProperty(Window window, #ifdef WARNING fprintf(stderr, "nxagentImportProperty: WARNING! Failed to look up remote icon " - "mask %x from hint importing property [%ld] type %s on window %p.\n", + "mask [0x%x] from hint importing property [%ld] type [%s] on window [%p].\n", (unsigned int) wmHints.icon_mask, (long int) property, typeS, (void *) pWin); #endif } @@ -1044,7 +1032,7 @@ void nxagentImportProperty(Window window, #ifdef WARNING fprintf(stderr, "nxagentImportProperty: WARNING! Failed to look up remote window " - "group %x from hint importing property [%ld] type %s on window %p.\n", + "group [0x%x] from hint importing property [%ld] type [%s] on window [%p].\n", (unsigned int) wmHints.window_group, (long int) property, typeS, (void *) pWin); #endif @@ -1055,12 +1043,11 @@ void nxagentImportProperty(Window window, { Atom *atoms = malloc(nitems * sizeof(Atom)); Atom *input = (Atom*) buffer; - int i; if (atoms == NULL) { #ifdef WARNING - fprintf(stderr, "nxagentImportProperty: WARNING! malloc() failed for '%s' - bailing out.\n", typeS); + fprintf(stderr, "nxagentImportProperty: WARNING! malloc() failed for '[%s]' - bailing out.\n", typeS); #endif return; @@ -1070,14 +1057,14 @@ void nxagentImportProperty(Window window, import = True; output = (char *) atoms; - for (i = 0; i < nitems; i++) + for (int i = 0; i < nitems; i++) { atoms[i] = nxagentRemoteToLocalAtom(input[i]); if (atoms[i] == None) { #ifdef WARNING - fprintf(stderr, "nxagentImportProperty: WARNING! Failed to convert remote atom %ld.\n", + fprintf(stderr, "nxagentImportProperty: WARNING! Failed to convert remote atom [%ld].\n", (long int) input[i]); #endif } @@ -1088,12 +1075,11 @@ void nxagentImportProperty(Window window, Window *input = (Window*) buffer; Window *wind = malloc(nitems * sizeof(Window)); WindowPtr pWindow; - int i; if (!wind) { #ifdef WARNING - fprintf(stderr, "nxagentImportProperty: WARNING! malloc() failed for '%s' - bailing out.\n", typeS); + fprintf(stderr, "nxagentImportProperty: WARNING! malloc() failed for '[%s]' - bailing out.\n", typeS); #endif return; @@ -1102,7 +1088,7 @@ void nxagentImportProperty(Window window, import = True; output = (char*) wind; - for (i = 0; i < nitems; i++) + for (int i = 0; i < nitems; i++) { pWindow = nxagentWindowPtr(input[i]); @@ -1113,8 +1099,8 @@ void nxagentImportProperty(Window window, else { #ifdef WARNING - fprintf(stderr, "nxagentImportProperty: WARNING! Failed to look up remote window %lx " - "importing property [%ld] type %s on window %p.\n", + fprintf(stderr, "nxagentImportProperty: WARNING! Failed to look up remote window [0x%lx] " + "importing property [%ld] type [%s] on window [%p].\n", (long int) input[i], (long int) property, typeS, (void*)pWin); #endif @@ -1127,7 +1113,7 @@ void nxagentImportProperty(Window window, { #ifdef TEST fprintf(stderr, "nxagentImportProperty: ChangeProperty " - "on window %lx property [%ld] type %s nitems %ld format %d\n", + "on window [0x%lx] property [%ld] type [%s] nitems [%ld] format [%d]\n", window, property, typeS, nitems, format); #endif @@ -1138,7 +1124,7 @@ void nxagentImportProperty(Window window, { #ifdef TEST fprintf(stderr, "nxagentImportProperty: WARNING! Ignored ChangeProperty " - "on window %lx property [%ld] type %s ntems %ld format %d\n", + "on window [0x%lx] property [%ld] type [%s] ntems [%ld] format [%d]\n", window, property, validateString(typeS), nitems, format); #endif } @@ -1183,7 +1169,7 @@ void nxagentRemovePropertyFromList(void) struct nxagentPropertyRec *tmp = nxagentPropertyList.first; #ifdef TEST - fprintf(stderr, "nxagentRemovePropertyFromList: Property %ld on Window %lx to list, list size is %d.\n\n", + fprintf(stderr, "nxagentRemovePropertyFromList: Property [%ld] on Window [0x%lx] to list, list size is [%d].\n\n", nxagentPropertyList.first -> property, nxagentPropertyList.first -> window, nxagentPropertyList.size); #endif @@ -1220,8 +1206,8 @@ void nxagentAddPropertyToList(Atom property, WindowPtr pWin) } #ifdef TEST - fprintf(stderr, "nxagentAddPropertyToList: Adding record Property %ld - Window %lx[%p]" - "to list, list size is %d.\n", property, nxagentWindow(pWin), (void*) pWin, + fprintf(stderr, "nxagentAddPropertyToList: Adding record Property [%ld] - Window [0x%lx][%p]" + "to list, list size is [%d].\n", property, nxagentWindow(pWin), (void*) pWin, nxagentPropertyList.size); #endif @@ -1262,12 +1248,12 @@ Bool nxagentNotifyMatchChangeProperty(void *p) XPropertyEvent *X = p; #ifdef TEST - fprintf(stderr, "nxagentNotifyMatchChangeProperty: Property notify on window %lx property %ld.\n", + fprintf(stderr, "nxagentNotifyMatchChangeProperty: Property notify on window [0x%lx] property [%ld].\n", X -> window, X -> atom); if (first) { - fprintf(stderr, "nxagentNotifyMatchChangeProperty: First element on list is window %lx property %ld list size is %d.\n", + fprintf(stderr, "nxagentNotifyMatchChangeProperty: First element on list is window [0x%lx] property [%ld] list size is [%d].\n", first -> window, first -> property, nxagentPropertyList.size); } else diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index 8568562c2..6ec4b245f 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -844,6 +844,19 @@ static int nxagentColorOffset(unsigned long mask) return count; } +void freeDepths(DepthPtr depths, int num) +{ + for (int i = 0; i < num; i++) + { + #ifdef DEBUG + fprintf(stderr, "%s: freeing depth [%d] index [%d] vids [%p]\n", __func__, depths[i].depth, i, (void*) depths[i].vids); + #endif + free(depths[i].vids); + depths[i].vids = NULL; + } + free(depths); +} + Bool nxagentOpenScreen(ScreenPtr pScreen, int argc, char *argv[]) { @@ -1335,6 +1348,8 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, if (!pFrameBufferBits) { + freeDepths(depths, numDepths); + free(visuals); return FALSE; } @@ -1356,6 +1371,8 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, if (!fbScreenInit(pScreen, pFrameBufferBits, nxagentOption(RootWidth), nxagentOption(RootHeight), monitorResolution, monitorResolution, PixmapBytePad(nxagentOption(RootWidth), rootDepth), bitsPerPixel)) { + freeDepths(depths, numDepths); + free(visuals); return FALSE; } @@ -1391,22 +1408,15 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, * by fbScreenInit with our own. */ - free(pScreen -> visuals); - free(pScreen -> allowedDepths); - - pScreen -> visuals = visuals; + freeDepths(pScreen->allowedDepths, pScreen->numDepths); pScreen -> allowedDepths = depths; - pScreen -> numVisuals = numVisuals; pScreen -> numDepths = numDepths; - pScreen -> rootVisual = defaultVisual; pScreen -> rootDepth = rootDepth; - /* - * Complete the initialization of the RANDR - * extension. - */ - - nxagentInitRandRExtension(pScreen); + free(pScreen -> visuals); + pScreen -> visuals = visuals; + pScreen -> numVisuals = numVisuals; + pScreen -> rootVisual = defaultVisual; /* * Set up the internal structures used for @@ -1694,6 +1704,13 @@ N/A nxagentOption(Height)) / 32) } + /* + * Complete the initialization of the RANDR + * extension. + */ + + nxagentInitRandRExtension(pScreen); + #ifdef TEST nxagentPrintAgentGeometry(NULL, "nxagentOpenScreen:"); #endif @@ -2135,26 +2152,31 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio Bool nxagentCloseScreen(ScreenPtr pScreen) { - int i; - #ifdef DEBUG fprintf(stderr, "running nxagentCloseScreen()\n"); #endif - for (i = 0; i < pScreen->numDepths; i++) - { - free(pScreen->allowedDepths[i].vids); - } + /* + * We have called fbScreenInit() in nxagenOpenScreen, which in turn + * called fbOpenScreen. But we are not using the data as created by + * fbOpenScreen but have freed it and replaced by our own. So we free + * our own stuff here and take care that fbCloseScreen will not free + * them again. + */ + + freeDepths(pScreen->allowedDepths, pScreen->numDepths); + pScreen->allowedDepths = NULL; + pScreen->numDepths = 0; /* * Free the frame buffer. */ free(((PixmapPtr)pScreen -> devPrivate) -> devPrivate.ptr); + free(pScreen->devPrivate);pScreen->devPrivate = NULL; + free(pScreen->visuals); pScreen->visuals = NULL; - free(pScreen->allowedDepths); - free(pScreen->visuals); - free(pScreen->devPrivate); + fbCloseScreen(pScreen); /* * Reset the geometry and alpha information diff --git a/nx-X11/programs/Xserver/hw/nxagent/Window.c b/nx-X11/programs/Xserver/hw/nxagent/Window.c index 8307c3de4..78a5081f0 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Window.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Window.c @@ -727,7 +727,7 @@ Bool nxagentPositionWindow(WindowPtr pWin, int x, int y) (void *) pWin, nxagentWindow(pWin), x, y); #endif - nxagentAddConfiguredWindow(pWin, CWParent | CWX | CWY | CWWidth | + nxagentAddConfiguredWindow(pWin, CWSibling | CWX | CWY | CWWidth | CWHeight | CWBorderWidth); return True; @@ -1284,7 +1284,7 @@ void nxagentConfigureWindow(WindowPtr pWin, unsigned int mask) { if (mask & CW_RootlessRestack) { - mask = CWStackingOrder; + mask = CWStackMode; } } @@ -1299,7 +1299,7 @@ void nxagentConfigureWindow(WindowPtr pWin, unsigned int mask) if (mask & CW_Update) { - mask |= CWX | CWY | CWWidth | CWHeight | CWBorderWidth | CWStackingOrder; + mask |= CWX | CWY | CWWidth | CWHeight | CWBorderWidth | CWStackMode; } if (mask & CWX) @@ -1378,7 +1378,7 @@ void nxagentConfigureWindow(WindowPtr pWin, unsigned int mask) MAKE_SYNC_CONFIGURE_WINDOW; } - if (mask & CWStackingOrder && + if (mask & CWStackMode && nxagentWindowPriv(pWin)->siblingAbove != nxagentWindowSiblingAbove(pWin)) { WindowPtr pSib; @@ -1478,7 +1478,7 @@ void nxagentConfigureWindow(WindowPtr pWin, unsigned int mask) * really needed? * * - * else if (mask & CWStackingOrder) + * else if (mask & CWStackMode) * { * if (nxagentSplashWindow) * { @@ -1920,12 +1920,12 @@ Bool nxagentRealizeWindow(WindowPtr pWin) /* * Not needed. * - * nxagentConfigureWindow(pWin, CWStackingOrder); + * nxagentConfigureWindow(pWin, CWStackMode); * * nxagentFlushConfigureWindow(); */ - nxagentAddConfiguredWindow(pWin, CWStackingOrder); + nxagentAddConfiguredWindow(pWin, CWStackMode); nxagentAddConfiguredWindow(pWin, CW_Shape); /* add by dimbor */ @@ -1942,20 +1942,6 @@ Bool nxagentRealizeWindow(WindowPtr pWin) #endif */ - /* - * Mapping of the root window is called by - * InitRootWindow in DIX. Skip the operation - * if we are in rootless mode. - */ - - /* - * if (!nxagentOption(Rootless) || - * nxagentRootlessWindow != pWin) - * { - * XMapWindow(nxagentDisplay, nxagentWindow(pWin)); - * } - */ - #ifdef TEST if (nxagentOption(Rootless) && nxagentLastWindowDestroyed) { @@ -2130,10 +2116,10 @@ void nxagentCopyWindow(WindowPtr pWin, xPoint oldOrigin, RegionPtr oldRegion) void nxagentClipNotify(WindowPtr pWin, int dx, int dy) { /* - * nxagentConfigureWindow(pWin, CWStackingOrder); + * nxagentConfigureWindow(pWin, CWStackMode); */ - nxagentAddConfiguredWindow(pWin, CWStackingOrder); + nxagentAddConfiguredWindow(pWin, CWStackMode); nxagentAddConfiguredWindow(pWin, CW_Shape); #ifndef NXAGENT_SHAPE @@ -3484,6 +3470,12 @@ void nxagentSetTopLevelEventMask(WindowPtr pWin) } /* + * Run nxagentConfigureWindow() on all windows in + * nxagentConfiguredWindowList and move them from the list + * afterwards. The list will be empty then. + * + * This is also taking care of entries in nxagentExposeQueue that need + * to be synchronized with the real X server. */ void nxagentFlushConfigureWindow(void) { @@ -3586,10 +3578,10 @@ void nxagentAddConfiguredWindow(WindowPtr pWin, unsigned int valuemask) { unsigned int mask; - mask = valuemask & (CWParent | CWX | CWY | CWWidth | CWHeight | - CWBorderWidth | CWStackingOrder | CW_Map | CW_Update | CW_Shape); + mask = valuemask & (CWSibling | CWX | CWY | CWWidth | CWHeight | + CWBorderWidth | CWStackMode | CW_Map | CW_Update | CW_Shape); - valuemask &= ~(CWParent | CWX | CWY | CWWidth | CWHeight | CWBorderWidth | CWStackingOrder); + valuemask &= ~(CWSibling | CWX | CWY | CWWidth | CWHeight | CWBorderWidth | CWStackMode); if (mask & CWX && nxagentWindowPriv(pWin)->x != @@ -3626,11 +3618,11 @@ void nxagentAddConfiguredWindow(WindowPtr pWin, unsigned int valuemask) valuemask |= CWBorderWidth; } - if (mask & CWStackingOrder && + if (mask & CWStackMode && nxagentWindowPriv(pWin)->siblingAbove != nxagentWindowSiblingAbove(pWin)) { - valuemask |= CWStackingOrder; + valuemask |= CWStackMode; } { @@ -3952,16 +3944,16 @@ int nxagentEmptyBSPixmapList(void) StoringPixmapPtr nxagentFindItemBSPixmapList(unsigned long pixmapId) { - int i; - - for (i = 0; i < BSPIXMAPLIMIT; i++) + for (int i = 0; i < BSPIXMAPLIMIT; i++) { if ((nxagentBSPixmapList[i] != NULL) && (nxagentBSPixmapList[i] -> storingPixmapId == pixmapId)) { #ifdef TEST - fprintf(stderr, "nxagentFindItemBSPixmapList: pixmapId [%lu].\n", pixmapId); - fprintf(stderr, "nxagentFindItemBSPixmapList: nxagentBSPixmapList[%d] -> storingPixmapId [%lu].\n", + fprintf(stderr, "%s: pixmapId [%lu].\n", __func__, pixmapId); + fprintf(stderr, "%s: nxagentBSPixmapList[%d] = [%p].\n", __func__, + i, (void *) nxagentBSPixmapList[i]); + fprintf(stderr, "%s: nxagentBSPixmapList[%d] -> storingPixmapId [%lu].\n", __func__, i, nxagentBSPixmapList[i] -> storingPixmapId); #endif @@ -3969,15 +3961,13 @@ StoringPixmapPtr nxagentFindItemBSPixmapList(unsigned long pixmapId) } } - #ifdef TEST - fprintf(stderr, "nxagentFindItemBSPixmapList: WARNING! Item not found.\n"); + #ifdef WARNING + fprintf(stderr, "%s: WARNING! Item not found.\n", __func__); #endif #ifdef TEST - fprintf(stderr, "nxagentFindItemBSPixmapList: Pixmap with id [%lu] not found.\n", + fprintf(stderr, "%s: Pixmap with id [%lu] not found.\n", __func__, pixmapId); - fprintf(stderr, "nxagentBSPixmapList[%d] = [%p].\n", - i, (void *) nxagentBSPixmapList[i]); #endif return NULL; diff --git a/nx-X11/programs/Xserver/hw/nxagent/Windows.h b/nx-X11/programs/Xserver/hw/nxagent/Windows.h index 8612cdf82..35d686a33 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Windows.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Windows.h @@ -159,9 +159,6 @@ extern int nxagentWindowPrivateIndex; #define nxagentDefaultWindowIsVisible() \ (nxagentVisibility != VisibilityFullyObscured) -#define CWParent CWSibling -#define CWStackingOrder CWStackMode - #define CW_Map (1 << 15) #define CW_Update (1 << 16) #define CW_Shape (1 << 17) diff --git a/nx-X11/programs/Xserver/hw/nxagent/compext/Png.c b/nx-X11/programs/Xserver/hw/nxagent/compext/Png.c index 0a258c5a3..5c3a27612 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/compext/Png.c +++ b/nx-X11/programs/Xserver/hw/nxagent/compext/Png.c @@ -253,17 +253,6 @@ char *PngCompressData(XImage *image, int *compressed_size) NXColorTable color_table[NB_COLOR_MAX]; CARD8 *image_index; - image_index = (CARD8 *) malloc((image -> height) * (image -> width) * sizeof(CARD8)); - - /* - * TODO: Be sure the padded bytes are cleaned. - * It would be better to set to zero the bytes - * that are not aligned to the word boundary - * at the end of the procedure. - */ - - memset(image_index, 0, (image -> height) * (image -> width) * sizeof(CARD8)); - *compressed_size = 0; pngDataLen = 0; @@ -283,7 +272,6 @@ char *PngCompressData(XImage *image, int *compressed_size) bitsPerPixel); #endif - free(image_index); return NULL; } @@ -316,7 +304,6 @@ char *PngCompressData(XImage *image, int *compressed_size) fprintf(stderr, "******PngCompressData: PANIC! Failed creating the png_create_write_struct.\n"); #endif - free(image_index); return NULL; } @@ -329,7 +316,6 @@ char *PngCompressData(XImage *image, int *compressed_size) #endif png_destroy_write_struct(&png_ptr, NULL); - free(image_index); return NULL; } @@ -341,7 +327,6 @@ char *PngCompressData(XImage *image, int *compressed_size) #endif png_destroy_write_struct(&png_ptr, &info_ptr); - free(image_index); return NULL; } @@ -364,8 +349,6 @@ char *PngCompressData(XImage *image, int *compressed_size) PNG_DEST_SIZE(w, h)); #endif - free(image_index); - return NULL; } @@ -383,6 +366,24 @@ char *PngCompressData(XImage *image, int *compressed_size) return NULL; } + image_index = (CARD8 *) calloc(1, (image -> height) * (image -> width) * sizeof(CARD8)); + if (image_index == NULL) + { + #ifdef PANIC + fprintf(stderr, "******PngCompressData: PANIC! Could not alloc image_index.\n"); + #endif + + free(pngCompBuf); + return NULL; + } + + /* + * TODO: Be sure the padded bytes are cleaned. + * It would be better to set to zero the bytes + * that are not aligned to the word boundary + * at the end of the procedure. + */ + png_set_compression_level(png_ptr, PNG_Z_LEVEL); if (bitsPerPixel == 16) @@ -480,47 +481,23 @@ char *PngCompressData(XImage *image, int *compressed_size) return NULL; } + int count; if (color_type == PNG_COLOR_TYPE_PALETTE) { - srcBuf = (CARD8 *) malloc(w * sizeof(CARD8)); - - if (srcBuf == NULL) - { - #ifdef PANIC - fprintf(stderr, "******PngCompressData: PANIC! Cannot allocate [%d] bytes.\n", - (int) (w * sizeof(CARD8))); - #endif - - free(image_index); - - return NULL; - } - - /* - * TODO: Be sure the padded bytes are cleaned. - * It would be better to set to zero the bytes - * that are not aligned to the word boundary - * at the end of the procedure. - */ - - memset(srcBuf, 0, w * sizeof(CARD8)); + count = w; } else { - srcBuf = (CARD8 *) malloc(w * 3 * sizeof(CARD8)); - - /* - * TODO: See above. - */ - - memset(srcBuf, 0, w * 3 * sizeof(CARD8)); + count = 3 * w; } + srcBuf = (CARD8 *) calloc(count, sizeof(CARD8)); + if (srcBuf == NULL) { #ifdef PANIC fprintf(stderr, "******PngCompressData: PANIC! Cannot allocate [%d] bytes.\n", - w * 3); + (int) (count * sizeof(CARD8))); #endif free(pngCompBuf); @@ -529,6 +506,13 @@ char *PngCompressData(XImage *image, int *compressed_size) return NULL; } + /* + * TODO: Be sure the padded bytes are cleaned. + * It would be better to set to zero the bytes + * that are not aligned to the word boundary + * at the end of the procedure. + */ + for (dy = 0; dy < h; dy++) { if (color_type == PNG_COLOR_TYPE_RGB) @@ -548,8 +532,8 @@ char *PngCompressData(XImage *image, int *compressed_size) dy, h); #endif - free(srcBuf); - free(image_index); + free(srcBuf); srcBuf = NULL; + free(image_index); image_index = NULL; if (setjmp(png_jmpbuf(png_ptr))) { |