diff options
Diffstat (limited to 'nx-X11/programs/Xserver/hw')
20 files changed, 451 insertions, 659 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Atoms.c b/nx-X11/programs/Xserver/hw/nxagent/Atoms.c index 4e9b7fb1f..af6260d15 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Atoms.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Atoms.c @@ -75,26 +75,61 @@ Atom nxagentAtoms[NXAGENT_NUMBER_OF_ATOMS]; static char *nxagentAtomNames[NXAGENT_NUMBER_OF_ATOMS + 1] = { - "NX_IDENTITY", /* 0 */ - "WM_PROTOCOLS", /* 1 */ - "WM_DELETE_WINDOW", /* 2 */ - "WM_NX_READY", /* 3 */ - "MCOPGLOBALS", /* 4 */ - "NX_CUT_BUFFER_SERVER", /* 5 */ - /* Unfortunately we cannot rename this to NX_SELTRANS_TO_AGENT + "NX_IDENTITY", /* 0 */ + /* NX_IDENTITY was used in earlier nx versions to communicate + the version to NXwin. Got dropped between nxagent 1.5.0-45 + and 1.5.0-112. */ + "WM_PROTOCOLS", /* 1 */ + /* standard ICCCM Atom */ + "WM_DELETE_WINDOW", /* 2 */ + /* standard ICCCM Atom */ + "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. */ + "MCOPGLOBALS", /* 4 */ + /* used for artsd support. */ + "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 + content from clients of the real X server to nxagent's clients + + Unfortunately we cannot rename this to NX_SELTRANS_TO_AGENT because nomachine's nxclient is depending on this selection */ - "TARGETS", /* 6 */ - "TEXT", /* 7 */ - "NX_AGENT_SIGNATURE", /* 8 */ - "NXDARWIN", /* 9 */ + + "TARGETS", /* 6 */ + /* used to request a list of supported data formats from the + selection owner. Standard ICCCM Atom */ + "TEXT", /* 7 */ + /* one of the supported data formats for selections. Standard + ICCCM Atom */ + "NX_AGENT_SIGNATURE", /* 8 */ + /* this is used to set a property on nxagent's window if nxagent + is started with the fullscreen option set. Unsure, what this + is used for. */ + "NXDARWIN", /* 9 */ + /* this was an Atom in nxdarwin, nomachine's X server for MacOS. */ "CLIPBOARD", /* 10 */ + /* Atom for the clipboard selection. PRIMARY is fixed in X11 but + CLIPBOARD is not. Standard ICCCM Atom. */ "TIMESTAMP", /* 11 */ + /* used to request the time a selection has been owned. Standard + ICCCM Atom */ "UTF8_STRING", /* 12 */ + /* one of the supported data formats for selections. Standard + ICCCM Atom */ "_NET_WM_STATE", /* 13 */ + /* standard ICCCM Atom */ "_NET_WM_STATE_FULLSCREEN", /* 14 */ + /* standard ICCCM Atom */ "NX_SELTRANS_FROM_AGENT", /* 15 */ + /* this is the name of a property on nxagent's window on the real + X server. This property is used for passing clipboard content + from nxagent's clients to clients on the real X server */ "COMPOUND_TEXT", /* 16 */ + /* one of the supported data formats for selections. Standard + ICCCM Atom */ NULL, NULL }; diff --git a/nx-X11/programs/Xserver/hw/nxagent/Display.c b/nx-X11/programs/Xserver/hw/nxagent/Display.c index a93fd2418..dad6bfb2b 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Display.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Display.c @@ -561,11 +561,6 @@ static void nxagentSigchldHandler(int signal) Display *nxagentInternalOpenDisplay(char *display) { - struct sigaction oldAction; - struct sigaction newAction; - - int result; - /* * Stop the smart schedule timer since it uses SIGALRM as we do. */ @@ -583,12 +578,17 @@ FIXME: Should print a warning if the user tries to let the agent explanation for the error to the user. */ - newAction.sa_handler = nxagentRejectConnection; + struct sigaction newAction = { + .sa_handler = nxagentRejectConnection + }; sigfillset(&newAction.sa_mask); newAction.sa_flags = 0; + int result; + struct sigaction oldAction; + while (((result = sigaction(SIGALRM, &newAction, &oldAction)) == -1) && (errno == EINTR)); @@ -754,6 +754,20 @@ static void nxagentDisplayFlushHandler(Display *display, int length) } } +/* + * From the changelog for nx-X11-3.0.0-4: + * "Added the _NXDisplayErrorPredicate function in XlibInt.c. It is + * actually a pointer to a function called whenever Xlib is going to + * perform a network operation. If the function returns true, the + * call will be aborted and Xlib will return the control to the ap- + * plication. It is up to the application to set the XlibDisplayIO- + * Error flag after the _NXDisplayErrorPredicate returns true. The + * function can be used to activate additional checks, besides the + * normal failures detected by Xlib on the display socket. For exam- + * ple, the application can set the funciton to verify if an inter- + * rupt was received or if any other event occurred mandating the + + end of the session." + */ static int nxagentDisplayErrorPredicate(Display *display, int error) { #ifdef TEST @@ -925,8 +939,6 @@ void nxagentInstallSignalHandlers(void) struct sigaction newAction; - int result; - /* * By default nxcomp installs its signal handlers. We need to * ensure that SIGUSR1 and SIGUSR2 are ignored if the NX transport @@ -939,6 +951,8 @@ void nxagentInstallSignalHandlers(void) newAction.sa_flags = 0; + int result; + while (((result = sigaction(SIGUSR1, &newAction, NULL)) == -1) && (errno == EINTR)); @@ -1054,12 +1068,6 @@ void nxagentPostInstallSignalHandlers(void) void nxagentResetSignalHandlers(void) { - struct sigaction newAction; - - int result; - - memset(&newAction, 0, sizeof(newAction)); - /* * Reset the signal handlers to a well known state. */ @@ -1074,10 +1082,13 @@ void nxagentResetSignalHandlers(void) nxagentStopTimer(); - newAction.sa_handler = SIG_DFL; + struct sigaction newAction = { + .sa_handler = SIG_DFL + }; sigfillset(&newAction.sa_mask); + int result; while (((result = sigaction(SIGALRM, &newAction, NULL)) == -1) && (errno == EINTR)); @@ -1091,7 +1102,6 @@ void nxagentResetSignalHandlers(void) */ nxagentInitTimer(); - } void nxagentOpenDisplay(int argc, char *argv[]) @@ -1100,12 +1110,9 @@ void nxagentOpenDisplay(int argc, char *argv[]) return; #ifdef NXAGENT_TIMESTAMP - startTime = GetTimeInMillis(); - fprintf(stderr, "Display: Opening the display on real X server with time [%d] ms.\n", GetTimeInMillis() - startTime); - #endif /* @@ -1175,10 +1182,8 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio #endif #ifdef NXAGENT_TIMESTAMP - fprintf(stderr, "Display: Display on real X server opened with time [%d] ms.\n", GetTimeInMillis() - startTime); - #endif nxagentUseNXTrans = @@ -1397,10 +1402,8 @@ N/A #endif #ifdef NXAGENT_TIMESTAMP - fprintf(stderr, "Display: Open of the display finished with time [%d] ms.\n", GetTimeInMillis() - startTime); - #endif if (nxagentOption(Persistent)) @@ -1435,10 +1438,11 @@ void nxagentSetDefaultVisual(void) } else { - XVisualInfo vi = {0}; + XVisualInfo vi = { + .visualid = XVisualIDFromVisual(DefaultVisual(nxagentDisplay, + DefaultScreen(nxagentDisplay))) + }; - vi.visualid = XVisualIDFromVisual(DefaultVisual(nxagentDisplay, - DefaultScreen(nxagentDisplay))); nxagentDefaultVisualIndex = 0; for (int i = 0; i < nxagentNumVisuals; i++) @@ -1453,14 +1457,13 @@ void nxagentSetDefaultVisual(void) void nxagentInitVisuals(void) { + long mask = VisualScreenMask; XVisualInfo vi = { .screen = DefaultScreen(nxagentDisplay), - .depth = DefaultDepth(nxagentDisplay, DefaultScreen(nxagentDisplay)), + .depth = DefaultDepth(nxagentDisplay, DefaultScreen(nxagentDisplay)) }; - long mask = VisualScreenMask; int viNumList; XVisualInfo *viList = XGetVisualInfo(nxagentDisplay, mask, &vi, &viNumList); - nxagentVisuals = (XVisualInfo *) malloc(viNumList * sizeof(XVisualInfo)); nxagentNumVisuals = 0; @@ -1566,7 +1569,6 @@ XXX: Some X server doesn't list 1 among available depths... if (nxagentDepths[j] == i) { depth = i; - break; } } @@ -1744,7 +1746,6 @@ FIXME: Is this needed? nxagentDisplay = NULL; } - Bool nxagentMakeIcon(Display *display, Pixmap *nxIcon, Pixmap *nxMask) { char** agentIconData; @@ -1752,7 +1753,7 @@ Bool nxagentMakeIcon(Display *display, Pixmap *nxIcon, Pixmap *nxMask) /* * selecting x2go icon when running as X2Go agent */ - if(nxagentX2go) + if (nxagentX2go) { agentIconData = x2goagentIconData; } @@ -1778,8 +1779,7 @@ Bool nxagentMakeIcon(Display *display, Pixmap *nxIcon, Pixmap *nxMask) else { #ifdef TEST - fprintf(stderr, "%s: Xpm operation failed with error '%s'.\n", __func__, - XpmGetErrorString(status)); + fprintf(stderr, "%s: Xpm operation failed.\n", __func__); #endif return False; @@ -1911,14 +1911,15 @@ static int nxagentCheckForDefaultDepthCompatibility(void) /* * Depending on the (reconnect) tolerance checks value, this * function checks stricter or looser: - * - Strict means that the old and new default depth values must - * match exactly. - * - Safe or Risky means that the default depth values might - * differ, but the new default depth value must be at least as - * high as the former default depth value. This is recommended, - * because it allows clients with a higher default depth value - * to still connect, but not lose functionality. - * - Bypass means that all of these checks are essentially + * - "Strict" means that the old and new default depth values + * must match exactly. + * - "Safe" or "Risky" means that the default depth values might differ, + * but the new default depth value must be at least as + * high as the former default depth value. This is + * recommended, because it allows clients with a + * higher default depth value to still connect, but + * not lose functionality. + * - "Bypass" means that all of these checks are essentially * deactivated. This is probably a very bad idea. */ @@ -1970,17 +1971,19 @@ static int nxagentCheckForDepthsCompatibility(void) /* * Depending on the (reconnect) tolerance checks value, this * function checks stricter or looser: - * - Strict means that the number of old and new depths must match - * exactly and every old depth value must be available in the - * new depth array. - * - Safe means that the number of depths might diverge, but all - * former depth must also be included in the new depth - * array. This is recommended, because it allows clients with - * more depths to still connect, but not lose functionality. - * - Risky means that the new depths array is allowed to be - * smaller than the old depths array, but at least one depth - * value must be included in both. This is potentially unsafe. - * - Bypass or higher means that all of these checks are + * - "Strict" means that the number of old and new depths must + * match exactly and every old depth value must be + * available in the new depth array. + * - "Safe" means that the number of depths might diverge, + * but all former depth must also be included in the + * new depth array. This is recommended, because + * it allows clients with more depths to still + * connect, but not lose functionality. + * - "Risky" means that the new depths array is allowed to be + * smaller than the old depths array, but at least + * one depth value must be included in both. + * This is potentially unsafe. + * - "Bypass" or higher means that all of these checks are * essentially deactivated. This is a very bad idea. */ @@ -2021,12 +2024,12 @@ static int nxagentCheckForDepthsCompatibility(void) /* * By now the tolerance is either: - * - Strict and both depth numbers match - * - Safe and: + * - "Strict" and both depth numbers match + * - "Safe" and: * o the number of old and new depths matches exactly, or * o the number of old depths is lower than the number * of new depths - * - Risky + * - "Risky" */ bool compatible = true; @@ -2122,19 +2125,21 @@ static int nxagentCheckForPixmapFormatsCompatibility(void) /* * Depending on the (reconnect) tolerance checks value, this * function checks stricter or looser: - * - Strict means that the number of internal and external pixmap - * formats must match exactly and every internal pixmap format - * must be available in the external pixmap format array. - * - Safe means that the number of pixmap formats might diverge, - * but all internal pixmap formats must also be included in the - * external pixmap formats array. This is recommended, because - * it allows clients with more pixmap formats to still connect, + * - "Strict" means that the number of internal and external + * pixmap formats must match exactly and every + * internal pixmap format must be available in the + * external pixmap format array. + * - "Safe" means that the number of pixmap formats might + * diverge, but all internal pixmap formats must + * also be included in the external pixmap formats + * array. This is recommended, because it allows + * clients with more pixmap formats to still connect, * but not lose functionality. - * - Risky means that the internal pixmap formats array is allowed - * to be smaller than the external pixmap formats array, but at - * least one pixmap format must be included in both. This is - * potentially unsafe. - * - Bypass or higher means that all of these checks are + * - "Risky" means that the internal pixmap formats array is + * allowed to be smaller than the external pixmap + * formats array, but at least one pixmap format must + * be included in both. This is potentially unsafe. + * - "Bypass" or higher means that all of these checks are * essentially deactivated. This is a very bad idea. */ @@ -2173,13 +2178,13 @@ static int nxagentCheckForPixmapFormatsCompatibility(void) /* * By now the tolerance is either: - * - Strict - * - Safe and: + * - "Strict" + * - "Safe" and: * o the number of internal and external pixmap formats * matches exactly, or * o the number of external pixmap formats is higher than * the number of internal pixmap formats, - * - Risky + * - "Risky" */ bool compatible = true; @@ -2250,6 +2255,9 @@ static int nxagentInitAndCheckVisuals(int flexibility) { /* FIXME: does this also need work? */ + bool matched; + bool compatible = true; + long viMask = VisualScreenMask; XVisualInfo viTemplate = { .screen = DefaultScreen(nxagentDisplay), @@ -2260,8 +2268,6 @@ static int nxagentInitAndCheckVisuals(int flexibility) XVisualInfo *newVisuals = malloc(sizeof(XVisualInfo) * nxagentNumVisuals); - bool compatible = true; - for (int i = 0; i < nxagentNumVisuals; i++) { bool matched = false; @@ -2473,7 +2479,7 @@ Bool nxagentReconnectDisplay(void *p0) nxagentNumDefaultColormaps = nxagentNumVisuals; nxagentDefaultColormaps = (Colormap *) realloc(nxagentDefaultColormaps, - nxagentNumDefaultColormaps * sizeof(Colormap)); + nxagentNumDefaultColormaps * sizeof(Colormap)); if (nxagentDefaultColormaps == NULL) { @@ -2603,7 +2609,7 @@ Bool nxagentReconnectDisplay(void *p0) useXpmIcon = nxagentMakeIcon(nxagentDisplay, &nxagentIconPixmap, &nxagentIconShape); /* - * All went fine. We can continue handling our clients. + * Everything went fine. We can continue handling our clients. */ reconnectDisplayState = EVERYTHING_DONE; diff --git a/nx-X11/programs/Xserver/hw/nxagent/Error.c b/nx-X11/programs/Xserver/hw/nxagent/Error.c index ab8da2db4..add5fae85 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Error.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Error.c @@ -114,10 +114,11 @@ int nxagentErrorHandler(Display *dpy, XErrorEvent *event) return 0; } -/* copied from XlibInt.c */ -/* extension stuff roughly commented out */ -/* FIXME: why? What's wrong with printing extension stuff? - We could drop this in favour of _XprintDefaultError then! */ +/* copied from XlibInt.c:_XprintDefaultError + * We cannot use the whole function because it requires XlibInt + * internals. And we cannot call _XPrintDefaultError because it + * is not exported. + */ static int nxagentPrintError(dpy, event, fp) Display *dpy; XErrorEvent *event; @@ -126,11 +127,11 @@ static int nxagentPrintError(dpy, event, fp) char buffer[BUFSIZ]; char mesg[BUFSIZ]; char number[32]; - char *mtype = "XlibMessage"; - /* + const char *mtype = "XlibMessage"; +#ifndef NXAGENT_SERVER register _XExtension *ext = (_XExtension *)NULL; _XExtension *bext = (_XExtension *)NULL; - */ +#endif XGetErrorText(dpy, event->error_code, buffer, BUFSIZ); XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ); (void) fprintf(fp, "%s: %s\n ", mesg, buffer); @@ -141,14 +142,16 @@ static int nxagentPrintError(dpy, event, fp) snprintf(number, sizeof(number), "%d", event->request_code); XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ); } else { - /* for (ext = dpy->ext_procs; +#ifndef NXAGENT_SERVER + for (ext = dpy->ext_procs; ext && (ext->codes.major_opcode != event->request_code); ext = ext->next) ; - if (ext) + if (ext) { strncpy(buffer, ext->name, BUFSIZ); - else - */ + buffer[BUFSIZ - 1] = '\0'; + } else +#endif buffer[0] = '\0'; } (void) fprintf(fp, " (%s)\n", buffer); @@ -157,19 +160,19 @@ static int nxagentPrintError(dpy, event, fp) 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); } - */ +#endif fputs("\n", fp); } if (event->error_code >= 128) { /* 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, @@ -187,7 +190,7 @@ static int nxagentPrintError(dpy, event, fp) 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]) { @@ -196,12 +199,12 @@ static int nxagentPrintError(dpy, event, fp) 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); } - */ +#endif } else if ((event->error_code == BadWindow) || (event->error_code == BadPixmap) || (event->error_code == BadCursor) || @@ -229,10 +232,12 @@ static int nxagentPrintError(dpy, event, fp) mesg, BUFSIZ); fputs(" ", fp); (void) fprintf(fp, mesg, event->serial); - /* XGetErrorDatabaseText(dpy, mtype, "CurrentSerial", "Current Serial #%d", +#ifndef NXAGENT_SERVER + XGetErrorDatabaseText(dpy, mtype, "CurrentSerial", "Current Serial #%d", mesg, BUFSIZ); fputs("\n ", fp); - (void) fprintf(fp, mesg, dpy->request); */ + (void) fprintf(fp, mesg, (unsigned long long)(X_DPY_GET_REQUEST(dpy))); +#endif fputs("\n", fp); if (event->error_code == BadImplementation) return 0; return 1; diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c index b9d3a9238..597359cf1 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Events.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c @@ -2197,7 +2197,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already { if (nxagentOption(AllScreens) == 0 && nxagentOption(Fullscreen) == 1) { - nxagentSwitchFullscreen(pScreen, 0); + nxagentSwitchFullscreen(pScreen, False); } else { @@ -2578,11 +2578,6 @@ int nxagentHandleClientMessageEvent(XEvent *X, enum HandleEventResult *result) { *result = doNothing; - #ifdef TEST - fprintf(stderr, "%s: ClientMessage event window [%ld] with type [%ld] format [%d].\n", - __func__, X -> xclient.window, X -> xclient.message_type, X -> xclient.format); - #endif - /* * If window is 0, message_type is 0 and format is 32 then we assume * event is coming from proxy. @@ -2592,11 +2587,25 @@ int nxagentHandleClientMessageEvent(XEvent *X, enum HandleEventResult *result) X -> xclient.message_type == 0 && X -> xclient.format == 32) { + #ifdef TEST + fprintf(stderr, "%s: got nxproxy event\n", __func__); + #endif nxagentHandleProxyEvent(X); return 1; } + #ifdef TEST + char * name = XGetAtomName(nxagentDisplay, X -> xclient.message_type); + fprintf(stderr, "nxagentHandleClientMessageEvent: ClientMessage event window [0x%lx] with " + "message_type [%ld][%s] format [%d] type [%d] source_indication [%ld][%s] timestamp [%ld] " + "curwin [0x%lx].\n", X -> xclient.window, X -> xclient.message_type, name, + X -> xclient.format, X -> xclient.type, X -> xclient.data.l[0], + X -> xclient.data.l[0] == 1 ? "'application'" : X -> xclient.data.l[0] == 1 ? "'pager'" : "'none (old spec)'", + X -> xclient.data.l[1], X -> xclient.data.l[2]); + SAFE_XFree(name); + #endif + if (nxagentOption(Rootless)) { Atom message_type = nxagentRemoteToLocalAtom(X -> xclient.message_type); @@ -2611,11 +2620,20 @@ int nxagentHandleClientMessageEvent(XEvent *X, enum HandleEventResult *result) } WindowPtr pWin = nxagentWindowPtr(X -> xclient.window); - if (pWin == NULL) { + /* + * If some window on the real X server sends a + * _NET_ACTIVE_WINDOW ClientMessage to indicate the active + * window that window will be one not belonging to nxagent so + * this situation is perfectly legal. For all other situations + * we print a warning. + */ #ifdef WARNING - fprintf(stderr, "WARNING: Invalid window in ClientMessage.\n"); + if (message_type != MakeAtom("_NET_ACTIVE_WINDOW", strlen("_NET_ACTIVE_WINDOW"), False)) + { + fprintf(stderr, "WARNING: Invalid window in ClientMessage xclient.window [0x%lx].\n", X->xclient.window); + } #endif return 0; diff --git a/nx-X11/programs/Xserver/hw/nxagent/Font.c b/nx-X11/programs/Xserver/hw/nxagent/Font.c index 93fb93295..ddae19cf0 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Font.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Font.c @@ -469,9 +469,6 @@ Bool nxagentRealizeFont(ScreenPtr pScreen, FontPtr pFont) FontSetPrivate(pFont, nxagentFontPrivateIndex, NULL); #endif /* HAS_XFONT2 */ - if (requestingClient && XpClientIsPrintClient(requestingClient, NULL)) - return True; - name_atom = MakeAtom("FONT", 4, True); value_atom = 0L; diff --git a/nx-X11/programs/Xserver/hw/nxagent/Handlers.c b/nx-X11/programs/Xserver/hw/nxagent/Handlers.c index f1455b935..559eae719 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Handlers.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Handlers.c @@ -726,8 +726,6 @@ void nxagentShadowBlockHandler(void * data, struct timeval **timeout, void * mas } #endif - #ifndef __CYGWIN32__ - if (nxagentReadEvents(nxagentDisplay) > 0 || nxagentReadEvents(nxagentShadowDisplay) > 0) { @@ -745,19 +743,6 @@ void nxagentShadowBlockHandler(void * data, struct timeval **timeout, void * mas nxagentShadowAdaptToRatio(); } - #else - - if (nxagentReadEvents(nxagentDisplay) > 0) - { - #ifdef TEST - fprintf(stderr, "nxagentShadowBlockHandler: Reading X events queued.\n"); - #endif - - nxagentDispatchEvents(NULL); - } - - #endif - changed = 0; NXShadowGetScreenSize(&width_, &height_); @@ -800,26 +785,6 @@ FIXME: Must queue multiple writes and handle the events by resembling *timeout = &zero; } - #ifdef __CYGWIN32__ - - if (nxagentOption(SleepTime) > 0) { -#ifdef TEST - fprintf(stderr, "nxagentShadowBlockHandler: sleeping for %d milliseconds for slowdown.\n", - nxagentOption(SleepTime)); -#endif - usleep(nxagentOption(SleepTime) * 1000); - } -#ifdef TEST - else if (0 == nxagentOption(SleepTime)) { - fprintf(stderr, "nxagentShadowBlockHandler: not sleeping for slowdown.\n"); - } -#endif - - (*timeout) -> tv_sec = 0; - (*timeout) -> tv_usec = 50 * 1000; - - #else - if (changed == 0) { (*timeout) -> tv_sec = 0; @@ -831,8 +796,6 @@ FIXME: Must queue multiple writes and handle the events by resembling (*timeout) -> tv_usec = 0; } - #endif - nxagentPrintGeometry(); #ifdef BLOCKS @@ -857,7 +820,6 @@ void nxagentShadowWakeupHandler(void * data, int count, void * mask) if (!SmartScheduleSignalEnable) { - #ifdef DEBUG fprintf(stderr, "nxagentShadowWakeupHandler: Resetting the dispatch state after wakeup.\n"); #endif @@ -866,7 +828,6 @@ void nxagentShadowWakeupHandler(void * data, int count, void * mask) nxagentDispatch.in = nxagentBytesIn; nxagentDispatch.out = nxagentBytesOut; - } /* diff --git a/nx-X11/programs/Xserver/hw/nxagent/Image.c b/nx-X11/programs/Xserver/hw/nxagent/Image.c index 34d5cf9f9..9e50b5d60 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Image.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Image.c @@ -99,6 +99,7 @@ extern void nxagentBitOrderInvert(unsigned char *, int); extern void nxagentTwoByteSwap(unsigned char *, register int); extern void nxagentFourByteSwap(register unsigned char *, register int); +extern ClientPtr nxagentRequestingClient; /* * Store the last visual used to unpack the images for the given * client. @@ -140,9 +141,7 @@ static char *nxagentImageCopy(XImage *source, XImage *destination); * expensive than a copy. */ -#define nxagentNeedCache(image, method) \ -\ - ((method) != PACK_BITMAP_16M_COLORS) +#define nxagentNeedCache(image, method) ((method) != PACK_BITMAP_16M_COLORS) /* * With the bitmap encoding, if the image is 32 bits-per-pixel the 4th @@ -276,6 +275,7 @@ int nxagentImagePad(int width, int format, int leftPad, int depth) else if (format == XYPixmap) { line = BitmapBytePad(width + leftPad); + /* FIXME: shouldn't we multiply by depth here like in nxagentImageLength? */ } else if (format == ZPixmap) { @@ -1074,7 +1074,7 @@ void nxagentPutSubImage(DrawablePtr pDrawable, GCPtr pGC, int depth, /* FIXME: Should use an unpack resource here. */ - client = requestingClient; + client = nxagentRequestingClient; if (client == NULL) { @@ -1093,7 +1093,7 @@ FIXME: Should use an unpack resource here. #ifdef TEST fprintf(stderr, "nxagentPutSubImage: Display image order is [%d] bitmap order is [%d].\n", - ImageByteOrder(nxagentDisplay), nxagentBitmapBitOrder(nxagentDisplay)); + ImageByteOrder(nxagentDisplay), BitmapBitOrder(nxagentDisplay)); #endif /* @@ -1559,7 +1559,6 @@ int nxagentScaleImage(int x, int y, unsigned xRatio, unsigned yRatio, XImage **pImage, int *scaledx, int *scaledy) { XImage *image = *pImage; - if (image == NULL) { return 0; diff --git a/nx-X11/programs/Xserver/hw/nxagent/Imakefile b/nx-X11/programs/Xserver/hw/nxagent/Imakefile index b6a343e68..e37f97e84 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Imakefile +++ b/nx-X11/programs/Xserver/hw/nxagent/Imakefile @@ -59,7 +59,6 @@ SRCS = \ Composite.c \ Pixels.c \ stubs.c \ - xpstubs.c \ miinitext.c \ $(NULL) @@ -116,7 +115,6 @@ OBJS = \ Composite.o \ Pixels.o \ stubs.o \ - xpstubs.o \ miinitext.o \ $(NULL) @@ -264,7 +262,6 @@ DEFINES = \ all:: $(OBJS) LinkSourceFile(stubs.c,$(SERVERSRC)/Xi) -LinkSourceFile(xpstubs.c,$(SERVERSRC)/dix) LinkSourceFile(miinitext.c,$(SERVERSRC)/mi) SpecialCObjectRule(miinitext,$(ICONFIGFILES), $(_NOOP_)) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Init.h b/nx-X11/programs/Xserver/hw/nxagent/Init.h index 1bea17600..246f600cf 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Init.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Init.h @@ -45,7 +45,7 @@ extern int nxagentDoFullGeneration; extern int nxagentBackingStore; extern int nxagentSaveUnder; -extern int nxagentX2go; +extern int nxagentX2go; void checkX2goAgent(void); extern ServerGrabInfoRec nxagentGrabServerInfo; diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c index 695fce40d..950aec839 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c @@ -567,7 +567,7 @@ XkbError: if (nxagentKeyboard[i] == '\0' || nxagentKeyboard[i + 1] == '\0' || i == 0) { - ErrorF("Warning: Wrong keyboard type: %s.\n", nxagentKeyboard); + ErrorF("Warning: Wrong keyboard type: '%s'.\n", nxagentKeyboard); goto XkbError; } @@ -1466,7 +1466,7 @@ static void nxagentWriteKeyboardDir(void) if (keyboard_file_path) { /* - * special case: if rules is NULL create a directory insteas of + * special case: if rules is NULL create a directory instead of * a file. This is the defined method to disable x2gosetkeyboard. */ if (mkdir(keyboard_file_path, 0555) < 0) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c index b6d8f5817..ea139b10f 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -432,7 +432,7 @@ void nxagentDumpKeystrokes(void) { int maxlen = 0; for (int i = 0; nxagentSpecialKeystrokeNames[i]; i++) - maxlen = min(maxlen, strlen(nxagentSpecialKeystrokeNames[i])); + maxlen = max(maxlen, strlen(nxagentSpecialKeystrokeNames[i])); fprintf(stderr, "Currently known keystrokes:\n"); diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c b/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c index 00fb4ddd8..e804acbd2 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c @@ -200,6 +200,12 @@ extern int nxagentMaxSelections; extern int nxOpenFont(ClientPtr, XID, Mask, unsigned, char*); + +/* + * This used to be a dix variable used only by XPRINT, so xorg dropped it. + */ +ClientPtr nxagentRequestingClient; + void InitSelections(void) { @@ -245,6 +251,7 @@ Dispatch(void) InitSelections(); nClients = 0; +#ifdef NXAGENT_SERVER /* * The agent initialization was successfully * completed. We can now handle our clients. @@ -269,10 +276,12 @@ Dispatch(void) #endif +#endif /* NXAGENT_SERVER */ clientReady = (int *) malloc(sizeof(int) * MaxClients); if (!clientReady) return; +#ifdef NXAGENT_SERVER #ifdef WATCH fprintf(stderr, "Dispatch: Watchpoint 12.\n"); @@ -303,6 +312,7 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio if (!(dispatchException & DE_TERMINATE)) dispatchException = 0; +#endif /* NXAGENT_SERVER */ while (!dispatchException) { @@ -312,6 +322,7 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio FlushIfCriticalOutputPending(); } +#ifdef NXAGENT_SERVER /* * Ensure we remove the splash after the timeout. * Initializing clientReady[0] to -1 will tell @@ -351,9 +362,11 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio #ifdef BLOCKS fprintf(stderr, "[End dispatch]\n"); #endif +#endif /* NXAGENT_SERVER */ nready = WaitForSomething(clientReady); +#ifdef NXAGENT_SERVER #ifdef BLOCKS fprintf(stderr, "[Begin dispatch]\n"); #endif @@ -378,6 +391,7 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio nxagentClients = nClients; #endif +#endif /* NXAGENT_SERVER */ if (nready) { @@ -405,7 +419,9 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio } isItTimeToYield = FALSE; - requestingClient = client; +#ifdef NXAGENT_SERVER + nxagentRequestingClient = client; +#endif start_tick = SmartScheduleTime; while (!isItTimeToYield) { @@ -423,10 +439,15 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio } /* now, finally, deal with client requests */ + /* Update currentTime so request time checks, such as for input + * device grabs, are calculated correctly */ + UpdateCurrentTimeIf(); +#ifdef NXAGENT_SERVER #ifdef TEST fprintf(stderr, "******Dispatch: Reading request from client [%d].\n", client->index); #endif +#endif /* NXAGENT_SERVER */ result = ReadRequestFromClient(client); if (result <= 0) @@ -435,8 +456,8 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio CloseDownClient(client); break; } -#ifdef NXAGENT_SERVER +#ifdef NXAGENT_SERVER #ifdef TEST else @@ -463,10 +484,9 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio if (result > (maxBigRequestSize << 2)) result = BadLength; else -#ifdef NXAGENT_SERVER { result = (* client->requestVector[MAJOROP])(client); - +#ifdef NXAGENT_SERVER #ifdef TEST if (MAJOROP > 127) @@ -492,11 +512,8 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio */ nxagentDispatchHandler(client, client->req_len << 2, 0); - } -#else - result = (* client->requestVector[MAJOROP])(client); #endif - + } if (!SmartScheduleSignalEnable) SmartScheduleTime = GetTimeInMillis(); @@ -519,13 +536,17 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio client = clients[clientReady[nready]]; if (client) client->smart_stop_tick = SmartScheduleTime; - requestingClient = NULL; +#ifdef NXAGENT_SERVER + nxagentRequestingClient = NULL; +#endif } dispatchException &= ~DE_PRIORITYCHANGE; } #if defined(DDXBEFORERESET) ddxBeforeReset (); #endif + +#ifdef NXAGENT_SERVER /* FIXME: maybe move the code up to the KillAllClients() call to ddxBeforeReset? */ if ((dispatchException & DE_RESET) && (serverGeneration > nxagentMaxAllowedResets)) @@ -559,6 +580,7 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio NXShadowDestroy(); } saveAgentState("TERMINATED"); +#endif /* NXAGENT_SERVER */ KillAllClients(); free(clientReady); @@ -580,7 +602,9 @@ ProcReparentWindow(register ClientPtr client) if (!pWin) return(BadWindow); +#ifdef NXAGENT_SERVER nxagentRemoveSplashWindow(); +#endif pParent = (WindowPtr)SecurityLookupWindow(stuff->parent, client, DixWriteAccess); @@ -807,7 +831,7 @@ ProcCloseFont(register ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); pFont = (FontPtr)SecurityLookupIDByType(client, stuff->id, RT_FONT, DixDestroyAccess); - if (pFont != (FontPtr)NULL) + if ( pFont != (FontPtr)NULL) /* id was valid */ { #ifdef NXAGENT_SERVER @@ -1140,6 +1164,8 @@ CloseDownClient(register ClientPtr client) xorg_CloseDownClient(client); } +/* FIXME: Instead of having a own function use the provided Callback + mechanism */ int InitClientPrivates(ClientPtr client) { diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c b/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c index 7ccc04bc8..159a7b55d 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c @@ -215,7 +215,9 @@ AllocatePicture (ScreenPtr pScreen) ppriv->ptr = (void *)NULL; } +#ifdef NXAGENT_SERVER nxagentPicturePriv(pPicture) -> picture = 0; +#endif return pPicture; } @@ -245,13 +247,14 @@ CreatePicture (Picture pid, pPicture->format = pFormat->format | (pDrawable->bitsPerPixel << 24); if (pDrawable->type == DRAWABLE_PIXMAP) { +#ifdef NXAGENT_SERVER /* * Let picture always point to the virtual pixmap. * For sure this is not the best way to deal with * the virtual frame-buffer. */ pPicture->pDrawable = nxagentVirtualDrawable(pDrawable); - +#endif ++((PixmapPtr)pDrawable)->refcnt; pPicture->pNext = 0; } diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXproperty.c b/nx-X11/programs/Xserver/hw/nxagent/NXproperty.c index cc10ad760..dc2f5b07f 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXproperty.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXproperty.c @@ -215,16 +215,9 @@ ChangeWindowProperty(WindowPtr pWin, Atom property, Atom type, int format, int mode, unsigned long len, void * value, Bool sendevent) { - PropertyPtr pProp; - int sizeInBytes; - int totalSize; - void * data; - int copySize; - - sizeInBytes = format>>3; - totalSize = len * sizeInBytes; - - copySize = nxagentOption(CopyBufferSize); + int sizeInBytes = format>>3; + int totalSize = len * sizeInBytes; + int copySize = nxagentOption(CopyBufferSize); if (copySize != COPY_UNLIMITED && property == clientCutProperty) { @@ -236,105 +229,7 @@ ChangeWindowProperty(WindowPtr pWin, Atom property, Atom type, int format, } } - /* first see if property already exists */ - - pProp = wUserProps (pWin); - while (pProp) - { - if (pProp->propertyName == property) - break; - pProp = pProp->next; - } - if (!pProp) /* just add to list */ - { - if (!pWin->optional && !MakeWindowOptional (pWin)) - return(BadAlloc); - pProp = (PropertyPtr)malloc(sizeof(PropertyRec)); - if (!pProp) - return(BadAlloc); - data = (void *)malloc(totalSize); - if (!data && len) - { - free(pProp); - return(BadAlloc); - } - pProp->propertyName = property; - pProp->type = type; - pProp->format = format; - pProp->data = data; - if (len) - memmove((char *)data, (char *)value, totalSize); - pProp->size = len; - pProp->next = pWin->optional->userProps; - pWin->optional->userProps = pProp; - } - else - { - /* To append or prepend to a property the request format and type - must match those of the already defined property. The - existing format and type are irrelevant when using the mode - "PropModeReplace" since they will be written over. */ - - if ((format != pProp->format) && (mode != PropModeReplace)) - return(BadMatch); - if ((pProp->type != type) && (mode != PropModeReplace)) - return(BadMatch); - if (mode == PropModeReplace) - { - if (totalSize != pProp->size * (pProp->format >> 3)) - { - data = (void *)realloc(pProp->data, totalSize); - if (!data && len) - return(BadAlloc); - pProp->data = data; - } - if (len) - memmove((char *)pProp->data, (char *)value, totalSize); - pProp->size = len; - pProp->type = type; - pProp->format = format; - } - else if (len == 0) - { - /* do nothing */ - } - else if (mode == PropModeAppend) - { - data = (void *)realloc(pProp->data, - sizeInBytes * (len + pProp->size)); - if (!data) - return(BadAlloc); - pProp->data = data; - memmove(&((char *)data)[pProp->size * sizeInBytes], - (char *)value, - totalSize); - pProp->size += len; - } - else if (mode == PropModePrepend) - { - data = (void *)malloc(sizeInBytes * (len + pProp->size)); - if (!data) - return(BadAlloc); - memmove(&((char *)data)[totalSize], (char *)pProp->data, - (int)(pProp->size * sizeInBytes)); - memmove((char *)data, (char *)value, totalSize); - free(pProp->data); - pProp->data = data; - pProp->size += len; - } - } - if (sendevent) - { - xEvent event; - memset(&event, 0, sizeof(xEvent)); - event.u.u.type = PropertyNotify; - event.u.property.window = pWin->drawable.id; - event.u.property.state = PropertyNewValue; - event.u.property.atom = pProp->propertyName; - event.u.property.time = currentTime.milliseconds; - DeliverEvents(pWin, &event, 1, (WindowPtr)NULL); - } - return(Success); + return Xorg_ChangeWindowProperty(pWin, property, type, format, mode, len, value, sendevent); } /***************** diff --git a/nx-X11/programs/Xserver/hw/nxagent/Options.c b/nx-X11/programs/Xserver/hw/nxagent/Options.c index 9e11dc5f2..4d5fa3e16 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Options.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Options.c @@ -107,16 +107,8 @@ void nxagentInitOptions(void) nxagentOptions.ViewportXSpan = 0; nxagentOptions.ViewportYSpan = 0; - #ifndef __CYGWIN32__ - nxagentOptions.DesktopResize = 1; - #else - - nxagentOptions.DesktopResize = 0; - - #endif - nxagentOptions.Ratio = DONT_SCALE; nxagentOptions.XRatio = DONT_SCALE; nxagentOptions.YRatio = DONT_SCALE; diff --git a/nx-X11/programs/Xserver/hw/nxagent/Pointer.c b/nx-X11/programs/Xserver/hw/nxagent/Pointer.c index 379a19fa0..b5d47623a 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Pointer.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Pointer.c @@ -87,7 +87,7 @@ void nxagentChangePointerControl(DeviceIntPtr pDev, PtrCtrl *ctrl) if (nxagentOption(DeviceControl) == True) { #ifdef TEST - fprintf(stderr, "nxagentChangePointerControl: WARNING! Propagating changes to pointer settings.\n"); + fprintf(stderr, "%s: WARNING! Propagating changes to pointer settings.\n", __func__); #endif XChangePointerControl(nxagentDisplay, True, True, @@ -97,7 +97,7 @@ void nxagentChangePointerControl(DeviceIntPtr pDev, PtrCtrl *ctrl) } #ifdef TEST - fprintf(stderr, "nxagentChangePointerControl: WARNING! Not propagating changes to pointer settings.\n"); + fprintf(stderr, "%s: WARNING! Not propagating changes to pointer settings.\n", __func__); #endif } @@ -108,7 +108,7 @@ int nxagentPointerProc(DeviceIntPtr pDev, int onoff) case DEVICE_INIT: #ifdef TEST - fprintf(stderr, "nxagentPointerProc: Called for [DEVICE_INIT].\n"); + fprintf(stderr, "%s: Called for [DEVICE_INIT].\n", __func__); #endif if (NXDisplayError(nxagentDisplay) == 1) @@ -129,7 +129,7 @@ int nxagentPointerProc(DeviceIntPtr pDev, int onoff) case DEVICE_ON: #ifdef TEST - fprintf(stderr, "nxagentPointerProc: Called for [DEVICE_ON].\n"); + fprintf(stderr, "%s: Called for [DEVICE_ON].\n", __func__); #endif if (NXDisplayError(nxagentDisplay) == 1) @@ -146,7 +146,7 @@ int nxagentPointerProc(DeviceIntPtr pDev, int onoff) case DEVICE_OFF: #ifdef TEST - fprintf(stderr, "nxagentPointerProc: Called for [DEVICE_OFF].\n"); + fprintf(stderr, "%s: Called for [DEVICE_OFF].\n", __func__); #endif if (NXDisplayError(nxagentDisplay) == 1) @@ -160,7 +160,7 @@ int nxagentPointerProc(DeviceIntPtr pDev, int onoff) case DEVICE_CLOSE: #ifdef TEST - fprintf(stderr, "nxagentPointerProc: Called for [DEVICE_CLOSE].\n"); + fprintf(stderr, "%s: Called for [DEVICE_CLOSE].\n", __func__); #endif break; @@ -174,14 +174,14 @@ void nxagentInitPointerMap(void) unsigned char pointerMap[MAXBUTTONS]; #ifdef DEBUG - fprintf(stderr, "nxagentInitPointerMap: Going to retrieve the " - "pointer map from remote display.\n"); + fprintf(stderr, "%s: Going to retrieve the " + "pointer map from remote display.\n", __func__); #endif int numButtons = XGetPointerMapping(nxagentDisplay, pointerMap, MAXBUTTONS); /* - * Computing revers pointer map. + * Computing reverse pointer map. */ for (int i = 1; i <= numButtons; i++) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c b/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c index 5ff0c6506..86d3ba502 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c @@ -666,7 +666,7 @@ Bool nxagentReconnectSession(void) } /* Re-read keystrokes definitions in case the keystrokes file has - changed while being supended */ + changed while being suspended */ nxagentInitKeystrokes(True); #ifdef NX_DEBUG_INPUT diff --git a/nx-X11/programs/Xserver/hw/nxagent/Rootless.c b/nx-X11/programs/Xserver/hw/nxagent/Rootless.c index 86e3c9ca7..85643a853 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Rootless.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Rootless.c @@ -285,7 +285,7 @@ void nxagentRootlessRestack(unsigned long children[], unsigned int nchildren) if (!toplevel) { - /* FIXME: Is this too much and we and simply return here? */ + /* FIXME: Is this too much and we should simply return here? */ FatalError("nxagentRootlessRestack: malloc() failed."); } diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index 9e4d3e433..2ed7d9593 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -454,8 +454,6 @@ Window nxagentCreateIconWindow(void) */ XSizeHints* sizeHints = XAllocSizeHints(); - XWMHints* wmHints = XAllocWMHints();; - if (sizeHints) { sizeHints->flags = PMinSize | PMaxSize; @@ -463,27 +461,23 @@ Window nxagentCreateIconWindow(void) sizeHints->min_height = sizeHints->max_height = 1; } + XWMHints* wmHints = XAllocWMHints();; if (wmHints) { - wmHints->flags = IconPixmapHint | IconMaskHint; + wmHints->flags = StateHint | IconPixmapHint; wmHints->initial_state = IconicState; wmHints->icon_pixmap = nxagentIconPixmap; if (useXpmIcon) { + wmHints->flags |= IconMaskHint; wmHints->icon_mask = nxagentIconShape; - wmHints->flags = IconPixmapHint | IconMaskHint; - } - else - { - wmHints->flags = StateHint | IconPixmapHint; } } - char *window_name = nxagentWindowName; Xutf8SetWMProperties(nxagentDisplay, w, - window_name, window_name, - NULL , 0 , sizeHints, wmHints, NULL); + nxagentWindowName, nxagentWindowName, + NULL , 0 , sizeHints, wmHints, NULL); SAFE_XFree(sizeHints); SAFE_XFree(wmHints); @@ -1901,10 +1895,8 @@ N/A XSelectInput(nxagentDisplay, nxagentFullscreenWindow, mask); } - XSizeHints* sizeHints; - XWMHints* wmHints; - - if ((sizeHints = XAllocSizeHints())) + XSizeHints* sizeHints = XAllocSizeHints(); + if (sizeHints) { sizeHints->flags = PPosition | PMinSize | PMaxSize; sizeHints->x = nxagentOption(X) + POSITION_OFFSET; @@ -1932,18 +1924,16 @@ N/A sizeHints->flags |= USSize; } - if ((wmHints = XAllocWMHints())) + XWMHints* wmHints = XAllocWMHints(); + if (wmHints) { + wmHints->flags = IconPixmapHint; wmHints->icon_pixmap = nxagentIconPixmap; if (useXpmIcon) { + wmHints->flags |= IconMaskHint; wmHints->icon_mask = nxagentIconShape; - wmHints->flags = IconPixmapHint | IconMaskHint; - } - else - { - wmHints->flags = IconPixmapHint; } } @@ -2192,19 +2182,17 @@ Bool nxagentCloseScreen(ScreenPtr pScreen) static void nxagentSetRootClip (ScreenPtr pScreen, Bool enable) { WindowPtr pWin = pScreen->root; - WindowPtr pChild; Bool WasViewable = (Bool)(pWin->viewable); Bool anyMarked = FALSE; - RegionPtr pOldClip = NULL, bsExposed; + RegionPtr pOldClip = NULL; #ifdef DO_SAVE_UNDERS Bool dosave = FALSE; #endif WindowPtr pLayerWin; - BoxRec box; if (WasViewable) { - for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib) + for (WindowPtr pChild = pWin->firstChild; pChild; pChild = pChild->nextSib) { (void) (*pScreen->MarkOverlappedWindows)(pChild, pChild, @@ -2216,9 +2204,7 @@ static void nxagentSetRootClip (ScreenPtr pScreen, Bool enable) { if (HasBorder (pWin)) { - RegionPtr borderVisible; - - borderVisible = RegionCreate(NullBox, 1); + RegionPtr borderVisible = RegionCreate(NullBox, 1); RegionSubtract(borderVisible, &pWin->borderClip, &pWin->winSize); pWin->valdata->before.borderVisible = borderVisible; @@ -2229,15 +2215,12 @@ static void nxagentSetRootClip (ScreenPtr pScreen, Bool enable) /* * Use REGION_BREAK to avoid optimizations in ValidateTree - * that assume the root borderClip can't change well, normally + * that assume the root borderClip can't change. Well, normally * it doesn't...) */ if (enable) { - box.x1 = 0; - box.y1 = 0; - box.x2 = pScreen->width; - box.y2 = pScreen->height; + BoxRec box = {.x1 = 0, .y1 = 0, .x2 = pScreen->width, .y2 = pScreen->height}; RegionInit(&pWin->winSize, &box, 1); RegionInit(&pWin->borderSize, &box, 1); if (WasViewable) @@ -2290,14 +2273,14 @@ static void nxagentSetRootClip (ScreenPtr pScreen, Bool enable) { if (!WasViewable) pOldClip = &pWin->clipList; /* a convenient empty region */ - bsExposed = (*pScreen->TranslateBackingStore) + RegionPtr bsExposed = (*pScreen->TranslateBackingStore) (pWin, 0, 0, pOldClip, pWin->drawable.x, pWin->drawable.y); if (WasViewable) RegionDestroy(pOldClip); if (bsExposed) { - RegionPtr valExposed = NullRegion; + RegionPtr valExposed = NullRegion; if (pWin->valdata) valExposed = &pWin->valdata->after.exposed; @@ -2326,15 +2309,6 @@ static void nxagentSetRootClip (ScreenPtr pScreen, Bool enable) Bool nxagentResizeScreen(ScreenPtr pScreen, int width, int height, int mmWidth, int mmHeight) { - BoxRec box; - PixmapPtr pPixmap; - char *fbBits; - - int oldWidth; - int oldHeight; - int oldMmWidth; - int oldMmHeight; - #ifdef TEST nxagentPrintAgentGeometry("Before Resize Screen", "nxagentResizeScreen:"); #endif @@ -2343,10 +2317,10 @@ Bool nxagentResizeScreen(ScreenPtr pScreen, int width, int height, * Change screen properties. */ - oldWidth = pScreen -> width; - oldHeight = pScreen -> height; - oldMmWidth = pScreen -> mmWidth; - oldMmHeight = pScreen -> mmHeight; + int oldWidth = pScreen -> width; + int oldHeight = pScreen -> height; + int oldMmWidth = pScreen -> mmWidth; + int oldMmHeight = pScreen -> mmHeight; pScreen -> width = width; pScreen -> height = height; @@ -2396,10 +2370,11 @@ Bool nxagentResizeScreen(ScreenPtr pScreen, int width, int height, pScreen -> mmWidth = mmWidth; pScreen -> mmHeight = mmHeight; - pPixmap = fbGetScreenPixmap(pScreen); + PixmapPtr pPixmap = fbGetScreenPixmap(pScreen); - if ((fbBits = realloc(pPixmap -> devPrivate.ptr, PixmapBytePad(width, pScreen->rootDepth) * - height * BitsPerPixel(pScreen->rootDepth) / 8)) == NULL) + char *fbBits = realloc(pPixmap -> devPrivate.ptr, PixmapBytePad(width, pScreen->rootDepth) * + height * BitsPerPixel(pScreen->rootDepth) / 8); + if (fbBits == NULL) { pScreen -> width = oldWidth; pScreen -> height = oldHeight; @@ -2466,10 +2441,7 @@ FIXME: We should try to restore the previously * Set properties for the agent root window. */ - box.x1 = 0; - box.y1 = 0; - box.x2 = width; - box.y2 = height; + BoxRec box = {.x1 = 0, .y1 = 0, .x2 = width, .y2 = height}; pScreen->root -> drawable.width = width; pScreen->root -> drawable.height = height; @@ -2511,9 +2483,6 @@ nxagentResizeScreenError: void nxagentShadowSetRatio(float floatXRatio, float floatYRatio) { - int intXRatio; - int intYRatio; - if (floatXRatio == 0) { floatXRatio = 1.0; @@ -2524,8 +2493,8 @@ void nxagentShadowSetRatio(float floatXRatio, float floatYRatio) floatYRatio = 1.0; } - intXRatio = floatXRatio * (1 << PRECISION); - intYRatio = floatYRatio * (1 << PRECISION); + int intXRatio = floatXRatio * (1 << PRECISION); + int intYRatio = floatYRatio * (1 << PRECISION); nxagentChangeOption(FloatXRatio, floatXRatio); nxagentChangeOption(FloatYRatio, floatYRatio); @@ -2563,16 +2532,6 @@ void nxagentShadowSetWindowOptions(void) int nxagentShadowInit(ScreenPtr pScreen, WindowPtr pWin) { char *layout = NULL; - XlibGC gc; - XGCValues value; - - #ifndef __CYGWIN32__ - - Atom nxagentShadowAtom; - - int fd; - - #endif #ifdef TEST fprintf(stderr, "Info: Init shadow session. nxagentDisplayName [%s] " @@ -2603,8 +2562,6 @@ int nxagentShadowInit(ScreenPtr pScreen, WindowPtr pWin) nxagentShadowUid); #endif -#if !defined (__CYGWIN32__) && !defined (WIN32) - if (nxagentShadowUid != -1) { NXShadowSetDisplayUid(nxagentShadowUid); @@ -2615,8 +2572,6 @@ int nxagentShadowInit(ScreenPtr pScreen, WindowPtr pWin) NXShadowDisableDamage(); } -#endif - if (NXShadowCreate(nxagentDisplay, layout, nxagentShadowDisplayName, (void *) &nxagentShadowDisplay) != 1) { @@ -2629,18 +2584,14 @@ int nxagentShadowInit(ScreenPtr pScreen, WindowPtr pWin) } /* - * The shadow nxagent sets the _NX_SHADOW - * property on the master X server root - * window in order to notify its presence. + * The shadow nxagent sets the _NX_SHADOW property on the master X + * server root window in order to notify its presence. */ - #ifndef __CYGWIN__ - - nxagentShadowAtom = XInternAtom(nxagentShadowDisplay, "_NX_SHADOW", False); + XlibAtom nxagentShadowAtom = XInternAtom(nxagentShadowDisplay, "_NX_SHADOW", False); XChangeProperty(nxagentShadowDisplay, DefaultRootWindow(nxagentShadowDisplay), nxagentShadowAtom, XA_STRING, 8, PropModeReplace, NULL, 0); - #endif if (NXShadowAddUpdaterDisplay(nxagentDisplay, &nxagentShadowWidth, &nxagentShadowHeight, &nxagentMasterDepth) == 0) @@ -2653,8 +2604,6 @@ int nxagentShadowInit(ScreenPtr pScreen, WindowPtr pWin) return -1; } - #ifndef __CYGWIN32__ - if (nxagentOption(Fullscreen) == 1) { nxagentShadowSetRatio(WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)) * 1.0 / nxagentShadowWidth, @@ -2686,36 +2635,12 @@ int nxagentShadowInit(ScreenPtr pScreen, WindowPtr pWin) switch (DefaultVisualOfScreen(DefaultScreenOfDisplay(nxagentShadowDisplay)) -> class) { - case StaticGray: - { - className = "StaticGray"; - break; - } - case StaticColor: - { - className = "StaticColor"; - break; - } - case PseudoColor: - { - className = "PseudoColor"; - break; - } - case DirectColor: - { - className = "DirectColor"; - break; - } - case GrayScale: - { - className = "GrayScale"; - break; - } - default: - { - className = ""; - break; - } + case StaticGray: { className = "StaticGray"; break; } + case StaticColor: { className = "StaticColor"; break; } + case PseudoColor: { className = "PseudoColor"; break; } + case DirectColor: { className = "DirectColor"; break; } + case GrayScale: { className = "GrayScale"; break; } + default: { className = ""; break; } } fprintf(stderr, "nxagentShadowInit: PANIC! Cannot shadow the display. " @@ -2727,8 +2652,6 @@ int nxagentShadowInit(ScreenPtr pScreen, WindowPtr pWin) return -1; } - #endif - nxagentShadowDepth = pScreen -> rootDepth; switch (nxagentMasterDepth) @@ -2813,19 +2736,13 @@ int nxagentShadowInit(ScreenPtr pScreen, WindowPtr pWin) nxagentBppShadow = 1; } -#if !defined(__CYGWIN__) - imageByteOrder = nxagentShadowDisplay -> byte_order; - fd = XConnectionNumber(nxagentShadowDisplay); - - nxagentShadowXConnectionNumber = fd; - -#endif + nxagentShadowXConnectionNumber = XConnectionNumber(nxagentShadowDisplay); #ifdef TEST fprintf(stderr, "nxagentShadowInit: Adding the X connection [%d] " - "to the device set.\n", fd); + "to the device set.\n", nxagentShadowXConnectionNumber); #endif SetNotifyFd(nxagentShadowXConnectionNumber, nxagentNotifyConnection, X_NOTIFY_READ, NULL); @@ -2855,13 +2772,15 @@ int nxagentShadowInit(ScreenPtr pScreen, WindowPtr pWin) * Clean up the main window. */ - value.foreground = 0x00000000; - value.background = 0x00000000; - value.plane_mask = 0xffffffff; - value.fill_style = FillSolid; + XGCValues value = { + .foreground = 0x00000000, + .background = 0x00000000, + .plane_mask = 0xffffffff, + .fill_style = FillSolid, + }; - gc = XCreateGC(nxagentDisplay, nxagentPixmap(nxagentShadowPixmapPtr), GCBackground | - GCForeground | GCFillStyle | GCPlaneMask, &value); + XlibGC gc = XCreateGC(nxagentDisplay, nxagentPixmap(nxagentShadowPixmapPtr), GCBackground | + GCForeground | GCFillStyle | GCPlaneMask, &value); XFillRectangle(nxagentDisplay, nxagentPixmap(nxagentShadowPixmapPtr), gc, 0, 0, nxagentShadowWidth, nxagentShadowHeight); @@ -2875,12 +2794,6 @@ int nxagentShadowInit(ScreenPtr pScreen, WindowPtr pWin) int nxagentShadowCreateMainWindow(ScreenPtr pScreen, WindowPtr pWin, int width, int height) { - XWindowChanges changes; - Mask mask,maskb; - XID values[4], *vlist; - int error; - XID xid; - nxagentShadowWidth = width; nxagentShadowHeight = height; @@ -2926,9 +2839,9 @@ int nxagentShadowCreateMainWindow(ScreenPtr pScreen, WindowPtr pWin, int width, XFreePixmap(nxagentDisplay, nxagentPixmap(nxagentVirtualPixmap(nxagentShadowPixmapPtr))); - xid = XCreatePixmap(nxagentDisplay, nxagentDefaultWindows[0], - nxagentScale(nxagentShadowWidth, nxagentOption(XRatio)), - nxagentScale(nxagentShadowHeight, nxagentOption(YRatio)), nxagentShadowDepth); + XID xid = XCreatePixmap(nxagentDisplay, nxagentDefaultWindows[0], + nxagentScale(nxagentShadowWidth, nxagentOption(XRatio)), + nxagentScale(nxagentShadowHeight, nxagentOption(YRatio)), nxagentShadowDepth); nxagentPixmap(nxagentVirtualPixmap(nxagentShadowPixmapPtr)) = xid; @@ -2957,24 +2870,27 @@ int nxagentShadowCreateMainWindow(ScreenPtr pScreen, WindowPtr pWin, int width, #endif } - mask = CWBackPixmap | CWEventMask | CWCursor; + Mask mask = CWBackPixmap | CWEventMask | CWCursor; + Mask maskb = nxagentGetDefaultEventMask() | ResizeRedirectMask | ExposureMask; - maskb = nxagentGetDefaultEventMask(); - maskb |= ResizeRedirectMask | ExposureMask; - - vlist = values; + XID values[4]; + XID *vlist = values; *vlist++ = (XID)nxagentShadowPixmapPtr -> drawable.id; *vlist++ = (XID)maskb; *vlist = (XID)None; + int error; + nxagentShadowWindowPtr = CreateWindow(accessWindowID, pWin, 0, 0, nxagentShadowWidth, nxagentShadowHeight, 0, InputOutput, mask, (XID *)values, nxagentShadowDepth, serverClient, CopyFromParent, &error); mask = CWWidth | CWHeight; - changes.width = nxagentScale(nxagentShadowWidth, nxagentOption(XRatio)); - changes.height = nxagentScale(nxagentShadowHeight, nxagentOption(YRatio)); + XWindowChanges changes = { + .width = nxagentScale(nxagentShadowWidth, nxagentOption(XRatio)), + .height = nxagentScale(nxagentShadowHeight, nxagentOption(YRatio)) + }; XConfigureWindow(nxagentDisplay, nxagentWindow(nxagentShadowWindowPtr), mask, &changes); @@ -3038,51 +2954,33 @@ int nxagentShadowPoll(PixmapPtr nxagentShadowPixmapPtr, GCPtr nxagentShadowGCPtr unsigned char nxagentShadowDepth, int nxagentShadowWidth, int nxagentShadowHeight, char *nxagentShadowBuffer, int *changed, int *suspended) { - int x, y, y2, n, c, line; - int result; - long numRects; - unsigned int width, height, length; - char *tBuffer = NULL; - char *iBuffer, *ptBox; - BoxRec *pBox; RegionRec updateRegion; RegionRec tempRegion; - BoxRec box; - int overlap; - RegionNull(&updateRegion); - RegionNull(&tempRegion); -#ifdef __CYGWIN32__ - - if (NXShadowCaptureCursor(nxagentWindow(nxagentShadowWindowPtr), - nxagentShadowWindowPtr -> drawable.pScreen -> visuals) == -1) - { - #ifdef WARNING - fprintf(stderr, "nxagentShadowPoll: Failed to capture cursor.\n"); - #endif - } - -#endif - - result = NXShadowHasChanged(nxagentUserInput, NULL, suspended); + int result = NXShadowHasChanged(nxagentUserInput, NULL, suspended); *changed = result; if (result == 1) { + char *tBuffer = NULL; + char *iBuffer, *ptBox; + nxagentRemoveSplashWindow(); + long numRects; NXShadowExportChanges(&numRects, &ptBox); - pBox = (BoxRec *)ptBox; + + BoxRec *pBox = (BoxRec *)ptBox; #ifdef TEST fprintf(stderr, "nxagentShadowPoll: nRects[%ld], pBox[%p] depth[%d].\n", numRects, (void *) pBox, nxagentShadowDepth); #endif - for (n = 0; n < numRects; n++) + for (int n = 0; n < numRects; n++) { /* * The BoxRec struct defined in the Xserver has a different @@ -3090,11 +2988,11 @@ int nxagentShadowPoll(PixmapPtr nxagentShadowPixmapPtr, GCPtr nxagentShadowGCPtr * the second and third field are inverted. */ - x = pBox[n].x1; - y = pBox[n].x2; - y2 = pBox[n].y2; - width = pBox[n].y1 - pBox[n].x1;/* y1 = x2 */ - height = y2 - pBox[n].x2; /* x2 = y1 */ + int x = pBox[n].x1; + int y = pBox[n].x2; + int y2 = pBox[n].y2; + unsigned int width = pBox[n].y1 - pBox[n].x1;/* y1 = x2 */ + unsigned int height = y2 - pBox[n].x2; /* x2 = y1 */ if((x + width) > nxagentShadowWidth || (y + height) > nxagentShadowHeight) { @@ -3105,13 +3003,13 @@ int nxagentShadowPoll(PixmapPtr nxagentShadowPixmapPtr, GCPtr nxagentShadowGCPtr continue; } - line = PixmapBytePad(width, nxagentMasterDepth); + int line = PixmapBytePad(width, nxagentMasterDepth); #ifdef DEBUG fprintf(stderr, "nxagentShadowPoll: Rectangle Number[%d] - x[%d]y[%d]W[%u]H[%u].\n", n+1, x, y, width, height); #endif - length = nxagentImageLength(width, height, ZPixmap, 0, nxagentMasterDepth); + unsigned int length = nxagentImageLength(width, height, ZPixmap, 0, nxagentMasterDepth); SAFE_free(tBuffer); @@ -3128,7 +3026,7 @@ int nxagentShadowPoll(PixmapPtr nxagentShadowPixmapPtr, GCPtr nxagentShadowGCPtr iBuffer = tBuffer; - for (c = 0; c + y < y2; c++) + for (int c = 0; c + y < y2; c++) { memcpy(tBuffer, nxagentShadowBuffer + x * nxagentBppMaster + (y + c) * nxagentShadowWidth * nxagentBppMaster, line); @@ -3139,25 +3037,15 @@ int nxagentShadowPoll(PixmapPtr nxagentShadowPixmapPtr, GCPtr nxagentShadowGCPtr tBuffer = iBuffer; -#ifdef __CYGWIN32__ - if (nxagentBppMaster == 2) - { - NXShadowCorrectColor(length, tBuffer); - } -#else if (nxagentCheckDepth == 1) { nxagentShadowAdaptDepth(width, height, line, &tBuffer); } -#endif fbPutImage(nxagentVirtualDrawable((DrawablePtr)nxagentShadowPixmapPtr), nxagentShadowGCPtr, nxagentShadowDepth, x, y, width, height, 0, ZPixmap, tBuffer); - box.x1 = x; - box.x2 = x + width; - box.y1 = y; - box.y2 = y + height; + BoxRec box = {.x1 = x, .x2 = x + width, .y1 = y, .y2 = y + height}; RegionInit(&tempRegion, &box, 1); @@ -3165,6 +3053,7 @@ int nxagentShadowPoll(PixmapPtr nxagentShadowPixmapPtr, GCPtr nxagentShadowGCPtr RegionUninit(&tempRegion); + int overlap; RegionValidate(&updateRegion, &overlap); RegionUnion(&nxagentShadowUpdateRegion, &nxagentShadowUpdateRegion, &updateRegion); @@ -3398,43 +3287,40 @@ unsigned char fromHexNibble(char c) void nxagentPropagateArtsdProperties(ScreenPtr pScreen, char *port) { - Window rootWin; - XlibAtom atomReturnType; - XlibAtom propAtom; - int iReturnFormat; - unsigned long ulReturnItems; - unsigned long ulReturnBytesLeft; - unsigned char *pszReturnData = NULL; - int iReturn; char tchar[] = " "; /* FIXME: The port information is not used at the moment and produces a warning on recent gcc versions. Do we need such information - to run the audio forawrding? + to run the audio forwarding? char *chport; char hex[] = "0123456789abcdef"; */ - rootWin = DefaultRootWindow(nxagentDisplay); - propAtom = nxagentAtoms[4]; /* MCOPGLOBALS */ + Window rootWin = DefaultRootWindow(nxagentDisplay); + XlibAtom propAtom = nxagentAtoms[4]; /* MCOPGLOBALS */ + XlibAtom atomReturnType; + int iReturnFormat; + unsigned long ulReturnItems; + unsigned long ulReturnBytesLeft; + unsigned char *pszReturnData = NULL; /* * Get at most 64KB of data. */ - iReturn = XGetWindowProperty(nxagentDisplay, - rootWin, - propAtom, - 0, - 65536 / 4, - False, - XA_STRING, - &atomReturnType, - &iReturnFormat, - &ulReturnItems, - &ulReturnBytesLeft, - &pszReturnData); + int iReturn = XGetWindowProperty(nxagentDisplay, + rootWin, + propAtom, + 0, + 65536 / 4, + False, + XA_STRING, + &atomReturnType, + &iReturnFormat, + &ulReturnItems, + &ulReturnBytesLeft, + &pszReturnData); if (iReturn == Success && atomReturnType != None && ulReturnItems > 0 && pszReturnData != NULL) @@ -3462,72 +3348,69 @@ FIXME: The port information is not used at the moment and produces a int i, in; for (i = 0, in = 0; pszReturnData[i] != '\0'; i++) { - local_buf[in]=pszReturnData[i]; + local_buf[in] = pszReturnData[i]; - if(pszReturnData[i]==':') + if(pszReturnData[i] == ':') { i++; - while(pszReturnData[i]!='\n') + while(pszReturnData[i] != '\n') { - unsigned char h; - unsigned char l; - - h = fromHexNibble(pszReturnData[i]); + unsigned char h = fromHexNibble(pszReturnData[i]); i++; - if(pszReturnData[i]=='\0') continue; - l = fromHexNibble(pszReturnData[i]); + if (pszReturnData[i] == '\0') + continue; + unsigned char l = fromHexNibble(pszReturnData[i]); i++; if(h >= 16 || l >= 16) continue; /* - * FIXME: The array tchar[] was used uninitialized. - * It's not clear to me the original purpose of the - * piece of code using it. To be removed in future - * versions. + * FIXME: The array tchar[] was used uninitialized. It's + * not clear to me the original purpose of the piece of + * code using it. To be removed in future versions. */ - tchar[0]=tchar[1]; - tchar[1]=tchar[2]; - tchar[2]=tchar[3]; + tchar[0] = tchar[1]; + tchar[1] = tchar[2]; + tchar[2] = tchar[3]; tchar[3] = (h << 4) + l; - tchar[4]='\0'; + tchar[4] ='\0'; if (strncmp(tchar, "tcp:", 4) == 0) { - local_buf[in-7]='1'; - local_buf[in-6]=strlen(port)+47; + local_buf[in - 7] = '1'; + local_buf[in - 6] = strlen(port) + 47; in++; - local_buf[in]=pszReturnData[i-2]; + local_buf[in] = pszReturnData[i - 2]; in++; - local_buf[in]=pszReturnData[i-1]; + local_buf[in] = pszReturnData[i - 1]; /* "localhost:" */ strcat(local_buf,"6c6f63616c686f73743a"); - in+=20; + in += 20; /* FIXME: The port information is not used at the moment and produces a warning on recent gcc versions. Do we need such information to run the audio forawrding? - chport=&port[0]; + chport = &port[0]; - while(*chport!='\0') + while(*chport != '\0') { in++; - local_buf[in]=hex[(*chport >> 4) & 0xf]; + local_buf[in] = hex[(*chport >> 4) & 0xf]; in++; - local_buf[in]=hex[*chport & 0xf]; + local_buf[in] = hex[*chport & 0xf]; *chport++; } */ strcat(local_buf,"00"); - in+=2; + in += 2; - while(pszReturnData[i]!='\n') + while(pszReturnData[i] != '\n') { i++; } @@ -3535,20 +3418,20 @@ FIXME: The port information is not used at the moment and produces a else { in++; - local_buf[in]=pszReturnData[i-2]; + local_buf[in] = pszReturnData[i - 2]; in++; - local_buf[in]=pszReturnData[i-1]; + local_buf[in] = pszReturnData[i - 1]; } } in++; - local_buf[in]=pszReturnData[i]; + local_buf[in] = pszReturnData[i]; } in++; } - local_buf[in]=0; + local_buf[in] = 0; if (strlen(local_buf)) { @@ -3623,9 +3506,6 @@ Bool intersect(int ax1, int ay1, unsigned int aw, unsigned int ah, int bx1, int by1, unsigned int bw, unsigned int bh, int *x, int *y, unsigned int *w, unsigned int *h) { - int tx1, ty1, tx2, ty2, ix, iy; - unsigned int iw, ih; - int ax2 = ax1 + aw; int ay2 = ay1 + ah; int bx2 = bx1 + bw; @@ -3643,15 +3523,15 @@ Bool intersect(int ax1, int ay1, unsigned int aw, unsigned int ah, return FALSE; } - tx1 = max(ax1, bx1); - ty1 = max(ay1, by1); - tx2 = min(ax2, bx2); - ty2 = min(ay2, by2); + int tx1 = max(ax1, bx1); + int ty1 = max(ay1, by1); + int tx2 = min(ax2, bx2); + int ty2 = min(ay2, by2); - ix = tx1 - ax1; - iy = ty1 - ay1; - iw = tx2 - tx1; - ih = ty2 - ty1; + int ix = tx1 - ax1; + int iy = ty1 - ay1; + unsigned int iw = tx2 - tx1; + unsigned int ih = ty2 - ty1; /* check if the resulting rectangle is feasible */ if (iw <= 0 || ih <= 0) { @@ -3691,34 +3571,31 @@ Bool intersect_bb(int ax1, int ay1, unsigned int aw, unsigned int ah, Bool result = intersect(ax1, ay1, aw, ah, bx1, by1, bw, bh, x, y, w, h); - if (result == TRUE) { - + if (result == TRUE) + { /* * ###### The X-Coordinate ###### */ /* check if outside-left of bounding box */ - if (bx1 == bbx1 && ax1 < bbx1) { - + if (bx1 == bbx1 && ax1 < bbx1) + { *w += bbx1 - ax1; *x = 0; #ifdef DEBUG fprintf(stderr, "intersect_bb: session box is outside-left of the bounding box - width gets adapted to [%d]\n", *w); #endif - - } /* check if outside-right of bounding box */ - if (bx1 + bw == bbx2 && ax1 + aw > bbx2) { - + if (bx1 + bw == bbx2 && ax1 + aw > bbx2) + { *w += ax1 + aw - bbx2; #ifdef DEBUG fprintf(stderr, "intersect_bb: session box is outside-right of the bounding box - width gets adapted to [%d]\n", *w); #endif - } /* @@ -3726,34 +3603,31 @@ Bool intersect_bb(int ax1, int ay1, unsigned int aw, unsigned int ah, */ /* check if outside-above of bounding box */ - if (by1 == bby1 && ay1 < bby1) { - + if (by1 == bby1 && ay1 < bby1) + { *h += bby1 - ay1; *y = 0; #ifdef DEBUG fprintf(stderr, "intersect_bb: session box is outside-above of the bounding box - height gets adapted to [%d]\n", *h); #endif - } /* check if outside-below of bounding box */ - if (by1 + bh == bby2 && ay1 + ah > bby2) { - + if (by1 + bh == bby2 && ay1 + ah > bby2) + { *h += ay1 + ah - bby2; #ifdef DEBUG fprintf(stderr, "intersect_bb: session box is outside-below of the bounding box - height gets adapted to [%d]\n", *h); #endif - } - } return result; } #endif -RRModePtr nxagentRRCustomMode = NULL; +RRModePtr nxagentRRCustomMode = NULL; /* This is basically the code that was used on screen resize before @@ -3763,38 +3637,36 @@ RRModePtr nxagentRRCustomMode = NULL; void nxagentAdjustCustomMode(ScreenPtr pScreen) { rrScrPrivPtr pScrPriv = rrGetScrPriv(pScreen); - RROutputPtr output; if (pScrPriv) { - output = RRFirstOutput(pScreen); + RROutputPtr output = RRFirstOutput(pScreen); if (output && output -> crtc) { - RRCrtcPtr crtc; - char name[100]; - xRRModeInfo modeInfo; const int refresh = 60; int width = nxagentOption(Width); int height = nxagentOption(Height); - crtc = output -> crtc; + RRCrtcPtr crtc = output -> crtc; for (int c = 0; c < pScrPriv -> numCrtcs; c++) { RRCrtcSet(pScrPriv -> crtcs[c], NULL, 0, 0, RR_Rotate_0, 0, NULL); } - memset(&modeInfo, '\0', sizeof(modeInfo)); + char name[100]; sprintf(name, "%dx%d", width, height); - modeInfo.width = width; - modeInfo.height = height; - modeInfo.hTotal = width; - modeInfo.vTotal = height; - modeInfo.dotClock = ((CARD32) width * (CARD32) height * - (CARD32) refresh); - modeInfo.nameLength = strlen(name); + xRRModeInfo modeInfo = { + .width = width, + .height = height, + .hTotal = width, + .vTotal = height, + .dotClock = ((CARD32) width * (CARD32) height * + (CARD32) refresh), + .nameLength = strlen(name) + }; if (nxagentRRCustomMode != NULL) { @@ -3936,19 +3808,13 @@ void nxagentDropOutput(RROutputPtr o) int nxagentAdjustRandRXinerama(ScreenPtr pScreen) { - rrScrPrivPtr pScrPriv; - RROutputPtr output; - xRRModeInfo modeInfo; - char name[100]; - int refresh = 60; - int width = nxagentOption(Width); - int height = nxagentOption(Height); + int width = nxagentOption(Width); + int height = nxagentOption(Height); - pScrPriv = rrGetScrPriv(pScreen); + rrScrPrivPtr pScrPriv = rrGetScrPriv(pScreen); if (pScrPriv) { - int i; int number = 0; XineramaScreenInfo *screeninfo = XineramaQueryScreens(nxagentDisplay, &number); @@ -3957,7 +3823,7 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) { #ifdef DEBUG fprintf(stderr, "nxagentAdjustRandRXinerama: XineramaQueryScreens() returned [%d] screens:\n", number); - for (int i=0; i < number; i++) { + for (int i = 0; i < number; i++) { fprintf(stderr, "nxagentAdjustRandRXinerama: screen_number [%d] x_org [%d] y_org [%d] width [%d] height [%d]\n", screeninfo[i].screen_number, screeninfo[i].x_org, screeninfo[i].y_org, screeninfo[i].width, screeninfo[i].height); } #endif @@ -4002,15 +3868,13 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) #ifdef DEBUG fprintf(stderr, "nxagentAdjustRandRXinerama: numCrtcs [%d], numOutputs [%d]\n", pScrPriv->numCrtcs, pScrPriv->numOutputs); { - Bool rrgetinfo; - /* * Convert old RANDR 1.0 data (if any) to current structure. This * is needed once at the first run of this function. If we don't * do this here it will be done implicitly later and add mode(s) to * our crtc(s)! */ - rrgetinfo = RRGetInfo(pScreen, FALSE); + Bool rrgetinfo = RRGetInfo(pScreen, FALSE); fprintf(stderr, "nxagentAdjustRandRXinerama: RRGetInfo returned [%d]\n", rrgetinfo); } @@ -4025,7 +3889,7 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) bbx2 = bby2 = 0; bbx1 = bby1 = INT_MAX; - for (i = 0; i < number; i++) + for (int i = 0; i < number; i++) { bbx2 = max(bbx2, screeninfo[i].x_org + screeninfo[i].width); bby2 = max(bby2, screeninfo[i].y_org + screeninfo[i].height); @@ -4070,7 +3934,7 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) /* set gamma. Currently the only reason for doing this is preventing the xrandr command from complaining about missing gamma. */ - for (i = 0; i < pScrPriv->numCrtcs; i++) + for (int i = 0; i < pScrPriv->numCrtcs; i++) { if (pScrPriv->crtcs[i]->gammaSize == 0) { @@ -4082,19 +3946,22 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) } /* delete superfluous non-NX outputs */ - for (i = pScrPriv->numOutputs - 1; i >= 0; i--) + for (int i = pScrPriv->numOutputs - 1; i >= 0; i--) if (strncmp(pScrPriv->outputs[i]->name, "NX", 2)) nxagentDropOutput(pScrPriv->outputs[i]); /* at this stage only NX outputs are left - we delete the superfluous ones */ - for (i = pScrPriv->numOutputs - 1; i >= number; i--) + for (int i = pScrPriv->numOutputs - 1; i >= number; i--) nxagentDropOutput(pScrPriv->outputs[i]); /* add and init outputs */ - for (i = 0; i < number; i++) + for (int i = 0; i < number; i++) { + RROutputPtr output; + if (i >= pScrPriv->numOutputs) { + char name[100]; sprintf(name, "NX%d", i+1); output = RROutputCreate(pScreen, name, strlen(name), NULL); /* will be done later @@ -4120,10 +3987,8 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) RROutputSetPhysicalSize(output, 0, 0); } - for (i = 0; i < pScrPriv->numOutputs; i++) + for (int i = 0; i < pScrPriv->numOutputs; i++) { - Bool disable_output = FALSE; - RRModePtr mymode = NULL, prevmode = NULL; int new_x = 0; int new_y = 0; unsigned int new_w = 0; @@ -4131,22 +3996,22 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) /* if there's no intersection disconnect the output */ #ifdef NXAGENT_RANDR_XINERAMA_CLIPPING - disable_output = !intersect(nxagentOption(X), nxagentOption(Y), - width, height, - screeninfo[i].x_org, screeninfo[i].y_org, - screeninfo[i].width, screeninfo[i].height, - &new_x, &new_y, &new_w, &new_h); + Bool disable_output = !intersect(nxagentOption(X), nxagentOption(Y), + width, height, + screeninfo[i].x_org, screeninfo[i].y_org, + screeninfo[i].width, screeninfo[i].height, + &new_x, &new_y, &new_w, &new_h); #else - disable_output = !intersect_bb(nxagentOption(X), nxagentOption(Y), - width, height, - screeninfo[i].x_org, screeninfo[i].y_org, - screeninfo[i].width, screeninfo[i].height, - bbx1, bby1, bbx2, bby2, - &new_x, &new_y, &new_w, &new_h); + Bool disable_output = !intersect_bb(nxagentOption(X), nxagentOption(Y), + width, height, + screeninfo[i].x_org, screeninfo[i].y_org, + screeninfo[i].width, screeninfo[i].height, + bbx1, bby1, bbx2, bby2, + &new_x, &new_y, &new_w, &new_h); #endif /* save previous mode */ - prevmode = pScrPriv->crtcs[i]->mode; + RRModePtr prevmode = pScrPriv->crtcs[i]->mode; #ifdef DEBUG if (prevmode) { @@ -4197,22 +4062,25 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) RROutputSetConnection(pScrPriv->outputs[i], RR_Connected); - memset(&modeInfo, '\0', sizeof(modeInfo)); - /* avoid collisions with pre-existing default modes by using a separate namespace. If we'd simply use XxY we could not distinguish between pre-existing modes which should stay and our own modes that should be removed after use. */ + char name[100]; sprintf(name, "%s%dx%d", QUOTE(NXAGENT_RANDR_MODE_PREFIX), new_w, new_h); - modeInfo.width = new_w; - modeInfo.height = new_h; - modeInfo.hTotal = new_w; - modeInfo.vTotal = new_h; - modeInfo.dotClock = ((CARD32) new_w * (CARD32) new_h * (CARD32) refresh); - modeInfo.nameLength = strlen(name); + const int refresh = 60; + + xRRModeInfo modeInfo = { + .width = new_w, + .height = new_h, + .hTotal = new_w, + .vTotal = new_h, + .dotClock = ((CARD32) new_w * (CARD32) new_h * (CARD32) refresh), + .nameLength = strlen(name) + }; - mymode = RRModeGet(&modeInfo, name); + RRModePtr mymode = RRModeGet(&modeInfo, name); #ifdef DEBUG if (mymode) @@ -4310,8 +4178,6 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) void nxagentSaveAreas(PixmapPtr pPixmap, RegionPtr prgnSave, int xorg, int yorg, WindowPtr pWin) { - XGCValues values = {0}; - miBSWindowPtr pBackingStore = (miBSWindowPtr) pWin -> backStorage; PixmapPtr pVirtualPixmap = nxagentVirtualPixmap(pPixmap); @@ -4323,7 +4189,7 @@ void nxagentSaveAreas(PixmapPtr pPixmap, RegionPtr prgnSave, int xorg, int yorg, fbCopyWindowProc(&pWin -> drawable, &pVirtualPixmap -> drawable, 0, RegionRects(prgnSave), RegionNumRects(prgnSave), xorg, yorg, FALSE, FALSE, 0, 0); - values.subwindow_mode = IncludeInferiors; + XGCValues values = {.subwindow_mode = IncludeInferiors}; XlibGC gc = XCreateGC(nxagentDisplay, nxagentWindow(screenInfo.screens[0]->root), GCSubwindowMode, &values); @@ -4417,8 +4283,6 @@ void nxagentSaveAreas(PixmapPtr pPixmap, RegionPtr prgnSave, int xorg, int yorg, void nxagentRestoreAreas(PixmapPtr pPixmap, RegionPtr prgnRestore, int xorg, int yorg, WindowPtr pWin) { - XGCValues values = {0}; - /* * Limit the area to restore to the * root window size. @@ -4434,7 +4298,7 @@ void nxagentRestoreAreas(PixmapPtr pPixmap, RegionPtr prgnRestore, int xorg, fbCopyWindowProc(&pVirtualPixmap -> drawable, &pWin -> drawable, 0, RegionRects(prgnRestore), RegionNumRects(prgnRestore), -xorg, -yorg, FALSE, FALSE, 0, 0); - values.subwindow_mode = ClipByChildren; + XGCValues values = {.subwindow_mode = ClipByChildren}; XlibGC gc = XCreateGC(nxagentDisplay, nxagentWindow(screenInfo.screens[0]->root), GCSubwindowMode, &values); @@ -4597,9 +4461,9 @@ void nxagentSetWMNormalHints(int screen, int width, int height) */ void nxagentSetWMNormalHintsMaxsize(ScreenPtr pScreen, int maxwidth, int maxheight) { - XSizeHints* sizeHints; + XSizeHints* sizeHints = XAllocSizeHints(); - if ((sizeHints = XAllocSizeHints())) + if (sizeHints) { sizeHints->flags = PMaxSize; sizeHints->max_width = maxwidth; diff --git a/nx-X11/programs/Xserver/hw/nxagent/Window.c b/nx-X11/programs/Xserver/hw/nxagent/Window.c index 40af9c60e..d60be1aa7 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Window.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Window.c @@ -407,7 +407,7 @@ Bool nxagentCreateWindow(WindowPtr pWin) if (nxagentReportPrivateWindowIds) { - fprintf (stderr, "NXAGENT_WINDOW_ID: PRIVATE_WINDOW,WID:[0x%x]\n", nxagentWindowPriv(pWin)->window); + fprintf(stderr, "NXAGENT_WINDOW_ID: PRIVATE_WINDOW,WID:[0x%x],INT:[0x%x]\n", nxagentWindowPriv(pWin)->window, pWin->drawable.id); } #ifdef TEST fprintf(stderr, "nxagentCreateWindow: Created new window with id [0x%x].\n", @@ -1228,8 +1228,8 @@ void nxagentMoveViewport(ScreenPtr pScreen, int hShift, int vShift) /* * This will update the window on the real X server by calling - * XConfigureWindow()/XMapWindow()/XLowerWindow()/XRaiseWindow() - * mask definesthe values that need to be updated, see e.g + * XConfigureWindow()/XMapWindow()/XLowerWindow()/XRaiseWindow(). + * mask defines the values that need to be updated, see e.g. * man XConfigureWindow. * * In addition to the bit flags known to Xorg it uses these @@ -1281,35 +1281,30 @@ void nxagentConfigureWindow(WindowPtr pWin, unsigned int mask) if (mask & CWX) { valuemask |= CWX; - values.x = nxagentWindowPriv(pWin)->x = pWin->origin.x - wBorderWidth(pWin); } if (mask & CWY) { valuemask |= CWY; - values.y = nxagentWindowPriv(pWin)->y = pWin->origin.y - wBorderWidth(pWin); } if (mask & CWWidth) { valuemask |= CWWidth; - values.width = nxagentWindowPriv(pWin)->width = pWin->drawable.width; } if (mask & CWHeight) { valuemask |= CWHeight; - values.height = nxagentWindowPriv(pWin)->height = pWin->drawable.height; } if (mask & CWBorderWidth) { valuemask |= CWBorderWidth; - values.border_width = nxagentWindowPriv(pWin)->borderWidth = pWin->borderWidth; } @@ -3037,7 +3032,7 @@ static void nxagentReconnectWindow(void * param0, XID param1, void * data_buffer if (nxagentReportPrivateWindowIds) { - fprintf (stderr, "NXAGENT_WINDOW_ID: PRIVATE_WINDOW,WID:[0x%x]\n", nxagentWindowPriv(pWin)->window); + fprintf(stderr, "NXAGENT_WINDOW_ID: PRIVATE_WINDOW,WID:[0x%x],INT:[0x%x]\n", nxagentWindowPriv(pWin)->window, pWin->drawable.id); } #ifdef TEST fprintf(stderr, "nxagentReconnectWindow: Created new window with id [0x%x].\n", @@ -3447,10 +3442,7 @@ void nxagentSetTopLevelEventMask(WindowPtr pWin) */ void nxagentFlushConfigureWindow(void) { - ConfiguredWindowStruct *index; - XWindowChanges changes; - - index = nxagentConfiguredWindowList; + ConfiguredWindowStruct *index = nxagentConfiguredWindowList; while (index) { @@ -3493,8 +3485,10 @@ void nxagentFlushConfigureWindow(void) if (nxagentExposeQueue.exposures[i].synchronize == 1) { - changes.x = nxagentExposeQueue.exposures[i].serial; - changes.y = -2; + XWindowChanges changes = { + .x = nxagentExposeQueue.exposures[i].serial, + .y = -2 + }; #ifdef DEBUG fprintf(stderr, "nxagentFlushConfigureWindow: Sending synch ConfigureWindow for " |