diff options
Diffstat (limited to 'nx-X11/programs/Xserver/hw/nxagent/compext/Compext.c')
-rw-r--r-- | nx-X11/programs/Xserver/hw/nxagent/compext/Compext.c | 452 |
1 files changed, 267 insertions, 185 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/compext/Compext.c b/nx-X11/programs/Xserver/hw/nxagent/compext/Compext.c index 7a6cb9e30..dcb91348b 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/compext/Compext.c +++ b/nx-X11/programs/Xserver/hw/nxagent/compext/Compext.c @@ -74,7 +74,23 @@ #define PANIC #define WARNING #undef TEST +#undef TEST_DISPLAY +#undef TEST_IMAGE +#undef TEST_INPUT +#undef TEST_PARAMS +#undef TEST_POINTER +#undef TEST_PROPERTY +#undef TEST_SPLIT +#undef TEST_UNPACK #undef DEBUG +#undef DEBUG_DISPLAY +#undef DEBUG_IMAGE +#undef DEBUG_INPUT +#undef DEBUG_PARAMS +#undef DEBUG_POINTER +#undef DEBUG_PROPERTY +#undef DEBUG_SPLIT +#undef DEBUG_UNPACK #undef DUMP /* @@ -271,7 +287,7 @@ extern int _NXInternalResetEncoders(Display *dpy); int NXInitDisplay(Display *dpy) { - #ifdef TEST + #ifdef TEST_DISPLAY fprintf(stderr, "******NXInitDisplay: Called for display at [%p].\n", (void *) dpy); #endif @@ -286,7 +302,7 @@ int NXInitDisplay(Display *dpy) return 1; } - #ifdef TEST + #ifdef TEST_DISPLAY fprintf(stderr, "******NXInitDisplay: WARNING! Internal structures already initialized.\n"); #endif @@ -295,7 +311,7 @@ int NXInitDisplay(Display *dpy) int NXResetDisplay(Display *dpy) { - #ifdef TEST + #ifdef TEST_DISPLAY fprintf(stderr, "******NXResetDisplay: Called for display at [%p].\n", (void *) dpy); #endif @@ -310,7 +326,7 @@ int NXResetDisplay(Display *dpy) return 1; } - #ifdef TEST + #ifdef TEST_DISPLAY fprintf(stderr, "******NXResetDisplay: WARNING! Internal structures already reset.\n"); #endif @@ -324,20 +340,18 @@ int _NXInternalInitResources(Display *dpy) int _NXInternalResetResources(Display *dpy) { - int i; - - #ifdef TEST + #if defined(TEST_IMAGE) || defined(TEST_PROPERTY) || defined(TEST_POINTER) || defined(TEST_INPUT) fprintf(stderr, "******_NXInternalResetResources: Clearing all the internal structures.\n"); #endif - for (i = 0; i < NXNumberOfResources; i++) + for (int i = 0; i < NXNumberOfResources; i++) { _NXSplitResources[i] = 0; _NXUnpackResources[i] = 0; if (_NXCollectedImages[i] != NULL) { - #ifdef TEST + #ifdef TEST_IMAGE fprintf(stderr, "******_NXInternalResetResources: WARNING! Clearing collect image data " "for resource [%d].\n", i); #endif @@ -359,7 +373,7 @@ int _NXInternalResetResources(Display *dpy) if (_NXCollectedProperties[i] != NULL) { - #ifdef TEST + #ifdef TEST_PROPERTY fprintf(stderr, "******_NXInternalResetResources: WARNING! Clearing collect property data " "for resource [%d].\n", i); #endif @@ -378,7 +392,7 @@ int _NXInternalResetResources(Display *dpy) if (_NXCollectedGrabPointers[i] != NULL) { - #ifdef TEST + #ifdef TEST_POINTER fprintf(stderr, "******_NXInternalResetResources: WARNING! Clearing grab pointer data " "for resource [%d].\n", i); #endif @@ -395,7 +409,7 @@ int _NXInternalResetResources(Display *dpy) if (_NXCollectedInputFocuses[i] != NULL) { - #ifdef TEST + #ifdef TEST_INPUT fprintf(stderr, "******_NXInternalResetResources: WARNING! Clearing collect input focus data " "for resource [%d].\n", i); #endif @@ -440,6 +454,11 @@ int NXSetDisplayPolicy(Display *dpy, int policy) } } +/* + * return codes: + * -1 something went wrong + * 1 success + */ int NXSetDisplayBuffer(Display *dpy, int size) { /* @@ -454,7 +473,7 @@ int NXSetDisplayBuffer(Display *dpy, int size) if (dpy -> bufmax - size == dpy -> buffer) { - #ifdef TEST + #ifdef TEST_DISPLAY fprintf(stderr, "******NXSetDisplayBuffer: Nothing to do with buffer size matching.\n"); #endif @@ -484,7 +503,7 @@ int NXSetDisplayBuffer(Display *dpy, int size) dpy -> bufptr = dpy -> buffer; dpy -> bufmax = dpy -> bufptr + size; - #ifdef TEST + #ifdef TEST_DISPLAY fprintf(stderr, "******NXSetDisplayBuffer: Set the display output buffer size to [%d].\n", size); #endif @@ -527,7 +546,7 @@ int NXHandleDisplayError(int value) _NXHandleDisplayError = value; - #ifdef TEST + #ifdef TEST_DISPLAY fprintf(stderr, "******NXHandleDisplayError: Set the flag to [%d] with previous value [%d].\n", value, previous); #endif @@ -596,7 +615,7 @@ int NXDisplayReadable(Display *dpy) if (result == 0) { - #ifdef DEBUG + #ifdef DEBUG_DISPLAY fprintf(stderr, "******NXDisplayReadable: Returning [%d] bytes readable from fd [%d].\n", readable, dpy -> fd); #endif @@ -604,7 +623,7 @@ int NXDisplayReadable(Display *dpy) return readable; } - #ifdef DEBUG + #ifdef DEBUG_DISPLAY fprintf(stderr, "******NXDisplayReadable: WARNING! Error detected on display fd [%d].\n", dpy -> fd); #endif @@ -614,7 +633,7 @@ int NXDisplayReadable(Display *dpy) int NXDisplayFlushable(Display *dpy) { - #ifdef DEBUG + #ifdef DEBUG_DISPLAY int flushable; @@ -637,7 +656,7 @@ int NXDisplayFlushable(Display *dpy) int NXDisplayCongestion(Display *dpy) { - #ifdef DEBUG + #ifdef DEBUG_DISPLAY int congestion = NXTransCongestion(dpy -> fd); @@ -658,7 +677,7 @@ int NXFlushDisplay(Display *dpy, int what) if (!(dpy -> flags & XlibDisplayWriting) && dpy -> bufptr - dpy -> buffer > 0) { - #ifdef DEBUG + #ifdef DEBUG_DISPLAY fprintf(stderr, "******NXFlushDisplay: Writing with [%d] bytes in the buffer.\n", (int) (dpy -> bufptr - dpy -> buffer)); #endif @@ -671,7 +690,7 @@ int NXFlushDisplay(Display *dpy, int what) return 0; } - #ifdef DEBUG + #ifdef DEBUG_DISPLAY fprintf(stderr, "******NXFlushDisplay: Flushing with [%d] bytes in the NX transport.\n", NXDisplayFlushable(dpy)); #endif @@ -685,7 +704,7 @@ NXDisplayErrorPredicate NXSetDisplayErrorPredicate(NXDisplayErrorPredicate predi _NXDisplayErrorFunction = predicate; - #ifdef TEST + #ifdef TEST_DISPLAY fprintf(stderr, "******NXSetDisplayErrorPredicate: Set the predicate to [%p] with previous value [%p].\n", predicate, previous); #endif @@ -699,7 +718,7 @@ NXDisplayBlockHandler NXSetDisplayBlockHandler(NXDisplayBlockHandler handler) _NXDisplayBlockFunction = handler; - #ifdef TEST + #ifdef TEST_DISPLAY fprintf(stderr, "******NXSetDisplayBlockHandler: Set the handler to [%p] with previous value [%p].\n", handler, previous); #endif @@ -713,7 +732,7 @@ NXDisplayWriteHandler NXSetDisplayWriteHandler(NXDisplayWriteHandler handler) _NXDisplayWriteFunction = handler; - #ifdef TEST + #ifdef TEST_DISPLAY fprintf(stderr, "******NXSetDisplayWriteHandler: Set the handler to [%p] with previous value [%p].\n", handler, previous); #endif @@ -730,7 +749,7 @@ NXDisplayFlushHandler NXSetDisplayFlushHandler(NXDisplayFlushHandler handler, Di NXTransHandler(NX_FD_ANY, NX_HANDLER_FLUSH, (void (*)(void *, int)) handler, (void *) display); - #ifdef TEST + #ifdef TEST_DISPLAY fprintf(stderr, "******NXSetDisplayFlushHandler: Set the handler to [%p] with display [%p] " "and previous value [%p].\n", handler, display, previous); #endif @@ -751,7 +770,7 @@ NXDisplayStatisticsHandler NXSetDisplayStatisticsHandler(NXDisplayStatisticsHand NXTransHandler(NX_FD_ANY, NX_HANDLER_STATISTICS, (void (*)(void *, int)) handler, (void *) buffer); - #ifdef TEST + #ifdef TEST_DISPLAY fprintf(stderr, "******NXSetDisplayStatisticsHandler: Set the handler to [%p] with buffer pointer [%p] " "and previous value [%p].\n", handler, buffer, previous); #endif @@ -803,6 +822,11 @@ void _NXInternalLostSequenceFunction(Display *dpy, unsigned long newseq, #endif } +/* + * return codes: + * 0 error receiving reply + * 1 success + */ Status NXGetControlParameters(Display *dpy, unsigned int *link_type, unsigned int *local_major, unsigned int *local_minor, unsigned int *local_patch, unsigned int *remote_major, unsigned int *remote_minor, @@ -820,14 +844,14 @@ Status NXGetControlParameters(Display *dpy, unsigned int *link_type, unsigned in GetEmptyReq(NXGetControlParameters, req); - #ifdef TEST + #ifdef TEST_PARAMS fprintf(stderr, "******NXGetControlParameters: Sending message opcode [%d].\n", X_NXGetControlParameters); #endif if (_XReply(dpy, (xReply *) &rep, 0, xTrue) == xFalse) { - #ifdef TEST + #ifdef TEST_PARAMS fprintf(stderr, "******NXGetControlParameters: Error receiving reply.\n"); #endif @@ -838,7 +862,7 @@ Status NXGetControlParameters(Display *dpy, unsigned int *link_type, unsigned in return 0; } - #ifdef TEST + #ifdef TEST_PARAMS fprintf(stderr, "******NXGetControlParameters: Got reply with link type [%u].\n", rep.linkType); fprintf(stderr, "******NXGetControlParameters: Local protocol major [%u] minor [%u] patch [%u].\n", @@ -905,6 +929,11 @@ Status NXGetControlParameters(Display *dpy, unsigned int *link_type, unsigned in * remote proxy? */ +/* + * return codes: + * 0 something went wrong + * 1 success + */ Status NXGetUnpackParameters(Display *dpy, unsigned int *entries, unsigned char supported_methods[]) { register xNXGetUnpackParametersReq *req; @@ -913,13 +942,9 @@ Status NXGetUnpackParameters(Display *dpy, unsigned int *entries, unsigned char register unsigned n; - #ifdef TEST - register unsigned i; - #endif - if (*entries < NXNumberOfPackMethods) { - #ifdef TEST + #ifdef TEST_PARAMS fprintf(stderr, "******NXGetUnpackParameters: Requested only [%d] entries while they should be [%d].\n", *entries, NXNumberOfPackMethods); #endif @@ -933,14 +958,14 @@ Status NXGetUnpackParameters(Display *dpy, unsigned int *entries, unsigned char req -> entries = *entries; - #ifdef TEST + #ifdef TEST_PARAMS fprintf(stderr, "******NXGetUnpackParameters: Sending message opcode [%d] with [%d] requested entries.\n", X_NXGetUnpackParameters, *entries); #endif if (_XReply(dpy, (xReply *) &rep, 0, xFalse) == xFalse || rep.length == 0) { - #ifdef TEST + #ifdef TEST_PARAMS fprintf(stderr, "******NXGetUnpackParameters: Error receiving reply.\n"); #endif @@ -953,7 +978,7 @@ Status NXGetUnpackParameters(Display *dpy, unsigned int *entries, unsigned char if ((n = rep.length << 2) > *entries) { - #ifdef TEST + #ifdef TEST_PARAMS fprintf(stderr, "******NXGetUnpackParameters: Got [%d] bytes of reply data while they should be [%d].\n", n, *entries); #endif @@ -969,17 +994,17 @@ Status NXGetUnpackParameters(Display *dpy, unsigned int *entries, unsigned char *entries = n; - #ifdef TEST + #ifdef TEST_PARAMS fprintf(stderr, "******NXGetUnpackParameters: Reading [%d] bytes of reply data.\n", n); #endif _XReadPad(dpy, (char *) supported_methods, n); - #ifdef TEST + #ifdef TEST_PARAMS fprintf(stderr, "******NXGetUnpackParameters: Got reply with methods: "); - for (i = 0; i < n; i++) + for (unsigned int i = 0; i < n; i++) { if (supported_methods[i] != 0) { @@ -1011,6 +1036,11 @@ Status NXGetUnpackParameters(Display *dpy, unsigned int *entries, unsigned char * reserve the XID that will be used by the remote. */ +/* + * return codes: + * 0 something went wrong + * 1 success + */ Status NXGetShmemParameters(Display *dpy, unsigned int *enable_client, unsigned int *enable_server, unsigned int *client_segment, unsigned int *server_segment, unsigned int *client_size, @@ -1057,12 +1087,12 @@ Status NXGetShmemParameters(Display *dpy, unsigned int *enable_client, req -> clientSegment = *client_segment; req -> serverSegment = *server_segment; - #ifdef TEST + #ifdef TEST_PARAMS fprintf(stderr, "******NXGetShmemParameters: Sending message opcode [%d] at stage [%d].\n", X_NXGetShmemParameters, stage); #endif - #ifdef TEST + #ifdef TEST_PARAMS if (stage == 0) { @@ -1101,7 +1131,7 @@ Status NXGetShmemParameters(Display *dpy, unsigned int *enable_client, if (_XReply(dpy, (xReply *) &rep, 0, xTrue) == xFalse) { - #ifdef TEST + #ifdef TEST_PARAMS fprintf(stderr, "******NXGetShmemParameters: Error receiving reply.\n"); #endif @@ -1126,7 +1156,7 @@ Status NXGetShmemParameters(Display *dpy, unsigned int *enable_client, *client_size = rep.clientSize; *server_size = rep.serverSize; - #ifdef TEST + #ifdef TEST_PARAMS fprintf(stderr, "******NXGetShmemParameters: Got final reply with enabled client [%u] and server [%u].\n", *enable_client, *enable_server); @@ -1160,6 +1190,11 @@ Status NXGetShmemParameters(Display *dpy, unsigned int *enable_client, * advertise only the fonts that can be opened at both sides. */ +/* + * return codes: + * 0 something went wrong + * 1 success + */ Status NXGetFontParameters(Display *dpy, unsigned int path_length, char path_data[]) { _X_UNUSED register xNXGetFontParametersReq *req; @@ -1168,13 +1203,13 @@ Status NXGetFontParameters(Display *dpy, unsigned int path_length, char path_dat register unsigned n; - #ifdef TEST + #ifdef TEST_PARAMS register unsigned i; #endif if (path_length < 1) { - #ifdef TEST + #ifdef TEST_PARAMS fprintf(stderr, "******NXGetFontParameters: No room to store the reply.\n"); #endif @@ -1187,14 +1222,14 @@ Status NXGetFontParameters(Display *dpy, unsigned int path_length, char path_dat GetReq(NXGetFontParameters, req); - #ifdef TEST + #ifdef TEST_PARAMS fprintf(stderr, "******NXGetFontParameters: Sending message opcode [%d].\n", X_NXGetFontParameters); #endif if (_XReply(dpy, (xReply *) &rep, 0, xFalse) == xFalse || rep.length == 0) { - #ifdef TEST + #ifdef TEST_PARAMS fprintf(stderr, "******NXGetFontParameters: Error receiving reply.\n"); #endif @@ -1207,7 +1242,7 @@ Status NXGetFontParameters(Display *dpy, unsigned int path_length, char path_dat if ((n = rep.length << 2) > path_length) { - #ifdef TEST + #ifdef TEST_PARAMS fprintf(stderr, "******NXGetFontParameters: Got [%d] bytes of reply data with only room for [%d].\n", n, path_length); #endif @@ -1221,7 +1256,7 @@ Status NXGetFontParameters(Display *dpy, unsigned int path_length, char path_dat return 0; } - #ifdef TEST + #ifdef TEST_PARAMS fprintf(stderr, "******NXGetFontParameters: Reading [%d] bytes of reply data.\n", n); #endif @@ -1234,7 +1269,7 @@ Status NXGetFontParameters(Display *dpy, unsigned int path_length, char path_dat if (*path_data > path_length - 1) { - #ifdef TEST + #ifdef TEST_PARAMS fprintf(stderr, "******NXGetFontParameters: Inconsistent length in the returned string.\n"); #endif @@ -1245,7 +1280,7 @@ Status NXGetFontParameters(Display *dpy, unsigned int path_length, char path_dat return 0; } - #ifdef TEST + #ifdef TEST_PARAMS fprintf(stderr, "******NXGetFontParameters: Got font path of [%d] bytes and value [", (int) *path_data); @@ -1276,7 +1311,7 @@ unsigned int NXAllocSplit(Display *dpy, unsigned int resource) { _NXSplitResources[resource] = 1; - #ifdef TEST + #ifdef TEST_SPLIT fprintf(stderr, "******NXAllocSplit: Reserved resource [%u].\n", resource); #endif @@ -1285,7 +1320,7 @@ unsigned int NXAllocSplit(Display *dpy, unsigned int resource) } } - #ifdef TEST + #ifdef TEST_SPLIT fprintf(stderr, "******NXAllocSplit: WARNING! Resource limit exausted.\n"); #endif @@ -1293,7 +1328,7 @@ unsigned int NXAllocSplit(Display *dpy, unsigned int resource) } else if (resource >= 0 && resource < NXNumberOfResources) { - #ifdef TEST + #ifdef TEST_SPLIT if (_NXSplitResources[resource] == 0) { @@ -1334,7 +1369,7 @@ int NXStartSplit(Display *dpy, unsigned int resource, unsigned int mode) req -> resource = resource; req -> mode = mode; - #ifdef TEST + #ifdef TEST_SPLIT fprintf(stderr, "******NXStartSplit: Sending opcode [%d] with resource [%d] mode [%d].\n", X_NXStartSplit, resource, mode); #endif @@ -1361,7 +1396,7 @@ int NXEndSplit(Display *dpy, unsigned int resource) req -> resource = resource; - #ifdef TEST + #ifdef TEST_SPLIT fprintf(stderr, "******NXEndSplit: Sending opcode [%d] with resource [%d].\n", X_NXStartSplit, resource); #endif @@ -1395,7 +1430,7 @@ int NXCommitSplit(Display *dpy, unsigned int resource, unsigned int propagate, req -> request = request; req -> position = position; - #ifdef TEST + #ifdef TEST_SPLIT fprintf(stderr, "******NXCommitSplit: Sending opcode [%d] with resource [%d] propagate [%d] " "request [%d] position [%d].\n", X_NXCommitSplit, resource, propagate, request, position); @@ -1416,7 +1451,7 @@ int NXAbortSplit(Display *dpy, unsigned int resource) GetReq(NXAbortSplit, req); - #ifdef TEST + #ifdef TEST_SPLIT fprintf(stderr, "******NXAbortSplit: Sending message opcode [%d] with resource [%u].\n", X_NXAbortSplit, resource); #endif @@ -1438,7 +1473,7 @@ int NXFinishSplit(Display *dpy, unsigned int resource) GetReq(NXFinishSplit, req); - #ifdef TEST + #ifdef TEST_SPLIT fprintf(stderr, "******NXFinishSplit: Sending message opcode [%d] with resource [%u].\n", X_NXFinishSplit, resource); #endif @@ -1462,7 +1497,7 @@ int NXFreeSplit(Display *dpy, unsigned int resource) GetReq(NXFreeSplit, req); - #ifdef TEST + #ifdef TEST_SPLIT fprintf(stderr, "******NXFreeSplit: Sending message opcode [%d] with resource [%u].\n", X_NXFreeSplit, resource); #endif @@ -1473,14 +1508,14 @@ int NXFreeSplit(Display *dpy, unsigned int resource) SyncHandle(); - #ifdef TEST + #ifdef TEST_SPLIT fprintf(stderr, "******NXFreeSplit: Making the resource [%u] newly available.\n", resource); #endif _NXSplitResources[resource] = 0; } - #ifdef TEST + #ifdef TEST_SPLIT else { fprintf(stderr, "******NXFreeSplit: Nothing to do for resource [%u].\n", @@ -1508,7 +1543,7 @@ int NXSetExposeParameters(Display *dpy, int expose, int graphics_expose, int no_ req -> graphicsExpose = graphics_expose; req -> noExpose = no_expose; - #ifdef TEST + #ifdef TEST_PARAMS fprintf(stderr, "******NXSetExposeParameters: Sending message opcode [%d] with flags [%d][%d][%d].\n", X_NXSetExposeParameters, req -> expose, req -> graphicsExpose, req -> noExpose); #endif @@ -1538,7 +1573,7 @@ int NXSetCacheParameters(Display *dpy, int enable_cache, int enable_split, req -> enableSave = enable_save; req -> enableLoad = enable_load; - #ifdef TEST + #ifdef TEST_PARAMS fprintf(stderr, "******NXSetCacheParameters: Sending message opcode [%d] with " "flags [%d][%d][%d][%d].\n", X_NXSetCacheParameters, req -> enableCache, req -> enableSplit, req -> enableSave, req -> enableLoad); @@ -1561,7 +1596,7 @@ unsigned int NXAllocUnpack(Display *dpy, unsigned int resource) { _NXUnpackResources[resource] = 1; - #ifdef TEST + #ifdef TEST_UNPACK fprintf(stderr, "******NXAllocUnpack: Reserved resource [%u].\n", resource); #endif @@ -1570,7 +1605,7 @@ unsigned int NXAllocUnpack(Display *dpy, unsigned int resource) } } - #ifdef TEST + #ifdef TEST_UNPACK fprintf(stderr, "******NXAllocUnpack: WARNING! Resource limit exausted.\n"); #endif @@ -1578,7 +1613,7 @@ unsigned int NXAllocUnpack(Display *dpy, unsigned int resource) } else if (resource >= 0 && resource < NXNumberOfResources) { - #ifdef TEST + #ifdef TEST_UNPACK if (_NXUnpackResources[resource] == 0) { @@ -1640,7 +1675,7 @@ int NXSetUnpackGeometry(Display *dpy, unsigned int resource, Visual *visual) return -1; } - #ifdef TEST + #ifdef TEST_UNPACK fprintf(stderr, "******NXSetUnpackGeometry: Resource [%u] Depth/Bpp [1/%d][4/%d][8/%d]" "[16/%d][24/%d][32/%d].\n", resource, req -> depth1Bpp, req -> depth4Bpp, req -> depth8Bpp, req -> depth16Bpp, req -> depth24Bpp, req -> depth32Bpp); @@ -1683,7 +1718,7 @@ int NXSetUnpackColormap(Display *dpy, unsigned int resource, unsigned int method req -> length += (dst_data_length >> 2); - #ifdef TEST + #ifdef TEST_UNPACK fprintf(stderr, "******NXSetUnpackColormap: Resource [%u] data size [%u] destination " "data size [%u].\n", resource, data_length, dst_data_length); #endif @@ -1746,7 +1781,7 @@ int NXSetUnpackAlpha(Display *dpy, unsigned int resource, unsigned int method, req -> length += (dst_data_length >> 2); - #ifdef TEST + #ifdef TEST_UNPACK fprintf(stderr, "******NXSetUnpackAlpha: Resource [%u] data size [%u] destination data size [%u].\n", resource, data_length, dst_data_length); #endif @@ -1812,12 +1847,6 @@ int NXSetUnpackColormapCompat(Display *dpy, unsigned int resource, register int dst_data_length; - #ifdef DUMP - - int i; - - #endif - LockDisplay(dpy); GetReq(NXSetUnpackColormapCompat, req); @@ -1829,7 +1858,7 @@ int NXSetUnpackColormapCompat(Display *dpy, unsigned int resource, req -> length += (dst_data_length >> 2); - #ifdef TEST + #ifdef TEST_UNPACK fprintf(stderr, "******NXSetUnpackColormapCompat: Resource [%u] number of entries [%u] " "destination data size [%u].\n", resource, entries, dst_data_length); #endif @@ -1862,7 +1891,7 @@ int NXSetUnpackColormapCompat(Display *dpy, unsigned int resource, fprintf(stderr, "******NXSetUnpackColormapCompat: Dumping colormap entries:\n"); - for (i = 0; i < entries; i++) + for (int i = 0; i < entries; i++) { fprintf(stderr, "******NXSetUnpackColormapCompat: [%d] -> [0x%x].\n", i, *((int *) (dst_data + (i * 4)))); @@ -1907,12 +1936,6 @@ int NXSetUnpackAlphaCompat(Display *dpy, unsigned int resource, register unsigned int dst_data_length; - #ifdef DUMP - - int i; - - #endif - LockDisplay(dpy); GetReq(NXSetUnpackAlphaCompat, req); @@ -1924,7 +1947,7 @@ int NXSetUnpackAlphaCompat(Display *dpy, unsigned int resource, req -> length += (dst_data_length >> 2); - #ifdef TEST + #ifdef TEST_UNPACK fprintf(stderr, "******NXSetUnpackAlphaCompat: Resource [%u] number of entries [%u] " "destination data size [%u].\n", resource, entries, dst_data_length); #endif @@ -1962,7 +1985,7 @@ int NXSetUnpackAlphaCompat(Display *dpy, unsigned int resource, fprintf(stderr, "******NXSetUnpackAlphaCompat: Dumping alpha channel data:\n"); - for (i = 0; i < dst_data_length; i++) + for (int i = 0; i < dst_data_length; i++) { fprintf(stderr, "******NXSetUnpackAlphaCompat: [%d] -> [0x%02x].\n", i, ((unsigned int) *(dst_data + i)) & 0xff); @@ -2004,7 +2027,7 @@ int NXFreeUnpack(Display *dpy, unsigned int resource) GetReq(NXFreeUnpack, req); - #ifdef TEST + #ifdef TEST_UNPACK fprintf(stderr, "******NXFreeUnpack: Sending message opcode [%d] with resource [%u].\n", X_NXFreeUnpack, resource); #endif @@ -2015,14 +2038,14 @@ int NXFreeUnpack(Display *dpy, unsigned int resource) SyncHandle(); - #ifdef TEST + #ifdef TEST_UNPACK fprintf(stderr, "******NXFreeUnpack: Making the resource [%u] newly available.\n", resource); #endif _NXUnpackResources[resource] = 0; } - #ifdef TEST + #ifdef TEST_UNPACK else { fprintf(stderr, "******NXFreeUnpack: Nothing to do for resource [%u].\n", @@ -2074,7 +2097,7 @@ int NXDestroyPackedImage(NXPackedImage *image) int NXCleanImage(XImage *image) { - #ifdef TEST + #ifdef TEST_IMAGE fprintf(stderr, "******NXCleanImage: Cleaning image with format [%d] depth [%d] " "bits per pixel [%d].\n", image -> format, image -> depth, image -> bits_per_pixel); @@ -2109,7 +2132,7 @@ NXPackedImage *NXPackImage(Display *dpy, XImage *src_image, unsigned int method) unsigned int dst_bits_per_pixel; unsigned int dst_packed_bits_per_pixel; - #ifdef TEST + #ifdef TEST_IMAGE fprintf(stderr, "******NXPackImage: Going to pack a new image with method [%d].\n", method); #endif @@ -2161,7 +2184,7 @@ NXPackedImage *NXPackImage(Display *dpy, XImage *src_image, unsigned int method) *dst_image = *src_image; - #ifdef TEST + #ifdef TEST_IMAGE fprintf(stderr, "******NXPackImage: Source width [%d], bytes per line [%d] with depth [%d].\n", src_image -> width, src_image -> bytes_per_line, src_image -> depth); #endif @@ -2192,7 +2215,7 @@ NXPackedImage *NXPackImage(Display *dpy, XImage *src_image, unsigned int method) dst_bits_per_pixel = dst_image -> bits_per_pixel; dst_packed_bits_per_pixel = MethodBitsPerPixel(method); - #ifdef TEST + #ifdef TEST_IMAGE fprintf(stderr, "******NXPackImage: Destination depth [%d], bits per pixel [%d], packed bits per pixel [%d].\n", dst_image -> depth, dst_bits_per_pixel, dst_packed_bits_per_pixel); #endif @@ -2239,7 +2262,7 @@ NXPackedImage *NXPackImage(Display *dpy, XImage *src_image, unsigned int method) * be able to handle ovelapping areas. */ - #ifdef TEST + #ifdef TEST_IMAGE fprintf(stderr, "******NXPackImage: Plain bits per pixel [%d], data size [%d].\n", dst_bits_per_pixel, dst_data_size); #endif @@ -2247,7 +2270,7 @@ NXPackedImage *NXPackImage(Display *dpy, XImage *src_image, unsigned int method) dst_packed_data_size = dst_data_size * dst_packed_bits_per_pixel / dst_bits_per_pixel; - #ifdef TEST + #ifdef TEST_IMAGE fprintf(stderr, "******NXPackImage: Packed bits per pixel [%d], data size [%d].\n", dst_packed_bits_per_pixel, dst_packed_data_size); #endif @@ -2296,7 +2319,7 @@ XImage *NXInPlacePackImage(Display *dpy, XImage *src_image, unsigned int method) unsigned int dst_bits_per_pixel; unsigned int dst_packed_bits_per_pixel; - #ifdef TEST + #ifdef TEST_IMAGE fprintf(stderr, "******NXInPlacePackImage: Going to pack a new image with method [%d].\n", method); #endif @@ -2347,7 +2370,7 @@ XImage *NXInPlacePackImage(Display *dpy, XImage *src_image, unsigned int method) *dst_image = *src_image; - #ifdef TEST + #ifdef TEST_IMAGE fprintf(stderr, "******NXInPlacePackImage: Source width [%d], bytes per line [%d] with depth [%d].\n", src_image -> width, src_image -> bytes_per_line, src_image -> depth); #endif @@ -2365,7 +2388,7 @@ XImage *NXInPlacePackImage(Display *dpy, XImage *src_image, unsigned int method) dst_bits_per_pixel = dst_image -> bits_per_pixel; dst_packed_bits_per_pixel = MethodBitsPerPixel(method); - #ifdef TEST + #ifdef TEST_IMAGE fprintf(stderr, "******NXInPlacePackImage: Destination depth [%d], bits per pixel [%d], packed bits per pixel [%d].\n", dst_image -> depth, dst_bits_per_pixel, dst_packed_bits_per_pixel); #endif @@ -2373,7 +2396,7 @@ XImage *NXInPlacePackImage(Display *dpy, XImage *src_image, unsigned int method) if (dst_packed_bits_per_pixel > dst_bits_per_pixel || ShouldMaskImage(src_image, mask) == 0) { - #ifdef TEST + #ifdef TEST_IMAGE fprintf(stderr, "******NXInPlacePackImage: Just clean image packed_bits_per_pixel[%d], bits_per_pixel[%d].\n", dst_packed_bits_per_pixel, dst_bits_per_pixel); #endif @@ -2408,7 +2431,7 @@ XImage *NXInPlacePackImage(Display *dpy, XImage *src_image, unsigned int method) * be able to handle ovelapping areas. */ - #ifdef TEST + #ifdef TEST_IMAGE fprintf(stderr, "******NXInPlacePackImage: Plain bits per pixel [%d], data size [%d].\n", dst_bits_per_pixel, dst_data_size); #endif @@ -2416,7 +2439,7 @@ XImage *NXInPlacePackImage(Display *dpy, XImage *src_image, unsigned int method) dst_packed_data_size = dst_data_size * dst_packed_bits_per_pixel / dst_bits_per_pixel; - #ifdef TEST + #ifdef TEST_IMAGE fprintf(stderr, "******NXInPlacePackImage: Packed bits per pixel [%d], data size [%d].\n", dst_packed_bits_per_pixel, dst_packed_data_size); #endif @@ -2451,7 +2474,7 @@ int NXPutPackedImage(Display *dpy, unsigned int resource, Drawable drawable, req -> drawable = drawable; req -> gc = ((GC) gc) -> gid; - #ifdef TEST + #ifdef TEST_IMAGE fprintf(stderr, "******NXPutPackedImage: Image resource [%d] drawable [%d] gc [%d].\n", req -> resource, (int) req -> drawable, (int) req -> gc); #endif @@ -2492,7 +2515,7 @@ int NXPutPackedImage(Display *dpy, unsigned int resource, Drawable drawable, req -> method = method; - #ifdef TEST + #ifdef TEST_IMAGE fprintf(stderr, "******NXPutPackedImage: Source image depth [%d] destination depth [%d] " "method [%d].\n", req -> srcDepth, req -> dstDepth, req -> method); #endif @@ -2526,7 +2549,7 @@ int NXPutPackedImage(Display *dpy, unsigned int resource, Drawable drawable, dst_data_length = ROUNDUP(src_data_length, 4); - #ifdef TEST + #ifdef TEST_IMAGE fprintf(stderr, "******NXPutPackedImage: Source data length [%d] request data length [%d].\n", src_data_length, dst_data_length); #endif @@ -2573,11 +2596,9 @@ int NXAllocColors(Display *dpy, Colormap colormap, unsigned int entries, Bool alloc_error = False; - register unsigned int i; - LockDisplay(dpy); - for (i = 0; i < entries; i++) + for (unsigned int i = 0; i < entries; i++) { GetReq(AllocColor, req); @@ -2588,7 +2609,7 @@ int NXAllocColors(Display *dpy, Colormap colormap, unsigned int entries, req -> blue = screens_in_out[i].blue; } - for (i = 0; i < entries; i++) + for (unsigned int i = 0; i < entries; i++) { result = _XReply(dpy, (xReply *) &rep, 0, xTrue); @@ -2941,7 +2962,7 @@ void NXMaskImage(XImage *image, unsigned int method) { maskMethod = MASK_8_COLORS; - #ifdef DEBUG + #ifdef DEBUG_IMAGE fprintf(stderr, "******NXMaskImage: Method is MASK_8_COLORS\n"); #endif @@ -2952,7 +2973,7 @@ void NXMaskImage(XImage *image, unsigned int method) { maskMethod = MASK_64_COLORS; - #ifdef DEBUG + #ifdef DEBUG_IMAGE fprintf(stderr, "******NXMaskImage: Method is MASK_64K_COLORS\n"); #endif @@ -2963,7 +2984,7 @@ void NXMaskImage(XImage *image, unsigned int method) { maskMethod = MASK_256_COLORS; - #ifdef DEBUG + #ifdef DEBUG_IMAGE fprintf(stderr, "******NXMaskImage: Method is MASK_256_COLORS\n"); #endif @@ -2974,7 +2995,7 @@ void NXMaskImage(XImage *image, unsigned int method) { maskMethod = MASK_512_COLORS; - #ifdef DEBUG + #ifdef DEBUG_IMAGE fprintf(stderr, "******NXMaskImage: Method is MASK_512K_COLORS\n"); #endif @@ -2985,7 +3006,7 @@ void NXMaskImage(XImage *image, unsigned int method) { maskMethod = MASK_4K_COLORS; - #ifdef DEBUG + #ifdef DEBUG_IMAGE fprintf(stderr, "******NXMaskImage: Method is MASK_4K_COLORS\n"); #endif @@ -2996,7 +3017,7 @@ void NXMaskImage(XImage *image, unsigned int method) { maskMethod = MASK_32K_COLORS; - #ifdef DEBUG + #ifdef DEBUG_IMAGE fprintf(stderr, "******NXMaskImage: Method is MASK_32K_COLORS\n"); #endif @@ -3007,7 +3028,7 @@ void NXMaskImage(XImage *image, unsigned int method) { maskMethod = MASK_64K_COLORS; - #ifdef DEBUG + #ifdef DEBUG_IMAGE fprintf(stderr, "******NXMaskImage: Method is MASK_64K_COLORS\n"); #endif @@ -3018,7 +3039,7 @@ void NXMaskImage(XImage *image, unsigned int method) { maskMethod = MASK_256K_COLORS; - #ifdef DEBUG + #ifdef DEBUG_IMAGE fprintf(stderr, "******NXMaskImage: Method is MASK_256K_COLORS\n"); #endif @@ -3029,7 +3050,7 @@ void NXMaskImage(XImage *image, unsigned int method) { maskMethod = MASK_2M_COLORS; - #ifdef DEBUG + #ifdef DEBUG_IMAGE fprintf(stderr, "******NXMaskImage: Method is MASK_2M_COLORS\n"); #endif @@ -3040,7 +3061,7 @@ void NXMaskImage(XImage *image, unsigned int method) { maskMethod = MASK_16M_COLORS; - #ifdef DEBUG + #ifdef DEBUG_IMAGE fprintf(stderr, "******NXMaskImage: Method is MASK_16M_COLORS\n"); #endif @@ -3057,7 +3078,7 @@ void NXMaskImage(XImage *image, unsigned int method) } } - #ifdef TEST + #ifdef TEST_IMAGE fprintf(stderr, "******NXMaskImage: packMethod[%d] => maskMethod[%d]\n", method, maskMethod); #endif @@ -3100,7 +3121,7 @@ void NXMaskImage(XImage *image, unsigned int method) if (ShouldMaskImage(image, mask) == 0) { - #ifdef TEST + #ifdef TEST_IMAGE fprintf(stderr, "******NXMaskImage: the image will not be masked\n"); #endif } @@ -3123,7 +3144,7 @@ void NXInitCache(Display *dpy, int entries) { if (NXImageCache != NULL && NXImageCacheSize == entries) { - #ifdef DEBUG + #ifdef DEBUG_IMAGE fprintf(stderr, "******NXInitCache: Nothing to do with image cache at [%p] and [%d] entries.\n", NXImageCache, NXImageCacheSize); #endif @@ -3131,7 +3152,7 @@ void NXInitCache(Display *dpy, int entries) return; } - #ifdef DEBUG + #ifdef DEBUG_IMAGE fprintf(stderr, "******NXInitCache: Initializing the cache with [%d] entries.\n", entries); #endif @@ -3150,7 +3171,7 @@ void NXInitCache(Display *dpy, int entries) NXImageCacheSize = entries; - #ifdef DEBUG + #ifdef DEBUG_IMAGE fprintf(stderr, "******NXInitCache: Image cache initialized with [%d] entries.\n", entries); #endif } @@ -3163,26 +3184,23 @@ void _NXCacheDump(const char *label) { char s[MD5_LENGTH * 2 + 1]; - int i; - int j; - - #ifdef DEBUG + #ifdef DEBUG_IMAGE fprintf(stderr, "%s: Dumping the content of image cache:\n", label); #endif - for (i = 0; i < NXImageCacheSize; i++) + for (int i = 0; i < NXImageCacheSize; i++) { if (NXImageCache[i].image == NULL) { break; } - for (j = 0; j < MD5_LENGTH; j++) + for (int j = 0; j < MD5_LENGTH; j++) { sprintf(s + (j * 2), "%02X", ((unsigned char *) NXImageCache[i].md5)[j]); } - #ifdef DEBUG + #ifdef DEBUG_IMAGE fprintf(stderr, "%s: [%d][%s].\n", label, i, s); #endif } @@ -3244,7 +3262,7 @@ XImage *NXCacheFindImage(NXPackedImage *src_image, unsigned int *method, unsigne NXImageCacheHits++; - #ifdef DEBUG + #ifdef DEBUG_IMAGE fprintf(stderr, "******NXCacheFindImage: Found at position [%d] with hits [%d] and [%d] packs.\n", i, NXImageCacheHits, NXImageCacheOps); #endif @@ -3259,7 +3277,7 @@ XImage *NXCacheFindImage(NXPackedImage *src_image, unsigned int *method, unsigne if (i > 16) { - #ifdef DEBUG + #ifdef DEBUG_IMAGE fprintf(stderr, "******NXCacheFindImage: Moving the image at the head of the list.\n"); #endif @@ -3320,7 +3338,7 @@ int NXCacheAddImage(NXPackedImage *image, unsigned int method, unsigned char *md if (NXImageCacheOps >= NXImageCacheSize) { - #ifdef DEBUG + #ifdef DEBUG_IMAGE fprintf(stderr, "******NXCacheAddImage: Freeing up the oldest entry.\n"); #endif @@ -3338,7 +3356,7 @@ int NXCacheAddImage(NXPackedImage *image, unsigned int method, unsigned char *md NXImageCacheOps++; - #ifdef DEBUG + #ifdef DEBUG_IMAGE fprintf(stderr, "******NXCacheAddImage: Going to add new image with data size [%d].\n", image -> xoffset); #endif @@ -3362,23 +3380,21 @@ int NXCacheAddImage(NXPackedImage *image, unsigned int method, unsigned char *md void NXFreeCache(Display *dpy) { - int i; - if (NXImageCache == NULL) { - #ifdef DEBUG + #ifdef DEBUG_IMAGE fprintf(stderr, "******NXFreeCache: Nothing to do with a null image cache.\n"); #endif return; } - #ifdef DEBUG + #ifdef DEBUG_IMAGE fprintf(stderr, "******NXFreeCache: Freeing the cache with [%d] entries.\n", NXImageCacheSize); #endif - for (i = 0; i < NXImageCacheSize; i++) + for (int i = 0; i < NXImageCacheSize; i++) { if (NXImageCache[i].image != NULL) { @@ -3434,11 +3450,18 @@ static Bool _NXCollectImageHandler(Display *dpy, xReply *rep, char *buf, state = (_NXCollectImageState *) data; + #ifdef DEBUG_IMAGE + fprintf(stderr, "******%s: sequence: received [%hu] expected [%lu] 16bit received [%hu] expected [%hu]\n", + __func__, + rep -> generic.sequenceNumber, state -> sequence, + rep -> generic.sequenceNumber % 65536, (CARD16)(state -> sequence) % 65536); + #endif + if ((rep -> generic.sequenceNumber % 65536) != ((CARD16)(state -> sequence) % 65536)) { - #ifdef TEST - fprintf(stderr, "******_NXCollectImageHandler: Unmatched sequence [%d] for opcode [%d] " + #ifdef TEST_IMAGE + fprintf(stderr, "******_NXCollectImageHandler: Unmatched sequence [%d] of type [%d] " "with length [%d].\n", rep -> generic.sequenceNumber, rep -> generic.type, (int) rep -> generic.length << 2); #endif @@ -3446,7 +3469,7 @@ static Bool _NXCollectImageHandler(Display *dpy, xReply *rep, char *buf, return False; } - #ifdef TEST + #ifdef TEST_IMAGE fprintf(stderr, "******_NXCollectImageHandler: Going to handle asynchronous GetImage reply.\n"); #endif @@ -3463,7 +3486,7 @@ static Bool _NXCollectImageHandler(Display *dpy, xReply *rep, char *buf, if (rep -> generic.type == X_Error) { - #ifdef TEST + #ifdef TEST_IMAGE fprintf(stderr, "******_NXCollectImageHandler: Error received from X server for resource [%d].\n", state -> resource); #endif @@ -3477,7 +3500,7 @@ static Bool _NXCollectImageHandler(Display *dpy, xReply *rep, char *buf, return False; } - #ifdef TEST + #ifdef TEST_IMAGE fprintf(stderr, "******_NXCollectImageHandler: Matched request with sequence [%ld].\n", state -> sequence); #endif @@ -3502,7 +3525,7 @@ static Bool _NXCollectImageHandler(Display *dpy, xReply *rep, char *buf, return False; } - #ifdef TEST + #ifdef TEST_IMAGE fprintf(stderr, "******_NXCollectImageHandler: Going to get reply with size [%d].\n", (int) rep -> generic.length << 2); #endif @@ -3527,7 +3550,7 @@ static Bool _NXCollectImageHandler(Display *dpy, xReply *rep, char *buf, return False; } - #ifdef TEST + #ifdef TEST_IMAGE fprintf(stderr, "******_NXCollectImageHandler: Got reply with depth [%d] visual [%d] size [%d].\n", async_rep -> depth, (int) async_rep -> visual, (int) async_rep -> length << 2); #endif @@ -3556,7 +3579,7 @@ static Bool _NXCollectImageHandler(Display *dpy, xReply *rep, char *buf, return False; } - #ifdef TEST + #ifdef TEST_IMAGE fprintf(stderr, "******_NXCollectImageHandler: Going to get data with size [%d].\n", async_size); #endif @@ -3603,7 +3626,7 @@ static Bool _NXCollectImageHandler(Display *dpy, xReply *rep, char *buf, return True; } - #ifdef TEST + #ifdef TEST_IMAGE fprintf(stderr, "******_NXCollectImageHandler: Successfully stored image data for resource [%d].\n", state -> resource); #endif @@ -3625,9 +3648,7 @@ static Bool _NXCollectImageHandler(Display *dpy, xReply *rep, char *buf, int NXGetCollectImageResource(Display *dpy) { - int i; - - for (i = 0; i < NXNumberOfResources; i++) + for (int i = 0; i < NXNumberOfResources; i++) { if (_NXCollectedImages[i] == NULL) { @@ -3638,6 +3659,12 @@ int NXGetCollectImageResource(Display *dpy) return -1; } +/* + * return codes: + * 0 no data found for resource (currently unused) + * -1 Failed + * True (1) Handler has been installed, will generate NXCollectImageNotify event when answer arrives + */ int NXCollectImage(Display *dpy, unsigned int resource, Drawable drawable, int src_x, int src_y, unsigned int width, unsigned int height, unsigned long plane_mask, int format) @@ -3695,7 +3722,7 @@ int NXCollectImage(Display *dpy, unsigned int resource, Drawable drawable, req -> height = height; req -> planeMask = plane_mask; - #ifdef TEST + #ifdef TEST_IMAGE fprintf(stderr, "******NXCollectImage: Sending message opcode [%d] sequence [%ld] for resource [%d].\n", X_GetImage, dpy -> request, resource); @@ -3772,7 +3799,7 @@ int NXGetCollectedImage(Display *dpy, unsigned int resource, XImage **image) SAFE_free(state); - #ifdef TEST + #ifdef TEST_IMAGE fprintf(stderr, "******NXGetCollectedImage: Returning GetImage data for resource [%u].\n", resource); #endif @@ -3818,19 +3845,27 @@ static Bool _NXCollectPropertyHandler(Display *dpy, xReply *rep, char *buf, state = (_NXCollectPropertyState *) data; + #ifdef DEBUG_PROPERTY + fprintf(stderr, "******%s: sequence: received [%hu] expected [%lu] 16bit received [%hu] expected [%hu]\n", + __func__, + rep -> generic.sequenceNumber, state -> sequence, + rep -> generic.sequenceNumber % 65536, (CARD16)(state -> sequence) % 65536); + #endif + if ((rep -> generic.sequenceNumber % 65536) != ((CARD16)(state -> sequence) % 65536)) { - #ifdef TEST - fprintf(stderr, "******_NXCollectPropertyHandler: Unmatched sequence [%d] for opcode [%d] " - "with length [%d].\n", rep -> generic.sequenceNumber, rep -> generic.type, + #ifdef TEST_PROPERTY + fprintf(stderr, "******_NXCollectPropertyHandler: Unmatched sequence [%d] of type [%d] " + "with length [%d].\n", rep -> generic.sequenceNumber, rep -> generic.type, (int) rep -> generic.length << 2); + #endif return False; } - #ifdef TEST + #ifdef TEST_PROPERTY fprintf(stderr, "******_NXCollectPropertyHandler: Going to handle asynchronous GetProperty reply.\n"); #endif @@ -3847,7 +3882,7 @@ static Bool _NXCollectPropertyHandler(Display *dpy, xReply *rep, char *buf, if (rep -> generic.type == X_Error) { - #ifdef TEST + #ifdef TEST_PROPERTY fprintf(stderr, "******_NXCollectPropertyHandler: Error received from X server for resource [%d].\n", state -> resource); #endif @@ -3861,7 +3896,7 @@ static Bool _NXCollectPropertyHandler(Display *dpy, xReply *rep, char *buf, return False; } - #ifdef TEST + #ifdef TEST_PROPERTY fprintf(stderr, "******_NXCollectPropertyHandler: Matched request with sequence [%ld].\n", state -> sequence); #endif @@ -3886,7 +3921,7 @@ static Bool _NXCollectPropertyHandler(Display *dpy, xReply *rep, char *buf, return False; } - #ifdef TEST + #ifdef TEST_PROPERTY fprintf(stderr, "******_NXCollectPropertyHandler: Going to get reply with size [%d].\n", (int) rep -> generic.length << 2); #endif @@ -3911,7 +3946,7 @@ static Bool _NXCollectPropertyHandler(Display *dpy, xReply *rep, char *buf, return False; } - #ifdef TEST + #ifdef TEST_PROPERTY fprintf(stderr, "******_NXCollectPropertyHandler: Got reply with format [%d] type [%d] size [%d].\n", async_rep -> format, (int) async_rep -> propertyType, (int) async_rep -> length << 2); @@ -3948,7 +3983,7 @@ static Bool _NXCollectPropertyHandler(Display *dpy, xReply *rep, char *buf, return False; } - #ifdef TEST + #ifdef TEST_PROPERTY fprintf(stderr, "******_NXCollectPropertyHandler: Going to get data with size [%d].\n", async_size); #endif @@ -3962,12 +3997,12 @@ static Bool _NXCollectPropertyHandler(Display *dpy, xReply *rep, char *buf, state -> data = async_data; - #ifdef TEST + #ifdef TEST_PROPERTY fprintf(stderr, "******_NXCollectPropertyHandler: Successfully stored property data for resource [%d].\n", state -> resource); #endif } - #ifdef TEST + #ifdef TEST_PROPERTY else { fprintf(stderr, "******_NXCollectPropertyHandler: WARNING! Null property data stored for resource [%d].\n", @@ -3995,6 +4030,12 @@ int NXGetCollectPropertyResource(Display *dpy) return -1; } +/* + * return codes: + * 0 no data found for resource (currently unused) + * -1 Failed + * True Handler has been installed, will generate NXCollectPropertyNotify event when answer arrives + */ int NXCollectProperty(Display *dpy, unsigned int resource, Window window, Atom property, long long_offset, long long_length, Bool delete, Atom req_type) { @@ -4046,7 +4087,7 @@ int NXCollectProperty(Display *dpy, unsigned int resource, Window window, Atom p req -> longOffset = long_offset; req -> longLength = long_length; - #ifdef TEST + #ifdef TEST_PROPERTY fprintf(stderr, "******NXCollectProperty: Sending message opcode [%d] sequence [%ld] for resource [%d].\n", X_GetProperty, dpy -> request, resource); @@ -4103,6 +4144,11 @@ int NXCollectProperty(Display *dpy, unsigned int resource, Window window, Atom p return True; } +/* + * return codes: + * 0 not data available + * True success + */ int NXGetCollectedProperty(Display *dpy, unsigned int resource, Atom *actual_type_return, int *actual_format_return, unsigned long *nitems_return, unsigned long *bytes_after_return, unsigned char **data) @@ -4132,7 +4178,7 @@ int NXGetCollectedProperty(Display *dpy, unsigned int resource, Atom *actual_typ _NXCollectedProperties[resource] = NULL; - #ifdef TEST + #ifdef TEST_PROPERTY fprintf(stderr, "******NXGetCollectedProperty: Returning GetProperty data for resource [%u].\n", resource); #endif @@ -4172,11 +4218,18 @@ static Bool _NXCollectGrabPointerHandler(Display *dpy, xReply *rep, char *buf, state = (_NXCollectGrabPointerState *) data; + #ifdef DEBUG_POINTER + fprintf(stderr, "******%s: sequence: received [%hu] expected [%lu] 16bit received [%hu] expected [%hu]\n", + __func__, + rep -> generic.sequenceNumber, state -> sequence, + rep -> generic.sequenceNumber % 65536, (CARD16)(state -> sequence) % 65536); + #endif + if ((rep -> generic.sequenceNumber % 65536) != ((CARD16)(state -> sequence) % 65536)) { - #ifdef TEST - fprintf(stderr, "******_NXCollectGrabPointerHandler: Unmatched sequence [%d] for opcode [%d] " + #ifdef TEST_POINTER + fprintf(stderr, "******_NXCollectGrabPointerHandler: Unmatched sequence [%d] of type [%d] " "with length [%d].\n", rep -> generic.sequenceNumber, rep -> generic.type, (int) rep -> generic.length << 2); #endif @@ -4184,7 +4237,7 @@ static Bool _NXCollectGrabPointerHandler(Display *dpy, xReply *rep, char *buf, return False; } - #ifdef TEST + #ifdef TEST_POINTER fprintf(stderr, "******_NXCollectGrabPointerHandler: Going to handle asynchronous GrabPointer reply.\n"); #endif @@ -4194,7 +4247,7 @@ static Bool _NXCollectGrabPointerHandler(Display *dpy, xReply *rep, char *buf, if (rep -> generic.type == X_Error) { - #ifdef TEST + #ifdef TEST_POINTER fprintf(stderr, "******_NXCollectGrabPointerHandler: Error received from X server for resource [%d].\n", state -> resource); #endif @@ -4208,7 +4261,7 @@ static Bool _NXCollectGrabPointerHandler(Display *dpy, xReply *rep, char *buf, return False; } - #ifdef TEST + #ifdef TEST_POINTER fprintf(stderr, "******_NXCollectGrabPointerHandler: Matched request with sequence [%ld].\n", state -> sequence); #endif @@ -4233,7 +4286,7 @@ static Bool _NXCollectGrabPointerHandler(Display *dpy, xReply *rep, char *buf, return False; } - #ifdef TEST + #ifdef TEST_POINTER fprintf(stderr, "******_NXCollectGrabPointerHandler: Going to get reply with size [%d].\n", (int) rep -> generic.length << 2); #endif @@ -4258,7 +4311,7 @@ static Bool _NXCollectGrabPointerHandler(Display *dpy, xReply *rep, char *buf, return False; } - #ifdef TEST + #ifdef TEST_POINTER fprintf(stderr, "******_NXCollectGrabPointerHandler: Got reply with status [%d] size [%d].\n", async_rep -> status, (int) async_rep -> length << 2); #endif @@ -4285,6 +4338,12 @@ int NXGetCollectGrabPointerResource(Display *dpy) return -1; } +/* + * return codes: + * 0 no data found for resource + * -1 Failed + * True Handler has been installed, will generate NXCollectGrabPointerNotify event when answer arrives + */ int NXCollectGrabPointer(Display *dpy, unsigned int resource, Window grab_window, Bool owner_events, unsigned int event_mask, int pointer_mode, int keyboard_mode, Window confine_to, Cursor cursor, Time time) @@ -4338,7 +4397,7 @@ int NXCollectGrabPointer(Display *dpy, unsigned int resource, Window grab_window req -> cursor = cursor; req -> time = time; - #ifdef TEST + #ifdef TEST_POINTER fprintf(stderr, "******NXCollectGrabPointer: Sending message opcode [%d] sequence [%ld] " "for resource [%d].\n", X_GrabPointer, dpy -> request, resource); #endif @@ -4384,6 +4443,11 @@ int NXCollectGrabPointer(Display *dpy, unsigned int resource, Window grab_window return True; } +/* + * return codes: + * 0 not data available + * True success + */ int NXGetCollectedGrabPointer(Display *dpy, unsigned int resource, int *status) { register _NXCollectGrabPointerState *state; @@ -4406,7 +4470,7 @@ int NXGetCollectedGrabPointer(Display *dpy, unsigned int resource, int *status) _NXCollectedGrabPointers[resource] = NULL; - #ifdef TEST + #ifdef TEST_POINTER fprintf(stderr, "******NXGetCollectedGrabPointer: Returning GrabPointer data for resource [%u].\n", resource); #endif @@ -4446,11 +4510,18 @@ static Bool _NXCollectInputFocusHandler(Display *dpy, xReply *rep, char *buf, state = (_NXCollectInputFocusState *) data; + #ifdef DEBUG_INPUT + fprintf(stderr, "******%s: sequence: received [%hu] expected [%lu] 16bit received [%hu] expected [%hu]\n", + __func__, + rep -> generic.sequenceNumber, state -> sequence, + rep -> generic.sequenceNumber % 65536, (CARD16)(state -> sequence) % 65536); + #endif + if ((rep -> generic.sequenceNumber % 65536) != ((CARD16)(state -> sequence) % 65536)) { - #ifdef TEST - fprintf(stderr, "******_NXCollectInputFocusHandler: Unmatched sequence [%d] for opcode [%d] " + #ifdef TEST_INPUT + fprintf(stderr, "******_NXCollectInputFocusHandler: Unmatched sequence [%d] of type [%d] " "with length [%d].\n", rep -> generic.sequenceNumber, rep -> generic.type, (int) rep -> generic.length << 2); #endif @@ -4458,7 +4529,7 @@ static Bool _NXCollectInputFocusHandler(Display *dpy, xReply *rep, char *buf, return False; } - #ifdef TEST + #ifdef TEST_INPUT fprintf(stderr, "******_NXCollectInputFocusHandler: Going to handle asynchronous GetInputFocus reply.\n"); #endif @@ -4468,7 +4539,7 @@ static Bool _NXCollectInputFocusHandler(Display *dpy, xReply *rep, char *buf, if (rep -> generic.type == X_Error) { - #ifdef TEST + #ifdef TEST_INPUT fprintf(stderr, "******_NXCollectInputFocusHandler: Error received from X server for resource [%d].\n", state -> resource); #endif @@ -4482,7 +4553,7 @@ static Bool _NXCollectInputFocusHandler(Display *dpy, xReply *rep, char *buf, return False; } - #ifdef TEST + #ifdef TEST_INPUT fprintf(stderr, "******_NXCollectInputFocusHandler: Matched request with sequence [%ld].\n", state -> sequence); #endif @@ -4507,7 +4578,7 @@ static Bool _NXCollectInputFocusHandler(Display *dpy, xReply *rep, char *buf, return False; } - #ifdef TEST + #ifdef TEST_INPUT fprintf(stderr, "******_NXCollectInputFocusHandler: Going to get reply with size [%d].\n", (int) rep -> generic.length << 2); #endif @@ -4532,7 +4603,7 @@ static Bool _NXCollectInputFocusHandler(Display *dpy, xReply *rep, char *buf, return False; } - #ifdef TEST + #ifdef TEST_INPUT fprintf(stderr, "******_NXCollectInputFocusHandler: Got reply with focus [%d] revert to [%d] " "size [%d].\n", (int) async_rep -> focus, (int) async_rep -> revertTo, (int) async_rep -> length << 2); @@ -4561,6 +4632,12 @@ int NXGetCollectInputFocusResource(Display *dpy) return -1; } +/* + * return codes: + * 0 no data found for resource (currently unused) + * -1 Failed + * True (1) Handler has been installed, will generate NXCollectInputFocusNotify event when answer arrives + */ int NXCollectInputFocus(Display *dpy, unsigned int resource) { _X_UNUSED register xReq *req; @@ -4603,7 +4680,7 @@ int NXCollectInputFocus(Display *dpy, unsigned int resource) GetEmptyReq(GetInputFocus, req); - #ifdef TEST + #ifdef TEST_INPUT fprintf(stderr, "******NXCollectInputFocus: Sending message opcode [%d] sequence [%ld] for resource [%d].\n", X_GetInputFocus, dpy -> request, resource); #endif @@ -4650,6 +4727,11 @@ int NXCollectInputFocus(Display *dpy, unsigned int resource) return True; } +/* + * return codes: + * 0 not data available + * True success + */ int NXGetCollectedInputFocus(Display *dpy, unsigned int resource, Window *focus_return, int *revert_to_return) { @@ -4674,7 +4756,7 @@ int NXGetCollectedInputFocus(Display *dpy, unsigned int resource, _NXCollectedInputFocuses[resource] = NULL; - #ifdef TEST + #ifdef TEST_INPUT fprintf(stderr, "******NXGetCollectedInputFocus: Returning GetInputFocus data for resource [%u].\n", resource); #endif |