diff --git a/nx-X11/programs/Xserver/GL/glx/glxext.c b/nx-X11/programs/Xserver/GL/glx/glxext.c index 4f2d2082dd..328b0a3cf9 100644 --- a/nx-X11/programs/Xserver/GL/glx/glxext.c +++ b/nx-X11/programs/Xserver/GL/glx/glxext.c @@ -387,12 +387,15 @@ __GLXcontext *__glXForceCurrent(__GLXclientState *cl, GLXContextTag tag, /************************************************************************/ -#ifndef NXAGENT_SERVER /* ** Top level dispatcher; all commands are executed from here down. */ +#ifdef NXAGENT_SERVER +static int xorg__glXDispatch(ClientPtr client) +#else static int __glXDispatch(ClientPtr client) +#endif { REQUEST(xGLXSingleReq); CARD8 opcode; @@ -449,8 +452,6 @@ static int __glXDispatch(ClientPtr client) return (*proc)(cl, (GLbyte *) stuff); } -#endif /* NXAGENT_SERVER */ - int __glXNoSuchSingleOpcode(__GLXclientState *cl, GLbyte *pc) { diff --git a/nx-X11/programs/Xserver/Imakefile b/nx-X11/programs/Xserver/Imakefile index db2f0d7a55..29bd485ce5 100644 --- a/nx-X11/programs/Xserver/Imakefile +++ b/nx-X11/programs/Xserver/Imakefile @@ -247,7 +247,7 @@ NXAGENTOBJS = hw/nxagent/miinitext.o \ hw/nxagent/NXextension.o \ hw/nxagent/NXglxext.o \ hw/nxagent/NXresource.o \ - hw/nxagent/NXdamage.o \ + hw/nxagent/damage.o \ $(NULL) #elif !defined(Win32Architecture) NXAGENTOBJS = hw/nxagent/miinitext.o \ @@ -264,7 +264,7 @@ NXAGENTOBJS = hw/nxagent/miinitext.o \ hw/nxagent/NXglxext.o \ hw/nxagent/NXxvdisp.o \ hw/nxagent/NXresource.o \ - hw/nxagent/NXdamage.o \ + hw/nxagent/damage.o \ $(NULL) #else NXAGENTOBJS = hw/nxagent/miinitext.o \ @@ -281,7 +281,7 @@ NXAGENTOBJS = hw/nxagent/miinitext.o \ hw/nxagent/NXglxext.o \ hw/nxagent/NXxvdisp.o \ hw/nxagent/NXresource.o \ - hw/nxagent/NXdamage.o \ + hw/nxagent/damage.o \ dix/main.o \ $(NULL) #endif diff --git a/nx-X11/programs/Xserver/Xext/Imakefile b/nx-X11/programs/Xserver/Xext/Imakefile index 8262f667dc..8198e302c8 100644 --- a/nx-X11/programs/Xserver/Xext/Imakefile +++ b/nx-X11/programs/Xserver/Xext/Imakefile @@ -43,10 +43,7 @@ XF86BIGFOBJS = xf86bigfont.o #endif #endif -#if BuildXvExt && ( (defined(NXAgentServer) && NXAgentServer) && !defined(SunArchitecture) && !defined(cygwinArchitecture) ) - XVSRCS = xvmain.c xvmc.c - XVOBJS = xvmain.o xvmc.o -#elif BuildXvExt +#if BuildXvExt XVSRCS = xvmain.c xvdisp.c xvmc.c XVOBJS = xvmain.o xvdisp.o xvmc.o #endif diff --git a/nx-X11/programs/Xserver/Xext/shm.c b/nx-X11/programs/Xserver/Xext/shm.c index 8e99b10473..4818719848 100644 --- a/nx-X11/programs/Xserver/Xext/shm.c +++ b/nx-X11/programs/Xserver/Xext/shm.c @@ -189,9 +189,12 @@ static Bool CheckForShmSyscall() #endif -#ifndef NXAGENT_SERVER void +#ifdef NXAGENT_SERVER +xorg_ShmExtensionInit(void) +#else ShmExtensionInit(void) +#endif { ExtensionEntry *extEntry; int i; @@ -253,7 +256,6 @@ ShmExtensionInit(void) EventSwapVector[ShmCompletionCode] = (EventSwapPtr) SShmCompletionEvent; } } -#endif /* NXAGENT_SERVER */ /*ARGSUSED*/ static void @@ -490,9 +492,12 @@ ProcShmDetach(client) return(client->noClientException); } -#ifndef NXAGENT_SERVER static void +#ifdef NXAGENT_SERVER +xorg_miShmPutImage(dst, pGC, depth, format, w, h, sx, sy, sw, sh, dx, dy, data) +#else miShmPutImage(dst, pGC, depth, format, w, h, sx, sy, sw, sh, dx, dy, data) +#endif DrawablePtr dst; GCPtr pGC; int depth, w, h, sx, sy, sw, sh, dx, dy; @@ -525,6 +530,7 @@ miShmPutImage(dst, pGC, depth, format, w, h, sx, sy, sw, sh, dx, dy, data) (*pmap->drawable.pScreen->DestroyPixmap)(pmap); } +#ifndef NXAGENT_SERVER static void fbShmPutImage(dst, pGC, depth, format, w, h, sx, sy, sw, sh, dx, dy, data) DrawablePtr dst; @@ -1138,9 +1144,12 @@ ProcShmCreatePixmap(client) return (BadAlloc); } -#ifndef NXAGENT_SERVER static int +#ifdef NXAGENT_SERVER +xorg_ProcShmDispatch (client) +#else ProcShmDispatch (client) +#endif register ClientPtr client; { REQUEST(xReq); @@ -1174,7 +1183,6 @@ ProcShmDispatch (client) return BadRequest; } } -#endif /* NXAGENT_SERVER */ static void SShmCompletionEvent(from, to) @@ -1278,9 +1286,12 @@ SProcShmCreatePixmap(client) return ProcShmCreatePixmap(client); } -#ifndef NXAGENT_SERVER static int +#ifdef NXAGENT_SERVER +xorg_SProcShmDispatch (client) +#else SProcShmDispatch (client) +#endif register ClientPtr client; { REQUEST(xReq); @@ -1302,4 +1313,3 @@ SProcShmDispatch (client) return BadRequest; } } -#endif /* NXAGENT_SERVER */ diff --git a/nx-X11/programs/Xserver/Xext/xvdisp.c b/nx-X11/programs/Xserver/Xext/xvdisp.c index 54ab4ac48b..60239b5e39 100644 --- a/nx-X11/programs/Xserver/Xext/xvdisp.c +++ b/nx-X11/programs/Xserver/Xext/xvdisp.c @@ -224,10 +224,12 @@ static int SWriteImageFormatInfo(ClientPtr, xvImageFormatInfo*); ** */ -#if !defined(NXAGENT_SERVER) || defined(__sun) || defined(__CYGWIN__) - int +#ifdef NXAGENT_SERVER +xorg_ProcXvDispatch(ClientPtr client) +#else ProcXvDispatch(ClientPtr client) +#endif { REQUEST(xReq); @@ -309,7 +311,11 @@ ProcXvDispatch(ClientPtr client) } int +#ifdef NXAGENT_SERVER +xorg_SProcXvDispatch(ClientPtr client) +#else SProcXvDispatch(ClientPtr client) +#endif { REQUEST(xReq); @@ -353,7 +359,6 @@ SProcXvDispatch(ClientPtr client) } } } -#endif /* !defined(NXAGENT_SERVER) || defined(__sun) || defined(__CYGWIN__) */ static int diff --git a/nx-X11/programs/Xserver/dix/dispatch.c b/nx-X11/programs/Xserver/dix/dispatch.c index d656da748d..23db801ddc 100644 --- a/nx-X11/programs/Xserver/dix/dispatch.c +++ b/nx-X11/programs/Xserver/dix/dispatch.c @@ -213,16 +213,18 @@ UpdateCurrentTimeIf() currentTime = systime; } -#ifndef NXAGENT_SERVER void -InitSelections() +#ifdef NXAGENT_SERVER +xorg_InitSelections(void) +#else +InitSelections(void) +#endif { if (CurrentSelections) free(CurrentSelections); CurrentSelections = (Selection *)NULL; NumCurrentSelections = 0; } -#endif /* NXAGENT_SERVER */ #undef SMART_DEBUG @@ -3475,11 +3477,14 @@ InitProcVectors(void) * then killed again, the client is really destroyed. *********************/ -#ifndef NXAGENT_SERVER char dispatchExceptionAtReset = DE_RESET; void -CloseDownClient(register ClientPtr client) +#ifdef NXAGENT_SERVER +xorg_CloseDownClient(ClientPtr client) +#else +CloseDownClient(ClientPtr client) +#endif { Bool really_close_down = client->clientGone || client->closeDownMode == DestroyAll; @@ -3564,7 +3569,6 @@ CloseDownClient(register ClientPtr client) currentMaxClients--; } } -#endif /* NXAGENT_SERVER */ static void KillAllClients() @@ -3641,9 +3645,12 @@ void InitClient(ClientPtr client, int i, void * ospriv) client->clientIds = NULL; } -#ifndef NXAGENT_SERVER int +#ifdef NXAGENT_SERVER +xorg_InitClientPrivates(ClientPtr client) +#else InitClientPrivates(ClientPtr client) +#endif { register char *ptr; DevUnion *ppriv; @@ -3687,7 +3694,6 @@ InitClientPrivates(ClientPtr client) } return 1; } -#endif /* NXAGENT_SERVER */ /************************ * int NextAvailableClient(ospriv) diff --git a/nx-X11/programs/Xserver/dix/events.c b/nx-X11/programs/Xserver/dix/events.c index 70224c3b8a..c99e55a87a 100644 --- a/nx-X11/programs/Xserver/dix/events.c +++ b/nx-X11/programs/Xserver/dix/events.c @@ -1216,10 +1216,14 @@ CheckGrabForSyncs(register DeviceIntPtr thisDev, Bool thisMode, Bool otherMode) ComputeFreezes(); } -#ifndef NXAGENT_SERVER void -ActivatePointerGrab(register DeviceIntPtr mouse, register GrabPtr grab, +#ifdef NXAGENT_SERVER +xorg_ActivatePointerGrab(register DeviceIntPtr mouse, register GrabPtr grab, + TimeStamp time, Bool autoGrab) +#else +ActivatePointerGrab(register DeviceIntPtr mouse, register GrabPtr grab, TimeStamp time, Bool autoGrab) +#endif { WindowPtr oldWin = (mouse->grab) ? mouse->grab->window : sprite.win; @@ -1246,7 +1250,11 @@ ActivatePointerGrab(register DeviceIntPtr mouse, register GrabPtr grab, } void +#ifdef NXAGENT_SERVER +xorg_DeactivatePointerGrab(register DeviceIntPtr mouse) +#else DeactivatePointerGrab(register DeviceIntPtr mouse) +#endif { register GrabPtr grab = mouse->grab; register DeviceIntPtr dev; @@ -1268,7 +1276,6 @@ DeactivatePointerGrab(register DeviceIntPtr mouse) FreeCursor(grab->cursor, (Cursor)0); ComputeFreezes(); } -#endif /* NXAGENT_SERVER */ void ActivateKeyboardGrab(register DeviceIntPtr keybd, GrabPtr grab, TimeStamp time, Bool passive) @@ -1429,7 +1436,11 @@ AllowSome(ClientPtr client, TimeStamp time, DeviceIntPtr thisDev, int newState) } int +#ifdef NXAGENT_SERVER +xorg_ProcAllowEvents(register ClientPtr client) +#else ProcAllowEvents(register ClientPtr client) +#endif { TimeStamp time; DeviceIntPtr mouse = inputInfo.pointer; @@ -2063,9 +2074,12 @@ void ReinitializeRootWindow(WindowPtr win, int xoff, int yoff) } #endif -#ifndef NXAGENT_SERVER void +#ifdef NXAGENT_SERVER +xorg_DefineInitialRootWindow(register WindowPtr win) +#else DefineInitialRootWindow(register WindowPtr win) +#endif { register ScreenPtr pScreen = win->drawable.pScreen; @@ -2105,7 +2119,6 @@ DefineInitialRootWindow(register WindowPtr win) } #endif } -#endif /* NXAGENT_SERVER */ /* * This does not take any shortcuts, and even ignores its argument, since @@ -3940,9 +3953,12 @@ CloseDownEvents(void) spriteTraceSize = 0; } -#ifndef NXAGENT_SERVER int +#ifdef NXAGENT_SERVER +xorg_ProcSendEvent(ClientPtr client) +#else ProcSendEvent(ClientPtr client) +#endif { WindowPtr pWin; WindowPtr effectiveFocus = NullWindow; /* only set if dest==InputFocus */ @@ -4027,7 +4043,6 @@ ProcSendEvent(ClientPtr client) NullGrab, 0); return Success; } -#endif /* NXAGENT_SERVER */ int ProcUngrabKey(ClientPtr client) diff --git a/nx-X11/programs/Xserver/dix/extension.c b/nx-X11/programs/Xserver/dix/extension.c index 763f57337c..d12eb80d90 100644 --- a/nx-X11/programs/Xserver/dix/extension.c +++ b/nx-X11/programs/Xserver/dix/extension.c @@ -79,6 +79,10 @@ extern int extensionPrivateLen; extern unsigned *extensionPrivateSizes; extern unsigned totalExtensionSize; +#ifdef NXAGENT_SERVER +#include "NXhooks.h" +#endif + static void InitExtensionPrivates(ExtensionEntry *ext) { @@ -332,7 +336,6 @@ CloseDownExtensions() } } -#ifndef NXAGENT_SERVER int ProcQueryExtension(ClientPtr client) { @@ -354,6 +357,9 @@ ProcQueryExtension(ClientPtr client) { i = FindExtension((char *)&stuff[1], stuff->nbytes); if (i < 0 +#ifdef NXAGENT_SERVER + || nxagentHook_IsFaultyRenderExtension(extensions[i]->name) +#endif #ifdef XCSECURITY /* don't show insecure extensions to untrusted clients */ || (client->trustLevel == XSecurityClientUntrusted && @@ -400,6 +406,10 @@ ProcListExtensions(ClientPtr client) if (client->trustLevel == XSecurityClientUntrusted && !extensions[i]->secure) continue; +#endif +#ifdef NXAGENT_SERVER + if (nxagentHook_IsFaultyRenderExtension(extensions[i]->name)) + continue; #endif total_length += strlen(extensions[i]->name) + 1; reply.nExtensions += 1 + extensions[i]->num_aliases; @@ -437,7 +447,6 @@ ProcListExtensions(ClientPtr client) } return(client->noClientException); } -#endif ExtensionLookupProc LookupProc(char *name, GCPtr pGC) diff --git a/nx-X11/programs/Xserver/dix/window.c b/nx-X11/programs/Xserver/dix/window.c index ee146d7830..9bfaaceae4 100644 --- a/nx-X11/programs/Xserver/dix/window.c +++ b/nx-X11/programs/Xserver/dix/window.c @@ -497,9 +497,12 @@ CreateRootWindow(ScreenPtr pScreen) return TRUE; } -#ifndef NXAGENT_SERVER void +#ifdef NXAGENT_SERVER +xorg_InitRootWindow(WindowPtr pWin) +#else InitRootWindow(WindowPtr pWin) +#endif { ScreenPtr pScreen = pWin->drawable.pScreen; int backFlag = CWBorderPixel | CWCursor | CWBackingStore; @@ -531,7 +534,6 @@ InitRootWindow(WindowPtr pWin) MapWindow(pWin, serverClient); } -#endif /* NXAGENT_SERVER */ /* Set the region to the intersection of the rectangle and the * window's winSize. The window is typically the parent of the @@ -913,7 +915,6 @@ CrushTree(WindowPtr pWin) * If wid is None, don't send any events *****/ -#ifndef NXAGENT_SERVER int DeleteWindow(void * value, XID wid) { @@ -949,7 +950,6 @@ DeleteWindow(void * value, XID wid) free(pWin); return Success; } -#endif /* NXAGENT_SERVER */ void DestroySubwindows(register WindowPtr pWin, ClientPtr client) @@ -1801,7 +1801,6 @@ GravityTranslate (register int x, register int y, int oldx, int oldy, } /* XXX need to retile border on each window with ParentRelative origin */ -#ifndef NXAGENT_SERVER void ResizeChildrenWinSize(register WindowPtr pWin, int dx, int dy, int dw, int dh) { @@ -1838,7 +1837,23 @@ ResizeChildrenWinSize(register WindowPtr pWin, int dx, int dy, int dw, int dh) pSib->drawable.y = pWin->drawable.y + pSib->origin.y; SetWinSize (pSib); SetBorderSize (pSib); + +#ifdef NXAGENT_SERVER + /* + * Don't force X to move children. It will position them + * according with gravity. + * + * (*pScreen->PositionWindow)(pSib, pSib->drawable.x, pSib->drawable.y); + */ + + /* + * Update pSib privates, as this window is moved by X. + */ + + nxagentAddConfiguredWindow(pSib, CW_Update); +#else (*pScreen->PositionWindow)(pSib, pSib->drawable.x, pSib->drawable.y); +#endif if ( (pChild = pSib->firstChild) ) { @@ -1866,7 +1881,6 @@ ResizeChildrenWinSize(register WindowPtr pWin, int dx, int dy, int dw, int dh) } } } -#endif /* NXAGENT_SERVER */ #define GET_INT16(m, f) \ if (m & mask) \ @@ -2210,7 +2224,6 @@ ReflectStackChange( * ConfigureWindow *****/ -#ifndef NXAGENT_SERVER int ConfigureWindow(register WindowPtr pWin, register Mask mask, XID *vlist, ClientPtr client) { @@ -2228,7 +2241,7 @@ ConfigureWindow(register WindowPtr pWin, register Mask mask, XID *vlist, ClientP h = pWin->drawable.height, bw = pWin->borderWidth; int action, smode = Above; - xEvent event; + xEvent event = {0}; if ((pWin->drawable.class == InputOnly) && (mask & IllegalInputOnlyConfigureMask)) return(BadMatch); @@ -2317,6 +2330,32 @@ ConfigureWindow(register WindowPtr pWin, register Mask mask, XID *vlist, ClientP /* Figure out if the window should be moved. Doesnt make the changes to the window if event sent */ +#ifdef NXAGENT_SERVER + extern Bool nxagentScreenTrap; + + #ifdef TEST + if (nxagentWindowTopLevel(pWin)) + { + + fprintf(stderr, "ConfigureWindow: pWin [%p] mask [%lu] client [%p]\n", + pWin, mask, client); + + fprintf(stderr, "ConfigureWindow: x [%d] y [%d] w [%d] h [%d] CWStackMode [%d] " + "smode [%d] pSib [%p]\n", + x, y, w, h, (mask & CWStackMode) ? 1 : 0, smode, pSib); + } + #endif + + if (nxagentOption(Rootless) && nxagentWindowTopLevel(pWin) && + pWin -> overrideRedirect == 0 && + nxagentScreenTrap == 0) + { + nxagentConfigureRootlessWindow(pWin, x, y, w, h, bw, pSib, smode, mask); + + return Success; + } +#endif + if (mask & CWStackMode) pSib = WhereDoIGoInTheStack(pWin, pSib, pParent->drawable.x + x, pParent->drawable.y + y, @@ -2458,13 +2497,17 @@ ConfigureWindow(register WindowPtr pWin, register Mask mask, XID *vlist, ClientP if (action != RESTACK_WIN) CheckCursorConfinement(pWin); + +#ifdef NXAGENT_SERVER + nxagentFlushConfigureWindow(); +#endif + return(Success); #undef RESTACK_WIN #undef MOVE_WIN #undef RESIZE_WIN #undef REBORDER_WIN } -#endif /* NXAGENT_SERVER */ /****** @@ -2560,7 +2603,6 @@ CompareWIDs( * ReparentWindow *****/ -#ifndef NXAGENT_SERVER int ReparentWindow(register WindowPtr pWin, register WindowPtr pParent, int x, int y, ClientPtr client) @@ -2611,6 +2653,14 @@ ReparentWindow(register WindowPtr pWin, register WindowPtr pParent, /* insert at begining of pParent */ pWin->parent = pParent; pPrev = RealChildHead(pParent); + +#ifdef NXAGENT_SERVER + if (pWin->parent == screenInfo.screens[0]->root) + { + nxagentSetTopLevelEventMask(pWin); + } +#endif + if (pPrev) { pWin->nextSib = pPrev->nextSib; @@ -2653,7 +2703,6 @@ ReparentWindow(register WindowPtr pWin, register WindowPtr pParent, RecalculateDeliverableEvents(pWin); return(Success); } -#endif /* NXAGENT_SERVER */ static void RealizeTree(WindowPtr pWin) @@ -2696,9 +2745,12 @@ RealizeTree(WindowPtr pWin) * MapNotify event is generated. *****/ -#ifndef NXAGENT_SERVER int +#ifdef NXAGENT_SERVER +xorg_MapWindow(register WindowPtr pWin, ClientPtr client) +#else MapWindow(register WindowPtr pWin, ClientPtr client) +#endif { register ScreenPtr pScreen; @@ -2797,9 +2849,19 @@ MapWindow(register WindowPtr pWin, ClientPtr client) RegionUninit(&temp); } +#ifdef NXAGENT_SERVER + /* + * MapWindow() is always returning Success, no matter + * what. Therefore its returncode is never checked anywhere! We + * make use of that to inform the (parent) NX version of + * MapWindow() that it needs to call + * nxagentFlushConfigureWindow() + */ + return(BadImplementation); +#endif + return(Success); } -#endif /* NXAGENT_SERVER */ /***** * MapSubwindows @@ -2988,7 +3050,6 @@ UnrealizeTree( * generated. Cannot unmap a root window. *****/ -#ifndef NXAGENT_SERVER int UnmapWindow(register WindowPtr pWin, Bool fromConfigure) { @@ -3042,7 +3103,6 @@ UnmapWindow(register WindowPtr pWin, Bool fromConfigure) WindowsRestructured (); return(Success); } -#endif /* NXAGENT_SERVER */ /***** * UnmapSubwindows @@ -3336,7 +3396,6 @@ static void DrawLogo( ); #endif -#ifndef NXAGENT_SERVER void SaveScreens(int on, int mode) { @@ -3365,9 +3424,21 @@ SaveScreens(int on, int mode) (* screenInfo.screens[i]->SaveScreen) (screenInfo.screens[i], on); if (savedScreenInfo[i].ExternalScreenSaver) { - if ((*savedScreenInfo[i].ExternalScreenSaver) - (screenInfo.screens[i], type, on == SCREEN_SAVER_FORCER)) - continue; +#ifdef NXAGENT_SERVER + if (nxagentOption(Timeout) != 0) + { + #ifdef TEST + fprintf(stderr, "SaveScreens: An external screen-saver handler is installed. " + "Ignoring it to let the auto-disconnect feature work.\n"); + #endif + } + else +#endif + { + if ((*savedScreenInfo[i].ExternalScreenSaver) + (screenInfo.screens[i], type, on == SCREEN_SAVER_FORCER)) + continue; + } } if (type == screenIsSaved) continue; @@ -3447,7 +3518,6 @@ SaveScreens(int on, int mode) if (mode == ScreenSaverReset) SetScreenSaverTimer(); } -#endif /* NXAGENT_SERVER */ static Bool TileScreenSaver(int i, int kind) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Args.c b/nx-X11/programs/Xserver/hw/nxagent/Args.c index 2d998980cd..0b3fee7ffd 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Args.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Args.c @@ -277,32 +277,19 @@ int ddxProcessArgument(int argc, char *argv[], int i) { if ((!strcmp(argv[j], "-options") || !strcmp(argv[j], "-option")) && j + 1 < argc) { - if (nxagentOptionsFilenameOrString) - { - nxagentOptionsFilenameOrString = (char *) realloc(nxagentOptionsFilenameOrString, strlen(argv[j + 1]) + 1); - } - else - { - nxagentOptionsFilenameOrString = (char *) malloc(strlen(argv[j + 1]) +1); - } + free(nxagentOptionsFilenameOrString); + nxagentOptionsFilenameOrString = NULL; - if (nxagentOptionsFilenameOrString != NULL) + if (-1 == asprintf(&nxagentOptionsFilenameOrString, "%s", argv[j + 1])) { - nxagentOptionsFilenameOrString = strcpy(nxagentOptionsFilenameOrString, argv[j + 1]); - } - #ifdef WARNING - else - { - fprintf(stderr, "ddxProcessArgument: WARNING! failed string allocation.\n"); + FatalError("malloc failed"); } - #endif - break; } } nxagentProcessOptions(nxagentOptionsFilenameOrString); - } + } /* if (resetOptions == True) */ if (!strcmp(argv[i], "-B")) { @@ -1000,7 +987,7 @@ int ddxProcessArgument(int argc, char *argv[], int i) { nxagentChangeOption(Clipboard, ClipboardServer); } - else if ((!strcmp(argv[i+1], "none")) || (!strcmp(argv[i+1], "1"))) + else if ((!strcmp(argv[i+1], "none")) || (!strcmp(argv[i+1], "0"))) { nxagentChangeOption(Clipboard, ClipboardNone); } @@ -1391,29 +1378,6 @@ static void nxagentParseSingleOption(char *name, char *value) return; } - else if (strcmp(name, "clipboard") == 0) - { - if ((strcmp(value, "both") == 0) || (strcmp(value, "1") == 0)) - { - nxagentChangeOption(Clipboard, ClipboardBoth); - } - else if (strcmp(value, "client") == 0) - { - nxagentChangeOption(Clipboard, ClipboardClient); - } - else if (strcmp(value, "server") == 0) - { - nxagentChangeOption(Clipboard, ClipboardServer); - } - else if ((strcmp(value, "none") == 0) || (strcmp(value, "0") == 0)) - { - nxagentChangeOption(Clipboard, ClipboardNone); - } - else - { - nxagentChangeOption(Clipboard, ClipboardBoth); - } - } else if (!strcmp(name, "sleep")) { long sleep_parse = 0; diff --git a/nx-X11/programs/Xserver/hw/nxagent/Atoms.c b/nx-X11/programs/Xserver/hw/nxagent/Atoms.c index 2ee67b9bb1..a6b38de27e 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Atoms.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Atoms.c @@ -176,7 +176,7 @@ void nxagentWMDetect() finishWMDetection(verbose); } -int nxagentInitAtoms(WindowPtr pWin) +int nxagentInitAtoms(void) { Atom atom; diff --git a/nx-X11/programs/Xserver/hw/nxagent/Atoms.h b/nx-X11/programs/Xserver/hw/nxagent/Atoms.h index 391e061811..07d3a9b8a0 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Atoms.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Atoms.h @@ -41,7 +41,7 @@ extern Bool nxagentWMIsRunning; * to the agent server. */ -int nxagentInitAtoms(WindowPtr pWin); +int nxagentInitAtoms(void); /* * Query and create all the required atoms diff --git a/nx-X11/programs/Xserver/hw/nxagent/Imakefile b/nx-X11/programs/Xserver/hw/nxagent/Imakefile index b3450440e3..73823d8103 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Imakefile +++ b/nx-X11/programs/Xserver/hw/nxagent/Imakefile @@ -19,9 +19,10 @@ SRCS = \ NXextension.c \ NXshm.c \ NXglxext.c \ + NXhooks.c \ NXxvdisp.c \ NXresource.c \ - NXdamage.c \ + damage.c \ NXmitrap.c \ Args.c \ Binder.c \ @@ -79,9 +80,10 @@ OBJS = \ NXextension.o \ NXshm.o \ NXglxext.o \ + NXhooks.o \ NXxvdisp.o \ NXresource.o \ - NXdamage.o \ + damage.o \ NXmitrap.o \ Args.o \ Binder.o \ @@ -258,6 +260,7 @@ all:: $(OBJS) LinkSourceFile(stubs.c,$(SERVERSRC)/Xi) LinkSourceFile(xpstubs.c,$(SERVERSRC)/dix) LinkSourceFile(miinitext.c,$(SERVERSRC)/mi) +LinkSourceFile(damage.c,$(SERVERSRC)/miext/damage) SpecialCObjectRule(miinitext,$(ICONFIGFILES), $(_NOOP_)) NormalLibraryObjectRule() diff --git a/nx-X11/programs/Xserver/hw/nxagent/Init.c b/nx-X11/programs/Xserver/hw/nxagent/Init.c index 2a0bceaf51..bac64224bd 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Init.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Init.c @@ -71,6 +71,7 @@ is" without express or implied warranty. #include "Millis.h" #include "Error.h" #include "Keystroke.h" +#include "Atoms.h" #include #include "compext/Compext.h" @@ -421,6 +422,8 @@ FIXME: These variables, if not removed at all because have probably #ifdef NXAGENT_CLIPBOARD AddCallback(&SelectionCallback, nxagentSetSelectionCallback, NULL); #endif + + nxagentInitAtoms(); } void diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXdamage.c b/nx-X11/programs/Xserver/hw/nxagent/NXdamage.c deleted file mode 100644 index ef50edbee1..0000000000 --- a/nx-X11/programs/Xserver/hw/nxagent/NXdamage.c +++ /dev/null @@ -1,225 +0,0 @@ -/**************************************************************************/ -/* */ -/* Copyright (c) 2001, 2011 NoMachine (http://www.nomachine.com) */ -/* Copyright (c) 2008-2014 Oleksandr Shneyder */ -/* Copyright (c) 2011-2016 Mike Gabriel */ -/* Copyright (c) 2014-2016 Mihai Moldovan */ -/* Copyright (c) 2014-2016 Ulrich Sibiller */ -/* Copyright (c) 2015-2016 Qindel Group (http://www.qindel.com) */ -/* */ -/* NXAGENT, NX protocol compression and NX extensions to this software */ -/* are copyright of the aforementioned persons and companies. */ -/* */ -/* Redistribution and use of the present software is allowed according */ -/* to terms specified in the file LICENSE which comes in the source */ -/* distribution. */ -/* */ -/* All rights reserved. */ -/* */ -/* NOTE: This software has received contributions from various other */ -/* contributors, only the core maintainers and supporters are listed as */ -/* copyright holders. Please contact us, if you feel you should be listed */ -/* as copyright holder, as well. */ -/* */ -/**************************************************************************/ - -/* - * $Id: damage.c,v 1.19 2005/10/06 21:55:41 anholt Exp $ - * - * Copyright © 2003 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#include "regionstr.h" -#include "../../miext/damage/damage.h" -#include - -/* prototypes */ - -static int -damageText (DrawablePtr pDrawable, - GCPtr pGC, - int x, - int y, - unsigned long count, - char *chars, - FontEncoding fontEncoding, - Bool textType); -static int -damagePolyText8(DrawablePtr pDrawable, - GCPtr pGC, - int x, - int y, - int count, - char *chars); -static int -damagePolyText16(DrawablePtr pDrawable, - GCPtr pGC, - int x, - int y, - int count, - unsigned short *chars); -static void -damageImageText8(DrawablePtr pDrawable, - GCPtr pGC, - int x, - int y, - int count, - char *chars); -static void -damageImageText16(DrawablePtr pDrawable, - GCPtr pGC, - int x, - int y, - int count, - unsigned short *chars); - -#include "../../miext/damage/damage.c" - -static int -damageText (DrawablePtr pDrawable, - GCPtr pGC, - int x, - int y, - unsigned long count, - char *chars, - FontEncoding fontEncoding, - Bool textType) -{ - CharInfoPtr *charinfo; - CharInfoPtr *info; - unsigned long i; - unsigned int n; - int w; - Bool imageblt; - - imageblt = (textType == TT_IMAGE8) || (textType == TT_IMAGE16); - - charinfo = (CharInfoPtr *) malloc(count * sizeof(CharInfoPtr)); - if (!charinfo) - return x; - - GetGlyphs(pGC->font, count, (unsigned char *)chars, - fontEncoding, &i, charinfo); - n = (unsigned int)i; - w = 0; - if (!imageblt) - for (info = charinfo; i--; info++) - w += (*info)->metrics.characterWidth; - - if (n != 0) { - damageDamageChars (pDrawable, pGC->font, x + pDrawable->x, y + pDrawable->y, n, - charinfo, imageblt, pGC->subWindowMode); - -#ifndef NXAGENT_SERVER - - if (imageblt) - (*pGC->ops->ImageGlyphBlt)(pDrawable, pGC, x, y, n, charinfo, - FONTGLYPHS(pGC->font)); - else - (*pGC->ops->PolyGlyphBlt)(pDrawable, pGC, x, y, n, charinfo, - FONTGLYPHS(pGC->font)); -#endif - - } - free(charinfo); - return x + w; -} - -static int -damagePolyText8(DrawablePtr pDrawable, - GCPtr pGC, - int x, - int y, - int count, - char *chars) -{ - DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); - - if (checkGCDamage (pDrawable, pGC)) - x = damageText (pDrawable, pGC, x, y, (unsigned long) count, chars, - Linear8Bit, TT_POLY8); - else - x = (*pGC->ops->PolyText8)(pDrawable, pGC, x, y, count, chars); - - DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); - return x; -} - -static int -damagePolyText16(DrawablePtr pDrawable, - GCPtr pGC, - int x, - int y, - int count, - unsigned short *chars) -{ - DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); - - if (checkGCDamage (pDrawable, pGC)) - x = damageText (pDrawable, pGC, x, y, (unsigned long) count, (char *) chars, - FONTLASTROW(pGC->font) == 0 ? Linear16Bit : TwoD16Bit, - TT_POLY16); - else - x = (*pGC->ops->PolyText16)(pDrawable, pGC, x, y, count, chars); - - DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); - return x; -} - -static void -damageImageText8(DrawablePtr pDrawable, - GCPtr pGC, - int x, - int y, - int count, - char *chars) -{ - DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); - - if (checkGCDamage (pDrawable, pGC)) - damageText (pDrawable, pGC, x, y, (unsigned long) count, chars, - Linear8Bit, TT_IMAGE8); - else - (*pGC->ops->ImageText8)(pDrawable, pGC, x, y, count, chars); - - DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); -} - -static void -damageImageText16(DrawablePtr pDrawable, - GCPtr pGC, - int x, - int y, - int count, - unsigned short *chars) -{ - DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); - - if (checkGCDamage (pDrawable, pGC)) - damageText (pDrawable, pGC, x, y, (unsigned long) count, (char *) chars, - FONTLASTROW(pGC->font) == 0 ? Linear16Bit : TwoD16Bit, - TT_IMAGE16); - else - (*pGC->ops->ImageText16)(pDrawable, pGC, x, y, count, chars); - - DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); -} - diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c b/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c index 10616834ec..d0f96e6b4d 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c @@ -128,8 +128,6 @@ Equipment Corporation. const int nxagentMaxFontNames = 10000; -char dispatchExceptionAtReset = DE_RESET; - /* * This allows the agent to exit if no * client is connected within a timeout. @@ -196,12 +194,9 @@ extern int nxagentFindClientResource(int, RESTYPE, void *); void -InitSelections() +InitSelections(void) { - if (CurrentSelections) - free(CurrentSelections); - CurrentSelections = (Selection *)NULL; - NumCurrentSelections = 0; + xorg_InitSelections(); #ifdef NXAGENT_CLIPBOARD { @@ -225,7 +220,6 @@ InitSelections() CurrentSelections[1].client = NullClient; } #endif - } #define MAJOROP ((xReq *)client->requestBuffer)->reqType @@ -628,12 +622,17 @@ ProcQueryTree(register ClientPtr client) reply.parent = (Window)None; pHead = RealChildHead(pWin); for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib) +#ifdef NXAGENT_SERVER { - if (!IsViewportFrame(pChild)) - { - numChildren++; - } + if (!IsViewportFrame(pChild)) + { + numChildren++; + } + } +#else + numChildren++; +#endif if (numChildren) { int curChild = 0; @@ -642,12 +641,16 @@ ProcQueryTree(register ClientPtr client) if (!childIDs) return BadAlloc; for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib) - { - if (!IsViewportFrame(pChild)) - { - childIDs[curChild++] = pChild->drawable.id; - } +#ifdef NXAGENT_SERVER + { + if (!IsViewportFrame(pChild)) + { + childIDs[curChild++] = pChild->drawable.id; + } } +#else + childIDs[curChild++] = pChild->drawable.id; +#endif } reply.nChildren = numChildren; @@ -710,8 +713,12 @@ ProcConvertSelection(register ClientPtr client) i = 0; while ((i < NumCurrentSelections) && CurrentSelections[i].selection != stuff->selection) i++; - if ((i < NumCurrentSelections) && + if ((i < NumCurrentSelections) && +#ifdef NXAGENT_SERVER (CurrentSelections[i].window != None) && (CurrentSelections[i].client != NullClient) +#else + (CurrentSelections[i].window != None)) +#endif #ifdef XCSECURITY && (!client->CheckAccess || (* client->CheckAccess)(client, CurrentSelections[i].window, @@ -719,7 +726,6 @@ ProcConvertSelection(register ClientPtr client) CurrentSelections[i].pWin)) #endif ) - { memset(&event, 0, sizeof(xEvent)); event.u.u.type = SelectionRequest; @@ -758,13 +764,14 @@ int ProcOpenFont(register ClientPtr client) { int err; - char fontReq[256]; REQUEST(xOpenFontReq); REQUEST_FIXED_SIZE(xOpenFontReq, stuff->nbytes); client->errorValue = stuff->fid; LEGAL_NEW_RESOURCE(stuff->fid, client); +#ifdef NXAGENT_SERVER + char fontReq[256]; memcpy(fontReq,(char *)&stuff[1],(stuff->nbytes<256)?stuff->nbytes:255); fontReq[stuff->nbytes]=0; if (strchr(fontReq,'*') || strchr(fontReq,'?')) @@ -778,6 +785,7 @@ ProcOpenFont(register ClientPtr client) stuff->nbytes, (char *)&stuff[1]); } else +#endif err = OpenFont(client, stuff->fid, (Mask) 0, stuff->nbytes, (char *)&stuff[1]); if (err == Success) @@ -848,11 +856,12 @@ ProcCloseFont(register ClientPtr client) int ProcListFonts(register ClientPtr client) { - char tmp[256]; - REQUEST(xListFontsReq); REQUEST_FIXED_SIZE(xListFontsReq, stuff->nbytes); + +#ifdef NXAGENT_SERVER + char tmp[256]; memcpy(tmp,(unsigned char *) &stuff[1],(stuff->nbytes<256)?stuff->nbytes:255); tmp[stuff->nbytes]=0; @@ -860,6 +869,8 @@ ProcListFonts(register ClientPtr client) fprintf(stderr, "Dispatch: ListFont request with pattern %s max_names=%d\n",tmp,stuff->maxNames); #endif nxagentListRemoteFonts(tmp, stuff -> maxNames < nxagentMaxFontNames ? nxagentMaxFontNames : stuff->maxNames); +#endif + return ListFonts(client, (unsigned char *) &stuff[1], stuff->nbytes, stuff->maxNames); } @@ -867,23 +878,24 @@ ProcListFonts(register ClientPtr client) int ProcListFontsWithInfo(register ClientPtr client) { - char tmp[256]; REQUEST(xListFontsWithInfoReq); REQUEST_FIXED_SIZE(xListFontsWithInfoReq, stuff->nbytes); +#ifdef NXAGENT_SERVER + char tmp[256]; memcpy(tmp,(unsigned char *) &stuff[1],(stuff->nbytes<256)?stuff->nbytes:255); tmp[stuff->nbytes]=0; #ifdef NXAGENT_FONTMATCH_DEBUG fprintf(stderr, "Dispatch: ListFont with info request with pattern %s max_names=%d\n",tmp,stuff->maxNames); #endif nxagentListRemoteFonts(tmp, stuff -> maxNames < nxagentMaxFontNames ? nxagentMaxFontNames :stuff->maxNames); +#endif return StartListFontsWithInfo(client, stuff->nbytes, (unsigned char *) &stuff[1], stuff->maxNames); } - int ProcFreePixmap(register ClientPtr client) { @@ -975,6 +987,7 @@ ProcSetScreenSaver (register ClientPtr client) return BadValue; } +#ifdef NXAGENT_SERVER /* * The NX agent uses the screen saver procedure * to monitor the user activities and launch its @@ -989,6 +1002,7 @@ ProcSetScreenSaver (register ClientPtr client) if (nxagentOption(Timeout) == 0) { +#endif if (blankingOption == DefaultBlanking) { ScreenSaverBlanking = defaultScreenSaverBlanking; @@ -1026,7 +1040,9 @@ ProcSetScreenSaver (register ClientPtr client) } SetScreenSaverTimer(); +#ifdef NXAGENT_SERVER } + #ifdef TEST else @@ -1036,7 +1052,7 @@ ProcSetScreenSaver (register ClientPtr client) } #endif - +#endif return (client->noClientException); } @@ -1054,6 +1070,7 @@ int ProcForceScreenSaver(register ClientPtr client) return BadValue; } +#ifdef NXAGENT_SERVER /* * The NX agent uses the screen saver procedure * to monitor the user activities and launch its @@ -1064,7 +1081,9 @@ int ProcForceScreenSaver(register ClientPtr client) if (nxagentOption(Timeout) == 0) { +#endif SaveScreens(SCREEN_SAVER_FORCER, (int)stuff->mode); +#ifdef NXAGENT_SERVER } #ifdef TEST @@ -1076,6 +1095,7 @@ int ProcForceScreenSaver(register ClientPtr client) } #endif +#endif return client->noClientException; } @@ -1091,9 +1111,7 @@ int ProcForceScreenSaver(register ClientPtr client) void CloseDownClient(register ClientPtr client) { - Bool really_close_down = client->clientGone || - client->closeDownMode == DestroyAll; - +#ifdef NXAGENT_SERVER /* * There must be a better way to hook a * call-back function to be called any @@ -1115,126 +1133,27 @@ CloseDownClient(register ClientPtr client) */ nxagentCheckIfShadowAgent(client); +#endif - if (!client->clientGone) - { - /* ungrab server if grabbing client dies */ - if (grabState != GrabNone && grabClient == client) - { - UngrabServer(client); - } - BITCLEAR(grabWaiters, client->index); - DeleteClientFromAnySelections(client); - ReleaseActiveGrabs(client); - DeleteClientFontStuff(client); - if (!really_close_down) - { - /* This frees resources that should never be retained - * no matter what the close down mode is. Actually we - * could do this unconditionally, but it's probably - * better not to traverse all the client's resources - * twice (once here, once a few lines down in - * FreeClientResources) in the common case of - * really_close_down == TRUE. - */ - FreeClientNeverRetainResources(client); - client->clientState = ClientStateRetained; - if (ClientStateCallback) - { - NewClientInfoRec clientinfo; - - clientinfo.client = client; - clientinfo.prefix = (xConnSetupPrefix *)NULL; - clientinfo.setup = (xConnSetup *) NULL; - CallCallbacks((&ClientStateCallback), (void *)&clientinfo); - } - } - client->clientGone = TRUE; /* so events aren't sent to client */ - if (ClientIsAsleep(client)) - ClientSignal (client); - ProcessWorkQueueZombies(); - CloseDownConnection(client); - - /* If the client made it to the Running stage, nClients has - * been incremented on its behalf, so we need to decrement it - * now. If it hasn't gotten to Running, nClients has *not* - * been incremented, so *don't* decrement it. - */ - if (client->clientState != ClientStateInitial && - client->clientState != ClientStateAuthenticating ) - { - --nClients; - } - } - - if (really_close_down) - { - if (client->clientState == ClientStateRunning && nClients == 0) - dispatchException |= dispatchExceptionAtReset; - - client->clientState = ClientStateGone; - if (ClientStateCallback) - { - NewClientInfoRec clientinfo; - - clientinfo.client = client; - clientinfo.prefix = (xConnSetupPrefix *)NULL; - clientinfo.setup = (xConnSetup *) NULL; - CallCallbacks((&ClientStateCallback), (void *)&clientinfo); - } - FreeClientResources(client); - /* Disable client ID tracking. This must be done after - * ClientStateCallback. */ - ReleaseClientIds(client); - if (client->index < nextFreeClientID) - nextFreeClientID = client->index; - clients[client->index] = NullClient; - SmartLastClient = NullClient; - free(client); - - while (!clients[currentMaxClients-1]) - currentMaxClients--; - } + xorg_CloseDownClient(client); } int InitClientPrivates(ClientPtr client) { - register char *ptr; - DevUnion *ppriv; - register unsigned *sizes; - register unsigned size; - register int i; - - if (totalClientSize == sizeof(ClientRec)) - ppriv = (DevUnion *)NULL; - else if (client->index) - ppriv = (DevUnion *)(client + 1); - else - { - ppriv = (DevUnion *)malloc(totalClientSize - sizeof(ClientRec)); - if (!ppriv) - return 0; - } - client->devPrivates = ppriv; - sizes = clientPrivateSizes; - ptr = (char *)(ppriv + clientPrivateLen); - for (i = clientPrivateLen; --i >= 0; ppriv++, sizes++) + int ret = xorg_InitClientPrivates(client); + +#ifdef NXAGENT_SERVER + if (ret == 1) { - if ( (size = *sizes) ) - { - ppriv->ptr = (void *)ptr; - ptr += size; - } - else - ppriv->ptr = (void *)NULL; - } - /* - * Initialize the private members. - */ + /* + * Initialize the private members. + */ - nxagentInitClientPrivates(client); + nxagentInitClientPrivates(client); + } +#endif - return 1; + return ret; } diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXevents.c b/nx-X11/programs/Xserver/hw/nxagent/NXevents.c index 78d74a0d58..acebeb8243 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXevents.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXevents.c @@ -151,28 +151,7 @@ void ActivatePointerGrab(register DeviceIntPtr mouse, register GrabPtr grab, TimeStamp time, Bool autoGrab) { - WindowPtr oldWin = (mouse->grab) ? mouse->grab->window - : sprite.win; - - if (grab->confineTo) - { - if (grab->confineTo->drawable.pScreen != sprite.hotPhys.pScreen) - sprite.hotPhys.x = sprite.hotPhys.y = 0; - ConfineCursorToWindow(grab->confineTo, FALSE, TRUE); - } - DoEnterLeaveEvents(oldWin, grab->window, NotifyGrab); - mouse->valuator->motionHintWindow = NullWindow; - if (syncEvents.playingEvents) - mouse->grabTime = syncEvents.time; - else - mouse->grabTime = time; - if (grab->cursor) - grab->cursor->refcnt++; - mouse->activeGrab = *grab; - mouse->grab = &mouse->activeGrab; - mouse->fromPassiveGrab = autoGrab; - PostNewCursor(); - CheckGrabForSyncs(mouse,(Bool)grab->pointerMode, (Bool)grab->keyboardMode); + xorg_ActivatePointerGrab(mouse, grab, time, autoGrab); #ifdef NXAGENT_SERVER @@ -223,25 +202,7 @@ ActivatePointerGrab(register DeviceIntPtr mouse, register GrabPtr grab, void DeactivatePointerGrab(register DeviceIntPtr mouse) { - register GrabPtr grab = mouse->grab; - register DeviceIntPtr dev; - - mouse->valuator->motionHintWindow = NullWindow; - mouse->grab = NullGrab; - mouse->sync.state = NOT_GRABBED; - mouse->fromPassiveGrab = FALSE; - for (dev = inputInfo.devices; dev; dev = dev->next) - { - if (dev->sync.other == grab) - dev->sync.other = NullGrab; - } - DoEnterLeaveEvents(grab->window, sprite.win, NotifyUngrab); - if (grab->confineTo) - ConfineCursorToWindow(ROOT, FALSE, FALSE); - PostNewCursor(); - if (grab->cursor) - FreeCursor(grab->cursor, (Cursor)0); - ComputeFreezes(); + xorg_DeactivatePointerGrab(mouse); #ifdef NXAGENT_SERVER @@ -260,59 +221,26 @@ DeactivatePointerGrab(register DeviceIntPtr mouse) #endif } -// int -// ProcAllowEvents(register ClientPtr client) -// { -// TimeStamp time; -// DeviceIntPtr mouse = inputInfo.pointer; -// DeviceIntPtr keybd = inputInfo.keyboard; -// REQUEST(xAllowEventsReq); -// -// REQUEST_SIZE_MATCH(xAllowEventsReq); -// time = ClientTimeToServerTime(stuff->time); -// switch (stuff->mode) -// { -// case ReplayPointer: -// AllowSome(client, time, mouse, NOT_GRABBED); -// break; -// case SyncPointer: -// AllowSome(client, time, mouse, FREEZE_NEXT_EVENT); -// break; -// case AsyncPointer: -// AllowSome(client, time, mouse, THAWED); -// break; -// case ReplayKeyboard: -// AllowSome(client, time, keybd, NOT_GRABBED); -// break; -// case SyncKeyboard: -// AllowSome(client, time, keybd, FREEZE_NEXT_EVENT); -// break; -// case AsyncKeyboard: -// AllowSome(client, time, keybd, THAWED); -// break; -// case SyncBoth: -// AllowSome(client, time, keybd, FREEZE_BOTH_NEXT_EVENT); -// break; -// case AsyncBoth: -// AllowSome(client, time, keybd, THAWED_BOTH); -// break; -// default: -// client->errorValue = stuff->mode; -// return BadValue; -// } -// -// /* -// * This is not necessary if we export grab to X as asynchronous. -// * -// * if (nxagentOption(Rootless) && stuff -> mode != ReplayKeyboard && -// * stuff -> mode != SyncKeyboard && stuff -> mode != AsyncKeyboard) -// * { -// * XAllowEvents(nxagentDisplay, stuff -> mode, CurrentTime); -// * } -// */ -// -// return Success; -// } +int +ProcAllowEvents(register ClientPtr client) +{ + int rc = xorg_ProcAllowEvents(client); + + if (rc != Success) + return rc; + + /* + * This is not necessary if we export grab to X as asynchronous. + * + * if (nxagentOption(Rootless) && stuff -> mode != ReplayKeyboard && + * stuff -> mode != SyncKeyboard && stuff -> mode != AsyncKeyboard) + * { + * XAllowEvents(nxagentDisplay, stuff -> mode, CurrentTime); + * } + */ + + return Success; +} static WindowPtr XYToWindow(int x, int y) @@ -322,6 +250,7 @@ XYToWindow(int x, int y) spriteTraceGood = 1; /* root window still there */ +#ifdef NXAGENT_SERVER if (nxagentOption(Rootless)) { if (nxagentLastEnteredWindow == NULL) @@ -340,7 +269,9 @@ XYToWindow(int x, int y) { pWin = ROOT->firstChild; } - +#else + pWin = ROOT->firstChild; +#endif while (pWin) { if ((pWin->mapped) && @@ -462,50 +393,17 @@ CheckMotion(xEvent *xE) return TRUE; } +extern int nxagentShadowInit(ScreenPtr, WindowPtr); +#ifdef VIEWPORT_FRAME +extern void nxagentInitViewportFrame(ScreenPtr, WindowPtr); +#endif + void DefineInitialRootWindow(register WindowPtr win) { register ScreenPtr pScreen = win->drawable.pScreen; - #ifdef VIEWPORT_FRAME - extern void nxagentInitViewportFrame(ScreenPtr, WindowPtr); - #endif - extern int nxagentShadowInit(ScreenPtr, WindowPtr); - - sprite.hotPhys.pScreen = pScreen; - sprite.hotPhys.x = pScreen->width / 2; - sprite.hotPhys.y = pScreen->height / 2; - sprite.hot = sprite.hotPhys; - sprite.hotLimits.x2 = pScreen->width; - sprite.hotLimits.y2 = pScreen->height; - sprite.win = win; - sprite.current = wCursor (win); - sprite.current->refcnt++; - spriteTraceGood = 1; - ROOT = win; - (*pScreen->CursorLimits) ( - pScreen, sprite.current, &sprite.hotLimits, &sprite.physLimits); - sprite.confined = FALSE; - (*pScreen->ConstrainCursor) (pScreen, &sprite.physLimits); - (*pScreen->SetCursorPosition) (pScreen, sprite.hot.x, sprite.hot.y, FALSE); - (*pScreen->DisplayCursor) (pScreen, sprite.current); -#ifdef PANORAMIX - if(!noPanoramiXExtension) { - sprite.hotLimits.x1 = -panoramiXdataPtr[0].x; - sprite.hotLimits.y1 = -panoramiXdataPtr[0].y; - sprite.hotLimits.x2 = PanoramiXPixWidth - panoramiXdataPtr[0].x; - sprite.hotLimits.y2 = PanoramiXPixHeight - panoramiXdataPtr[0].y; - sprite.physLimits = sprite.hotLimits; - sprite.confineWin = NullWindow; -#ifdef SHAPE - sprite.hotShape = NullRegion; -#endif - sprite.screen = pScreen; - /* gotta UNINIT these someplace */ - RegionNull(&sprite.Reg1); - RegionNull(&sprite.Reg2); - } -#endif + xorg_DefineInitialRootWindow(win); #ifdef VIEWPORT_FRAME nxagentInitViewportFrame(pScreen, win); @@ -523,18 +421,12 @@ DefineInitialRootWindow(register WindowPtr win) int ProcSendEvent(ClientPtr client) { - WindowPtr pWin; - WindowPtr effectiveFocus = NullWindow; /* only set if dest==InputFocus */ +#ifdef NXAGENT_CLIPBOARD + REQUEST(xSendEventReq); REQUEST_SIZE_MATCH(xSendEventReq); - /* The client's event type must be a core event type or one defined by an - extension. */ - - -#ifdef NXAGENT_CLIPBOARD - if (stuff -> event.u.u.type == SelectionNotify) { extern int nxagentSendNotify(xEvent*); @@ -542,78 +434,5 @@ ProcSendEvent(ClientPtr client) return Success; } #endif - - if ( ! ((stuff->event.u.u.type > X_Reply && - stuff->event.u.u.type < LASTEvent) || - (stuff->event.u.u.type >= EXTENSION_EVENT_BASE && - stuff->event.u.u.type < (unsigned)lastEvent))) - { - client->errorValue = stuff->event.u.u.type; - return BadValue; - } - if (stuff->event.u.u.type == ClientMessage && - stuff->event.u.u.detail != 8 && - stuff->event.u.u.detail != 16 && - stuff->event.u.u.detail != 32) - { - client->errorValue = stuff->event.u.u.detail; - return BadValue; - } - if (stuff->eventMask & ~AllEventMasks) - { - client->errorValue = stuff->eventMask; - return BadValue; - } - - if (stuff->destination == PointerWindow) - pWin = sprite.win; - else if (stuff->destination == InputFocus) - { - WindowPtr inputFocus = inputInfo.keyboard->focus->win; - - if (inputFocus == NoneWin) - return Success; - - /* If the input focus is PointerRootWin, send the event to where - the pointer is if possible, then perhaps propagate up to root. */ - if (inputFocus == PointerRootWin) - inputFocus = ROOT; - - if (IsParent(inputFocus, sprite.win)) - { - effectiveFocus = inputFocus; - pWin = sprite.win; - } - else - effectiveFocus = pWin = inputFocus; - } - else - pWin = SecurityLookupWindow(stuff->destination, client, - DixReadAccess); - if (!pWin) - return BadWindow; - if ((stuff->propagate != xFalse) && (stuff->propagate != xTrue)) - { - client->errorValue = stuff->propagate; - return BadValue; - } - stuff->event.u.u.type |= 0x80; - if (stuff->propagate) - { - for (;pWin; pWin = pWin->parent) - { - if (DeliverEventsToWindow(pWin, &stuff->event, 1, stuff->eventMask, - NullGrab, 0)) - return Success; - if (pWin == effectiveFocus) - return Success; - stuff->eventMask &= ~wDontPropagateMask(pWin); - if (!stuff->eventMask) - break; - } - } - else - (void)DeliverEventsToWindow(pWin, &stuff->event, 1, stuff->eventMask, - NullGrab, 0); - return Success; + return xorg_ProcSendEvent(client); } diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXextension.c b/nx-X11/programs/Xserver/hw/nxagent/NXextension.c index 9ec6be8ef1..101299ce38 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXextension.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXextension.c @@ -23,173 +23,11 @@ /* */ /**************************************************************************/ -/*********************************************************** - -Copyright 1987, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - - -Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Digital not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR -ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. - -******************************************************************/ - #include "Trap.h" -#include "../../dix/extension.c" +/* Unfortunately we cannot drop this file completely and rely on the + dix code because NXAGENT_SERVER is undefined during dix + compilation. We also cannot replace this file by a link because of + the then missing Trap.h include. */ -int -ProcQueryExtension(ClientPtr client) -{ - xQueryExtensionReply reply; - int i; - REQUEST(xQueryExtensionReq); - - REQUEST_FIXED_SIZE(xQueryExtensionReq, stuff->nbytes); - - memset(&reply, 0, sizeof(xQueryExtensionReply)); - reply.type = X_Reply; - reply.length = 0; - reply.major_opcode = 0; - reply.sequenceNumber = client->sequence; - - if ( ! NumExtensions ) - reply.present = xFalse; - else - { - i = FindExtension((char *)&stuff[1], stuff->nbytes); - if (i < 0 - - /* - * Hide RENDER if our implementation - * is faulty. - */ - - || (nxagentRenderTrap && strcmp(extensions[i]->name, "RENDER") == 0) -#ifdef XCSECURITY - /* don't show insecure extensions to untrusted clients */ - || (client->trustLevel == XSecurityClientUntrusted && - !extensions[i]->secure) -#endif - ) - reply.present = xFalse; - else - { - reply.present = xTrue; - reply.major_opcode = extensions[i]->base; - reply.first_event = extensions[i]->eventBase; - reply.first_error = extensions[i]->errorBase; - } - } - WriteReplyToClient(client, sizeof(xQueryExtensionReply), &reply); - return(client->noClientException); -} - -int -ProcListExtensions(ClientPtr client) -{ - xListExtensionsReply reply; - char *bufptr, *buffer; - int total_length = 0; - - REQUEST_SIZE_MATCH(xReq); - - memset(&reply, 0, sizeof(xListExtensionsReply)); - reply.type = X_Reply; - reply.nExtensions = 0; - reply.length = 0; - reply.sequenceNumber = client->sequence; - buffer = NULL; - - if ( NumExtensions ) - { - register int i, j; - - for (i=0; itrustLevel == XSecurityClientUntrusted && - !extensions[i]->secure) - continue; -#endif - /* - * Hide RENDER if our implementation - * is faulty. - */ - - if (nxagentRenderTrap && strcmp(extensions[i]->name, "RENDER") == 0) - continue; - - total_length += strlen(extensions[i]->name) + 1; - reply.nExtensions += 1 + extensions[i]->num_aliases; - for (j = extensions[i]->num_aliases; --j >= 0;) - total_length += strlen(extensions[i]->aliases[j]) + 1; - } - reply.length = (total_length + 3) >> 2; - buffer = bufptr = (char *)malloc(total_length); - if (!buffer) - return(BadAlloc); - for (i=0; itrustLevel == XSecurityClientUntrusted && - !extensions[i]->secure) - continue; -#endif - *bufptr++ = len = strlen(extensions[i]->name); - memmove(bufptr, extensions[i]->name, len); - bufptr += len; - for (j = extensions[i]->num_aliases; --j >= 0;) - { - *bufptr++ = len = strlen(extensions[i]->aliases[j]); - memmove(bufptr, extensions[i]->aliases[j], len); - bufptr += len; - } - } - } - WriteReplyToClient(client, sizeof(xListExtensionsReply), &reply); - if (reply.length) - { - WriteToClient(client, total_length, buffer); - free(buffer); - } - return(client->noClientException); -} +#include "../../dix/extension.c" diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXglxext.c b/nx-X11/programs/Xserver/hw/nxagent/NXglxext.c index 9d0f4f7198..7af295eacb 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXglxext.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXglxext.c @@ -57,60 +57,8 @@ */ static int __glXDispatch(ClientPtr client) { - REQUEST(xGLXSingleReq); - CARD8 opcode; - int (*proc)(__GLXclientState *cl, GLbyte *pc); - __GLXclientState *cl; int retval; - opcode = stuff->glxCode; - cl = __glXClients[client->index]; - if (!cl) { - cl = (__GLXclientState *) malloc(sizeof(__GLXclientState)); - __glXClients[client->index] = cl; - if (!cl) { - return BadAlloc; - } - memset(cl, 0, sizeof(__GLXclientState)); - } - - if (!cl->inUse) { - /* - ** This is first request from this client. Associate a resource - ** with the client so we will be notified when the client dies. - */ - XID xid = FakeClientID(client->index); - if (!AddResource( xid, __glXClientRes, (void *)(long)client->index)) { - return BadAlloc; - } - ResetClientState(client->index); - cl->inUse = GL_TRUE; - cl->client = client; - } - - /* - ** Check for valid opcode. - */ - if (opcode >= __GLX_SINGLE_TABLE_SIZE) { - return BadRequest; - } - - /* - ** If we're expecting a glXRenderLarge request, this better be one. - */ - if ((cl->largeCmdRequestsSoFar != 0) && (opcode != X_GLXRenderLarge)) { - client->errorValue = stuff->glxCode; - return __glXBadLargeRequest; - } - - /* - ** Use the opcode to index into the procedure table. - */ - if (client->swapped) - proc = __glXSwapSingleTable[opcode]; - else - proc = __glXSingleTable[opcode]; - /* * Report upstream that we are * dispatching a GLX operation. @@ -123,7 +71,7 @@ static int __glXDispatch(ClientPtr client) opcode, client -> index); #endif - retval = (*proc)(cl, (GLbyte *) stuff); + retval = xorg__glXDispatch(client); nxagentGlxTrap = 0; diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXglyph.c b/nx-X11/programs/Xserver/hw/nxagent/NXglyph.c index 72d8242bd1..022ef09f45 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXglyph.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXglyph.c @@ -161,30 +161,35 @@ AddGlyph (GlyphSetPtr glyphSet, GlyphPtr glyph, Glyph id) CheckDuplicates (&globalGlyphs[glyphSet->fdepth], "AddGlyph bottom"); } -GlyphPtr FindGlyph (GlyphSetPtr glyphSet, Glyph id) +GlyphPtr +FindGlyph (GlyphSetPtr glyphSet, Glyph id) { - GlyphRefPtr gr; - GlyphPtr glyph; - - gr = FindGlyphRef (&glyphSet->hash, id, FALSE, 0); - glyph = gr -> glyph; - - if (glyph == DeletedGlyph) - { - glyph = 0; - } - else if (gr -> corruptedGlyph == 1) - { - #ifdef DEBUG - fprintf(stderr, "FindGlyphRef: Going to synchronize the glyph [%p] for glyphset [%p].\n", + GlyphPtr glyph; + +#ifdef NXAGENT_SERVER + GlyphRefPtr gr = FindGlyphRef (&glyphSet->hash, id, FALSE, 0); + glyph = gr -> glyph; +#else + glyph = FindGlyphRef (&glyphSet->hash, id, FALSE, 0)->glyph; +#endif + if (glyph == DeletedGlyph) + { + glyph = 0; + } +#ifdef NXAGENT_SERVER + else if (gr -> corruptedGlyph == 1) + { + #ifdef DEBUG + fprintf(stderr, "FindGlyphRef: Going to synchronize the glyph [%p] for glyphset [%p].\n", (void *) glyph, (void *) glyphSet); - #endif + #endif - nxagentAddGlyphs(glyphSet, &id, &(glyph -> info), 1, + nxagentAddGlyphs(glyphSet, &id, &(glyph -> info), 1, (CARD8*)(glyph + 1), glyph -> size - sizeof(xGlyphInfo)); - } + } +#endif - return glyph; + return glyph; } Bool @@ -269,18 +274,21 @@ miGlyphs (CARD8 op, BoxRec extents; CARD32 component_alpha; +#ifdef NXAGENT_SERVER /* * Get rid of the warning. */ extents.x1 = 0; extents.y1 = 0; +#endif if (maskFormat) { GCPtr pGC; xRectangle rect; +#ifdef NXAGENT_SERVER if (nxagentGlyphsExtents != NullBox) { memcpy(&extents, nxagentGlyphsExtents, sizeof(BoxRec)); @@ -293,6 +301,9 @@ miGlyphs (CARD8 op, memcpy(nxagentGlyphsExtents, &extents, sizeof(BoxRec)); } +#else + GlyphExtents (nlist, list, glyphs, &extents); +#endif if (extents.x2 <= extents.x1 || extents.y2 <= extents.y1) return; @@ -364,6 +375,7 @@ miGlyphs (CARD8 op, glyph->info.width, glyph->info.height, 0, 0, -1, (void *) (glyph + 1)); +#ifdef NXAGENT_SERVER /* * The following line fixes a problem with glyphs that appeared * as clipped. It was a side effect due the validate function @@ -373,7 +385,7 @@ miGlyphs (CARD8 op, */ pPicture->pDrawable->serialNumber = NEXT_SERIAL_NUMBER; - +#endif pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER; if (maskFormat) { diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXglyphcurs.c b/nx-X11/programs/Xserver/hw/nxagent/NXglyphcurs.c index 549ab4333a..9f26b7d6fa 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXglyphcurs.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXglyphcurs.c @@ -100,6 +100,7 @@ ServerBitsFromGlyph(FontPtr pfont, unsigned ch, register CursorMetricPtr cm, uns PixmapPtr ppix; long nby; char *pbits; + ChangeGCVal gcval[3]; unsigned char char2b[2]; /* turn glyph index into a protocol-format char2b */ @@ -114,7 +115,8 @@ ServerBitsFromGlyph(FontPtr pfont, unsigned ch, register CursorMetricPtr cm, uns /* zeroing the (pad) bits seems to help some ddx cursor handling */ bzero(pbits, nby); - ppix = fbCreatePixmap(pScreen, cm->width, cm->height, 1, + ppix = fbCreatePixmap(pScreen, cm->width, + cm->height, 1, CREATE_PIXMAP_USAGE_SCRATCH); pGC = GetScratchGC(1, pScreen); if (!ppix || !pGC) @@ -143,28 +145,21 @@ ServerBitsFromGlyph(FontPtr pfont, unsigned ch, register CursorMetricPtr cm, uns rect.width = cm->width; rect.height = cm->height; - pGC->stateChanges |= GCFunction | GCForeground | GCFont; - pGC->alu = GXcopy; - - pGC->fgPixel = 0; - - pfont->refcnt++; - - if (pGC->font) - CloseFont(pGC->font, (Font)0); - - pGC->font = pfont; - + /* fill the pixmap with 0 */ + gcval[0].val = GXcopy; + gcval[1].val = 0; + gcval[2].ptr = (void *)pfont; + dixChangeGC(NullClient, pGC, GCFunction | GCForeground | GCFont, + NULL, gcval); ValidateGC((DrawablePtr)ppix, pGC); fbPolyFillRect((DrawablePtr)ppix, pGC, 1, &rect); /* draw the glyph */ - pGC->fgPixel = 1; - - pGC->stateChanges |= GCForeground; - + gcval[0].val = 1; + dixChangeGC(NullClient, pGC, GCForeground, NULL, gcval); ValidateGC((DrawablePtr)ppix, pGC); - miPolyText16((DrawablePtr)ppix, pGC, (int)cm->xhot, (int)cm->yhot, (int)1, (unsigned short*)char2b); + miPolyText16((DrawablePtr)ppix, pGC, (int)cm->xhot, (int)cm->yhot, + (int)1, (unsigned short*)char2b); fbGetImage((DrawablePtr)ppix, 0, 0, cm->width, cm->height, XYPixmap, 1, pbits); *ppbits = (unsigned char *)pbits; diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXhooks.c b/nx-X11/programs/Xserver/hw/nxagent/NXhooks.c new file mode 100644 index 0000000000..d336c7281e --- /dev/null +++ b/nx-X11/programs/Xserver/hw/nxagent/NXhooks.c @@ -0,0 +1,19 @@ + +#include +#include +#include "Trap.h" + + +/* Hook called from dix/extension.c */ + +Bool +nxagentHook_IsFaultyRenderExtension(char *name) +{ + /* + * Hide RENDER if our implementation + * is faulty. + */ + + return (nxagentRenderTrap && strcmp(name, "RENDER") == 0); +} + diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXhooks.h b/nx-X11/programs/Xserver/hw/nxagent/NXhooks.h new file mode 100644 index 0000000000..030a59b482 --- /dev/null +++ b/nx-X11/programs/Xserver/hw/nxagent/NXhooks.h @@ -0,0 +1,31 @@ +/**************************************************************************/ +/* */ +/* Copyright (c) 2001, 2011 NoMachine (http://www.nomachine.com) */ +/* Copyright (c) 2008-2014 Oleksandr Shneyder */ +/* Copyright (c) 2011-2016 Mike Gabriel */ +/* Copyright (c) 2014-2016 Mihai Moldovan */ +/* Copyright (c) 2014-2016 Ulrich Sibiller */ +/* Copyright (c) 2015-2016 Qindel Group (http://www.qindel.com) */ +/* */ +/* NXAGENT, NX protocol compression and NX extensions to this software */ +/* are copyright of the aforementioned persons and companies. */ +/* */ +/* Redistribution and use of the present software is allowed according */ +/* to terms specified in the file LICENSE which comes in the source */ +/* distribution. */ +/* */ +/* All rights reserved. */ +/* */ +/* NOTE: This software has received contributions from various other */ +/* contributors, only the core maintainers and supporters are listed as */ +/* copyright holders. Please contact us, if you feel you should be listed */ +/* as copyright holder, as well. */ +/* */ +/**************************************************************************/ + +#ifndef __NXhooks_H__ +#define __NXhooks_H__ + +Bool nxagentHook_IsFaultyRenderExtension(char *); + +#endif /* __NXhooks_H__ */ diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXmitrap.c b/nx-X11/programs/Xserver/hw/nxagent/NXmitrap.c index 1988ca1028..08666a3f8d 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXmitrap.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXmitrap.c @@ -80,6 +80,7 @@ miTrapezoids (CARD8 op, xDst = traps[0].left.p1.x >> 16; yDst = traps[0].left.p1.y >> 16; +#ifdef NXAGENT_SERVER if (nxagentTrapezoidExtents != NullBox) { memcpy(&bounds, nxagentTrapezoidExtents, sizeof(BoxRec)); @@ -92,7 +93,9 @@ miTrapezoids (CARD8 op, memcpy(nxagentTrapezoidExtents, &bounds, sizeof(BoxRec)); } - +#else + miTrapezoidBounds (ntrap, traps, &bounds); +#endif if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2) return; pPicture = miCreateAlphaPicture (pScreen, pDst, maskFormat, diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c b/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c index 491af5b300..4aa54ee3d8 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c @@ -81,6 +81,26 @@ void *nxagentMatchingFormats(PictFormatPtr pForm); void nxagentPictureCreateDefaultFormats(ScreenPtr pScreen, FormatInitRec *formats, int *nformats); +extern void nxagentRenderCreateSolidFill(PicturePtr pPicture, xRenderColor *color); + +extern void nxagentRenderCreateLinearGradient(PicturePtr pPicture, xPointFixed *p1, + xPointFixed *p2, int nStops, + xFixed *stops, + xRenderColor *colors); +extern void nxagentRenderCreateRadialGradient(PicturePtr pPicture, xPointFixed *inner, + xPointFixed *outer, + xFixed innerRadius, + xFixed outerRadius, + int nStops, + xFixed *stops, + xRenderColor *colors); +extern void nxagentRenderCreateConicalGradient(PicturePtr pPicture, + xPointFixed *center, + xFixed angle, int nStops, + xFixed *stops, + xRenderColor *colors); + + PictFormatPtr PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp) { @@ -213,7 +233,9 @@ AllocatePicture (ScreenPtr pScreen) ppriv->ptr = (void *)NULL; } +#ifdef NXAGENT_SERVER nxagentPicturePriv(pPicture) -> picture = 0; +#endif return pPicture; } @@ -243,13 +265,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; } @@ -275,32 +298,6 @@ CreatePicture (Picture pid, return pPicture; } -PicturePtr -CreateSolidPicture (Picture pid, xRenderColor *color, int *error) -{ - PicturePtr pPicture; - pPicture = createSourcePicture(); - if (!pPicture) { - *error = BadAlloc; - return 0; - } - - pPicture->id = pid; - pPicture->pSourcePict = (SourcePictPtr) calloc(1, sizeof(PictSolidFill)); - if (!pPicture->pSourcePict) { - *error = BadAlloc; - free(pPicture); - return 0; - } - pPicture->pSourcePict->type = SourcePictTypeSolidFill; - pPicture->pSourcePict->solidFill.color = xRenderColorToCard32(*color); - pPicture->pSourcePict->solidFill.fullColor.alpha=color->alpha; - pPicture->pSourcePict->solidFill.fullColor.red=color->red; - pPicture->pSourcePict->solidFill.fullColor.green=color->green; - pPicture->pSourcePict->solidFill.fullColor.blue=color->blue; - return pPicture; -} - static PicturePtr createSourcePicture(void) { extern int nxagentPicturePrivateIndex; @@ -644,3 +641,73 @@ void nxagentPictureCreateDefaultFormats(ScreenPtr pScreen, FormatInitRec *format } } +PicturePtr CreateSolidPicture (Picture pid, xRenderColor *color, int *error) +{ + PicturePtr pPicture = xorg_CreateSolidPicture(pid, color, error); + + if (pPicture) + { + pPicture->pSourcePict->solidFill.fullColor.alpha=color->alpha; + pPicture->pSourcePict->solidFill.fullColor.red=color->red; + pPicture->pSourcePict->solidFill.fullColor.green=color->green; + pPicture->pSourcePict->solidFill.fullColor.blue=color->blue; + } + +#ifdef NXAGENT_SERVER + if (pPicture) + nxagentRenderCreateSolidFill(pPicture, color); +#endif + + return pPicture; +} + +PicturePtr CreateLinearGradientPicture (Picture pid, xPointFixed *p1, xPointFixed *p2, + int nStops, xFixed *stops, xRenderColor *colors, int *error) +{ + PicturePtr pPicture = xorg_CreateLinearGradientPicture(pid, p1, p2, + nStops, stops, colors, + error); + +#ifdef NXAGENT_SERVER + if (pPicture) + nxagentRenderCreateLinearGradient(pPicture, p1, p2, + nStops, stops, colors); +#endif + + return pPicture; +} + +PicturePtr CreateRadialGradientPicture (Picture pid, xPointFixed *inner, xPointFixed *outer, + xFixed innerRadius, xFixed outerRadius, + int nStops, xFixed *stops, xRenderColor *colors, int *error) +{ + PicturePtr pPicture = xorg_CreateRadialGradientPicture(pid, inner, outer, + innerRadius, outerRadius, + nStops, stops, colors, + error); + +#ifdef NXAGENT_SERVER + if (pPicture) + nxagentRenderCreateRadialGradient(pPicture, inner, outer, + innerRadius, outerRadius, + nStops, stops, colors); +#endif + + return pPicture; +} + +PicturePtr CreateConicalGradientPicture (Picture pid, xPointFixed *center, xFixed angle, + int nStops, xFixed *stops, xRenderColor *colors, int *error) +{ + PicturePtr pPicture = xorg_CreateConicalGradientPicture(pid, center, angle, + nStops, stops, colors, + error); + +#ifdef NXAGENT_SERVER + if (pPicture) + nxagentRenderCreateConicalGradient(pPicture, center, angle, + nStops, stops, colors); +#endif + + return pPicture; +} diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXrender.c b/nx-X11/programs/Xserver/hw/nxagent/NXrender.c index 190f746a42..600db033e3 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXrender.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXrender.c @@ -90,7 +90,7 @@ void miTrapezoidBounds (int ntrap, xTrapezoid *traps, BoxPtr box); extern int nxagentCursorSaveRenderInfo(ScreenPtr, CursorPtr); extern void nxagentCursorPostSaveRenderInfo(CursorPtr, ScreenPtr, PicturePtr, int, int); -extern int nxagentRenderRealizeCursor(ScreenPtr, CursorPtr); +extern void nxagentRenderRealizeCursor(ScreenPtr, CursorPtr); extern int nxagentCreatePicture(PicturePtr, Mask); extern void nxagentChangePicture(PicturePtr, Mask); extern int nxagentChangePictureClip(PicturePtr, int, int, xRectangle *, int, int); @@ -106,24 +106,6 @@ extern void nxagentSetPictureFilter(PicturePtr pPicture, char *filter, int name_ void * params, int nparams); extern void nxagentTrapezoids(CARD8 op, PicturePtr pSrc, PicturePtr pDst, PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, int ntrap, xTrapezoid *traps); -extern void nxagentRenderCreateSolidFill(PicturePtr pPicture, xRenderColor *color); -extern void nxagentRenderCreateLinearGradient(PicturePtr pPicture, xPointFixed *p1, - xPointFixed *p2, int nStops, - xFixed *stops, - xRenderColor *colors); -extern void nxagentRenderCreateRadialGradient(PicturePtr pPicture, xPointFixed *inner, - xPointFixed *outer, - xFixed innerRadius, - xFixed outerRadius, - int nStops, - xFixed *stops, - xRenderColor *colors); -extern void nxagentRenderCreateConicalGradient(PicturePtr pPicture, - xPointFixed *center, - xFixed angle, int nStops, - xFixed *stops, - xRenderColor *colors); - /* * The void pointer is actually a XGlyphElt8. */ @@ -139,8 +121,13 @@ ProcRenderQueryVersion (ClientPtr client) .type = X_Reply, .sequenceNumber = client->sequence, .length = 0, +#ifdef NXAGENT_SERVER .majorVersion = nxagentRenderVersionMajor, .minorVersion = nxagentRenderVersionMinor +#else + .majorVersion = SERVER_RENDER_MAJOR_VERSION, + .minorVersion = SERVER_RENDER_MINOR_VERSION +#endif }; REQUEST(xRenderQueryVersionReq); @@ -183,8 +170,6 @@ ProcRenderQueryPictFormats (ClientPtr client) int s; int numScreens; int numSubpixel; - - extern int nxagentAlphaEnabled; /* REQUEST(xRenderQueryPictFormatsReq); */ REQUEST_SIZE_MATCH(xRenderQueryPictFormatsReq); @@ -228,9 +213,11 @@ ProcRenderQueryPictFormats (ClientPtr client) ndepth * sizeof (xPictDepth) + nvisual * sizeof (xPictVisual) + numSubpixel * sizeof (CARD32)); - reply = (xRenderQueryPictFormatsReply *) calloc (1, rlength); + reply = (xRenderQueryPictFormatsReply *) malloc (rlength); if (!reply) return BadAlloc; + memset(reply, 0, rlength); + reply->type = X_Reply; reply->sequenceNumber = client->sequence; reply->length = (rlength - sizeof(xGenericReply)) >> 2; @@ -261,7 +248,12 @@ ProcRenderQueryPictFormats (ClientPtr client) pictForm->direct.greenMask = pFormat->direct.greenMask; pictForm->direct.blue = pFormat->direct.blue; pictForm->direct.blueMask = pFormat->direct.blueMask; +#ifdef NXAGENT_SERVER + extern int nxagentAlphaEnabled; pictForm->direct.alpha = nxagentAlphaEnabled ? pFormat->direct.alpha : 0; +#else + pictForm->direct.alpha = pFormat->direct.alpha; +#endif pictForm->direct.alphaMask = pFormat->direct.alphaMask; if (pFormat->type == PictTypeIndexed && pFormat->index.pColormap) pictForm->colormap = pFormat->index.pColormap->mid; @@ -408,7 +400,10 @@ ProcRenderCreatePicture (ClientPtr client) &error); if (!pPicture) return error; +#ifdef NXAGENT_SERVER + /* FIXME: shouldn't this be integrated into CreatePicture? */ nxagentCreatePicture(pPicture, stuff -> mask); +#endif if (!AddResource (stuff->pid, PictureType, (void *)pPicture)) return BadAlloc; @@ -421,7 +416,6 @@ ProcRenderChangePicture (ClientPtr client) PicturePtr pPicture; REQUEST(xRenderChangePictureReq); int len; - int error; REQUEST_AT_LEAST_SIZE(xRenderChangePictureReq); VERIFY_PICTURE (pPicture, stuff->picture, client, DixWriteAccess, @@ -431,12 +425,19 @@ ProcRenderChangePicture (ClientPtr client) if (Ones(stuff->mask) != len) return BadLength; - error = ChangePicture (pPicture, stuff->mask, (XID *) (stuff + 1), - (DevUnion *) 0, client); +#ifdef NXAGENT_SERVER + { + int error = ChangePicture (pPicture, stuff->mask, (XID *) (stuff + 1), + (DevUnion *) 0, client); - nxagentChangePicture(pPicture, stuff->mask); + nxagentChangePicture(pPicture, stuff->mask); - return error; + return error; + } +#else + return ChangePicture (pPicture, stuff->mask, (XID *) (stuff + 1), + (DevUnion *) 0, client); +#endif } static int @@ -453,6 +454,7 @@ ProcRenderSetPictureClipRectangles (ClientPtr client) if (!pPicture->pDrawable) return BadDrawable; +#ifdef NXAGENT_SERVER /* * The original code used sizeof(xRenderChangePictureReq). * This was harmless, as both structures have the same size. @@ -460,18 +462,23 @@ ProcRenderSetPictureClipRectangles (ClientPtr client) * nr = (client->req_len << 2) - sizeof(xRenderChangePictureReq); */ nr = (client->req_len << 2) - sizeof(xRenderSetPictureClipRectanglesReq); +#else + nr = (client->req_len << 2) - sizeof(xRenderChangePictureReq); +#endif if (nr & 4) return BadLength; nr >>= 3; result = SetPictureClipRects (pPicture, stuff->xOrigin, stuff->yOrigin, nr, (xRectangle *) &stuff[1]); +#ifdef NXAGENT_SERVER nxagentChangePictureClip (pPicture, CT_NONE, nr, (xRectangle *) &stuff[1], (int)stuff -> xOrigin, (int)stuff -> yOrigin); +#endif if (client->noClientException != Success) return(client->noClientException); @@ -712,12 +719,15 @@ ProcRenderTrapezoids (ClientPtr client) return BadLength; ntraps /= sizeof (xTrapezoid); if (ntraps) +#ifdef NXAGENT_SERVER { if (pFormat != NULL) { - nxagentTrapezoidExtents = (BoxPtr) malloc(sizeof(BoxRec)); + if (nxagentTrapezoidExtents && nxagentTrapezoidExtents != NullBox) + free(nxagentTrapezoidExtents); - miTrapezoidBounds (ntraps, (xTrapezoid *) &stuff[1], nxagentTrapezoidExtents); + nxagentTrapezoidExtents = (BoxPtr) malloc(sizeof(BoxRec)); + miTrapezoidBounds (ntraps, (xTrapezoid *) &stuff[1], nxagentTrapezoidExtents); } if (nxagentCompositePredicate(pSrc, pDst) == 1) @@ -734,10 +744,14 @@ ProcRenderTrapezoids (ClientPtr client) if (nxagentTrapezoidExtents != NullBox) { free(nxagentTrapezoidExtents); - nxagentTrapezoidExtents = NullBox; } } +#else + CompositeTrapezoids (stuff->op, pSrc, pDst, pFormat, + stuff->xSrc, stuff->ySrc, + ntraps, (xTrapezoid *) &stuff[1]); +#endif return client->noClientException; } @@ -789,7 +803,9 @@ ProcRenderCreateGlyphSet (ClientPtr client) if (!AddResource (stuff->gsid, GlyphSetType, (void *)glyphSet)) return BadAlloc; +#ifdef NXAGENT_SERVER nxagentCreateGlyphSet(glyphSet); +#endif return Success; } @@ -815,7 +831,9 @@ ProcRenderReferenceGlyphSet (ClientPtr client) } glyphSet->refcnt++; +#ifdef NXAGENT_SERVER nxagentReferenceGlyphSet(glyphSet); +#endif if (!AddResource (stuff->gsid, GlyphSetType, (void *)glyphSet)) return BadAlloc; @@ -839,7 +857,9 @@ ProcRenderFreeGlyphSet (ClientPtr client) return RenderErrBase + BadGlyphSet; } +#ifdef NXAGENT_SERVER nxagentFreeGlyphSet(glyphSet); +#endif FreeResource (stuff->glyphset, RT_NONE); return client->noClientException; @@ -867,7 +887,9 @@ ProcRenderFreeGlyphs (ClientPtr client) nglyph = ((client->req_len << 2) - sizeof (xRenderFreeGlyphsReq)) >> 2; gids = (CARD32 *) (stuff + 1); +#ifdef NXAGENT_SERVER nxagentFreeGlyphs(glyphSet, gids, nglyph); +#endif while (nglyph-- > 0) { @@ -909,7 +931,9 @@ ProcRenderCompositeGlyphs (ClientPtr client) int size; int n; +#ifdef NXAGENT_SERVER XGlyphElt8 *elements, *elementsBase; +#endif REQUEST(xRenderCompositeGlyphsReq); @@ -997,23 +1021,28 @@ ProcRenderCompositeGlyphs (ClientPtr client) listsBase = (GlyphListPtr) malloc (nlist * sizeof (GlyphListRec)); if (!listsBase) { - free(glyphsBase); + if (glyphsBase != glyphsLocal) + free(glyphsBase); return BadAlloc; } } +#ifdef NXAGENT_SERVER elementsBase = malloc(nlist * sizeof(XGlyphElt8)); if (!elementsBase) { - free(glyphsBase); - free(listsBase); - return BadAlloc; + if (glyphsBase != glyphsLocal) + free(glyphsBase); + if (listsBase != listsLocal) + free(listsBase); + return BadAlloc; } + elements = elementsBase; +#endif buffer = (CARD8 *) (stuff + 1); glyphs = glyphsBase; lists = listsBase; - elements = elementsBase; while (buffer + sizeof (xGlyphElt) < end) { elt = (xGlyphElt *) buffer; @@ -1021,10 +1050,12 @@ ProcRenderCompositeGlyphs (ClientPtr client) if (elt->len == 0xff) { +#ifdef NXAGENT_SERVER #ifdef DEBUG fprintf(stderr, "ProcRenderCompositeGlyphs: Glyphset change with base size [%d].\n", size); #endif +#endif if (buffer + sizeof (GlyphSet) < end) { @@ -1040,6 +1071,9 @@ ProcRenderCompositeGlyphs (ClientPtr client) free (glyphsBase); if (listsBase != listsLocal) free (listsBase); +#ifdef NXAGENT_SERVER + free(elementsBase); +#endif return RenderErrBase + BadGlyphSet; } } @@ -1052,6 +1086,7 @@ ProcRenderCompositeGlyphs (ClientPtr client) lists->format = glyphSet->format; lists->len = 0; +#ifdef NXAGENT_SERVER if (glyphSet -> remoteID == 0) { #ifdef TEST @@ -1067,6 +1102,7 @@ ProcRenderCompositeGlyphs (ClientPtr client) elements -> nchars = elt->len; elements -> xOff = elt->deltax; elements -> yOff = elt->deltay; +#endif n = elt->len; while (n--) { @@ -1093,12 +1129,24 @@ ProcRenderCompositeGlyphs (ClientPtr client) if (space & 3) buffer += 4 - (space & 3); lists++; +#ifdef NXAGENT_SERVER elements++; +#endif } } if (buffer > end) + { + if (glyphsBase != glyphsLocal) + free(glyphsBase); + if (listsBase != listsLocal) + free(listsBase); +#ifdef NXAGENT_SERVER + free(elementsBase); +#endif return BadLength; + } +#ifdef NXAGENT_SERVER /* * We need to know the glyphs extents to synchronize * the drawables involved in the composite text ope- @@ -1141,17 +1189,28 @@ ProcRenderCompositeGlyphs (ClientPtr client) listsBase, glyphsBase); } - free(nxagentGlyphsExtents); nxagentGlyphsExtents = NullBox; + free(elementsBase); + +#else + CompositeGlyphs (stuff->op, + pSrc, + pDst, + pFormat, + stuff->xSrc, + stuff->ySrc, + nlist, + listsBase, + glyphsBase); +#endif + if (glyphsBase != glyphsLocal) free (glyphsBase); if (listsBase != listsLocal) free (listsBase); - free(elementsBase); - return client->noClientException; } @@ -1184,12 +1243,14 @@ ProcRenderFillRectangles (ClientPtr client) things, (xRectangle *) &stuff[1]); +#ifdef NXAGENT_SERVER ValidatePicture (pDst); nxagentCompositeRects(stuff -> op, pDst, &stuff -> color, things, (xRectangle *) &stuff[1]); +#endif return client->noClientException; } @@ -1212,8 +1273,6 @@ ProcRenderCreateCursor (ClientPtr client) CARD32 twocolor[3]; int ncolor; - RealizeCursorProcPtr saveRealizeCursor; - REQUEST_SIZE_MATCH (xRenderCreateCursorReq); LEGAL_NEW_RESOURCE(stuff->cid, client); @@ -1273,7 +1332,7 @@ ProcRenderCreateCursor (ClientPtr client) return (BadImplementation); } pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height, 32, - CREATE_PIXMAP_USAGE_SCRATCH); + CREATE_PIXMAP_USAGE_SCRATCH); if (!pPixmap) { free (argbbits); @@ -1383,6 +1442,7 @@ ProcRenderCreateCursor (ClientPtr client) cm.xhot = stuff->x; cm.yhot = stuff->y; +#ifdef NXAGENT_SERVER /* * This cursor uses RENDER, so we make sure * that it is allocated in a way that allows @@ -1392,10 +1452,10 @@ ProcRenderCreateCursor (ClientPtr client) * client. */ - saveRealizeCursor = pScreen -> RealizeCursor; + RealizeCursorProcPtr saveRealizeCursor = pScreen -> RealizeCursor; pScreen -> RealizeCursor = nxagentCursorSaveRenderInfo; - +#endif pCursor = AllocCursorARGB (srcbits, mskbits, argbbits, &cm, GetColor(twocolor[0], 16), GetColor(twocolor[0], 8), @@ -1404,6 +1464,7 @@ ProcRenderCreateCursor (ClientPtr client) GetColor(twocolor[1], 8), GetColor(twocolor[1], 0)); +#ifdef NXAGENT_SERVER pScreen -> RealizeCursor = saveRealizeCursor; /* @@ -1422,8 +1483,8 @@ ProcRenderCreateCursor (ClientPtr client) nxagentCursorPostSaveRenderInfo(pCursor, pScreen, pSrc, stuff -> x, stuff -> y); nxagentRenderRealizeCursor(pScreen, pCursor); - - if (AddResource(stuff->cid, RT_CURSOR, (void *)pCursor)) +#endif + if (pCursor && AddResource(stuff->cid, RT_CURSOR, (void *)pCursor)) return (client->noClientException); return BadAlloc; } @@ -1440,8 +1501,10 @@ ProcRenderSetPictureTransform (ClientPtr client) RenderErrBase + BadPicture); result = SetPictureTransform (pPicture, (PictTransform *) &stuff->transform); +#ifdef NXAGENT_SERVER nxagentSetPictureTransform(pPicture, &stuff->transform); - +#endif + if (client->noClientException != Success) return(client->noClientException); else @@ -1466,7 +1529,9 @@ ProcRenderSetPictureFilter (ClientPtr client) nparams = ((xFixed *) stuff + client->req_len) - params; result = SetPictureFilter (pPicture, name, stuff->nbytes, params, nparams); +#ifdef NXAGENT_SERVER nxagentSetPictureFilter(pPicture, name, stuff->nbytes, params, nparams); +#endif return result; } @@ -1511,160 +1576,25 @@ ProcRenderCreateAnimCursor (ClientPtr client) if (ret != Success) return ret; +#ifdef NXAGENT_SERVER nxagentAnimCursorBits = pCursor -> bits; for (i = 0; i < MAXSCREENS; i++) { pCursor -> devPriv[i] = NULL; } +#endif if (AddResource (stuff->cid, RT_CURSOR, (void *)pCursor)) return client->noClientException; return BadAlloc; } -static int ProcRenderCreateSolidFill(ClientPtr client) -{ - PicturePtr pPicture; - int error = 0; - REQUEST(xRenderCreateSolidFillReq); - - REQUEST_AT_LEAST_SIZE(xRenderCreateSolidFillReq); - - LEGAL_NEW_RESOURCE(stuff->pid, client); - - pPicture = CreateSolidPicture(stuff->pid, &stuff->color, &error); - if (!pPicture) - return error; - /* AGENT SERVER */ - - nxagentRenderCreateSolidFill(pPicture, &stuff -> color); - - /* AGENT SERVER */ - if (!AddResource (stuff->pid, PictureType, (void *)pPicture)) - return BadAlloc; - return Success; -} - -static int ProcRenderCreateLinearGradient (ClientPtr client) -{ - PicturePtr pPicture; - int len; - int error = 0; - xFixed *stops; - xRenderColor *colors; - REQUEST(xRenderCreateLinearGradientReq); - - REQUEST_AT_LEAST_SIZE(xRenderCreateLinearGradientReq); - - LEGAL_NEW_RESOURCE(stuff->pid, client); - - len = (client->req_len << 2) - sizeof(xRenderCreateLinearGradientReq); - if (stuff->nStops > UINT32_MAX/(sizeof(xFixed) + sizeof(xRenderColor))) - return BadLength; - if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor))) - return BadLength; - - stops = (xFixed *)(stuff + 1); - colors = (xRenderColor *)(stops + stuff->nStops); - - pPicture = CreateLinearGradientPicture (stuff->pid, &stuff->p1, &stuff->p2, - stuff->nStops, stops, colors, &error); - if (!pPicture) - return error; - /* AGENT SERVER */ - - nxagentRenderCreateLinearGradient(pPicture, &stuff->p1, &stuff->p2, - stuff->nStops, stops, colors); - - /* AGENT SERVER */ - if (!AddResource (stuff->pid, PictureType, (void *)pPicture)) - return BadAlloc; - return Success; -} - -static int ProcRenderCreateRadialGradient (ClientPtr client) -{ - PicturePtr pPicture; - int len; - int error = 0; - xFixed *stops; - xRenderColor *colors; - REQUEST(xRenderCreateRadialGradientReq); - - REQUEST_AT_LEAST_SIZE(xRenderCreateRadialGradientReq); - - LEGAL_NEW_RESOURCE(stuff->pid, client); - - len = (client->req_len << 2) - sizeof(xRenderCreateRadialGradientReq); - if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor))) - return BadLength; - - stops = (xFixed *)(stuff + 1); - colors = (xRenderColor *)(stops + stuff->nStops); - - pPicture = CreateRadialGradientPicture (stuff->pid, &stuff->inner, &stuff->outer, - stuff->inner_radius, stuff->outer_radius, - stuff->nStops, stops, colors, &error); - if (!pPicture) - return error; - /* AGENT SERVER */ - - nxagentRenderCreateRadialGradient(pPicture, &stuff->inner, &stuff->outer, - stuff->inner_radius, - stuff->outer_radius, - stuff->nStops, stops, colors); - - /* AGENT SERVER */ - if (!AddResource (stuff->pid, PictureType, (void *)pPicture)) - return BadAlloc; - return Success; -} - -static int ProcRenderCreateConicalGradient (ClientPtr client) -{ - PicturePtr pPicture; - int len; - int error = 0; - xFixed *stops; - xRenderColor *colors; - REQUEST(xRenderCreateConicalGradientReq); - - REQUEST_AT_LEAST_SIZE(xRenderCreateConicalGradientReq); - - LEGAL_NEW_RESOURCE(stuff->pid, client); - - len = (client->req_len << 2) - sizeof(xRenderCreateConicalGradientReq); - if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor))) - return BadLength; - - stops = (xFixed *)(stuff + 1); - colors = (xRenderColor *)(stops + stuff->nStops); - - pPicture = CreateConicalGradientPicture (stuff->pid, &stuff->center, stuff->angle, - stuff->nStops, stops, colors, &error); - if (!pPicture) - return error; - /* AGENT SERVER */ - - nxagentRenderCreateConicalGradient(pPicture, &stuff->center, - stuff->angle, stuff->nStops, stops, - colors); - - /* AGENT SERVER */ - if (!AddResource (stuff->pid, PictureType, (void *)pPicture)) - return BadAlloc; - return Success; -} - +static int xorg_ProcRenderDispatch (ClientPtr client); static int ProcRenderDispatch (ClientPtr client) { - int result; - - REQUEST(xReq); - /* * Let the client fail if we are * hiding the RENDER extension. @@ -1675,38 +1605,31 @@ ProcRenderDispatch (ClientPtr client) return BadRequest; } - if (stuff->data < RenderNumberRequests) - { - #ifdef TEST - fprintf(stderr, "ProcRenderDispatch: Request [%s] OPCODE#%d.\n", - nxagentRenderRequestLiteral[stuff->data], stuff->data); - #endif + #ifdef TEST + fprintf(stderr, "ProcRenderDispatch: Request [%s] OPCODE#%d.\n", + nxagentRenderRequestLiteral[stuff->data], stuff->data); + #endif - /* - * Set the nxagentGCTrap flag while - * dispatching a render operation to - * avoid reentrancy in GCOps.c. - */ + /* + * Set the nxagentGCTrap flag while + * dispatching a render operation to + * avoid reentrancy in GCOps.c. + */ - nxagentGCTrap = 1; + nxagentGCTrap = 1; - result = (*ProcRenderVector[stuff->data]) (client); + int result = xorg_ProcRenderDispatch(client); - nxagentGCTrap = 0; + nxagentGCTrap = 0; - return result; - } - else - return BadRequest; + return result; } +static int xorg_SProcRenderDispatch (ClientPtr client); + static int SProcRenderDispatch (ClientPtr client) { - int result; - - REQUEST(xReq); - /* * Let the client fail if we are * hiding the RENDER extension. @@ -1717,22 +1640,17 @@ SProcRenderDispatch (ClientPtr client) return BadRequest; } - if (stuff->data < RenderNumberRequests) - { - /* - * Set the nxagentGCTrap flag while - * dispatching a render operation to - * avoid reentrancy in GCOps.c. - */ + /* + * Set the nxagentGCTrap flag while + * dispatching a render operation to + * avoid reentrancy in GCOps.c. + */ - nxagentGCTrap = 1; + nxagentGCTrap = 1; - result = (*SProcRenderVector[stuff->data]) (client); + int result = xorg_SProcRenderDispatch(client); - nxagentGCTrap = 0; + nxagentGCTrap = 0; - return result; - } - else - return BadRequest; + return result; } diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXshm.c b/nx-X11/programs/Xserver/hw/nxagent/NXshm.c index 9a314391cc..bed89db309 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXshm.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXshm.c @@ -84,117 +84,59 @@ extern void fbPutImage (DrawablePtr pDrawable, GCPtr pGC, int depth, void ShmExtensionInit(void) { - ExtensionEntry *extEntry; - int i; + ShmFuncsPtr store[MAXSCREENS]; + static ShmFuncs nullfuncs = {NULL, NULL}; -#ifdef MUST_CHECK_FOR_SHM_SYSCALL - if (!CheckForShmSyscall()) - { - ErrorF("MIT-SHM extension disabled due to lack of kernel support\n"); - return; - } -#endif - -#ifdef NXAGENT_SERVER - if (nxagentOption(SharedMemory) == False) + if (nxagentOption(SharedMemory) == False) + { + return; + } + + /* + * xorg_ShmExtensionInit assumes sharedPixmaps being True. It then + * does some checks and sets it to xFalse under some + * circumstances. nxagent can be instructed via cmdline + * (-shpix/-noshpix) if sharedPixmaps are desired. If the + * commandline asks for -noshpix we trick xorg_ShmExtensionInit to + * set its internal variable sharedPixmaps to xFalse (and act + * accordingly) by preparing shmFuncs[] with nullfuncs and trigger + * sharePixmaps disablement. + */ + + if (nxagentOption(SharedPixmaps) == False) + { + for (int i = 0; i < screenInfo.numScreens; i++) { - return; + store[i] = shmFuncs[i]; + shmFuncs[i] = &nullfuncs; } -#endif - - sharedPixmaps = xFalse; - pixmapFormat = 0; + } + + xorg_ShmExtensionInit(); + + /* + * reset shmFuncs arrary to the previous values if they have not + * been altered by xorg_ShmExtensionInit. If the value has been + * NULL before we set it it &miFuncs, just like + * xorg_ShmExtensionInit would have done in that case. + */ + if (nxagentOption(SharedPixmaps) == False) + { + for (int i = 0; i < screenInfo.numScreens; i++) { -#ifdef NXAGENT_SERVER - sharedPixmaps = nxagentOption(SharedPixmaps); -#else - sharedPixmaps = xTrue; -#endif - pixmapFormat = shmPixFormat[0]; - for (i = 0; i < screenInfo.numScreens; i++) + if (shmFuncs[i] == &nullfuncs) { - if (!shmFuncs[i]) + if (store[i] == NULL) { - #ifdef TEST - fprintf(stderr, "ShmExtensionInit: Registering shmFuncs as miFuncs.\n"); - #endif - shmFuncs[i] = &miFuncs; + shmFuncs[i] = &miFuncs; + } + else + { + shmFuncs[i] = store[i]; } - if (!shmFuncs[i]->CreatePixmap) - sharedPixmaps = xFalse; - if (shmPixFormat[i] && (shmPixFormat[i] != pixmapFormat)) - { - sharedPixmaps = xFalse; - pixmapFormat = 0; - } - } - if (!pixmapFormat) - pixmapFormat = ZPixmap; - if (sharedPixmaps) - { - for (i = 0; i < screenInfo.numScreens; i++) - { - destroyPixmap[i] = screenInfo.screens[i]->DestroyPixmap; - screenInfo.screens[i]->DestroyPixmap = ShmDestroyPixmap; - } -#ifdef PIXPRIV - shmPixmapPrivate = AllocatePixmapPrivateIndex(); - for (i = 0; i < screenInfo.numScreens; i++) - { - if (!AllocatePixmapPrivate(screenInfo.screens[i], - shmPixmapPrivate, 0)) - return; - } -#endif } } - ShmSegType = CreateNewResourceType(ShmDetachSegment); - if (ShmSegType && - (extEntry = AddExtension(SHMNAME, ShmNumberEvents, ShmNumberErrors, - ProcShmDispatch, SProcShmDispatch, - ShmResetProc, StandardMinorOpcode))) - { - ShmReqCode = (unsigned char)extEntry->base; - ShmCompletionCode = extEntry->eventBase; - BadShmSegCode = extEntry->errorBase; - EventSwapVector[ShmCompletionCode] = (EventSwapPtr) SShmCompletionEvent; - } -} - -static void -nxagent_miShmPutImage(dst, pGC, depth, format, w, h, sx, sy, sw, sh, dx, dy, data) - DrawablePtr dst; - GCPtr pGC; - int depth, w, h, sx, sy, sw, sh, dx, dy; - unsigned int format; - char *data; -{ - PixmapPtr pmap; - GCPtr putGC; - - putGC = GetScratchGC(depth, dst->pScreen); - if (!putGC) - { - return; - } - pmap = (*dst->pScreen->CreatePixmap)(dst->pScreen, sw, sh, depth, - CREATE_PIXMAP_USAGE_SCRATCH); - if (!pmap) - { - FreeScratchGC(putGC); - return; - } - ValidateGC((DrawablePtr)pmap, putGC); - (*putGC->ops->PutImage)((DrawablePtr)pmap, putGC, depth, -sx, -sy, w, h, 0, - (format == XYPixmap) ? XYPixmap : ZPixmap, data); - FreeScratchGC(putGC); - if (format == XYBitmap) - (void)(*pGC->ops->CopyPlane)((DrawablePtr)pmap, dst, pGC, 0, 0, sw, sh, - dx, dy, 1L); - else - (void)(*pGC->ops->CopyArea)((DrawablePtr)pmap, dst, pGC, 0, 0, sw, sh, - dx, dy); - (*pmap->drawable.pScreen->DestroyPixmap)(pmap); + } } static void @@ -209,7 +151,7 @@ miShmPutImage(dst, pGC, depth, format, w, h, sx, sy, sw, sh, dx, dy, data) nxagentShmTrap = 0; - nxagent_miShmPutImage(dst, pGC, depth, format, w, h, sx, sy, sw, sh, dx, dy, data); + xorg_miShmPutImage(dst, pGC, depth, format, w, h, sx, sy, sw, sh, dx, dy, data); nxagentShmTrap = 1; @@ -485,77 +427,26 @@ fbShmCreatePixmap (pScreen, width, height, depth, addr) return result; } - +/* A wrapper that handles the trap. This construct is used + to keep the derived code closer to the original +*/ static int -nxagent_ProcShmDispatch (client) - register ClientPtr client; +ProcShmDispatch (register ClientPtr client) { - REQUEST(xReq); + int result; -#ifdef NXAGENT_SERVER #ifdef TEST - fprintf(stderr, "ProcShmDispatch: Going to execute operation [%d] for client [%d].\n", - stuff -> data, client -> index); - + REQUEST(xReq); if (stuff->data <= X_ShmCreatePixmap) { - fprintf(stderr, "ProcShmDispatch: Request [%s] OPCODE#%d.\n", - nxagentShmRequestLiteral[stuff->data], stuff->data); + fprintf(stderr, "ProcShmDispatch: Request [%s] OPCODE [%d] for client [%d].\n", + nxagentShmRequestLiteral[stuff->data], stuff->data, client->index); } #endif -#endif - - switch (stuff->data) - { - case X_ShmQueryVersion: - return ProcShmQueryVersion(client); - case X_ShmAttach: - return ProcShmAttach(client); - case X_ShmDetach: - return ProcShmDetach(client); - case X_ShmPutImage: - { -#ifdef NXAGENT_SERVER - #ifdef TEST - fprintf(stderr, "ProcShmDispatch: Going to execute ProcShmPutImage() for client [%d].\n", - client -> index); - #endif -#endif - -#ifdef PANORAMIX - if ( !noPanoramiXExtension ) - return ProcPanoramiXShmPutImage(client); -#endif - return ProcShmPutImage(client); - } - case X_ShmGetImage: -#ifdef PANORAMIX - if ( !noPanoramiXExtension ) - return ProcPanoramiXShmGetImage(client); -#endif - return ProcShmGetImage(client); - case X_ShmCreatePixmap: -#ifdef PANORAMIX - if ( !noPanoramiXExtension ) - return ProcPanoramiXShmCreatePixmap(client); -#endif - return ProcShmCreatePixmap(client); - default: - return BadRequest; - } -} - -/* A wrapper that handles the trap. This construct is used - to keep the derived code closer to the original -*/ -static int -ProcShmDispatch (register ClientPtr client) -{ - int result; nxagentShmTrap = 1; - result = nxagent_ProcShmDispatch(client); + result = xorg_ProcShmDispatch(client); nxagentShmTrap = 0; @@ -563,55 +454,24 @@ ProcShmDispatch (register ClientPtr client) } static int -SProcShmDispatch (client) - register ClientPtr client; +SProcShmDispatch (register ClientPtr client) { - REQUEST(xReq); + int result; #ifdef TEST - fprintf(stderr, "SProcShmDispatch: Going to execute operation [%d] for client [%d].\n", - stuff -> data, client -> index); - #endif - - switch (stuff->data) + REQUEST(xReq); + if (stuff->data <= X_ShmCreatePixmap) { - case X_ShmQueryVersion: - return SProcShmQueryVersion(client); - case X_ShmAttach: - return SProcShmAttach(client); - case X_ShmDetach: - return SProcShmDetach(client); - case X_ShmPutImage: - { - int result; - - #ifdef TEST - fprintf(stderr, "SProcShmDispatch: Going to execute SProcShmPutImage() for client [%d].\n", - client -> index); - #endif - -#ifdef NXAGENT_SERVER - nxagentShmTrap = 1; -#endif + fprintf(stderr, "SProcShmDispatch: Request [%s] OPCODE [%d] for client [%d].\n", + nxagentShmRequestLiteral[stuff->data], stuff->data, client->index); + } + #endif - result = SProcShmPutImage(client); + nxagentShmTrap = 1; -#ifdef NXAGENT_SERVER - nxagentShmTrap = 0; -#endif + result = xorg_SProcShmDispatch(client); - #ifdef TEST - fprintf(stderr, "SProcShmDispatch: Returning from SProcShmPutImage() for client [%d].\n", - client -> index); - #endif + nxagentShmTrap = 0; - return result; - } - case X_ShmGetImage: - return SProcShmGetImage(client); - case X_ShmCreatePixmap: - return SProcShmCreatePixmap(client); - default: - return BadRequest; - } + return result; } diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c b/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c index 3dcb552e5f..f88102d73b 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c @@ -133,24 +133,6 @@ extern void nxagentSetVersionProperty(WindowPtr pWin); void InitRootWindow(WindowPtr pWin) { - ScreenPtr pScreen = pWin->drawable.pScreen; - int backFlag = CWBorderPixel | CWCursor | CWBackingStore; - - #ifdef TEST - fprintf(stderr, "InitRootWindow: Called for window at [%p][%ld] with parent [%p].\n", - (void *) pWin, nxagentWindowPriv(pWin)->window, (void *) pWin -> parent); - #endif - - if (nxagentOption(Rootless)) - { - #ifdef TEST - fprintf(stderr, "InitRootWindow: Assigned agent root to window at [%p][%ld] with parent [%p].\n", - (void *) pWin, nxagentWindowPriv(pWin)->window, (void *) pWin -> parent); - #endif - - nxagentRootlessWindow = pWin; - } - /* * A root window is created for each screen by main * and the pointer is saved in screenInfo.screens as @@ -165,36 +147,17 @@ InitRootWindow(WindowPtr pWin) * if you prefer) fits in the big picture. */ - #ifdef TEST - fprintf(stderr, "InitRootWindow: Going to create window as root at [%p][%ld] with parent [%p].\n", - (void *) pWin, nxagentWindowPriv(pWin)->window, (void *) pWin -> parent); - #endif - - if (!(*pScreen->CreateWindow)(pWin)) - return; /* XXX */ - - #ifdef TEST - fprintf(stderr, "InitRootWindow: Created window as root at [%p][%ld] with parent [%p].\n", - (void *) pWin, nxagentWindowPriv(pWin)->window, (void *) pWin -> parent); - #endif - - (*pScreen->PositionWindow)(pWin, 0, 0); - - pWin->cursorIsNone = FALSE; - pWin->optional->cursor = rootCursor; - rootCursor->refcnt++; - - if (blackRoot) - pWin->background.pixel = pScreen->blackPixel; - else - pWin->background.pixel = pScreen->whitePixel; - backFlag |= CWBackPixel; + if (nxagentOption(Rootless)) + { + #ifdef TEST + fprintf(stderr, "InitRootWindow: Assigned agent root to window at [%p][%ld] with parent [%p].\n", + (void *) pWin, nxagentWindowPriv(pWin)->window, (void *) pWin -> parent); + #endif - pWin->backingStore = defaultBackingStore; - pWin->forcedBS = (defaultBackingStore != NotUseful); + nxagentRootlessWindow = pWin; + } - /* We SHOULD check for an error value here XXX */ - (*pScreen->ChangeWindowAttributes)(pWin, backFlag); + xorg_InitRootWindow(pWin); /* * Map both the root and the default agent window. @@ -204,8 +167,6 @@ InitRootWindow(WindowPtr pWin) fprintf(stderr, "InitRootWindow: Mapping default windows.\n"); #endif - nxagentInitAtoms(pWin); - nxagentInitClipboard(pWin); nxagentMapDefaultWindows(); @@ -219,548 +180,16 @@ InitRootWindow(WindowPtr pWin) extern void nxagentPropagateArtsdProperties(ScreenPtr pScreen, char *port); nPort = atoi(display) + 7000; sprintf(artsd_port,"%d", nPort); - nxagentPropagateArtsdProperties(pScreen, artsd_port); + nxagentPropagateArtsdProperties(pWin->drawable.pScreen, artsd_port); } #endif nxagentSetVersionProperty(pWin); } -/***** - * DeleteWindow - * Deletes child of window then window itself - * If wid is None, don't send any events - *****/ - -int -DeleteWindow(void * value, XID wid) - { - register WindowPtr pParent; - register WindowPtr pWin = (WindowPtr)value; - xEvent event; - - UnmapWindow(pWin, FALSE); - - CrushTree(pWin); - - pParent = pWin->parent; - if (wid && pParent && SubStrSend(pWin, pParent)) - { - memset(&event, 0, sizeof(xEvent)); - event.u.u.type = DestroyNotify; - event.u.destroyNotify.window = pWin->drawable.id; - DeliverEvents(pWin, &event, 1, NullWindow); - } - - FreeWindowResources(pWin); - if (pParent) - { - if (pParent->firstChild == pWin) - pParent->firstChild = pWin->nextSib; - if (pParent->lastChild == pWin) - pParent->lastChild = pWin->prevSib; - if (pWin->nextSib) - pWin->nextSib->prevSib = pWin->prevSib; - if (pWin->prevSib) - pWin->prevSib->nextSib = pWin->nextSib; - } - - if (pWin -> optional && - pWin -> optional -> colormap && - pWin -> parent) - { - nxagentSetInstalledColormapWindows(pWin -> drawable.pScreen); - } - - free(pWin); - return Success; -} - -/* XXX need to retile border on each window with ParentRelative origin */ -void -ResizeChildrenWinSize(register WindowPtr pWin, int dx, int dy, int dw, int dh) -{ - register ScreenPtr pScreen; - register WindowPtr pSib, pChild; - Bool resized = (dw || dh); - - pScreen = pWin->drawable.pScreen; - - for (pSib = pWin->firstChild; pSib; pSib = pSib->nextSib) - { - if (resized && (pSib->winGravity > NorthWestGravity)) - { - int cwsx, cwsy; - - cwsx = pSib->origin.x; - cwsy = pSib->origin.y; - GravityTranslate (cwsx, cwsy, cwsx - dx, cwsy - dy, dw, dh, - pSib->winGravity, &cwsx, &cwsy); - if (cwsx != pSib->origin.x || cwsy != pSib->origin.y) - { - xEvent event = {0}; - event.u.u.type = GravityNotify; - event.u.gravity.window = pSib->drawable.id; - event.u.gravity.x = cwsx - wBorderWidth (pSib); - event.u.gravity.y = cwsy - wBorderWidth (pSib); - DeliverEvents (pSib, &event, 1, NullWindow); - pSib->origin.x = cwsx; - pSib->origin.y = cwsy; - } - } - pSib->drawable.x = pWin->drawable.x + pSib->origin.x; - pSib->drawable.y = pWin->drawable.y + pSib->origin.y; - SetWinSize (pSib); - SetBorderSize (pSib); - - /* - * Don't force X to move children. It will position them - * according with gravity. - * - * (*pScreen->PositionWindow)(pSib, pSib->drawable.x, pSib->drawable.y); - */ - - /* - * Update pSib privates, as this window is moved by X. - */ - - nxagentAddConfiguredWindow(pSib, CW_Update); - - if ( (pChild = pSib->firstChild) ) - { - while (1) - { - pChild->drawable.x = pChild->parent->drawable.x + - pChild->origin.x; - pChild->drawable.y = pChild->parent->drawable.y + - pChild->origin.y; - SetWinSize (pChild); - SetBorderSize (pChild); - - (*pScreen->PositionWindow)(pChild, pChild->drawable.x, - pChild->drawable.y); - - if (pChild->firstChild) - { - pChild = pChild->firstChild; - continue; - } - while (!pChild->nextSib && (pChild != pSib)) - pChild = pChild->parent; - if (pChild == pSib) - break; - pChild = pChild->nextSib; - } - } - } -} - -/***** - * ConfigureWindow - *****/ - -int -ConfigureWindow(register WindowPtr pWin, register Mask mask, XID *vlist, ClientPtr client) -{ -#define RESTACK_WIN 0 -#define MOVE_WIN 1 -#define RESIZE_WIN 2 -#define REBORDER_WIN 3 - register WindowPtr pSib = NullWindow; - register WindowPtr pParent = pWin->parent; - Window sibwid = 0; - Mask index2, tmask; - register XID *pVlist; - short x, y, beforeX, beforeY; - unsigned short w = pWin->drawable.width, - h = pWin->drawable.height, - bw = pWin->borderWidth; - int action, smode = Above; - xEvent event = {0}; - - if ((pWin->drawable.class == InputOnly) && (mask & IllegalInputOnlyConfigureMask)) - return(BadMatch); - - if ((mask & CWSibling) && !(mask & CWStackMode)) - return(BadMatch); - - pVlist = vlist; - - if (pParent) - { - x = pWin->drawable.x - pParent->drawable.x - (int)bw; - y = pWin->drawable.y - pParent->drawable.y - (int)bw; - } - else - { - x = pWin->drawable.x; - y = pWin->drawable.y; - } - beforeX = x; - beforeY = y; - action = RESTACK_WIN; - if ((mask & (CWX | CWY)) && (!(mask & (CWHeight | CWWidth)))) - { - GET_INT16(CWX, x); - GET_INT16(CWY, y); - action = MOVE_WIN; - } - /* or should be resized */ - else if (mask & (CWX | CWY | CWWidth | CWHeight)) - { - GET_INT16(CWX, x); - GET_INT16(CWY, y); - GET_CARD16(CWWidth, w); - GET_CARD16 (CWHeight, h); - if (!w || !h) - { - client->errorValue = 0; - return BadValue; - } - action = RESIZE_WIN; - } - tmask = mask & ~ChangeMask; - while (tmask) - { - index2 = (Mask)lowbit (tmask); - tmask &= ~index2; - switch (index2) - { - case CWBorderWidth: - GET_CARD16(CWBorderWidth, bw); - break; - case CWSibling: - sibwid = (Window ) *pVlist; - pVlist++; - pSib = (WindowPtr )SecurityLookupIDByType(client, sibwid, - RT_WINDOW, DixReadAccess); - if (!pSib) - { - client->errorValue = sibwid; - return(BadWindow); - } - if (pSib->parent != pParent) - return(BadMatch); - if (pSib == pWin) - return(BadMatch); - break; - case CWStackMode: - GET_CARD8(CWStackMode, smode); - if ((smode != TopIf) && (smode != BottomIf) && - (smode != Opposite) && (smode != Above) && (smode != Below)) - { - client->errorValue = smode; - return(BadValue); - } - break; - default: - client->errorValue = mask; - return(BadValue); - } - } - /* root really can't be reconfigured, so just return */ - if (!pParent) - return Success; - - /* Figure out if the window should be moved. Doesn't - make the changes to the window if event sent */ - - #ifdef TEST - if (nxagentWindowTopLevel(pWin)) - { - - fprintf(stderr, "ConfigureWindow: pWin [%p] mask [%lu] client [%p]\n", - pWin, mask, client); - - fprintf(stderr, "ConfigureWindow: x [%d] y [%d] w [%d] h [%d] CWStackMode [%d] " - "smode [%d] pSib [%p]\n", - x, y, w, h, (mask & CWStackMode) ? 1 : 0, smode, pSib); - } - #endif - - if (nxagentOption(Rootless) && nxagentWindowTopLevel(pWin) && - pWin -> overrideRedirect == 0 && - nxagentScreenTrap == 0) - { - nxagentConfigureRootlessWindow(pWin, x, y, w, h, bw, pSib, smode, mask); - - return Success; - } - - if (mask & CWStackMode) - pSib = WhereDoIGoInTheStack(pWin, pSib, pParent->drawable.x + x, - pParent->drawable.y + y, - w + (bw << 1), h + (bw << 1), smode); - else - pSib = pWin->nextSib; - - - if ((!pWin->overrideRedirect) && - (RedirectSend(pParent) - )) - { - memset(&event, 0, sizeof(xEvent)); - event.u.u.type = ConfigureRequest; - event.u.configureRequest.window = pWin->drawable.id; - if (mask & CWSibling) - event.u.configureRequest.sibling = sibwid; - else - event.u.configureRequest.sibling = None; - if (mask & CWStackMode) - event.u.u.detail = smode; - else - event.u.u.detail = Above; - event.u.configureRequest.x = x; - event.u.configureRequest.y = y; -#ifdef PANORAMIX - if(!noPanoramiXExtension && (!pParent || !pParent->parent)) { - event.u.configureRequest.x += panoramiXdataPtr[0].x; - event.u.configureRequest.y += panoramiXdataPtr[0].y; - } -#endif - event.u.configureRequest.width = w; - event.u.configureRequest.height = h; - event.u.configureRequest.borderWidth = bw; - event.u.configureRequest.valueMask = mask; - event.u.configureRequest.parent = pParent->drawable.id; - if (MaybeDeliverEventsToClient(pParent, &event, 1, - SubstructureRedirectMask, client) == 1) - return(Success); - } - if (action == RESIZE_WIN) - { - Bool size_change = (w != pWin->drawable.width) - || (h != pWin->drawable.height); - if (size_change && ((pWin->eventMask|wOtherEventMasks(pWin)) & ResizeRedirectMask)) - { - xEvent eventT = {0}; - eventT.u.u.type = ResizeRequest; - eventT.u.resizeRequest.window = pWin->drawable.id; - eventT.u.resizeRequest.width = w; - eventT.u.resizeRequest.height = h; - if (MaybeDeliverEventsToClient(pWin, &eventT, 1, - ResizeRedirectMask, client) == 1) - { - /* if event is delivered, leave the actual size alone. */ - w = pWin->drawable.width; - h = pWin->drawable.height; - size_change = FALSE; - } - } - if (!size_change) - { - if (mask & (CWX | CWY)) - action = MOVE_WIN; - else if (mask & (CWStackMode | CWBorderWidth)) - action = RESTACK_WIN; - else /* really nothing to do */ - return(Success) ; - } - } - - if (action == RESIZE_WIN) - /* we've already checked whether there's really a size change */ - goto ActuallyDoSomething; - if ((mask & CWX) && (x != beforeX)) - goto ActuallyDoSomething; - if ((mask & CWY) && (y != beforeY)) - goto ActuallyDoSomething; - if ((mask & CWBorderWidth) && (bw != wBorderWidth (pWin))) - goto ActuallyDoSomething; - if (mask & CWStackMode) - { -#ifndef ROOTLESS - /* See above for why we always reorder in rootless mode. */ - if (pWin->nextSib != pSib) -#endif - goto ActuallyDoSomething; - } - return(Success); - -ActuallyDoSomething: - if (SubStrSend(pWin, pParent)) - { - memset(&event, 0, sizeof(xEvent)); - event.u.u.type = ConfigureNotify; - event.u.configureNotify.window = pWin->drawable.id; - if (pSib) - event.u.configureNotify.aboveSibling = pSib->drawable.id; - else - event.u.configureNotify.aboveSibling = None; - event.u.configureNotify.x = x; - event.u.configureNotify.y = y; -#ifdef PANORAMIX - if(!noPanoramiXExtension && (!pParent || !pParent->parent)) { - event.u.configureNotify.x += panoramiXdataPtr[0].x; - event.u.configureNotify.y += panoramiXdataPtr[0].y; - } -#endif - event.u.configureNotify.width = w; - event.u.configureNotify.height = h; - event.u.configureNotify.borderWidth = bw; - event.u.configureNotify.override = pWin->overrideRedirect; - DeliverEvents(pWin, &event, 1, NullWindow); - } - if (mask & CWBorderWidth) - { - if (action == RESTACK_WIN) - { - action = MOVE_WIN; - pWin->borderWidth = bw; - } - else if ((action == MOVE_WIN) && - (beforeX + wBorderWidth (pWin) == x + (int)bw) && - (beforeY + wBorderWidth (pWin) == y + (int)bw)) - { - action = REBORDER_WIN; - (*pWin->drawable.pScreen->ChangeBorderWidth)(pWin, bw); - } - else - pWin->borderWidth = bw; - } - if (action == MOVE_WIN) - (*pWin->drawable.pScreen->MoveWindow)(pWin, x, y, pSib, - (mask & CWBorderWidth) ? VTOther : VTMove); - else if (action == RESIZE_WIN) - (*pWin->drawable.pScreen->ResizeWindow)(pWin, x, y, w, h, pSib); - else if (mask & CWStackMode) - ReflectStackChange(pWin, pSib, VTOther); - - if (action != RESTACK_WIN) - CheckCursorConfinement(pWin); - - nxagentFlushConfigureWindow(); - - return(Success); -#undef RESTACK_WIN -#undef MOVE_WIN -#undef RESIZE_WIN -#undef REBORDER_WIN -} - -/***** - * ReparentWindow - *****/ - -int -ReparentWindow(register WindowPtr pWin, register WindowPtr pParent, - int x, int y, ClientPtr client) -{ - WindowPtr pPrev, pPriorParent; - Bool WasMapped = (Bool)(pWin->mapped); - xEvent event = {0}; - int bw = wBorderWidth (pWin); - register ScreenPtr pScreen; - - pScreen = pWin->drawable.pScreen; - if (TraverseTree(pWin, CompareWIDs, (void *)&pParent->drawable.id) == WT_STOPWALKING) - return(BadMatch); - if (!MakeWindowOptional(pWin)) - return(BadAlloc); - - if (WasMapped) - UnmapWindow(pWin, FALSE); - - event.u.u.type = ReparentNotify; - event.u.reparent.window = pWin->drawable.id; - event.u.reparent.parent = pParent->drawable.id; - event.u.reparent.x = x; - event.u.reparent.y = y; -#ifdef PANORAMIX - if(!noPanoramiXExtension && !pParent->parent) { - event.u.reparent.x += panoramiXdataPtr[0].x; - event.u.reparent.y += panoramiXdataPtr[0].y; - } -#endif - event.u.reparent.override = pWin->overrideRedirect; - DeliverEvents(pWin, &event, 1, pParent); - - /* take out of sibling chain */ - - pPriorParent = pPrev = pWin->parent; - if (pPrev->firstChild == pWin) - pPrev->firstChild = pWin->nextSib; - if (pPrev->lastChild == pWin) - pPrev->lastChild = pWin->prevSib; - - if (pWin->nextSib) - pWin->nextSib->prevSib = pWin->prevSib; - if (pWin->prevSib) - pWin->prevSib->nextSib = pWin->nextSib; - - /* insert at beginning of pParent */ - pWin->parent = pParent; - pPrev = RealChildHead(pParent); - - if (pWin->parent == screenInfo.screens[0]->root) - { - nxagentSetTopLevelEventMask(pWin); - } - - if (pPrev) - { - pWin->nextSib = pPrev->nextSib; - if (pPrev->nextSib) - pPrev->nextSib->prevSib = pWin; - else - pParent->lastChild = pWin; - pPrev->nextSib = pWin; - pWin->prevSib = pPrev; - } - else - { - pWin->nextSib = pParent->firstChild; - pWin->prevSib = NullWindow; - if (pParent->firstChild) - pParent->firstChild->prevSib = pWin; - else - pParent->lastChild = pWin; - pParent->firstChild = pWin; - } - - pWin->origin.x = x + bw; - pWin->origin.y = y + bw; - pWin->drawable.x = x + bw + pParent->drawable.x; - pWin->drawable.y = y + bw + pParent->drawable.y; - - /* clip to parent */ - SetWinSize (pWin); - SetBorderSize (pWin); - - if (pScreen->ReparentWindow) - (*pScreen->ReparentWindow)(pWin, pPriorParent); - - (*pScreen->PositionWindow)(pWin, pWin->drawable.x, pWin->drawable.y); - - ResizeChildrenWinSize(pWin, 0, 0, 0, 0); - - CheckWindowOptionalNeed(pWin); - - if (WasMapped) - MapWindow(pWin, client); - RecalculateDeliverableEvents(pWin); - return(Success); -} - -/***** - * MapWindow - * If some other client has selected SubStructureReDirect on the parent - * and override-redirect is xFalse, then a MapRequest event is generated, - * but the window remains unmapped. Otherwise, the window is mapped and a - * MapNotify event is generated. - *****/ - int MapWindow(register WindowPtr pWin, ClientPtr client) { - register ScreenPtr pScreen; - - register WindowPtr pParent; -#ifdef DO_SAVE_UNDERS - Bool dosave = FALSE; -#endif - WindowPtr pLayerWin; - #ifdef TEST if (nxagentWindowTopLevel(pWin)) { @@ -768,286 +197,12 @@ MapWindow(register WindowPtr pWin, ClientPtr client) } #endif - if (pWin->mapped) - return(Success); - -#ifdef XCSECURITY - /* don't let an untrusted client map a child-of-trusted-window, InputOnly - * window; too easy to steal device input + /* + * MapWindow() always returns Success. (Our) xorg_MapWindow() uses + * BadImplementation as a means to inform us to call + * nxagentFlushConfigureWindow() */ - if ( (client->trustLevel != XSecurityClientTrusted) && - (pWin->drawable.class == InputOnly) && - (wClient(pWin->parent)->trustLevel == XSecurityClientTrusted) ) - return Success; -#endif - - pScreen = pWin->drawable.pScreen; - if ( (pParent = pWin->parent) ) - { - xEvent event; - Bool anyMarked; - - if ((!pWin->overrideRedirect) && - (RedirectSend(pParent) - )) - { - memset(&event, 0, sizeof(xEvent)); - event.u.u.type = MapRequest; - event.u.mapRequest.window = pWin->drawable.id; - event.u.mapRequest.parent = pParent->drawable.id; - - if (MaybeDeliverEventsToClient(pParent, &event, 1, - SubstructureRedirectMask, client) == 1) - return(Success); - } - - pWin->mapped = TRUE; - if (SubStrSend(pWin, pParent) && MapUnmapEventsEnabled(pWin)) - { - memset(&event, 0, sizeof(xEvent)); - event.u.u.type = MapNotify; - event.u.mapNotify.window = pWin->drawable.id; - event.u.mapNotify.override = pWin->overrideRedirect; - DeliverEvents(pWin, &event, 1, NullWindow); - } - - if (!pParent->realized) - return(Success); - RealizeTree(pWin); - if (pWin->viewable) - { - anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pWin, - &pLayerWin); -#ifdef DO_SAVE_UNDERS - if (DO_SAVE_UNDERS(pWin)) - { - dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pWin->nextSib); - } -#endif /* DO_SAVE_UNDERS */ - if (anyMarked) - { - (*pScreen->ValidateTree)(pLayerWin->parent, pLayerWin, VTMap); - (*pScreen->HandleExposures)(pLayerWin->parent); - } -#ifdef DO_SAVE_UNDERS - if (dosave) - (*pScreen->PostChangeSaveUnder)(pLayerWin, pWin->nextSib); -#endif /* DO_SAVE_UNDERS */ - if (anyMarked && pScreen->PostValidateTree) - (*pScreen->PostValidateTree)(pLayerWin->parent, pLayerWin, VTMap); - } - WindowsRestructured (); - } - else - { - RegionRec temp; - - pWin->mapped = TRUE; - pWin->realized = TRUE; /* for roots */ - pWin->viewable = pWin->drawable.class == InputOutput; - /* We SHOULD check for an error value here XXX */ - (*pScreen->RealizeWindow)(pWin); - if (pScreen->ClipNotify) - (*pScreen->ClipNotify) (pWin, 0, 0); - if (pScreen->PostValidateTree) - (*pScreen->PostValidateTree)(NullWindow, pWin, VTMap); - RegionNull(&temp); - RegionCopy(&temp, &pWin->clipList); - (*pScreen->WindowExposures) (pWin, &temp, NullRegion); - RegionUninit(&temp); - } - - nxagentFlushConfigureWindow(); - + if (xorg_MapWindow(pWin, client) == BadImplementation) + nxagentFlushConfigureWindow(); return(Success); } - -/***** - * UnmapWindow - * If the window is already unmapped, this request has no effect. - * Otherwise, the window is unmapped and an UnMapNotify event is - * generated. Cannot unmap a root window. - *****/ - -int -UnmapWindow(register WindowPtr pWin, Bool fromConfigure) -{ - register WindowPtr pParent; - xEvent event; - Bool wasRealized = (Bool)pWin->realized; - Bool wasViewable = (Bool)pWin->viewable; - ScreenPtr pScreen = pWin->drawable.pScreen; - WindowPtr pLayerWin = pWin; - - #ifdef TEST - if (nxagentWindowTopLevel(pWin)) - { - fprintf(stderr, "UnmapWindow: pWin [%p] fromConfigure [%d]\n", pWin, - fromConfigure); - } - #endif - - if ((!pWin->mapped) || (!(pParent = pWin->parent))) - return(Success); - if (SubStrSend(pWin, pParent) && MapUnmapEventsEnabled(pWin)) - { - memset(&event, 0, sizeof(xEvent)); - event.u.u.type = UnmapNotify; - event.u.unmapNotify.window = pWin->drawable.id; - event.u.unmapNotify.fromConfigure = fromConfigure; - DeliverEvents(pWin, &event, 1, NullWindow); - } - if (wasViewable && !fromConfigure) - { - pWin->valdata = UnmapValData; - (*pScreen->MarkOverlappedWindows)(pWin, pWin->nextSib, &pLayerWin); - (*pScreen->MarkWindow)(pLayerWin->parent); - } - pWin->mapped = FALSE; - if (wasRealized) - UnrealizeTree(pWin, fromConfigure); - if (wasViewable) - { - if (!fromConfigure) - { - (*pScreen->ValidateTree)(pLayerWin->parent, pWin, VTUnmap); - (*pScreen->HandleExposures)(pLayerWin->parent); - } -#ifdef DO_SAVE_UNDERS - if (DO_SAVE_UNDERS(pWin)) - { - if ( (*pScreen->ChangeSaveUnder)(pLayerWin, pWin->nextSib) ) - { - (*pScreen->PostChangeSaveUnder)(pLayerWin, pWin->nextSib); - } - } - pWin->DIXsaveUnder = FALSE; -#endif /* DO_SAVE_UNDERS */ - if (!fromConfigure && pScreen->PostValidateTree) - (*pScreen->PostValidateTree)(pLayerWin->parent, pWin, VTUnmap); - } - if (wasRealized && !fromConfigure) - WindowsRestructured (); - return(Success); -} - -void -SaveScreens(int on, int mode) -{ - int i; - int what; - int type; - - if (on == SCREEN_SAVER_FORCER) - { - if (mode == ScreenSaverReset) - what = SCREEN_SAVER_OFF; - else - what = SCREEN_SAVER_ON; - type = what; - } - else - { - what = on; - type = what; - if (what == screenIsSaved) - type = SCREEN_SAVER_CYCLE; - } - for (i = 0; i < screenInfo.numScreens; i++) - { - if (on == SCREEN_SAVER_FORCER) - (* screenInfo.screens[i]->SaveScreen) (screenInfo.screens[i], on); - if (savedScreenInfo[i].ExternalScreenSaver) - { - if (nxagentOption(Timeout) != 0) - { - #ifdef TEST - fprintf(stderr, "SaveScreens: An external screen-saver handler is installed. " - "Ignoring it to let the auto-disconnect feature work.\n"); - #endif - } - else - { - if ((*savedScreenInfo[i].ExternalScreenSaver) - (screenInfo.screens[i], type, on == SCREEN_SAVER_FORCER)) - continue; - } - } - if (type == screenIsSaved) - continue; - switch (type) { - case SCREEN_SAVER_OFF: - if (savedScreenInfo[i].blanked == SCREEN_IS_BLANKED) - { - (* screenInfo.screens[i]->SaveScreen) (screenInfo.screens[i], - what); - } - else if (HasSaverWindow (i)) - { - savedScreenInfo[i].pWindow = NullWindow; - FreeResource(savedScreenInfo[i].wid, RT_NONE); - } - break; - case SCREEN_SAVER_CYCLE: - if (savedScreenInfo[i].blanked == SCREEN_IS_TILED) - { - WindowPtr pWin = savedScreenInfo[i].pWindow; - /* make it look like screen saver is off, so that - * NotClippedByChildren will compute a clip list - * for the root window, so miPaintWindow works - */ - screenIsSaved = SCREEN_SAVER_OFF; -#ifndef NOLOGOHACK - if (logoScreenSaver) - (*pWin->drawable.pScreen->ClearToBackground)(pWin, 0, 0, 0, 0, FALSE); -#endif - (*pWin->drawable.pScreen->MoveWindow)(pWin, - (short)(-(rand() % RANDOM_WIDTH)), - (short)(-(rand() % RANDOM_WIDTH)), - pWin->nextSib, VTMove); -#ifndef NOLOGOHACK - if (logoScreenSaver) - DrawLogo(pWin); -#endif - screenIsSaved = SCREEN_SAVER_ON; - } - /* - * Call the DDX saver in case it wants to do something - * at cycle time - */ - else if (savedScreenInfo[i].blanked == SCREEN_IS_BLANKED) - { - (* screenInfo.screens[i]->SaveScreen) (screenInfo.screens[i], - type); - } - break; - case SCREEN_SAVER_ON: - if (ScreenSaverBlanking != DontPreferBlanking) - { - if ((* screenInfo.screens[i]->SaveScreen) - (screenInfo.screens[i], what)) - { - savedScreenInfo[i].blanked = SCREEN_IS_BLANKED; - continue; - } - if ((ScreenSaverAllowExposures != DontAllowExposures) && - TileScreenSaver(i, SCREEN_IS_BLACK)) - { - savedScreenInfo[i].blanked = SCREEN_IS_BLACK; - continue; - } - } - if ((ScreenSaverAllowExposures != DontAllowExposures) && - TileScreenSaver(i, SCREEN_IS_TILED)) - { - savedScreenInfo[i].blanked = SCREEN_IS_TILED; - } - else - savedScreenInfo[i].blanked = SCREEN_ISNT_SAVED; - break; - } - } - screenIsSaved = what; - if (mode == ScreenSaverReset) - SetScreenSaverTimer(); -} diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXxvdisp.c b/nx-X11/programs/Xserver/hw/nxagent/NXxvdisp.c index 336ec10604..545d9255cb 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXxvdisp.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXxvdisp.c @@ -47,11 +47,12 @@ SOFTWARE. ******************************************************************/ -#if !defined(__sun) && !defined(__CYGWIN__) - #include "Trap.h" -#include "../../Xext/xvdisp.c" +#include "misc.h" + +extern int xorg_ProcXvDispatch(ClientPtr); +extern int xorg_SProcXvDispatch(ClientPtr); #undef TEST #undef DEBUG @@ -63,90 +64,6 @@ SOFTWARE. ** */ -int -nxagent_ProcXvDispatch(ClientPtr client) -{ - REQUEST(xReq); - - UpdateCurrentTime(); - - switch (stuff->data) - { - case xv_QueryExtension: return(ProcXvQueryExtension(client)); - case xv_QueryAdaptors: return(ProcXvQueryAdaptors(client)); - case xv_QueryEncodings: return(ProcXvQueryEncodings(client)); - case xv_PutVideo: -#ifdef PANORAMIX - if(!noPanoramiXExtension) - return(XineramaXvPutVideo(client)); - else -#endif - return(ProcXvPutVideo(client)); - case xv_PutStill: -#ifdef PANORAMIX - if(!noPanoramiXExtension) - return(XineramaXvPutStill(client)); - else -#endif - { - return(ProcXvPutStill(client)); - } - case xv_GetVideo: return(ProcXvGetVideo(client)); - case xv_GetStill: return(ProcXvGetStill(client)); - case xv_GrabPort: return(ProcXvGrabPort(client)); - case xv_UngrabPort: return(ProcXvUngrabPort(client)); - case xv_SelectVideoNotify: return(ProcXvSelectVideoNotify(client)); - case xv_SelectPortNotify: return(ProcXvSelectPortNotify(client)); - case xv_StopVideo: -#ifdef PANORAMIX - if(!noPanoramiXExtension) - return(XineramaXvStopVideo(client)); - else -#endif - return(ProcXvStopVideo(client)); - case xv_SetPortAttribute: -#ifdef PANORAMIX - if(!noPanoramiXExtension) - return(XineramaXvSetPortAttribute(client)); - else -#endif - return(ProcXvSetPortAttribute(client)); - case xv_GetPortAttribute: return(ProcXvGetPortAttribute(client)); - case xv_QueryBestSize: return(ProcXvQueryBestSize(client)); - case xv_QueryPortAttributes: return(ProcXvQueryPortAttributes(client)); - case xv_PutImage: -#ifdef PANORAMIX - if(!noPanoramiXExtension) - return(XineramaXvPutImage(client)); - else -#endif - return(ProcXvPutImage(client)); -#ifdef MITSHM - case xv_ShmPutImage: -#ifdef PANORAMIX - if(!noPanoramiXExtension) - return(XineramaXvShmPutImage(client)); - else -#endif - return(ProcXvShmPutImage(client)); -#endif - case xv_QueryImageAttributes: return(ProcXvQueryImageAttributes(client)); - case xv_ListImageFormats: return(ProcXvListImageFormats(client)); - default: - if (stuff->data < xvNumRequests) - { - SendErrorToClient(client, XvReqCode, stuff->data, 0, - BadImplementation); - return(BadImplementation); - } - else - { - SendErrorToClient(client, XvReqCode, stuff->data, 0, BadRequest); - return(BadRequest); - } - } -} - int ProcXvDispatch(ClientPtr client) { @@ -164,7 +81,7 @@ ProcXvDispatch(ClientPtr client) nxagentXvTrap = 1; - result = nxagent_ProcXvDispatch(client); + result = xorg_ProcXvDispatch(client); nxagentXvTrap = 0; @@ -176,54 +93,6 @@ ProcXvDispatch(ClientPtr client) return result; } - -int -nxagent_SProcXvDispatch(ClientPtr client) -{ - REQUEST(xReq); - - UpdateCurrentTime(); - - switch (stuff->data) - { - case xv_QueryExtension: return(SProcXvQueryExtension(client)); - case xv_QueryAdaptors: return(SProcXvQueryAdaptors(client)); - case xv_QueryEncodings: return(SProcXvQueryEncodings(client)); - case xv_PutVideo: return(SProcXvPutVideo(client)); - case xv_PutStill: return(SProcXvPutStill(client)); - case xv_GetVideo: return(SProcXvGetVideo(client)); - case xv_GetStill: return(SProcXvGetStill(client)); - case xv_GrabPort: return(SProcXvGrabPort(client)); - case xv_UngrabPort: return(SProcXvUngrabPort(client)); - case xv_SelectVideoNotify: return(SProcXvSelectVideoNotify(client)); - case xv_SelectPortNotify: return(SProcXvSelectPortNotify(client)); - case xv_StopVideo: return(SProcXvStopVideo(client)); - case xv_SetPortAttribute: return(SProcXvSetPortAttribute(client)); - case xv_GetPortAttribute: return(SProcXvGetPortAttribute(client)); - case xv_QueryBestSize: return(SProcXvQueryBestSize(client)); - case xv_QueryPortAttributes: return(SProcXvQueryPortAttributes(client)); - case xv_PutImage: return(SProcXvPutImage(client)); -#ifdef MITSHM - case xv_ShmPutImage: return(SProcXvShmPutImage(client)); -#endif - case xv_QueryImageAttributes: return(SProcXvQueryImageAttributes(client)); - case xv_ListImageFormats: return(SProcXvListImageFormats(client)); - default: - if (stuff->data < xvNumRequests) - { - SendErrorToClient(client, XvReqCode, stuff->data, 0, - BadImplementation); - return(BadImplementation); - } - else - { - SendErrorToClient(client, XvReqCode, stuff->data, 0, BadRequest); - return(BadRequest); - } - } -} - - int SProcXvDispatch(ClientPtr client) { @@ -241,7 +110,7 @@ SProcXvDispatch(ClientPtr client) nxagentXvTrap = 1; - result = nxagent_SProcXvDispatch(client); + result = xorg_SProcXvDispatch(client); nxagentXvTrap = 0; @@ -252,7 +121,3 @@ SProcXvDispatch(ClientPtr client) return result; } - - - -#endif /* !defined(__sun) && !defined(__CYGWIN__) */ diff --git a/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c b/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c index 58fea6c05b..41d331b3f0 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c @@ -591,89 +591,18 @@ Bool nxagentModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int dep bitsPerPixel, devKind, (void *) pPixData); #endif - if ((width > 0) && (height > 0) && (depth > 0) && - (bitsPerPixel > 0) && (devKind > 0) && pPixData) - { - pPixmap->drawable.depth = depth; - pPixmap->drawable.bitsPerPixel = bitsPerPixel; - pPixmap->drawable.id = 0; - pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER; - pPixmap->drawable.x = 0; - pPixmap->drawable.y = 0; - pPixmap->drawable.width = width; - pPixmap->drawable.height = height; - pPixmap->devKind = devKind; - pPixmap->refcnt = 1; - pPixmap->devPrivate.ptr = pPixData; - - pVirtualPixmap->drawable.depth = depth; - pVirtualPixmap->drawable.bitsPerPixel = bitsPerPixel; - pVirtualPixmap->drawable.id = 0; - pVirtualPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER; - pVirtualPixmap->drawable.x = 0; - pVirtualPixmap->drawable.y = 0; - pVirtualPixmap->drawable.width = width; - pVirtualPixmap->drawable.height = height; - pVirtualPixmap->devKind = devKind; - pVirtualPixmap->refcnt = 1; - pVirtualPixmap->devPrivate.ptr = pPixData; - } - else - { - if (width > 0) - pPixmap->drawable.width = width; - - if (height > 0) - pPixmap->drawable.height = height; - - if (depth > 0) - pPixmap->drawable.depth = depth; - - if (bitsPerPixel > 0) - pPixmap->drawable.bitsPerPixel = bitsPerPixel; - else if ((bitsPerPixel < 0) && (depth > 0)) - pPixmap->drawable.bitsPerPixel = BitsPerPixel(depth); - - if (devKind > 0) - pPixmap->devKind = devKind; - else if ((devKind < 0) && ((width > 0) || (depth > 0))) - pPixmap->devKind = PixmapBytePad(pPixmap->drawable.width, - pPixmap->drawable.depth); - - if (pPixData) - pPixmap->devPrivate.ptr = pPixData; - - /* - * XXX This was the previous assignment: - * - * pVirtualPixmap->devPrivate.ptr = pPixData; - */ - - if (width > 0) - pVirtualPixmap->drawable.width = width; - - if (height > 0) - pVirtualPixmap->drawable.height = height; - - if (depth > 0) - pVirtualPixmap->drawable.depth = depth; - - if (bitsPerPixel > 0) - pVirtualPixmap->drawable.bitsPerPixel = bitsPerPixel; - else if ((bitsPerPixel < 0) && (depth > 0)) - pVirtualPixmap->drawable.bitsPerPixel = BitsPerPixel(depth); - - if (devKind > 0) - pVirtualPixmap->devKind = devKind; - else if ((devKind < 0) && ((width > 0) || (depth > 0))) - pVirtualPixmap->devKind = PixmapBytePad(pVirtualPixmap->drawable.width, - pVirtualPixmap->drawable.depth); + /* + * ignore return code, because the only case where this will return + * FALSE is pPixmap == NULL, which we have already caught above. + */ + miModifyPixmapHeader(pPixmap, width, height, depth, bitsPerPixel, devKind, pPixData); + miModifyPixmapHeader(pVirtualPixmap, width, height, depth, bitsPerPixel, devKind, pPixData); - if (pPixData) - pVirtualPixmap->devPrivate.ptr = pPixData; - - #ifdef PANIC + #ifdef PANIC + if (!((width > 0) && (height > 0) && (depth > 0) && (bitsPerPixel > 0) && + (devKind > 0) && pPixData)) + { if (pPixmap->drawable.x != 0 || pPixmap->drawable.y != 0) { fprintf(stderr, "nxagentModifyPixmapHeader: PANIC! Pixmap at [%p] has x [%d] and y [%d].\n", @@ -681,9 +610,8 @@ Bool nxagentModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int dep FatalError("nxagentModifyPixmapHeader: PANIC! Pixmap has x or y greater than zero."); } - - #endif } + #endif return True; } diff --git a/nx-X11/programs/Xserver/hw/nxagent/Render.c b/nx-X11/programs/Xserver/hw/nxagent/Render.c index ebc1fe287a..ec83c7245c 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Render.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Render.c @@ -461,9 +461,9 @@ void nxagentRenderExtensionInit(void) * As the RENDER requests are passed directly to * the remote X server this can cause problems if * our RENDER version is different from the version - * supported by the remote. For this reasos let's + * supported by the remote. For this reasons let's * advertise to our clients the lowest between the - + two versions. + * two versions. */ if (major_version > SERVER_RENDER_MAJOR_VERSION || @@ -539,19 +539,14 @@ void nxagentCursorPostSaveRenderInfo(CursorPtr pCursor, ScreenPtr pScreen, nxagentCursorYOffset(pCursor, pScreen) = y; } -int nxagentRenderRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor) +void nxagentRenderRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor) { - int cid; - int x, y; - - PicturePtr pPicture; - - pPicture = nxagentCursorPicture(pCursor, pScreen); + PicturePtr pPicture = nxagentCursorPicture(pCursor, pScreen); pPicture -> refcnt++; - x = nxagentCursorXOffset(pCursor, pScreen); - y = nxagentCursorYOffset(pCursor, pScreen); + int x = nxagentCursorXOffset(pCursor, pScreen); + int y = nxagentCursorYOffset(pCursor, pScreen); /* * Set the lossless trap so that the image functions @@ -576,11 +571,7 @@ int nxagentRenderRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor) nxagentLosslessTrap = 0; - cid = XRenderCreateCursor(nxagentDisplay, nxagentPicture(pPicture), x, y); - - nxagentCursor(pCursor, pScreen) = cid; - - return 1; + nxagentCursor(pCursor, pScreen) = XRenderCreateCursor(nxagentDisplay, nxagentPicture(pPicture), x, y); } int nxagentCreatePicture(PicturePtr pPicture, Mask mask) @@ -801,9 +792,7 @@ int nxagentCreatePicture(PicturePtr pPicture, Mask mask) XRenderPictFormat *nxagentMatchingFormats(PictFormatPtr pFormat) { - int i; - - for (i = 0; i < nxagentNumFormats; i++) + for (int i = 0; i < nxagentNumFormats; i++) { if (pFormat -> type == nxagentArrayFormats[i].type && pFormat -> depth == nxagentArrayFormats[i].depth && @@ -1233,13 +1222,6 @@ FIXME: Is this useful or just a waste of bandwidth? #endif } -void nxagentValidatePicture(PicturePtr pPicture, Mask mask) -{ - #ifdef DEBUG - fprintf(stderr, "nxagentValidatePicture: Nothing to do.\n"); - #endif -} - void nxagentComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask, INT16 xDst, INT16 yDst, CARD16 width, CARD16 height) @@ -2062,14 +2044,6 @@ FIXME: Is this useful or just a waste of bandwidth? #endif } -void nxagentRasterizeTrapezoid(PicturePtr pMask, xTrapezoid *trap, - int x_off, int y_off) -{ - #ifdef DEBUG - fprintf(stderr, "nxagentRasterizeTrapezoids: Nothing to do.\n"); - #endif -} - void nxagentTriangles(CARD8 op, PicturePtr pSrc, PicturePtr pDst, PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, int ntri, xTriangle *tris) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Render.h b/nx-X11/programs/Xserver/hw/nxagent/Render.h index 1c56ec16b9..70fefe42dc 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Render.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Render.h @@ -104,7 +104,7 @@ while (0) void nxagentRenderExtensionInit(void); Bool nxagentPictureInit(ScreenPtr, PictFormatPtr, int); -int nxagentRenderRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor); +void nxagentRenderRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor); void nxagentAddGlyphs(GlyphSetPtr glyphSet, Glyph *gids, xGlyphInfo *gi, int nglyphs, CARD8 *images, int sizeImages); diff --git a/nx-X11/programs/Xserver/hw/nxagent/Window.c b/nx-X11/programs/Xserver/hw/nxagent/Window.c index 80e9bef3b0..e4046e8cb2 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Window.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Window.c @@ -2539,6 +2539,10 @@ void nxagentMapDefaultWindows(void) WindowPtr pWin = screenInfo.screens[i]->root; ScreenPtr pScreen = pWin -> drawable.pScreen; + /* + * InitRootWindow does that already, but as MapWindow() is + * idempotent we keep it here, too + */ MapWindow(pWin, serverClient); if (nxagentOption(Rootless) == 0) diff --git a/nx-X11/programs/Xserver/mi/miwindow.c b/nx-X11/programs/Xserver/mi/miwindow.c index c696caf26e..4e67987d63 100644 --- a/nx-X11/programs/Xserver/mi/miwindow.c +++ b/nx-X11/programs/Xserver/mi/miwindow.c @@ -1037,6 +1037,7 @@ miSetShape(pWin) (pWin, 0, 0, pOldClip, pWin->drawable.x, pWin->drawable.y); +#ifdef NXAGENT_SERVER /* * Applies to NXAGENT_SERVER builds: * @@ -1056,6 +1057,9 @@ miSetShape(pWin) */ if (WasViewable && pOldClip) +#else + if (WasViewable) +#endif RegionDestroy(pOldClip); if (bsExposed) { diff --git a/nx-X11/programs/Xserver/miext/damage/damage.c b/nx-X11/programs/Xserver/miext/damage/damage.c index 9c9161d36b..e9b4e947c3 100644 --- a/nx-X11/programs/Xserver/miext/damage/damage.c +++ b/nx-X11/programs/Xserver/miext/damage/damage.c @@ -1335,8 +1335,6 @@ damageDamageChars (DrawablePtr pDrawable, #define TT_POLY16 2 #define TT_IMAGE16 3 -#ifndef NXAGENT_SERVER - static int damageText (DrawablePtr pDrawable, GCPtr pGC, @@ -1371,12 +1369,14 @@ damageText (DrawablePtr pDrawable, if (n != 0) { damageDamageChars (pDrawable, pGC->font, x + pDrawable->x, y + pDrawable->y, n, charinfo, imageblt, pGC->subWindowMode); +#ifndef NXAGENT_SERVER if (imageblt) (*pGC->ops->ImageGlyphBlt)(pDrawable, pGC, x, y, n, charinfo, FONTGLYPHS(pGC->font)); else (*pGC->ops->PolyGlyphBlt)(pDrawable, pGC, x, y, n, charinfo, FONTGLYPHS(pGC->font)); +#endif } free(charinfo); return x + w; @@ -1458,8 +1458,6 @@ damageImageText16(DrawablePtr pDrawable, DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); } -#endif /* NXAGENT_SERVER */ - static void damageImageGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, diff --git a/nx-X11/programs/Xserver/render/picture.c b/nx-X11/programs/Xserver/render/picture.c index c06ac35509..1775a52379 100644 --- a/nx-X11/programs/Xserver/render/picture.c +++ b/nx-X11/programs/Xserver/render/picture.c @@ -989,9 +989,14 @@ static PicturePtr createSourcePicture(void) SetPictureToDefaults(pPicture); return pPicture; } +#endif PicturePtr +#ifdef NXAGENT_SERVER +xorg_CreateSolidPicture (Picture pid, xRenderColor *color, int *error) +#else CreateSolidPicture (Picture pid, xRenderColor *color, int *error) +#endif { PicturePtr pPicture; pPicture = createSourcePicture(); @@ -1011,11 +1016,15 @@ CreateSolidPicture (Picture pid, xRenderColor *color, int *error) pPicture->pSourcePict->solidFill.color = xRenderColorToCard32(*color); return pPicture; } -#endif PicturePtr +#ifdef NXAGENT_SERVER +xorg_CreateLinearGradientPicture (Picture pid, xPointFixed *p1, xPointFixed *p2, + int nStops, xFixed *stops, xRenderColor *colors, int *error) +#else CreateLinearGradientPicture (Picture pid, xPointFixed *p1, xPointFixed *p2, int nStops, xFixed *stops, xRenderColor *colors, int *error) +#endif { PicturePtr pPicture; @@ -1057,9 +1066,15 @@ CreateLinearGradientPicture (Picture pid, xPointFixed *p1, xPointFixed *p2, #define FixedToDouble(x) ((x)/65536.) PicturePtr +#ifdef NXAGENT_SERVER +xorg_CreateRadialGradientPicture (Picture pid, xPointFixed *inner, xPointFixed *outer, + xFixed innerRadius, xFixed outerRadius, + int nStops, xFixed *stops, xRenderColor *colors, int *error) +#else CreateRadialGradientPicture (Picture pid, xPointFixed *inner, xPointFixed *outer, xFixed innerRadius, xFixed outerRadius, int nStops, xFixed *stops, xRenderColor *colors, int *error) +#endif { PicturePtr pPicture; PictRadialGradient *radial; @@ -1118,8 +1133,13 @@ CreateRadialGradientPicture (Picture pid, xPointFixed *inner, xPointFixed *outer } PicturePtr +#ifdef NXAGENT_SERVER +xorg_CreateConicalGradientPicture (Picture pid, xPointFixed *center, xFixed angle, + int nStops, xFixed *stops, xRenderColor *colors, int *error) +#else CreateConicalGradientPicture (Picture pid, xPointFixed *center, xFixed angle, int nStops, xFixed *stops, xRenderColor *colors, int *error) +#endif { PicturePtr pPicture; diff --git a/nx-X11/programs/Xserver/render/render.c b/nx-X11/programs/Xserver/render/render.c index e4d8a3f763..97c142725c 100644 --- a/nx-X11/programs/Xserver/render/render.c +++ b/nx-X11/programs/Xserver/render/render.c @@ -1347,9 +1347,8 @@ ProcRenderCompositeGlyphs (ClientPtr client) listsBase = (GlyphListPtr) malloc (nlist * sizeof (GlyphListRec)); if (!listsBase) { - free(glyphsBase); - free(listsBase); - + if (glyphsBase != glyphsLocal) + free(glyphsBase); return BadAlloc; } } @@ -1417,8 +1416,13 @@ ProcRenderCompositeGlyphs (ClientPtr client) } } if (buffer > end) + { + if (glyphsBase != glyphsLocal) + free(glyphsBase); + if (listsBase != listsLocal) + free(listsBase); return BadLength; - + } CompositeGlyphs (stuff->op, pSrc, pDst, @@ -1910,7 +1914,6 @@ ProcRenderAddTraps (ClientPtr client) return client->noClientException; } -#ifndef NXAGENT_SERVER static int ProcRenderCreateSolidFill(ClientPtr client) { PicturePtr pPicture; @@ -2021,7 +2024,11 @@ static int ProcRenderCreateConicalGradient (ClientPtr client) static int +#ifdef NXAGENT_SERVER +xorg_ProcRenderDispatch (ClientPtr client) +#else ProcRenderDispatch (ClientPtr client) +#endif { REQUEST(xReq); @@ -2030,7 +2037,6 @@ ProcRenderDispatch (ClientPtr client) else return BadRequest; } -#endif /* NXAGENT_SERVER */ static int SProcRenderQueryVersion (ClientPtr client) @@ -2602,9 +2608,12 @@ SProcRenderCreateConicalGradient (ClientPtr client) return (*ProcRenderVector[stuff->renderReqType]) (client); } -#ifndef NXAGENT_SERVER static int +#ifdef NXAGENT_SERVER +xorg_SProcRenderDispatch (ClientPtr client) +#else SProcRenderDispatch (ClientPtr client) +#endif { REQUEST(xReq); @@ -2613,7 +2622,6 @@ SProcRenderDispatch (ClientPtr client) else return BadRequest; } -#endif /* NXAGENT_SERVER */ #ifdef PANORAMIX #include "panoramiX.h"