diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2021-06-08 12:59:56 +0200 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2021-06-08 12:59:56 +0200 |
commit | 59a0620f68e9377001f23f5f491a8b02b520d685 (patch) | |
tree | 977e12e055ffb34eb671eaa428afd22633cf6d48 /nx-X11/programs/Xserver | |
parent | 6208dade860c6429791a5897136506adfd505e9d (diff) | |
parent | fcc1b57fb980b821138301a9585b91d10bfd0901 (diff) | |
download | nx-libs-59a0620f68e9377001f23f5f491a8b02b520d685.tar.gz nx-libs-59a0620f68e9377001f23f5f491a8b02b520d685.tar.bz2 nx-libs-59a0620f68e9377001f23f5f491a8b02b520d685.zip |
Merge branch 'uli42-pr/various7' into 3.6.x
Attributes GH PR #1007: https://github.com/ArcticaProject/nx-libs/pull/1007
Diffstat (limited to 'nx-X11/programs/Xserver')
29 files changed, 493 insertions, 363 deletions
diff --git a/nx-X11/programs/Xserver/composite/compext.c b/nx-X11/programs/Xserver/composite/compext.c index 8513c6d73..a63b02075 100644 --- a/nx-X11/programs/Xserver/composite/compext.c +++ b/nx-X11/programs/Xserver/composite/compext.c @@ -39,6 +39,7 @@ static DevPrivateKeyRec CompositeClientPrivateKeyRec; #define CompositeClientPrivateKey (&CompositeClientPrivateKeyRec) #else /* !defined(NXAGENT_SERVER) */ +#include "../hw/nxagent/Options.h" static int CompositeClientPrivIndex = -1; #endif /* !defined(NXAGENT_SERVER) */ @@ -623,6 +624,11 @@ CompositeExtensionInit (void) /* Assume initialization is going to fail */ noCompositeExtension = TRUE; +#ifdef NXAGENT_SERVER + if (!nxagentOption(Composite)) + return; +#endif + fprintf(stderr, "COMPOSITE: trying to initialize extension.\n"); for (s = 0; s < screenInfo.numScreens; s++) { diff --git a/nx-X11/programs/Xserver/hw/nxagent/Args.c b/nx-X11/programs/Xserver/hw/nxagent/Args.c index 72d6d050c..be13efacd 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Args.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Args.c @@ -197,10 +197,12 @@ int ddxProcessArgument(int argc, char *argv[], int i) nxagentProgName = strdup(basename(basec)); SAFE_free(basec); +#ifdef X2GO /* * Check if we are running as X2Go Agent */ checkX2goAgent(); +#endif } #ifdef TEST @@ -691,6 +693,7 @@ int ddxProcessArgument(int argc, char *argv[], int i) { SAFE_free(nxagentKeyboard); +#ifdef X2GO if (nxagentX2go && strcmp(argv[i], "null/null") == 0) { #ifdef TEST @@ -701,6 +704,7 @@ int ddxProcessArgument(int argc, char *argv[], int i) nxagentKeyboard = strdup("clone"); } else +#endif { nxagentKeyboard = strdup(argv[i]); } @@ -733,6 +737,14 @@ int ddxProcessArgument(int argc, char *argv[], int i) return 1; } + /* the composite extension is disabled by default so we provide a + way to enable it */ + if (!strcmp(argv[i], "-composite")) + { + nxagentChangeOption(Composite, True); + return 1; + } + if (!strcmp(argv[i], "-nodamage")) { nxagentChangeOption(UseDamage, False); @@ -1775,11 +1787,13 @@ N/A if (*nxagentWindowName == '\0') { - if(nxagentX2go) +#ifdef X2GO + if (nxagentX2go) { snprintf(nxagentWindowName, NXAGENTWINDOWNAMELENGTH, "X2Go Agent"); } else +#endif { snprintf(nxagentWindowName, NXAGENTWINDOWNAMELENGTH, "NX Agent"); } @@ -1870,11 +1884,11 @@ N/A fprintf(stderr, "nxagentPostProcessArgs: WARNING! Using backward compatible alpha encoding.\n"); #endif - nxagentAlphaCompat = 1; + nxagentAlphaCompat = True; } else { - nxagentAlphaCompat = 0; + nxagentAlphaCompat = False; } nxagentRemoteMajor = remoteMajor; @@ -1984,16 +1998,16 @@ FIXME: In rootless mode the backing-store support is not functional yet. */ if (nxagentOption(Rootless)) { - enableBackingStore = 0; + enableBackingStore = FALSE; } else if (nxagentOption(BackingStore) == BackingStoreUndefined || nxagentOption(BackingStore) == BackingStoreForce) { - enableBackingStore = 1; + enableBackingStore = TRUE; } else if (nxagentOption(BackingStore) == BackingStoreNever) { - enableBackingStore = 0; + enableBackingStore = FALSE; } /* @@ -2098,9 +2112,13 @@ void ddxUseMsg(void) ErrorF("-autodpi detect real server's DPI and use that in the session\n"); ErrorF("-display string display name of the real server\n"); ErrorF("-sync synchronize with the real server\n"); + ErrorF("-nxrealwindowprop set property NX_REAL_WINDOW for each X11 window inside nxagent\n"); + ErrorF("-reportwids report externally exposed X11 window IDs to the session log\n"); + ErrorF("-reportprivatewids report internal X11 window ID to the session log\n"); #ifdef RENDER ErrorF("-norender disable the use of the render extension\n"); - ErrorF("-nocomposite disable the use of the composite extension\n"); + ErrorF("-nocomposite disable the use of the composite extension (default)\n"); + ErrorF("-composite enable the use of the composite extension\n"); #endif ErrorF("-nopersistent disable disconnection/reconnection to the X display on SIGHUP\n"); ErrorF("-noshmem disable use of shared memory extension\n"); @@ -2114,6 +2132,7 @@ void ddxUseMsg(void) ErrorF("-irlimit maximum image data rate to the encoder input in kB/s.\n"); ErrorF("-tile WxH maximum size of image tiles (minimum allowed: 32x32)\n"); ErrorF("-keystrokefile file file with keyboard shortcut definitions\n"); + ErrorF("-options file|string path to an options file or an option string (for testing/debugging)\n"); ErrorF("-verbose print more warning and error messages\n"); ErrorF("-D enable desktop mode\n"); ErrorF("-R enable rootless mode\n"); diff --git a/nx-X11/programs/Xserver/hw/nxagent/Atoms.c b/nx-X11/programs/Xserver/hw/nxagent/Atoms.c index ea7ad7599..2ddf87e55 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Atoms.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Atoms.c @@ -89,9 +89,12 @@ static char *nxagentAtomNames[NXAGENT_NUMBER_OF_ATOMS + 1] = "WM_NX_READY", /* 3 */ /* nxagent takes the ownership of the selection with this name to signal the nxclient (or any other watching program) - it is ready. */ + it is ready. This is only used if NXAGENT_ONSTART is defined. + We cannot enclose it in #ifdef here because we use the numeric + indices to this structure at multiple places. */ "MCOPGLOBALS", /* 4 */ - /* used for artsd support. */ + /* used for artsd support. Only used if compiled with + NXAGENT_ARTSD */ "NX_CUT_BUFFER_SERVER", /* 5 */ /* this is the name of a property on nxagent's window on the real X server. This property is used for passing clipboard diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c index 8ac2241a6..22fc96f4f 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c @@ -2237,6 +2237,7 @@ Bool nxagentInitClipboard(WindowPtr pWin) nxagentXFixesInfo.Initialized = True; } +#ifdef NXAGENT_ONSTART /* The first paste from CLIPBOARD did not work directly after session start. Removing this code makes it work. It is unsure why @@ -2247,6 +2248,7 @@ Bool nxagentInitClipboard(WindowPtr pWin) if (nxagentSessionId[0]) { + // nxagentAtoms[10] is the CLIPBOARD atom #ifdef TEST fprintf(stderr, "%s: setting the ownership of %s to %lx" " and registering for PropertyChangeMask events\n", __func__, @@ -2258,6 +2260,7 @@ Bool nxagentInitClipboard(WindowPtr pWin) nxagentChangeWindowAttributes(pWin, CWEventMask); } */ +#endif if (nxagentReconnectTrap) { diff --git a/nx-X11/programs/Xserver/hw/nxagent/Composite.c b/nx-X11/programs/Xserver/hw/nxagent/Composite.c index 745696219..9e14a82bb 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Composite.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Composite.c @@ -47,7 +47,7 @@ * Set if the composite extension is supported by the remote display. */ -int nxagentCompositeEnable = UNDEFINED; +Bool nxagentCompositeEnable = False; void nxagentCompositeExtensionInit(void) { @@ -55,7 +55,7 @@ void nxagentCompositeExtensionInit(void) * Set the flag only if the initialization completes. */ - nxagentCompositeEnable = 0; + nxagentCompositeEnable = False; if (nxagentOption(Composite)) { @@ -96,7 +96,7 @@ void nxagentCompositeExtensionInit(void) fprintf(stderr, "nxagentCompositeExtensionInit: Enabling the use of the composite extension.\n"); #endif - nxagentCompositeEnable = 1; + nxagentCompositeEnable = True; } #ifdef TEST else @@ -115,8 +115,7 @@ void nxagentCompositeExtensionInit(void) void nxagentRedirectDefaultWindows(void) { - if (nxagentOption(Rootless) || - nxagentCompositeEnable == 0) + if (nxagentOption(Rootless) || !nxagentCompositeEnable) { #ifdef TEST fprintf(stderr, "nxagentRedirectDefaultWindows: Not redirecting default " @@ -140,10 +139,10 @@ void nxagentRedirectDefaultWindows(void) /* * When trying to redirect only the top level window, and not the - * subwindows, we incur in a strange be- haviour. The top level is - * unmapped, mapped, unmap- ped and then reparented. This at first + * subwindows, we incur in a strange behaviour. The top level is + * unmapped, mapped, unmapped and then reparented. This at first * makes the agent think that the window manager is gone, then the - * agent window disappears. To make thinks even more weird, this + * agent window disappears. To make things even more weird, this * happens only at reconnection. */ @@ -154,8 +153,7 @@ void nxagentRedirectDefaultWindows(void) void nxagentRedirectWindow(WindowPtr pWin) { - if (!nxagentOption(Rootless) || - nxagentCompositeEnable == 0) + if (!nxagentOption(Rootless) || !nxagentCompositeEnable) { #ifdef TEST fprintf(stderr, "nxagentRedirectWindow: Not redirecting window id [%ld] " diff --git a/nx-X11/programs/Xserver/hw/nxagent/Composite.h b/nx-X11/programs/Xserver/hw/nxagent/Composite.h index abe2551bf..02f08f878 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Composite.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Composite.h @@ -31,7 +31,7 @@ * its use is enabled. */ -extern int nxagentCompositeEnable; +extern Bool nxagentCompositeEnable; /* * Query the composite extension on the diff --git a/nx-X11/programs/Xserver/hw/nxagent/Display.c b/nx-X11/programs/Xserver/hw/nxagent/Display.c index 89d49edf1..95b5aa3af 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Display.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Display.c @@ -92,7 +92,9 @@ is" without express or implied warranty. #include "compext/Compext.h" #include NXAGENT_ICON_NAME +#ifdef X2GO #include X2GOAGENT_ICON_NAME +#endif /* * Set here the required log level. @@ -1849,6 +1851,7 @@ Bool nxagentMakeIcon(Display *disp, Pixmap *nxIcon, Pixmap *nxMask) { char** agentIconData; +#ifdef X2GO /* * selecting x2go icon when running as X2Go agent */ @@ -1857,6 +1860,7 @@ Bool nxagentMakeIcon(Display *disp, Pixmap *nxIcon, Pixmap *nxMask) agentIconData = x2goagentIconData; } else +#endif { agentIconData = nxagentIconData; } diff --git a/nx-X11/programs/Xserver/hw/nxagent/Error.c b/nx-X11/programs/Xserver/hw/nxagent/Error.c index 8c9a52d2e..93f4f4387 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Error.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Error.c @@ -136,105 +136,105 @@ static int nxagentPrintError(dpy, event, fp) XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ); (void) fprintf(fp, "%s: %s\n ", mesg, buffer); XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d", - mesg, BUFSIZ); + mesg, BUFSIZ); (void) fprintf(fp, mesg, event->request_code); if (event->request_code < 128) { - snprintf(number, sizeof(number), "%d", event->request_code); - XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ); + snprintf(number, sizeof(number), "%d", event->request_code); + XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ); } else { #ifndef NXAGENT_SERVER - for (ext = dpy->ext_procs; - ext && (ext->codes.major_opcode != event->request_code); - ext = ext->next) - ; - if (ext) { - strncpy(buffer, ext->name, BUFSIZ); - buffer[BUFSIZ - 1] = '\0'; + for (ext = dpy->ext_procs; + ext && (ext->codes.major_opcode != event->request_code); + ext = ext->next) + ; + if (ext) { + strncpy(buffer, ext->name, BUFSIZ); + buffer[BUFSIZ - 1] = '\0'; } else #endif - buffer[0] = '\0'; + buffer[0] = '\0'; } (void) fprintf(fp, " (%s)\n", buffer); if (event->request_code >= 128) { - XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d", - mesg, BUFSIZ); - fputs(" ", fp); - (void) fprintf(fp, mesg, event->minor_code); + XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d", + mesg, BUFSIZ); + fputs(" ", fp); + (void) fprintf(fp, mesg, event->minor_code); #ifndef NXAGENT_SERVER - if (ext) { - snprintf(mesg, sizeof(mesg), "%s.%d", ext->name, event->minor_code); - XGetErrorDatabaseText(dpy, "XRequest", mesg, "", buffer, BUFSIZ); - (void) fprintf(fp, " (%s)", buffer); - } + if (ext) { + snprintf(mesg, sizeof(mesg), "%s.%d", ext->name, event->minor_code); + XGetErrorDatabaseText(dpy, "XRequest", mesg, "", buffer, BUFSIZ); + (void) fprintf(fp, " (%s)", buffer); + } #endif - fputs("\n", fp); + fputs("\n", fp); } if (event->error_code >= 128) { - /* kludge, try to find the extension that caused it */ - buffer[0] = '\0'; + /* kludge, try to find the extension that caused it */ + buffer[0] = '\0'; #ifndef NXAGENT_SERVER - for (ext = dpy->ext_procs; ext; ext = ext->next) { - if (ext->error_string) - (*ext->error_string)(dpy, event->error_code, &ext->codes, - buffer, BUFSIZ); - if (buffer[0]) { - bext = ext; - break; - } - if (ext->codes.first_error && - ext->codes.first_error < (int)event->error_code && - (!bext || ext->codes.first_error > bext->codes.first_error)) - bext = ext; - } - if (bext) - snprintf(buffer, sizeof(buffer), "%s.%d", bext->name, - event->error_code - bext->codes.first_error); - else + for (ext = dpy->ext_procs; ext; ext = ext->next) { + if (ext->error_string) + (*ext->error_string)(dpy, event->error_code, &ext->codes, + buffer, BUFSIZ); + if (buffer[0]) { + bext = ext; + break; + } + if (ext->codes.first_error && + ext->codes.first_error < (int)event->error_code && + (!bext || ext->codes.first_error > bext->codes.first_error)) + bext = ext; + } + if (bext) + snprintf(buffer, sizeof(buffer), "%s.%d", bext->name, + event->error_code - bext->codes.first_error); + else #endif - strcpy(buffer, "Value"); - XGetErrorDatabaseText(dpy, mtype, buffer, "", mesg, BUFSIZ); - if (mesg[0]) { - fputs(" ", fp); - (void) fprintf(fp, mesg, event->resourceid); - fputs("\n", fp); - } - /* let extensions try to print the values */ + strcpy(buffer, "Value"); + XGetErrorDatabaseText(dpy, mtype, buffer, "", mesg, BUFSIZ); + if (mesg[0]) { + fputs(" ", fp); + (void) fprintf(fp, mesg, event->resourceid); + fputs("\n", fp); + } + /* let extensions try to print the values */ #ifndef NXAGENT_SERVER - for (ext = dpy->ext_procs; ext; ext = ext->next) { - if (ext->error_values) - (*ext->error_values)(dpy, event, fp); - } + for (ext = dpy->ext_procs; ext; ext = ext->next) { + if (ext->error_values) + (*ext->error_values)(dpy, event, fp); + } #endif } else if ((event->error_code == BadWindow) || - (event->error_code == BadPixmap) || - (event->error_code == BadCursor) || - (event->error_code == BadFont) || - (event->error_code == BadDrawable) || - (event->error_code == BadColor) || - (event->error_code == BadGC) || - (event->error_code == BadIDChoice) || - (event->error_code == BadValue) || - (event->error_code == BadAtom)) { - if (event->error_code == BadValue) - XGetErrorDatabaseText(dpy, mtype, "Value", "Value 0x%x", - mesg, BUFSIZ); - else if (event->error_code == BadAtom) - XGetErrorDatabaseText(dpy, mtype, "AtomID", "AtomID 0x%x", - mesg, BUFSIZ); - else - XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x", - mesg, BUFSIZ); - fputs(" ", fp); - (void) fprintf(fp, mesg, event->resourceid); - fputs("\n", fp); + (event->error_code == BadPixmap) || + (event->error_code == BadCursor) || + (event->error_code == BadFont) || + (event->error_code == BadDrawable) || + (event->error_code == BadColor) || + (event->error_code == BadGC) || + (event->error_code == BadIDChoice) || + (event->error_code == BadValue) || + (event->error_code == BadAtom)) { + if (event->error_code == BadValue) + XGetErrorDatabaseText(dpy, mtype, "Value", "Value 0x%x", + mesg, BUFSIZ); + else if (event->error_code == BadAtom) + XGetErrorDatabaseText(dpy, mtype, "AtomID", "AtomID 0x%x", + mesg, BUFSIZ); + else + XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x", + mesg, BUFSIZ); + fputs(" ", fp); + (void) fprintf(fp, mesg, event->resourceid); + fputs("\n", fp); } XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d", - mesg, BUFSIZ); + mesg, BUFSIZ); fputs(" ", fp); (void) fprintf(fp, mesg, event->serial); #ifndef NXAGENT_SERVER XGetErrorDatabaseText(dpy, mtype, "CurrentSerial", "Current Serial #%d", - mesg, BUFSIZ); + mesg, BUFSIZ); fputs("\n ", fp); (void) fprintf(fp, mesg, (unsigned long long)(X_DPY_GET_REQUEST(dpy))); #endif diff --git a/nx-X11/programs/Xserver/hw/nxagent/GCOps.c b/nx-X11/programs/Xserver/hw/nxagent/GCOps.c index 57b7c2b57..bac9947f0 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/GCOps.c +++ b/nx-X11/programs/Xserver/hw/nxagent/GCOps.c @@ -700,7 +700,7 @@ RegionPtr nxagentCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, if (!nxagentOption(IgnoreVisibility) && pDstDrawable -> type == DRAWABLE_WINDOW && (!nxagentWindowIsVisible((WindowPtr) pDstDrawable) || - (!nxagentDefaultWindowIsVisible() && nxagentCompositeEnable == 0))) + (!nxagentDefaultWindowIsVisible() && !nxagentCompositeEnable))) { #ifdef TEST fprintf(stderr, "nxagentCopyArea: Prevented operation on fully obscured window at [%p].\n", diff --git a/nx-X11/programs/Xserver/hw/nxagent/Icons.h b/nx-X11/programs/Xserver/hw/nxagent/Icons.h index a8a155cec..30457402b 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Icons.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Icons.h @@ -32,6 +32,8 @@ #define NXAGENT_ICON_NAME "nxagent.xpm" +#ifdef X2GO #define X2GOAGENT_ICON_NAME "x2goagent.xpm" +#endif #endif /* __Icons_H__ */ diff --git a/nx-X11/programs/Xserver/hw/nxagent/Image.c b/nx-X11/programs/Xserver/hw/nxagent/Image.c index 8c828df20..c033bf70d 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Image.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Image.c @@ -87,8 +87,8 @@ int nxagentSplitThreshold = -1; * Set if images can use the alpha channel. */ -int nxagentAlphaEnabled = 0; -int nxagentAlphaCompat = 0; +Bool nxagentAlphaEnabled = False; +Bool nxagentAlphaCompat = False; /* * Used to reformat image when connecting to displays having different @@ -418,7 +418,7 @@ FIXME: Here the split trap is always set and so the caching of the * send the alpha data in compressed form. */ - if (nxagentAlphaCompat == 0) + if (!nxagentAlphaCompat) { NXSetUnpackAlpha(nxagentDisplay, resource, PACK_NONE, size, data, size); } @@ -526,7 +526,7 @@ void nxagentPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth, if (!nxagentOption(IgnoreVisibility) && pDrawable -> type == DRAWABLE_WINDOW && (!nxagentWindowIsVisible((WindowPtr) pDrawable) || - (!nxagentDefaultWindowIsVisible() && nxagentCompositeEnable == 0))) + (!nxagentDefaultWindowIsVisible() && !nxagentCompositeEnable))) { #ifdef TEST diff --git a/nx-X11/programs/Xserver/hw/nxagent/Image.h b/nx-X11/programs/Xserver/hw/nxagent/Image.h index 6e22fa9f6..5876f5152 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Image.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Image.h @@ -61,8 +61,8 @@ extern int nxagentSplitThreshold; * can be sent in compressed form. */ -extern int nxagentAlphaEnabled; -extern int nxagentAlphaCompat; +extern Bool nxagentAlphaEnabled; +extern Bool nxagentAlphaCompat; /* * Reset the visual and alpha cache diff --git a/nx-X11/programs/Xserver/hw/nxagent/Imakefile b/nx-X11/programs/Xserver/hw/nxagent/Imakefile index a713467ae..4e48f62f5 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Imakefile +++ b/nx-X11/programs/Xserver/hw/nxagent/Imakefile @@ -192,8 +192,6 @@ INCLUDES = \ ### list of existing NXAGENT macros: # -# NXAGENT_SHAPE Old shape code -# NXAGENT_SHAPE2 New shape code # NXAGENT_FIXKEYS Force the release of pressed key when losing focus # NXAGENT_CLIPBOARD Enables clipboard cut and paste function between X servers. # NXAGENT_RANDR_MODE_PREFIX Prefix for RandR display modes (i.e., nx_<x>x<y>) (default: nx_) @@ -206,6 +204,7 @@ INCLUDES = \ # This only has an effect if NX_TRANS_WAKEUP is also set for os/WaitFor.c # NXAGENT_ARTSD enable special handling of MCOPGLOBALS property used by artsd. # NXAGENT_RENDER_CLEANUP cleanup padding bits/bytes of glyphs to possibly increase compression rate +# X2GO include code to support running as x2goagent # ### macros not investigated yet: # @@ -245,7 +244,6 @@ DEFINES = \ -UXF86VIDMODE -UXFreeXDGA -UXF86MISC -UXF86DRI \ -DNXAGENT_SERVER \ -DNXAGENT_RENDER_CLEANUP \ - -DNXAGENT_SHAPE2 \ -DNXAGENT_FIXKEYS \ -DNXAGENT_CLIPBOARD \ -DNXAGENT_WAKEUP=1000 \ @@ -259,6 +257,7 @@ DEFINES = \ -DRANDR_15_INTERFACE=1 \ -DPANORAMIX \ -UDEBUG_TREE \ + -DX2GO \ -DSYSTEMFONTDIR=\"$(SYSTEMFONTDIR)\" \ $(NULL) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Init.c b/nx-X11/programs/Xserver/hw/nxagent/Init.c index e8e230956..8a9964154 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Init.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Init.c @@ -156,7 +156,7 @@ FIXME: These, if not removed, should at least be moved to Display.h and Display.c. */ int nxagentBackingStore; -int nxagentSaveUnder; +Bool nxagentSaveUnder; /* * This is true at startup and set to the value of @@ -173,7 +173,8 @@ int nxagentSaveUnder; */ Bool nxagentDoFullGeneration = True; - /* +#ifdef X2GO +/* * True if agent is running as X2goAgent * False if agent is running as NXAgent */ @@ -196,6 +197,7 @@ void checkX2goAgent(void) else nxagentX2go = False; } +#endif /* * Called at X server's initialization. diff --git a/nx-X11/programs/Xserver/hw/nxagent/Init.h b/nx-X11/programs/Xserver/hw/nxagent/Init.h index 6fa1bedd7..ec0bb3483 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Init.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Init.h @@ -40,13 +40,15 @@ is" without express or implied warranty. #ifndef __Init_H__ #define __Init_H__ -extern int nxagentDoFullGeneration; +extern Bool nxagentDoFullGeneration; extern int nxagentBackingStore; -extern int nxagentSaveUnder; +extern Bool nxagentSaveUnder; -extern int nxagentX2go; +#ifdef X2GO +extern Bool nxagentX2go; void checkX2goAgent(void); +#endif extern ServerGrabInfoRec nxagentGrabServerInfo; diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c index 731844874..2142adc8e 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c @@ -663,7 +663,8 @@ XkbError: #endif nxagentChangeOption(KeycodeConversion, KeycodeConversionOff); - /* +#ifdef X2GO + /* * when cloning we do not want X2Go to set the keyboard * via a keyboard file generated by nxagent. The defined * method for switching that off is the creation of a dir @@ -692,6 +693,7 @@ XkbError: { nxagentWriteKeyboardFile(nxagentRemoteRules, nxagentRemoteModel, nxagentRemoteLayout, nxagentRemoteVariant, nxagentRemoteOptions); } +#endif } nxagentKeycodeConversionSetup(); } diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c index aff2e56ab..5196e28b7 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -35,7 +35,7 @@ #include "Options.h" #include "Keyboard.h" #include "Drawable.h" -#include "Init.h" /* extern int nxagentX2go */ +#include "Init.h" /* extern Bool nxagentX2go */ #include "Utils.h" #include <unistd.h> @@ -314,11 +314,15 @@ void nxagentInitKeystrokes(Bool force) done = True; +#ifdef X2GO if (nxagentX2go) { homefile = "/.x2go/config/keystrokes.cfg"; etcfile = "/etc/x2go/keystrokes.cfg"; envvar = "X2GO_KEYSTROKEFILE"; - } else { + } + else +#endif + { homefile = "/.nx/config/keystrokes.cfg"; etcfile = "/etc/nxagent/keystrokes.cfg"; envvar = "NXAGENT_KEYSTROKEFILE"; diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXrender.c b/nx-X11/programs/Xserver/hw/nxagent/NXrender.c index 5851eb05c..eed64f808 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXrender.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXrender.c @@ -123,7 +123,7 @@ extern void nxagentRenderCreateConicalGradient(PicturePtr pPicture, xRenderColor *colors); #ifdef NXAGENT_SERVER -extern int nxagentAlphaEnabled; +extern Bool nxagentAlphaEnabled; #endif /* diff --git a/nx-X11/programs/Xserver/hw/nxagent/Options.c b/nx-X11/programs/Xserver/hw/nxagent/Options.c index afc6899e3..be6e5d5e1 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Options.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Options.c @@ -129,7 +129,7 @@ void nxagentInitOptions(void) nxagentOptions.DisplayBuffer = UNDEFINED; nxagentOptions.DisplayCoalescence = 0; - nxagentOptions.Composite = True; + nxagentOptions.Composite = False; nxagentOptions.IgnoreVisibility = False; diff --git a/nx-X11/programs/Xserver/hw/nxagent/Pixels.h b/nx-X11/programs/Xserver/hw/nxagent/Pixels.h index cf5e50c04..f2b43b0fc 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Pixels.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Pixels.h @@ -174,7 +174,7 @@ FIXME: Changed macro: NXAGENT_SHOULD_DEFER_COMPOSITE #define NXAGENT_SHOULD_SYNCHRONIZE_WINDOW(pDrawable) \ (nxagentWindowIsVisible((WindowPtr) pDrawable) && \ - (nxagentDefaultWindowIsVisible() || nxagentCompositeEnable == 1)) + (nxagentDefaultWindowIsVisible() || nxagentCompositeEnable)) #define MINIMUM_PIXMAP_USAGE_COUNTER 2 diff --git a/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c b/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c index e6d3ce6ec..58c1fc4e2 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c @@ -503,12 +503,14 @@ Bool nxagentReconnectSession(void) nxagentMapDefaultWindows(); +#ifdef NXAGENT_ONSTART /* * Ensure that the SetSelectionOwner request is sent through the * link. */ XFlush(nxagentDisplay); +#endif NXTransContinue(NULL); diff --git a/nx-X11/programs/Xserver/hw/nxagent/Render.c b/nx-X11/programs/Xserver/hw/nxagent/Render.c index 98d7aef67..205940ed7 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Render.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Render.c @@ -703,7 +703,7 @@ int nxagentCreatePicture(PicturePtr pPicture, Mask mask) nxagentPicturePriv(pPicture) -> picture = id; - if (nxagentAlphaEnabled == 1 && pPicture -> pDrawable->depth == 32 && + if (nxagentAlphaEnabled && pPicture -> pDrawable -> depth == 32 && pPicture -> pFormat -> direct.alpha != 0) { if (pPicture -> pDrawable -> type == DRAWABLE_PIXMAP) @@ -2431,7 +2431,7 @@ void nxagentReconnectPicture(void * p0, XID x1, void *p2) (void *) pPicture, nxagentPicture(pPicture)); #endif - if (nxagentAlphaEnabled == 1 && pPicture -> pDrawable -> depth == 32 && + if (nxagentAlphaEnabled && pPicture -> pDrawable -> depth == 32 && pPicture -> pFormat -> direct.alpha != 0) { if (pPicture -> pDrawable -> type == DRAWABLE_PIXMAP) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index b87c1e225..31b8b68a3 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -1616,7 +1616,7 @@ N/A pScreen->ClearBackingStore = (RegionPtr (*)()) 0; pScreen->DrawGuarantee = (void (*)()) 0; - if (enableBackingStore == 1) + if (enableBackingStore) { #ifdef TEST fprintf(stderr, "nxagentOpenScreen: Going to initialize backing store.\n"); @@ -1814,11 +1814,13 @@ N/A #endif } +#ifdef X2GO /* * Setting WM_CLASS to "X2GoAgent" when running in X2Go Agent mode * we need it to properly display all window parameters by some WMs * (for example on Maemo) */ +#endif { #ifdef TEST fprintf(stderr, "nxagentOpenScreen: Setting WM_CLASS and WM_NAME for window with id [%ld].\n", @@ -1827,12 +1829,14 @@ N/A XClassHint hint; - if(nxagentX2go) +#ifdef X2GO + if (nxagentX2go) { hint.res_name = strdup("X2GoAgent"); hint.res_class = strdup("X2GoAgent"); } else +#endif { hint.res_name = strdup("NXAgent"); hint.res_class = strdup("NXAgent"); @@ -1850,6 +1854,7 @@ N/A if (nxagentOption(Fullscreen)) { +#ifdef NXAGENT_ONSTART /* * FIXME: Do we still need to set this property? */ @@ -1865,6 +1870,7 @@ N/A (unsigned char*) "X-AGENT", strlen("X-AGENT")); } +#endif XSelectInput(nxagentDisplay, nxagentFullscreenWindow, nxagentGetDefaultEventMask()); } diff --git a/nx-X11/programs/Xserver/hw/nxagent/Splash.c b/nx-X11/programs/Xserver/hw/nxagent/Splash.c index 37f965f04..d28a96df1 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Splash.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Splash.c @@ -48,6 +48,12 @@ #undef TEST #undef DEBUG +#ifndef X2GO +void nxagentShowSplashWindow(XlibWindow parentWindow) {} +void nxagentPaintLogo(XlibWindow win, int scale, int width, int height) {} +void nxagentRemoveSplashWindow(void) {} +Bool nxagentHaveSplashWindow(void) {return False;} +#else /* * Colors used to paint the splash screen. */ @@ -68,7 +74,7 @@ void nxagentShowSplashWindow(XlibWindow parentWindow) /* * Show splash window only when running as X2Go Agent */ - if(!nxagentX2go) + if (!nxagentX2go) return; #ifdef TEST @@ -344,6 +350,7 @@ void nxagentRemoveSplashWindow(void) nxagentSplashWindow = None; nxagentRefreshWindows(screenInfo.screens[0]->root); +#ifdef NXAGENT_ONSTART #ifdef TEST fprintf(stderr, "%s: setting the ownership of %s (%d) on window [0x%lx]\n", __func__, "NX_CUT_BUFFER_SERVER", (int)serverTransToAgentProperty, nxagentWindow(screenInfo.screens[0]->root)); @@ -351,6 +358,7 @@ void nxagentRemoveSplashWindow(void) XSetSelectionOwner(nxagentDisplay, serverTransToAgentProperty, nxagentWindow(screenInfo.screens[0]->root), CurrentTime); +#endif } if (nxagentPixmapLogo) @@ -359,3 +367,4 @@ void nxagentRemoveSplashWindow(void) nxagentPixmapLogo = (XlibPixmap) 0; } } +#endif /* ifdef X2GO */ diff --git a/nx-X11/programs/Xserver/hw/nxagent/Trap.h b/nx-X11/programs/Xserver/hw/nxagent/Trap.h index 4203d2b13..1c10f00ea 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Trap.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Trap.h @@ -26,6 +26,8 @@ #ifndef __Traps_H__ #define __Traps_H__ +#include <nx-X11/Xdefs.h> + #ifndef False #define False 0 #endif @@ -38,72 +40,72 @@ * Set if we are dispatching a render extension request. Used to avoid * reentrancy in GC operations. */ -extern int nxagentGCTrap; +extern Bool nxagentGCTrap; /* * Set if we are enqueing an internal operation, CreateWindow and * Reparent- Window. Used to remove any screen operation. */ -extern int nxagentScreenTrap; +extern Bool nxagentScreenTrap; /* * Set if we are executing a GC operation only on the X side. Used to * avoid reentrancy in FB layer. */ -extern int nxagentFBTrap; +extern Bool nxagentFBTrap; /* * Set if we are dispatching a shared memory extension request. */ -extern int nxagentShmTrap; +extern Bool nxagentShmTrap; /* * Set if a shared pixmap operation is requested by the client. */ -extern int nxagentShmPixmapTrap; +extern Bool nxagentShmPixmapTrap; /* * Set if we are dispatching a XVideo extension request. */ -extern int nxagentXvTrap; +extern Bool nxagentXvTrap; /* * Set if we are dispatching a GLX extension request. */ -extern int nxagentGlxTrap; +extern Bool nxagentGlxTrap; /* * Set while we are resuming the session. */ -extern int nxagentReconnectTrap; +extern Bool nxagentReconnectTrap; /* * Set if we need to realize a drawable by using a lossless encoding. */ -extern int nxagentLosslessTrap; +extern Bool nxagentLosslessTrap; /* * Set to force the synchronization of a drawable. */ -extern int nxagentSplitTrap; +extern Bool nxagentSplitTrap; /* * Set to avoid CapsLock synchronization problems when CapsLock is the * first key to be pressed in the session. */ -extern int nxagentXkbCapsTrap; +extern Bool nxagentXkbCapsTrap; /* * Set to avoid NumLock synchronization problems when NumLock is the * first key to be pressed in the session. */ -extern int nxagentXkbNumTrap; +extern Bool nxagentXkbNumTrap; /* * Set to indicate we are processing a clipboard event triggered by * the real X server. This is used to avoid endless loops if callbacks * would trigger another event by the real X server */ -extern int nxagentExternalClipboardEventTrap; +extern Bool nxagentExternalClipboardEventTrap; #endif /* __Trap_H__ */ diff --git a/nx-X11/programs/Xserver/hw/nxagent/Window.c b/nx-X11/programs/Xserver/hw/nxagent/Window.c index 5f12fd48a..6f98ee57b 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Window.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Window.c @@ -471,13 +471,8 @@ Bool nxagentCreateWindow(WindowPtr pWin) } #ifdef SHAPE - #ifdef NXAGENT_SHAPE2 - nxagentWindowPriv(pWin)->boundingShape = NULL; - nxagentWindowPriv(pWin)->clipShape = NULL; - #else - nxagentWindowPriv(pWin)->boundingShape = RegionCreate(NULL, 1); - nxagentWindowPriv(pWin)->clipShape = RegionCreate(NULL, 1); - #endif + nxagentWindowPriv(pWin)->boundingShape = NULL; + nxagentWindowPriv(pWin)->clipShape = NULL; #endif /* SHAPE */ fbCreateWindow(pWin); @@ -583,21 +578,16 @@ Bool nxagentDestroyWindow(WindowPtr pWin) pWindowPriv->siblingAbove; } - #ifdef NXAGENT_SHAPE2 - #ifdef SHAPE - if (pWindowPriv->boundingShape) - { - RegionDestroy(pWindowPriv->boundingShape); - } - - if (pWindowPriv->clipShape) - { - RegionDestroy(pWindowPriv->clipShape); - } - #endif - #else + #ifdef SHAPE + if (pWindowPriv->boundingShape) + { RegionDestroy(pWindowPriv->boundingShape); + } + + if (pWindowPriv->clipShape) + { RegionDestroy(pWindowPriv->clipShape); + } #endif if (pWindowPriv -> corruptedRegion) @@ -2079,13 +2069,11 @@ void nxagentClipNotify(WindowPtr pWin, int dx, int dy) nxagentAddConfiguredWindow(pWin, CWStackMode); nxagentAddConfiguredWindow(pWin, CW_Shape); - #ifndef NXAGENT_SHAPE - #ifdef SHAPE - /* - * nxagentShapeWindow(pWin); - */ - #endif /* SHAPE */ - #endif /* NXAGENT_SHAPE */ + #ifdef SHAPE + /* + * nxagentShapeWindow(pWin); + */ + #endif /* SHAPE */ } /* @@ -2354,12 +2342,10 @@ void nxagentShapeWindow(WindowPtr pWin) RegionNumRects(wBoundingShape(pWin))); #endif - #ifdef NXAGENT_SHAPE2 if (!nxagentWindowPriv(pWin)->boundingShape) { nxagentWindowPriv(pWin)->boundingShape = RegionCreate(NULL, 1); } - #endif RegionCopy(nxagentWindowPriv(pWin)->boundingShape, wBoundingShape(pWin)); @@ -2378,10 +2364,8 @@ void nxagentShapeWindow(WindowPtr pWin) XUnionRectWithRegion(&rect, reg, reg); } - #ifndef NXAGENT_SHAPE XShapeCombineRegion(nxagentDisplay, nxagentWindow(pWin), ShapeBounding, 0, 0, reg, ShapeSet); - #endif XDestroyRegion(reg); } @@ -2393,10 +2377,8 @@ void nxagentShapeWindow(WindowPtr pWin) RegionEmpty(nxagentWindowPriv(pWin)->boundingShape); - #ifndef NXAGENT_SHAPE XShapeCombineMask(nxagentDisplay, nxagentWindow(pWin), ShapeBounding, 0, 0, None, ShapeSet); - #endif } } @@ -2413,12 +2395,10 @@ void nxagentShapeWindow(WindowPtr pWin) RegionNumRects(wClipShape(pWin))); #endif - #ifdef NXAGENT_SHAPE2 if (!nxagentWindowPriv(pWin)->clipShape) { nxagentWindowPriv(pWin)->clipShape = RegionCreate(NULL, 1); } - #endif RegionCopy(nxagentWindowPriv(pWin)->clipShape, wClipShape(pWin)); @@ -2437,10 +2417,8 @@ void nxagentShapeWindow(WindowPtr pWin) XUnionRectWithRegion(&rect, reg, reg); } - #ifndef NXAGENT_SHAPE XShapeCombineRegion(nxagentDisplay, nxagentWindow(pWin), ShapeClip, 0, 0, reg, ShapeSet); - #endif XDestroyRegion(reg); } @@ -2452,10 +2430,8 @@ void nxagentShapeWindow(WindowPtr pWin) RegionEmpty(nxagentWindowPriv(pWin)->clipShape); - #ifndef NXAGENT_SHAPE XShapeCombineMask(nxagentDisplay, nxagentWindow(pWin), ShapeClip, 0, 0, None, ShapeSet); - #endif } } } @@ -2575,12 +2551,14 @@ void nxagentMapDefaultWindows(void) } } +#ifdef NXAGENT_ONSTART /* * Send a SetSelectionOwner request to notify of the agent start. */ XSetSelectionOwner(nxagentDisplay, serverTransToAgentProperty, nxagentDefaultWindows[i], CurrentTime); +#endif } /* 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 diff --git a/nx-X11/programs/Xserver/hw/nxagent/man/nxagent.1 b/nx-X11/programs/Xserver/hw/nxagent/man/nxagent.1 index 2a83a5afb..74349cda7 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/man/nxagent.1 +++ b/nx-X11/programs/Xserver/hw/nxagent/man/nxagent.1 @@ -459,6 +459,9 @@ The nx-X11 system adds the following command line arguments: .B \-forcenx force use of NX protocol messages assuming communication through \fBnxproxy\fR .TP 8 +.B \-id \fIstring\fP +The session id. +.TP 8 .B \-autograb enable autograb mode on \fBnxagent\fR startup. The autograb feature can be toggled via nxagent keystrokes .TP 8 @@ -503,8 +506,8 @@ nx/nx option on session resumption .B \-norender disable the use of the render extension .TP 8 -.B \-nocomposite -disable the use of the composite extension +.B \-nocomposite/-composite +disable/enable the use of the composite extension (default ist disabled) .TP 8 .B \-nopersistent disable disconnection/reconnection to the X display on @@ -740,6 +743,9 @@ enable/disable shared pixmaps support. Accepted values: \fI1\fR (enable, default type of connecting operating system (supported: \fIlinux\fR, \fIwindows\fR, \fIsolaris\fR and \fImacosx\fR) .TP 8 +.B clients=<string> +filename where to log output of the nxagent's clients. This is ignored if no session id has been provided. It then points to stderr. Default: <sessiondir>/clients. +.TP 8 .B shadow=<string> define the display that should be shadowed .TP 8 @@ -749,6 +755,9 @@ unique identifier for the shadow session .B shadowmode=<bool> full access (set to \fI1\fR) or viewing-only (set to \fI0\fR, default) .TP 8 +.B state=<string> +filename where to store the state of the nxagent (for easier interoperation with software like x2go. Default: sessiondir/state. +.TP 8 .B defer=<int> defer image updates (enabled for all connection types except LAN), accepts values \fI0\fR, \fI1\fR and \fI2\fR diff --git a/nx-X11/programs/Xserver/os/utils.c b/nx-X11/programs/Xserver/os/utils.c index 853a33736..c788fae01 100644 --- a/nx-X11/programs/Xserver/os/utils.c +++ b/nx-X11/programs/Xserver/os/utils.c @@ -146,9 +146,7 @@ Bool noTestExtensions; Bool noBigReqExtension = FALSE; #endif #ifdef COMPOSITE -/* COMPOSITE is disabled by default for now until the - * interface is stable */ -Bool noCompositeExtension = TRUE; +Bool noCompositeExtension = FALSE; #endif #ifdef DAMAGE Bool noDamageExtension = FALSE; |