diff --git a/nx-X11/include/extensions/XI.h b/nx-X11/include/extensions/XI.h index a14c6746fc..8157be7250 100644 --- a/nx-X11/include/extensions/XI.h +++ b/nx-X11/include/extensions/XI.h @@ -135,6 +135,7 @@ SOFTWARE. #define XInput_Add_XDeviceBell 2 #define XInput_Add_XSetDeviceValuators 3 #define XInput_Add_XChangeDeviceControl 4 +#define XInput_Add_DevicePresenceNotify 5 #define XI_Absent 0 #define XI_Present 1 @@ -151,7 +152,14 @@ SOFTWARE. #define XI_Add_XChangeDeviceControl_Major 1 #define XI_Add_XChangeDeviceControl_Minor 3 +#define XI_Add_DevicePresenceNotify_Major 1 +#define XI_Add_DevicePresenceNotify_Minor 4 + #define DEVICE_RESOLUTION 1 +#define DEVICE_ABS_CALIB 2 +#define DEVICE_CORE 3 +#define DEVICE_ENABLE 4 +#define DEVICE_ABS_AREA 5 #define NoSuchExtension 1 @@ -169,6 +177,8 @@ SOFTWARE. #define IsXPointer 0 #define IsXKeyboard 1 #define IsXExtensionDevice 2 +#define IsXExtensionKeyboard 3 +#define IsXExtensionPointer 4 #define AsyncThisDevice 0 #define SyncThisDevice 1 @@ -202,12 +212,6 @@ SOFTWARE. #define DeviceMode (1L << 0) #define Relative 0 #define Absolute 1 -/* Merged from Metrolink tree for XINPUT stuff */ -#define TS_Raw 57 -#define TS_Scaled 58 -#define SendCoreEvents 59 -#define DontSendCoreEvents 60 -/* End of merged section */ #define ProximityState (1L << 1) #define InProximity (0L << 1) @@ -242,6 +246,14 @@ SOFTWARE. #define _deviceOwnerGrabButton 8 #define _noExtensionEvent 9 +#define _devicePresence 0 + +#define DeviceAdded 0 +#define DeviceRemoved 1 +#define DeviceEnabled 2 +#define DeviceDisabled 3 +#define DeviceUnrecoverable 4 + #define XI_BadDevice 0 #define XI_BadEvent 1 #define XI_BadMode 2 diff --git a/nx-X11/include/extensions/XIproto.h b/nx-X11/include/extensions/XIproto.h index c51480cd71..9cfaa3a3f8 100644 --- a/nx-X11/include/extensions/XIproto.h +++ b/nx-X11/include/extensions/XIproto.h @@ -70,7 +70,7 @@ SOFTWARE. #define numInputClasses 7 -#define IEVENTS 15 +#define IEVENTS 16 #define IERRORS 5 #define CLIENT_REQ 1 @@ -111,6 +111,7 @@ struct tmask #define XI_ChangeDeviceNotify 12 #define XI_DeviceKeystateNotify 13 #define XI_DeviceButtonstateNotify 14 +#define XI_DevicePresenceNotify 15 /********************************************************* * @@ -1288,6 +1289,46 @@ typedef struct { CARD32 num_valuators B32; /* number of valuators */ } xDeviceResolutionState; +typedef struct { + CARD16 control B16; + CARD16 length B16; + INT32 min_x B32; + INT32 max_x B32; + INT32 min_y B32; + INT32 max_y B32; + CARD32 flip_x B32; + CARD32 flip_y B32; + CARD32 rotation B32; + CARD32 button_threshold B32; +} xDeviceAbsCalibState; + +typedef struct { + CARD16 control B16; + CARD16 length B16; + CARD32 offset_x B32; + CARD32 offset_y B32; + CARD32 width B32; + CARD32 height B32; + CARD32 screen B32; + CARD32 following B32; +} xDeviceAbsAreaState; + +typedef struct { + CARD16 control B16; /* control type */ + CARD16 length B16; /* control length */ + CARD8 status; + CARD8 iscore; + CARD16 pad1 B16; +} xDeviceCoreState; + +typedef struct { + CARD16 control B16; /* control type */ + CARD16 length B16; /* control length */ + CARD8 enable; + CARD8 pad0; + CARD16 pad1 B16; +} xDeviceEnableState; + /********************************************************* * * ChangeDeviceControl. @@ -1330,21 +1371,45 @@ typedef struct { CARD8 pad1,pad2; } xDeviceResolutionCtl; - -/* Merged from Metrolink tree for XINPUT stuff */ - typedef struct { - CARD16 control; - CARD16 length; - CARD32 min_x; - CARD32 max_x; - CARD32 min_y; - CARD32 max_y; + CARD16 control B16; + CARD16 length B16; + INT32 min_x; + INT32 max_x; + INT32 min_y; + INT32 max_y; + CARD32 flip_x; + CARD32 flip_y; + CARD32 rotation; CARD32 button_threshold; -} xDeviceTSCalibrationCtl; +} xDeviceAbsCalibCtl; -/* End of merged section */ +typedef struct { + CARD16 control B16; + CARD16 length B16; + CARD32 offset_x; + CARD32 offset_y; + INT32 width; + INT32 height; + INT32 screen; + CARD32 following; +} xDeviceAbsAreaCtl; +typedef struct { + CARD16 control B16; + CARD16 length B16; + CARD8 status; + CARD8 pad0; + CARD16 pad1 B16; +} xDeviceCoreCtl; + +typedef struct { + CARD16 control B16; + CARD16 length B16; + CARD8 enable; + CARD8 pad0; + CARD16 pad1 B16; +} xDeviceEnableCtl; /********************************************************** * @@ -1521,6 +1586,28 @@ typedef struct CARD32 pad04 B32; } changeDeviceNotify; +/********************************************************** + * + * devicePresenceNotify. + * + */ + +typedef struct + { + BYTE type; + BYTE pad00; + CARD16 sequenceNumber B16; + Time time B32; + BYTE devchange; /* Device{Added|Removed|Enabled|Disabled} */ + BYTE deviceid; + CARD16 control B16; + CARD32 pad02 B32; + CARD32 pad03 B32; + CARD32 pad04 B32; + CARD32 pad05 B32; + CARD32 pad06 B32; + } devicePresenceNotify; + #undef Window #undef Time #undef KeyCode diff --git a/nx-X11/include/extensions/damageproto.h b/nx-X11/include/extensions/damageproto.h index 59157a35de..70048ad48c 100644 --- a/nx-X11/include/extensions/damageproto.h +++ b/nx-X11/include/extensions/damageproto.h @@ -1,7 +1,6 @@ /* - * $Id: damageproto.h,v 1.2 2004/07/29 19:29:55 stukreit Exp $ - * * Copyright © 2003 Keith Packard + * Copyright © 2007 Eric Anholt * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -115,6 +114,16 @@ typedef struct { #define sz_xDamageSubtractReq 16 +typedef struct { + CARD8 reqType; + CARD8 damageReqType; + CARD16 length B16; + Drawable drawable B32; + Region region B32; +} xDamageAddReq; + +#define sz_xDamageAddReq 12 + /* Events */ #define DamageNotifyMore 0x80 diff --git a/nx-X11/include/extensions/damagewire.h b/nx-X11/include/extensions/damagewire.h index d523cea982..d90a0dd7c4 100644 --- a/nx-X11/include/extensions/damagewire.h +++ b/nx-X11/include/extensions/damagewire.h @@ -1,6 +1,4 @@ /* - * $Id: damagewire.h,v 1.2 2004/07/29 19:29:55 stukreit Exp $ - * * Copyright © 2003 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its @@ -27,7 +25,7 @@ #define DAMAGE_NAME "DAMAGE" #define DAMAGE_MAJOR 1 -#define DAMAGE_MINOR 0 +#define DAMAGE_MINOR 1 /************* Version 1 ****************/ @@ -42,8 +40,9 @@ #define X_DamageCreate 1 #define X_DamageDestroy 2 #define X_DamageSubtract 3 +#define X_DamageAdd 4 -#define XDamageNumberRequests (X_DamageSubtract + 1) +#define XDamageNumberRequests (X_DamageAdd + 1) /* Events */ #define XDamageNotify 0 diff --git a/nx-X11/programs/Xserver/Imakefile b/nx-X11/programs/Xserver/Imakefile index bce802ec4c..184866b560 100644 --- a/nx-X11/programs/Xserver/Imakefile +++ b/nx-X11/programs/Xserver/Imakefile @@ -243,6 +243,7 @@ NXAGENTOBJS = hw/nxagent/miinitext.o \ hw/nxagent/NXglyph.o \ hw/nxagent/NXpicture.o \ hw/nxagent/NXglxext.o \ + hw/nxagent/NXmiglyph.o \ hw/nxagent/NXresource.o \ $(NULL) #elif !defined(Win32Architecture) @@ -258,6 +259,7 @@ NXAGENTOBJS = hw/nxagent/miinitext.o \ hw/nxagent/NXpicture.o \ hw/nxagent/NXglxext.o \ hw/nxagent/NXxvdisp.o \ + hw/nxagent/NXmiglyph.o \ hw/nxagent/NXresource.o \ $(NULL) #else @@ -273,6 +275,7 @@ NXAGENTOBJS = hw/nxagent/miinitext.o \ hw/nxagent/NXpicture.o \ hw/nxagent/NXglxext.o \ hw/nxagent/NXxvdisp.o \ + hw/nxagent/NXmiglyph.o \ hw/nxagent/NXresource.o \ dix/main.o \ $(NULL) diff --git a/nx-X11/programs/Xserver/Xext/security.c b/nx-X11/programs/Xserver/Xext/security.c index 2a7d5628f4..18df53af20 100644 --- a/nx-X11/programs/Xserver/Xext/security.c +++ b/nx-X11/programs/Xserver/Xext/security.c @@ -62,7 +62,7 @@ in this Software without prior written authorization from The Open Group. #include "colormapst.h" #include "propertyst.h" #include "protocol-versions.h" -#define _SECURITY_SERVER +#include "securitysrv.h" #include #include #include @@ -114,6 +114,23 @@ static char _NXPolicyFilePath[1024]; static int SecurityErrorBase; /* first Security error number */ static int SecurityEventBase; /* first Security event number */ +static int securityClientPrivateIndex; +static int securityExtnsnPrivateIndex; + +/* this is what we store as client security state */ +typedef struct { + unsigned int trustLevel; + XID authId; +} SecurityClientStateRec; + +#define STATEVAL(extnsn) \ + ((extnsn)->devPrivates[securityExtnsnPrivateIndex].val) +#define STATEPTR(client) \ + ((client)->devPrivates[securityClientPrivateIndex].ptr) +#define TRUSTLEVEL(client) \ + (((SecurityClientStateRec*)STATEPTR(client))->trustLevel) +#define AUTHID(client) \ + (((SecurityClientStateRec*)STATEPTR(client))->authId) CallbackListPtr SecurityValidateGroupCallback = NULL; /* see security.h */ @@ -2111,6 +2128,49 @@ XSecurityOptions(argc, argv, i) } /* XSecurityOptions */ +/* SecurityExtensionSetup + * + * Arguments: none. + * + * Returns: nothing. + * + * Side Effects: + * Sets up the Security extension if possible. + * This function contains things that need to be done + * before any other extension init functions get called. + */ + +void +SecurityExtensionSetup() +{ + /* Allocate the client private index */ + securityClientPrivateIndex = AllocateClientPrivateIndex(); + if (!AllocateClientPrivate(securityClientPrivateIndex, + sizeof (SecurityClientStateRec))) + FatalError("SecurityExtensionSetup: Can't allocate client private.\n"); + + /* Allocate the extension private index */ + securityExtnsnPrivateIndex = AllocateExtensionPrivateIndex(); + if (!AllocateExtensionPrivate(securityExtnsnPrivateIndex, 0)) + FatalError("SecurityExtensionSetup: Can't allocate extnsn private.\n"); + + /* register callbacks */ +/* + currently disabled because we are not using XACE yet. +#define XaceRC XaceRegisterCallback + XaceRC(XACE_RESOURCE_ACCESS, SecurityCheckResourceIDAccess, NULL); + XaceRC(XACE_DEVICE_ACCESS, SecurityCheckDeviceAccess, NULL); + XaceRC(XACE_PROPERTY_ACCESS, SecurityCheckPropertyAccess, NULL); + XaceRC(XACE_DRAWABLE_ACCESS, SecurityCheckDrawableAccess, NULL); + XaceRC(XACE_MAP_ACCESS, SecurityCheckMapAccess, NULL); + XaceRC(XACE_BACKGRND_ACCESS, SecurityCheckBackgrndAccess, NULL); + XaceRC(XACE_EXT_DISPATCH, SecurityCheckExtAccess, NULL); + XaceRC(XACE_EXT_ACCESS, SecurityCheckExtAccess, NULL); + XaceRC(XACE_HOSTLIST_ACCESS, SecurityCheckHostlistAccess, NULL); + XaceRC(XACE_DECLARE_EXT_SECURE, SecurityDeclareExtSecure, NULL); +*/ +} /* SecurityExtensionSetup */ + /* SecurityExtensionInit * diff --git a/nx-X11/programs/Xserver/Xext/securitysrv.h b/nx-X11/programs/Xserver/Xext/securitysrv.h new file mode 100644 index 0000000000..f31a8ab951 --- /dev/null +++ b/nx-X11/programs/Xserver/Xext/securitysrv.h @@ -0,0 +1,93 @@ +/* +Copyright 1996, 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. +*/ + +/* Xserver internals for Security extension - moved here from + _SECURITY_SERVER section of */ + +#ifndef _SECURITY_SRV_H +#define _SECURITY_SRV_H + +/* Allow client side portions of to compile */ +#ifndef Status +# define Status int +# define NEED_UNDEF_Status +#endif +#ifndef Display +# define Display void +# define NEED_UNDEF_Display +#endif + +#include + +#ifdef NEED_UNDEF_Status +# undef Status +# undef NEED_UNDEF_Status +#endif +#ifdef NEED_UNDEF_Display +# undef Display +# undef NEED_UNDEF_Display +#endif + + +#include "input.h" /* for DeviceIntPtr */ +#include "property.h" /* for PropertyPtr */ +#include "pixmap.h" /* for DrawablePtr */ +#include "resource.h" /* for RESTYPE */ + +/* resource type to pass in LookupIDByType for authorizations */ +extern RESTYPE SecurityAuthorizationResType; + +/* this is what we store for an authorization */ +typedef struct { + XID id; /* resource ID */ + CARD32 timeout; /* how long to live in seconds after refcnt == 0 */ + unsigned int trustLevel; /* trusted/untrusted */ + XID group; /* see embedding extension */ + unsigned int refcnt; /* how many clients connected with this auth */ + unsigned int secondsRemaining; /* overflow time amount for >49 days */ + OsTimerPtr timer; /* timer for this auth */ + struct _OtherClients *eventClients; /* clients wanting events */ +} SecurityAuthorizationRec, *SecurityAuthorizationPtr; + +typedef struct { + XID group; /* the group that was sent in GenerateAuthorization */ + Bool valid; /* did anyone recognize it? if so, set to TRUE */ +} SecurityValidateGroupInfoRec; + +extern int XSecurityOptions(int argc, char **argv, int i); + +/* Give this value or higher to the -audit option to get security messages */ +#define SECURITY_AUDIT_LEVEL 4 + +#define SecurityAllowOperation 0 +#define SecurityIgnoreOperation 1 +#define SecurityErrorOperation 2 + +#define SECURITY_POLICY_FILE_VERSION "version-1" + +extern char **SecurityGetSitePolicyStrings(int *n); + +#endif /* _SECURITY_SRV_H */ diff --git a/nx-X11/programs/Xserver/Xext/shm.c b/nx-X11/programs/Xserver/Xext/shm.c index 8680874627..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 diff --git a/nx-X11/programs/Xserver/Xi/allowev.c b/nx-X11/programs/Xserver/Xi/allowev.c index 76b2f60c5b..e6b3d3dd4a 100644 --- a/nx-X11/programs/Xserver/Xi/allowev.c +++ b/nx-X11/programs/Xserver/Xi/allowev.c @@ -74,7 +74,7 @@ SOFTWARE. */ int -SProcXAllowDeviceEvents(register ClientPtr client) +SProcXAllowDeviceEvents(ClientPtr client) { REQUEST(xAllowDeviceEventsReq); swaps(&stuff->length); @@ -90,7 +90,7 @@ SProcXAllowDeviceEvents(register ClientPtr client) */ int -ProcXAllowDeviceEvents(register ClientPtr client) +ProcXAllowDeviceEvents(ClientPtr client) { TimeStamp time; DeviceIntPtr thisdev; diff --git a/nx-X11/programs/Xserver/Xi/chgdctl.c b/nx-X11/programs/Xserver/Xi/chgdctl.c index 260dd0ec40..3e5bea8f6e 100644 --- a/nx-X11/programs/Xserver/Xi/chgdctl.c +++ b/nx-X11/programs/Xserver/Xi/chgdctl.c @@ -64,6 +64,7 @@ SOFTWARE. #include "extnsionst.h" #include "extinit.h" /* LookupDeviceIntRec */ #include "exglobals.h" +#include "exevents.h" #include "chgdctl.h" @@ -75,7 +76,7 @@ SOFTWARE. */ int -SProcXChangeDeviceControl(register ClientPtr client) +SProcXChangeDeviceControl(ClientPtr client) { REQUEST(xChangeDeviceControlReq); swaps(&stuff->length); @@ -94,12 +95,17 @@ int ProcXChangeDeviceControl(ClientPtr client) { unsigned len; - int i, status; + int i, status, ret = BadValue; DeviceIntPtr dev; xDeviceResolutionCtl *r; xChangeDeviceControlReply rep; AxisInfoPtr a; CARD32 *resolution; + xDeviceAbsCalibCtl *calib; + xDeviceAbsAreaCtl *area; + xDeviceCoreCtl *c; + xDeviceEnableCtl *e; + devicePresenceNotify dpn; REQUEST(xChangeDeviceControlReq); REQUEST_AT_LEAST_EXTRA_SIZE(xChangeDeviceControlReq, sizeof(xDeviceCtl)); @@ -107,9 +113,8 @@ ProcXChangeDeviceControl(ClientPtr client) len = stuff->length - (sizeof(xChangeDeviceControlReq) >> 2); dev = LookupDeviceIntRec(stuff->deviceid); if (dev == NULL) { - SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0, - BadDevice); - return Success; + ret = BadDevice; + goto out; } rep.repType = X_Reply; @@ -122,25 +127,22 @@ ProcXChangeDeviceControl(ClientPtr client) r = (xDeviceResolutionCtl *) & stuff[1]; if ((len < (sizeof(xDeviceResolutionCtl) >> 2)) || (len != (sizeof(xDeviceResolutionCtl) >> 2) + r->num_valuators)) { - SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, - 0, BadLength); - return Success; + ret = BadLength; + goto out; } if (!dev->valuator) { - SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0, - BadMatch); - return Success; + ret = BadMatch; + goto out; } if ((dev->grab) && !SameClient(dev->grab, client)) { rep.status = AlreadyGrabbed; - WriteReplyToClient(client, sizeof(xChangeDeviceControlReply), &rep); - return Success; + ret = Success; + goto out; } resolution = (CARD32 *) (r + 1); if (r->first_valuator + r->num_valuators > dev->valuator->numAxes) { - SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0, - BadValue); - return Success; + ret = BadValue; + goto out; } status = ChangeDeviceControl(client, dev, (xDeviceCtl *) r); if (status == Success) { @@ -154,21 +156,119 @@ ProcXChangeDeviceControl(ClientPtr client) } for (i = 0; i < r->num_valuators; i++) (a++)->resolution = *resolution++; + + ret = Success; } else if (status == DeviceBusy) { rep.status = DeviceBusy; - WriteReplyToClient(client, sizeof(xChangeDeviceControlReply), &rep); - return Success; + ret = Success; } else { - SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0, - BadMatch); - return Success; + ret = BadMatch; } break; + case DEVICE_ABS_CALIB: + calib = (xDeviceAbsCalibCtl *)&stuff[1]; + + if (calib->button_threshold < 0 || calib->button_threshold > 255) { + ret = BadValue; + goto out; + } + + status = ChangeDeviceControl(client, dev, (xDeviceCtl *) calib); + + if (status == Success) { + dev->absolute->min_x = calib->min_x; + dev->absolute->max_x = calib->max_x; + dev->absolute->min_y = calib->min_y; + dev->absolute->max_y = calib->max_y; + dev->absolute->flip_x = calib->flip_x; + dev->absolute->flip_y = calib->flip_y; + dev->absolute->rotation = calib->rotation; + dev->absolute->button_threshold = calib->button_threshold; + ret = Success; + } else if (status == DeviceBusy || status == BadValue) { + rep.status = status; + ret = Success; + } else { + ret = BadMatch; + } + + break; + case DEVICE_ABS_AREA: + area = (xDeviceAbsAreaCtl *)&stuff[1]; + + status = ChangeDeviceControl(client, dev, (xDeviceCtl *) area); + + if (status == Success) { + dev->absolute->offset_x = area->offset_x; + dev->absolute->offset_y = area->offset_y; + dev->absolute->width = area->width; + dev->absolute->height = area->height; + dev->absolute->screen = area->screen; + dev->absolute->following = area->following; + ret = Success; + } else if (status == DeviceBusy || status == BadValue) { + rep.status = status; + ret = Success; + } else { + ret = Success; + } + + break; + case DEVICE_CORE: + c = (xDeviceCoreCtl *)&stuff[1]; + + status = ChangeDeviceControl(client, dev, (xDeviceCtl *) c); + + if (status == Success) { + dev->coreEvents = c->status; + ret = Success; + } else if (status == DeviceBusy) { + rep.status = DeviceBusy; + ret = Success; + } else { + ret = BadMatch; + } + + break; + case DEVICE_ENABLE: + e = (xDeviceEnableCtl *)&stuff[1]; + + status = ChangeDeviceControl(client, dev, (xDeviceCtl *) e); + + if (status == Success) { + if (e->enable) + EnableDevice(dev); + else + DisableDevice(dev); + ret = Success; + } else if (status == DeviceBusy) { + rep.status = DeviceBusy; + ret = Success; + } else { + ret = BadMatch; + } + + break; default: - SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0, BadValue); - return Success; + ret = BadValue; } - WriteReplyToClient(client, sizeof(xChangeDeviceControlReply), &rep); + +out: + if (ret == Success) { + dpn.type = DevicePresenceNotify; + dpn.time = currentTime.milliseconds; + dpn.devchange = 1; + dpn.deviceid = dev->id; + dpn.control = stuff->control; + SendEventToAllWindows(dev, DevicePresenceNotifyMask, + (xEvent *) &dpn, 1); + + WriteReplyToClient(client, sizeof(xChangeDeviceControlReply), &rep); + } + else { + SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0, ret); + } + return Success; } diff --git a/nx-X11/programs/Xserver/Xi/chgfctl.c b/nx-X11/programs/Xserver/Xi/chgfctl.c index 00117fa6e8..81227b77fb 100644 --- a/nx-X11/programs/Xserver/Xi/chgfctl.c +++ b/nx-X11/programs/Xserver/Xi/chgfctl.c @@ -76,7 +76,7 @@ SOFTWARE. */ int -SProcXChangeFeedbackControl(register ClientPtr client) +SProcXChangeFeedbackControl(ClientPtr client) { REQUEST(xChangeFeedbackControlReq); swaps(&stuff->length); @@ -85,138 +85,13 @@ SProcXChangeFeedbackControl(register ClientPtr client) return (ProcXChangeFeedbackControl(client)); } -/*********************************************************************** - * - * Change the control attributes. - * - */ - -int -ProcXChangeFeedbackControl(ClientPtr client) -{ - unsigned len; - DeviceIntPtr dev; - KbdFeedbackPtr k; - PtrFeedbackPtr p; - IntegerFeedbackPtr i; - StringFeedbackPtr s; - BellFeedbackPtr b; - LedFeedbackPtr l; - - REQUEST(xChangeFeedbackControlReq); - REQUEST_AT_LEAST_SIZE(xChangeFeedbackControlReq); - - len = stuff->length - (sizeof(xChangeFeedbackControlReq) >> 2); - dev = LookupDeviceIntRec(stuff->deviceid); - if (dev == NULL) { - SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, - BadDevice); - return Success; - } - - switch (stuff->feedbackid) { - case KbdFeedbackClass: - if (len != (sizeof(xKbdFeedbackCtl) >> 2)) { - SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, - 0, BadLength); - return Success; - } - for (k = dev->kbdfeed; k; k = k->next) - if (k->ctrl.id == ((xKbdFeedbackCtl *) & stuff[1])->id) { - ChangeKbdFeedback(client, dev, stuff->mask, k, - (xKbdFeedbackCtl *) & stuff[1]); - return Success; - } - break; - case PtrFeedbackClass: - if (len != (sizeof(xPtrFeedbackCtl) >> 2)) { - SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, - 0, BadLength); - return Success; - } - for (p = dev->ptrfeed; p; p = p->next) - if (p->ctrl.id == ((xPtrFeedbackCtl *) & stuff[1])->id) { - ChangePtrFeedback(client, dev, stuff->mask, p, - (xPtrFeedbackCtl *) & stuff[1]); - return Success; - } - break; - case StringFeedbackClass: - { - xStringFeedbackCtl *f = ((xStringFeedbackCtl *) & stuff[1]); - if (client->swapped) - { - if (len < (sizeof(xStringFeedbackCtl) + 3) >> 2) - return BadLength; - swaps(&f->num_keysyms); - } - if (len != ((sizeof(xStringFeedbackCtl) >> 2) + f->num_keysyms)) { - SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, - 0, BadLength); - return Success; - } - for (s = dev->stringfeed; s; s = s->next) - if (s->ctrl.id == ((xStringFeedbackCtl *) & stuff[1])->id) { - ChangeStringFeedback(client, dev, stuff->mask, s, - (xStringFeedbackCtl *) & stuff[1]); - return Success; - } - break; - } - case IntegerFeedbackClass: - if (len != (sizeof(xIntegerFeedbackCtl) >> 2)) { - SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, - 0, BadLength); - return Success; - } - for (i = dev->intfeed; i; i = i->next) - if (i->ctrl.id == ((xIntegerFeedbackCtl *) & stuff[1])->id) { - ChangeIntegerFeedback(client, dev, stuff->mask, i, - (xIntegerFeedbackCtl *) & stuff[1]); - return Success; - } - break; - case LedFeedbackClass: - if (len != (sizeof(xLedFeedbackCtl) >> 2)) { - SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, - 0, BadLength); - return Success; - } - for (l = dev->leds; l; l = l->next) - if (l->ctrl.id == ((xLedFeedbackCtl *) & stuff[1])->id) { - ChangeLedFeedback(client, dev, stuff->mask, l, - (xLedFeedbackCtl *) & stuff[1]); - return Success; - } - break; - case BellFeedbackClass: - if (len != (sizeof(xBellFeedbackCtl) >> 2)) { - SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, - 0, BadLength); - return Success; - } - for (b = dev->bell; b; b = b->next) - if (b->ctrl.id == ((xBellFeedbackCtl *) & stuff[1])->id) { - ChangeBellFeedback(client, dev, stuff->mask, b, - (xBellFeedbackCtl *) & stuff[1]); - return Success; - } - break; - default: - break; - } - - SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, BadMatch); - return Success; -} - /****************************************************************************** * * This procedure changes KbdFeedbackClass data. * */ -int +static int ChangeKbdFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, KbdFeedbackPtr k, xKbdFeedbackCtl * f) { @@ -347,7 +222,7 @@ ChangeKbdFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, * */ -int +static int ChangePtrFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, PtrFeedbackPtr p, xPtrFeedbackCtl * f) { @@ -417,7 +292,7 @@ ChangePtrFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, * */ -int +static int ChangeIntegerFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, IntegerFeedbackPtr i, xIntegerFeedbackCtl * f) @@ -438,7 +313,7 @@ ChangeIntegerFeedback(ClientPtr client, DeviceIntPtr dev, * */ -int +static int ChangeStringFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, StringFeedbackPtr s, xStringFeedbackCtl * f) @@ -482,7 +357,7 @@ ChangeStringFeedback(ClientPtr client, DeviceIntPtr dev, * */ -int +static int ChangeBellFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, BellFeedbackPtr b, xBellFeedbackCtl * f) @@ -546,7 +421,7 @@ ChangeBellFeedback(ClientPtr client, DeviceIntPtr dev, * */ -int +static int ChangeLedFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, LedFeedbackPtr l, xLedFeedbackCtl * f) { @@ -570,3 +445,127 @@ ChangeLedFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, return Success; } + +/*********************************************************************** + * + * Change the control attributes. + * + */ + +int +ProcXChangeFeedbackControl(ClientPtr client) +{ + unsigned len; + DeviceIntPtr dev; + KbdFeedbackPtr k; + PtrFeedbackPtr p; + IntegerFeedbackPtr i; + StringFeedbackPtr s; + BellFeedbackPtr b; + LedFeedbackPtr l; + + REQUEST(xChangeFeedbackControlReq); + REQUEST_AT_LEAST_SIZE(xChangeFeedbackControlReq); + + len = stuff->length - (sizeof(xChangeFeedbackControlReq) >> 2); + dev = LookupDeviceIntRec(stuff->deviceid); + if (dev == NULL) { + SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, + BadDevice); + return Success; + } + + switch (stuff->feedbackid) { + case KbdFeedbackClass: + if (len != (sizeof(xKbdFeedbackCtl) >> 2)) { + SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, + 0, BadLength); + return Success; + } + for (k = dev->kbdfeed; k; k = k->next) + if (k->ctrl.id == ((xKbdFeedbackCtl *) & stuff[1])->id) { + ChangeKbdFeedback(client, dev, stuff->mask, k, + (xKbdFeedbackCtl *) & stuff[1]); + return Success; + } + break; + case PtrFeedbackClass: + if (len != (sizeof(xPtrFeedbackCtl) >> 2)) { + SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, + 0, BadLength); + return Success; + } + for (p = dev->ptrfeed; p; p = p->next) + if (p->ctrl.id == ((xPtrFeedbackCtl *) & stuff[1])->id) { + ChangePtrFeedback(client, dev, stuff->mask, p, + (xPtrFeedbackCtl *) & stuff[1]); + return Success; + } + break; + case StringFeedbackClass: + { + xStringFeedbackCtl *f = ((xStringFeedbackCtl *) & stuff[1]); + + if (client->swapped) { + swaps(&f->num_keysyms); + } + if (len != ((sizeof(xStringFeedbackCtl) >> 2) + f->num_keysyms)) { + SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, + 0, BadLength); + return Success; + } + for (s = dev->stringfeed; s; s = s->next) + if (s->ctrl.id == ((xStringFeedbackCtl *) & stuff[1])->id) { + ChangeStringFeedback(client, dev, stuff->mask, s, + (xStringFeedbackCtl *) & stuff[1]); + return Success; + } + break; + } + case IntegerFeedbackClass: + if (len != (sizeof(xIntegerFeedbackCtl) >> 2)) { + SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, + 0, BadLength); + return Success; + } + for (i = dev->intfeed; i; i = i->next) + if (i->ctrl.id == ((xIntegerFeedbackCtl *) & stuff[1])->id) { + ChangeIntegerFeedback(client, dev, stuff->mask, i, + (xIntegerFeedbackCtl *) & stuff[1]); + return Success; + } + break; + case LedFeedbackClass: + if (len != (sizeof(xLedFeedbackCtl) >> 2)) { + SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, + 0, BadLength); + return Success; + } + for (l = dev->leds; l; l = l->next) + if (l->ctrl.id == ((xLedFeedbackCtl *) & stuff[1])->id) { + ChangeLedFeedback(client, dev, stuff->mask, l, + (xLedFeedbackCtl *) & stuff[1]); + return Success; + } + break; + case BellFeedbackClass: + if (len != (sizeof(xBellFeedbackCtl) >> 2)) { + SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, + 0, BadLength); + return Success; + } + for (b = dev->bell; b; b = b->next) + if (b->ctrl.id == ((xBellFeedbackCtl *) & stuff[1])->id) { + ChangeBellFeedback(client, dev, stuff->mask, b, + (xBellFeedbackCtl *) & stuff[1]); + return Success; + } + break; + default: + break; + } + + SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, BadMatch); + return Success; +} + diff --git a/nx-X11/programs/Xserver/Xi/chgfctl.h b/nx-X11/programs/Xserver/Xi/chgfctl.h index 81e1153ec2..cfa9fc6b0a 100644 --- a/nx-X11/programs/Xserver/Xi/chgfctl.h +++ b/nx-X11/programs/Xserver/Xi/chgfctl.h @@ -36,46 +36,4 @@ int SProcXChangeFeedbackControl(ClientPtr /* client */ int ProcXChangeFeedbackControl(ClientPtr /* client */ ); -int ChangeKbdFeedback(ClientPtr /* client */ , - DeviceIntPtr /* dev */ , - unsigned long /* mask */ , - KbdFeedbackPtr /* k */ , - xKbdFeedbackCtl * /* f */ - ); - -int ChangePtrFeedback(ClientPtr /* client */ , - DeviceIntPtr /* dev */ , - unsigned long /* mask */ , - PtrFeedbackPtr /* p */ , - xPtrFeedbackCtl * /* f */ - ); - -int ChangeIntegerFeedback(ClientPtr /* client */ , - DeviceIntPtr /* dev */ , - unsigned long /* mask */ , - IntegerFeedbackPtr /* i */ , - xIntegerFeedbackCtl * /* f */ - ); - -int ChangeStringFeedback(ClientPtr /* client */ , - DeviceIntPtr /* dev */ , - unsigned long /* mask */ , - StringFeedbackPtr /* s */ , - xStringFeedbackCtl * /* f */ - ); - -int ChangeBellFeedback(ClientPtr /* client */ , - DeviceIntPtr /* dev */ , - unsigned long /* mask */ , - BellFeedbackPtr /* b */ , - xBellFeedbackCtl * /* f */ - ); - -int ChangeLedFeedback(ClientPtr /* client */ , - DeviceIntPtr /* dev */ , - unsigned long /* mask */ , - LedFeedbackPtr /* l */ , - xLedFeedbackCtl * /* f */ - ); - #endif /* CHGFCTL_H */ diff --git a/nx-X11/programs/Xserver/Xi/chgkbd.c b/nx-X11/programs/Xserver/Xi/chgkbd.c index 2ca631e2d8..ec36ae65c7 100644 --- a/nx-X11/programs/Xserver/Xi/chgkbd.c +++ b/nx-X11/programs/Xserver/Xi/chgkbd.c @@ -77,7 +77,7 @@ SOFTWARE. */ int -SProcXChangeKeyboardDevice(register ClientPtr client) +SProcXChangeKeyboardDevice(ClientPtr client) { REQUEST(xChangeKeyboardDeviceReq); swaps(&stuff->length); @@ -93,105 +93,12 @@ SProcXChangeKeyboardDevice(register ClientPtr client) */ int -ProcXChangeKeyboardDevice(register ClientPtr client) +ProcXChangeKeyboardDevice(ClientPtr client) { - int i; - DeviceIntPtr xkbd = inputInfo.keyboard; - DeviceIntPtr dev; - FocusClassPtr xf = xkbd->focus; - FocusClassPtr df; - KeyClassPtr k; - xChangeKeyboardDeviceReply rep; - changeDeviceNotify ev; - - REQUEST(xChangeKeyboardDeviceReq); + /*REQUEST(xChangeKeyboardDeviceReq);*/ REQUEST_SIZE_MATCH(xChangeKeyboardDeviceReq); - rep.repType = X_Reply; - rep.RepType = X_ChangeKeyboardDevice; - rep.length = 0; - rep.sequenceNumber = client->sequence; - - dev = LookupDeviceIntRec(stuff->deviceid); - if (dev == NULL) { - rep.status = -1; - SendErrorToClient(client, IReqCode, X_ChangeKeyboardDevice, 0, - BadDevice); - return Success; - } - - k = dev->key; - if (k == NULL) { - rep.status = -1; - SendErrorToClient(client, IReqCode, X_ChangeKeyboardDevice, 0, - BadMatch); - return Success; - } - - if (((dev->grab) && !SameClient(dev->grab, client)) || - ((xkbd->grab) && !SameClient(xkbd->grab, client))) - rep.status = AlreadyGrabbed; - else if ((dev->sync.frozen && - dev->sync.other && !SameClient(dev->sync.other, client)) || - (xkbd->sync.frozen && - xkbd->sync.other && !SameClient(xkbd->sync.other, client))) - rep.status = GrabFrozen; - else { - if (ChangeKeyboardDevice(xkbd, dev) != Success) { - SendErrorToClient(client, IReqCode, X_ChangeKeyboardDevice, 0, - BadDevice); - return Success; - } - if (!dev->focus) - InitFocusClassDeviceStruct(dev); - if (!dev->kbdfeed) - InitKbdFeedbackClassDeviceStruct(dev, (BellProcPtr) NoopDDA, - (KbdCtrlProcPtr) NoopDDA); - df = dev->focus; - df->win = xf->win; - df->revert = xf->revert; - df->time = xf->time; - df->traceGood = xf->traceGood; - if (df->traceSize != xf->traceSize) { - df->trace = (WindowPtr *) realloc(df->trace, - xf->traceSize * - sizeof(WindowPtr)); - } - df->traceSize = xf->traceSize; - for (i = 0; i < df->traceSize; i++) - df->trace[i] = xf->trace[i]; - RegisterOtherDevice(xkbd); - RegisterKeyboardDevice(dev); - - ev.type = ChangeDeviceNotify; - ev.deviceid = stuff->deviceid; - ev.time = currentTime.milliseconds; - ev.request = NewKeyboard; - - SendEventToAllWindows(dev, ChangeDeviceNotifyMask, (xEvent *) & ev, 1); - SendMappingNotify(MappingKeyboard, k->curKeySyms.minKeyCode, - k->curKeySyms.maxKeyCode - k->curKeySyms.minKeyCode + - 1, client); - - rep.status = 0; - } - - WriteReplyToClient(client, sizeof(xChangeKeyboardDeviceReply), &rep); + SendErrorToClient(client, IReqCode, X_ChangeKeyboardDevice, 0, + BadDevice); return Success; } - -/*********************************************************************** - * - * This procedure writes the reply for the XChangeKeyboardDevice - * function, if the client and server have a different byte ordering. - * - */ - -void -SRepXChangeKeyboardDevice(ClientPtr client, int size, - xChangeKeyboardDeviceReply * rep) -{ - swaps(&rep->sequenceNumber); - swapl(&rep->length); - WriteToClient(client, size, rep); -} diff --git a/nx-X11/programs/Xserver/Xi/chgkbd.h b/nx-X11/programs/Xserver/Xi/chgkbd.h index 7a883b7f0c..5f9922336e 100644 --- a/nx-X11/programs/Xserver/Xi/chgkbd.h +++ b/nx-X11/programs/Xserver/Xi/chgkbd.h @@ -36,9 +36,4 @@ int SProcXChangeKeyboardDevice(ClientPtr /* client */ int ProcXChangeKeyboardDevice(ClientPtr /* client */ ); -void SRepXChangeKeyboardDevice(ClientPtr /* client */ , - int /* size */ , - xChangeKeyboardDeviceReply * /* rep */ - ); - #endif /* CHGKBD_H */ diff --git a/nx-X11/programs/Xserver/Xi/chgkmap.c b/nx-X11/programs/Xserver/Xi/chgkmap.c index f8bad95569..d212314957 100644 --- a/nx-X11/programs/Xserver/Xi/chgkmap.c +++ b/nx-X11/programs/Xserver/Xi/chgkmap.c @@ -74,7 +74,7 @@ SOFTWARE. */ int -SProcXChangeDeviceKeyMapping(register ClientPtr client) +SProcXChangeDeviceKeyMapping(ClientPtr client) { unsigned int count; @@ -94,7 +94,7 @@ SProcXChangeDeviceKeyMapping(register ClientPtr client) */ int -ProcXChangeDeviceKeyMapping(register ClientPtr client) +ProcXChangeDeviceKeyMapping(ClientPtr client) { int ret; unsigned len; @@ -106,7 +106,6 @@ ProcXChangeDeviceKeyMapping(register ClientPtr client) count = stuff->keyCodes * stuff->keySymsPerKeyCode; REQUEST_FIXED_SIZE(xChangeDeviceKeyMappingReq, count * sizeof(CARD32)); - dev = LookupDeviceIntRec(stuff->deviceid); if (dev == NULL) { SendErrorToClient(client, IReqCode, X_ChangeDeviceKeyMapping, 0, diff --git a/nx-X11/programs/Xserver/Xi/chgprop.c b/nx-X11/programs/Xserver/Xi/chgprop.c index 6ee00a0915..0e29b5b379 100644 --- a/nx-X11/programs/Xserver/Xi/chgprop.c +++ b/nx-X11/programs/Xserver/Xi/chgprop.c @@ -76,7 +76,7 @@ SOFTWARE. */ int -SProcXChangeDeviceDontPropagateList(register ClientPtr client) +SProcXChangeDeviceDontPropagateList(ClientPtr client) { REQUEST(xChangeDeviceDontPropagateListReq); swaps(&stuff->length); @@ -96,7 +96,7 @@ SProcXChangeDeviceDontPropagateList(register ClientPtr client) */ int -ProcXChangeDeviceDontPropagateList(register ClientPtr client) +ProcXChangeDeviceDontPropagateList(ClientPtr client) { int i; WindowPtr pWin; diff --git a/nx-X11/programs/Xserver/Xi/chgptr.c b/nx-X11/programs/Xserver/Xi/chgptr.c index 76cd1e0717..597bc2bcdf 100644 --- a/nx-X11/programs/Xserver/Xi/chgptr.c +++ b/nx-X11/programs/Xserver/Xi/chgptr.c @@ -80,7 +80,7 @@ SOFTWARE. */ int -SProcXChangePointerDevice(register ClientPtr client) +SProcXChangePointerDevice(ClientPtr client) { REQUEST(xChangePointerDeviceReq); swaps(&stuff->length); @@ -95,138 +95,12 @@ SProcXChangePointerDevice(register ClientPtr client) */ int -ProcXChangePointerDevice(register ClientPtr client) +ProcXChangePointerDevice(ClientPtr client) { - DeviceIntPtr xptr = inputInfo.pointer; - DeviceIntPtr dev; - ValuatorClassPtr v; - xChangePointerDeviceReply rep; - changeDeviceNotify ev; - - REQUEST(xChangePointerDeviceReq); + /*REQUEST(xChangePointerDeviceReq);*/ REQUEST_SIZE_MATCH(xChangePointerDeviceReq); - rep.repType = X_Reply; - rep.RepType = X_ChangePointerDevice; - rep.length = 0; - rep.sequenceNumber = client->sequence; - - dev = LookupDeviceIntRec(stuff->deviceid); - if (dev == NULL) { - rep.status = -1; - SendErrorToClient(client, IReqCode, X_ChangePointerDevice, 0, - BadDevice); - return Success; - } - - v = dev->valuator; - if (v == NULL || v->numAxes < 2 || - stuff->xaxis >= v->numAxes || stuff->yaxis >= v->numAxes) { - rep.status = -1; - SendErrorToClient(client, IReqCode, X_ChangePointerDevice, 0, BadMatch); - return Success; - } - - if (((dev->grab) && !SameClient(dev->grab, client)) || - ((xptr->grab) && !SameClient(xptr->grab, client))) - rep.status = AlreadyGrabbed; - else if ((dev->sync.frozen && - dev->sync.other && !SameClient(dev->sync.other, client)) || - (xptr->sync.frozen && - xptr->sync.other && !SameClient(xptr->sync.other, client))) - rep.status = GrabFrozen; - else { - if (ChangePointerDevice(xptr, dev, stuff->xaxis, stuff->yaxis) != - Success) { - SendErrorToClient(client, IReqCode, X_ChangePointerDevice, 0, - BadDevice); - return Success; - } - if (dev->focus) - DeleteFocusClassDeviceStruct(dev); - if (!dev->button) - InitButtonClassDeviceStruct(dev, 0, NULL); - if (!dev->ptrfeed) - InitPtrFeedbackClassDeviceStruct(dev, (PtrCtrlProcPtr) NoopDDA); - RegisterOtherDevice(xptr); - RegisterPointerDevice(dev); - - ev.type = ChangeDeviceNotify; - ev.deviceid = stuff->deviceid; - ev.time = currentTime.milliseconds; - ev.request = NewPointer; - - SendEventToAllWindows(dev, ChangeDeviceNotifyMask, (xEvent *) & ev, 1); - SendMappingNotify(MappingPointer, 0, 0, client); - - rep.status = 0; - } - - WriteReplyToClient(client, sizeof(xChangePointerDeviceReply), &rep); + SendErrorToClient(client, IReqCode, X_ChangePointerDevice, 0, + BadDevice); return Success; } - -void -DeleteFocusClassDeviceStruct(DeviceIntPtr dev) -{ - free(dev->focus->trace); - free(dev->focus); - dev->focus = NULL; -} - -/*********************************************************************** - * - * Send an event to interested clients in all windows on all screens. - * - */ - -void -SendEventToAllWindows(DeviceIntPtr dev, Mask mask, xEvent * ev, int count) -{ - int i; - WindowPtr pWin, p1; - - for (i = 0; i < screenInfo.numScreens; i++) { - pWin = screenInfo.screens[i]->root; - (void)DeliverEventsToWindow(pWin, ev, count, mask, NullGrab, dev->id); - p1 = pWin->firstChild; - FindInterestedChildren(dev, p1, mask, ev, count); - } -} - -/*********************************************************************** - * - * Walk through the window tree, finding all clients that want to know - * about the ChangeDeviceNotify Event. - * - */ - -void -FindInterestedChildren(DeviceIntPtr dev, WindowPtr p1, Mask mask, - xEvent * ev, int count) -{ - WindowPtr p2; - - while (p1) { - p2 = p1->firstChild; - (void)DeliverEventsToWindow(p1, ev, count, mask, NullGrab, dev->id); - FindInterestedChildren(dev, p2, mask, ev, count); - p1 = p1->nextSib; - } -} - -/*********************************************************************** - * - * This procedure writes the reply for the XChangePointerDevice - * function, if the client and server have a different byte ordering. - * - */ - -void -SRepXChangePointerDevice(ClientPtr client, int size, - xChangePointerDeviceReply * rep) -{ - swaps(&rep->sequenceNumber); - swapl(&rep->length); - WriteToClient(client, size, rep); -} diff --git a/nx-X11/programs/Xserver/Xi/chgptr.h b/nx-X11/programs/Xserver/Xi/chgptr.h index aeda822aa7..2d8ab66e50 100644 --- a/nx-X11/programs/Xserver/Xi/chgptr.h +++ b/nx-X11/programs/Xserver/Xi/chgptr.h @@ -45,17 +45,4 @@ void SendEventToAllWindows(DeviceIntPtr /* dev */ , int /* count */ ); -void FindInterestedChildren( /* FIXME: could be static? */ - DeviceIntPtr /* dev */ , - WindowPtr /* p1 */ , - Mask /* mask */ , - xEvent * /* ev */ , - int /* count */ - ); - -void SRepXChangePointerDevice(ClientPtr /* client */ , - int /* size */ , - xChangePointerDeviceReply * /* rep */ - ); - #endif /* CHGPTR_H */ diff --git a/nx-X11/programs/Xserver/Xi/closedev.c b/nx-X11/programs/Xserver/Xi/closedev.c index 21180cdc7e..2e956217dd 100644 --- a/nx-X11/programs/Xserver/Xi/closedev.c +++ b/nx-X11/programs/Xserver/Xi/closedev.c @@ -75,7 +75,7 @@ SOFTWARE. */ int -SProcXCloseDevice(register ClientPtr client) +SProcXCloseDevice(ClientPtr client) { REQUEST(xCloseDeviceReq); swaps(&stuff->length); @@ -85,42 +85,29 @@ SProcXCloseDevice(register ClientPtr client) /*********************************************************************** * - * This procedure closes an input device. + * Clear out event selections and passive grabs from a window for the + * specified device. * */ -int -ProcXCloseDevice(register ClientPtr client) +static void +DeleteDeviceEvents(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client) { - int i; - WindowPtr pWin, p1; - DeviceIntPtr d; - - REQUEST(xCloseDeviceReq); - REQUEST_SIZE_MATCH(xCloseDeviceReq); - - d = LookupDeviceIntRec(stuff->deviceid); - if (d == NULL) { - SendErrorToClient(client, IReqCode, X_CloseDevice, 0, BadDevice); - return Success; - } - - if (d->grab && SameClient(d->grab, client)) - (*d->DeactivateGrab) (d); /* release active grab */ + InputClientsPtr others; + OtherInputMasks *pOthers; + GrabPtr grab, next; - /* Remove event selections from all windows for events from this device - * and selected by this client. - * Delete passive grabs from all windows for this device. */ + if ((pOthers = wOtherInputMasks(pWin)) != 0) + for (others = pOthers->inputClients; others; others = others->next) + if (SameClient(others, client)) + others->mask[dev->id] = NoEventMask; - for (i = 0; i < screenInfo.numScreens; i++) { - pWin = screenInfo.screens[i]->root; - DeleteDeviceEvents(d, pWin, client); - p1 = pWin->firstChild; - DeleteEventsFromChildren(d, p1, client); + for (grab = wPassiveGrabs(pWin); grab; grab = next) { + next = grab->next; + if ((grab->device == dev) && + (client->clientAsMask == CLIENT_BITS(grab->resource))) + FreeResource(grab->resource, RT_NONE); } - - CloseInputDevice(d, client); - return Success; } /*********************************************************************** @@ -130,7 +117,7 @@ ProcXCloseDevice(register ClientPtr client) * */ -void +static void DeleteEventsFromChildren(DeviceIntPtr dev, WindowPtr p1, ClientPtr client) { WindowPtr p2; @@ -145,27 +132,40 @@ DeleteEventsFromChildren(DeviceIntPtr dev, WindowPtr p1, ClientPtr client) /*********************************************************************** * - * Clear out event selections and passive grabs from a window for the - * specified device. + * This procedure closes an input device. * */ -void -DeleteDeviceEvents(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client) +int +ProcXCloseDevice(ClientPtr client) { - InputClientsPtr others; - OtherInputMasks *pOthers; - GrabPtr grab, next; + int i; + WindowPtr pWin, p1; + DeviceIntPtr d; - if ((pOthers = wOtherInputMasks(pWin)) != 0) - for (others = pOthers->inputClients; others; others = others->next) - if (SameClient(others, client)) - others->mask[dev->id] = NoEventMask; + REQUEST(xCloseDeviceReq); + REQUEST_SIZE_MATCH(xCloseDeviceReq); - for (grab = wPassiveGrabs(pWin); grab; grab = next) { - next = grab->next; - if ((grab->device == dev) && - (client->clientAsMask == CLIENT_BITS(grab->resource))) - FreeResource(grab->resource, RT_NONE); + d = LookupDeviceIntRec(stuff->deviceid); + if (d == NULL) { + SendErrorToClient(client, IReqCode, X_CloseDevice, 0, BadDevice); + return Success; } + + if (d->grab && SameClient(d->grab, client)) + (*d->DeactivateGrab) (d); /* release active grab */ + + /* Remove event selections from all windows for events from this device + * and selected by this client. + * Delete passive grabs from all windows for this device. */ + + for (i = 0; i < screenInfo.numScreens; i++) { + pWin = screenInfo.screens[i]->root; + DeleteDeviceEvents(d, pWin, client); + p1 = pWin->firstChild; + DeleteEventsFromChildren(d, p1, client); + } + + CloseInputDevice(d, client); + return Success; } diff --git a/nx-X11/programs/Xserver/Xi/closedev.h b/nx-X11/programs/Xserver/Xi/closedev.h index 6853d50029..400aaa60b0 100644 --- a/nx-X11/programs/Xserver/Xi/closedev.h +++ b/nx-X11/programs/Xserver/Xi/closedev.h @@ -36,14 +36,4 @@ int SProcXCloseDevice(ClientPtr /* client */ int ProcXCloseDevice(ClientPtr /* client */ ); -void DeleteEventsFromChildren(DeviceIntPtr /* dev */ , - WindowPtr /* p1 */ , - ClientPtr /* client */ - ); - -void DeleteDeviceEvents(DeviceIntPtr /* dev */ , - WindowPtr /* pWin */ , - ClientPtr /* client */ - ); - #endif /* CLOSEDEV_H */ diff --git a/nx-X11/programs/Xserver/Xi/devbell.c b/nx-X11/programs/Xserver/Xi/devbell.c index 22fe5cbee7..cfe77798cd 100644 --- a/nx-X11/programs/Xserver/Xi/devbell.c +++ b/nx-X11/programs/Xserver/Xi/devbell.c @@ -73,7 +73,7 @@ SOFTWARE. */ int -SProcXDeviceBell(register ClientPtr client) +SProcXDeviceBell(ClientPtr client) { REQUEST(xDeviceBellReq); swaps(&stuff->length); @@ -87,7 +87,7 @@ SProcXDeviceBell(register ClientPtr client) */ int -ProcXDeviceBell(register ClientPtr client) +ProcXDeviceBell(ClientPtr client) { DeviceIntPtr dev; KbdFeedbackPtr k; diff --git a/nx-X11/programs/Xserver/Xi/exevents.c b/nx-X11/programs/Xserver/Xi/exevents.c index 428e577f75..9d33059a2a 100644 --- a/nx-X11/programs/Xserver/Xi/exevents.c +++ b/nx-X11/programs/Xserver/Xi/exevents.c @@ -70,8 +70,11 @@ SOFTWARE. #include "exglobals.h" #include "dixevents.h" /* DeliverFocusedEvent */ #include "dixgrabs.h" /* CreateGrab() */ +#include "scrnintstr.h" -#include "chgptr.h" +#ifdef XKB +#include "xkbsrv.h" +#endif #define WID(w) ((w) ? ((w)->drawable.id) : 0) #define AllModifiersMask ( \ @@ -104,12 +107,12 @@ RegisterOtherDevice(DeviceIntPtr device) } /*ARGSUSED*/ void -ProcessOtherEvent(xEventPtr xE, register DeviceIntPtr other, int count) +ProcessOtherEvent(xEventPtr xE, DeviceIntPtr other, int count) { - register BYTE *kptr; - register int i; - register CARD16 modifiers; - register CARD16 mask; + BYTE *kptr; + int i; + CARD16 modifiers; + CARD16 mask; GrabPtr grab = other->grab; Bool deactivateDeviceGrab = FALSE; int key = 0, bit = 0, rootX, rootY; @@ -119,9 +122,14 @@ ProcessOtherEvent(xEventPtr xE, register DeviceIntPtr other, int count) deviceValuator *xV = (deviceValuator *) xE; if (xE->u.u.type != DeviceValuator) { - GetSpritePosition(&rootX, &rootY); - xE->u.keyButtonPointer.rootX = rootX; - xE->u.keyButtonPointer.rootY = rootY; + /* Other types already have root{X,Y} filled in. */ + if (xE->u.u.type == DeviceKeyPress || + xE->u.u.type == DeviceKeyRelease) { + GetSpritePosition(&rootX, &rootY); + xE->u.keyButtonPointer.rootX = rootX; + xE->u.keyButtonPointer.rootY = rootY; + } + key = xE->u.u.detail; NoticeEventTime(xE); xE->u.keyButtonPointer.state = inputInfo.keyboard->key->state | @@ -240,7 +248,7 @@ ProcessOtherEvent(xEventPtr xE, register DeviceIntPtr other, int count) other->valuator->motionHintWindow = NullWindow; b->buttonsDown++; b->motionMask = DeviceButtonMotionMask; - xE->u.u.detail = b->map[key]; + xE->u.u.detail = key; if (xE->u.u.detail == 0) return; if (xE->u.u.detail <= 5) @@ -248,7 +256,9 @@ ProcessOtherEvent(xEventPtr xE, register DeviceIntPtr other, int count) SetMaskForEvent(Motion_Filter(b), DeviceMotionNotify); if (!grab) if (CheckDeviceGrabs(other, xE, 0, count)) - return; + /* if a passive grab was activated, the event has been sent + * already */ + return; } else if (xE->u.u.type == DeviceButtonRelease) { if (!b) @@ -258,9 +268,9 @@ ProcessOtherEvent(xEventPtr xE, register DeviceIntPtr other, int count) *kptr &= ~bit; if (other->valuator) other->valuator->motionHintWindow = NullWindow; - if (!--b->buttonsDown) + if (b->buttonsDown >= 1 && !--b->buttonsDown) b->motionMask = 0; - xE->u.u.detail = b->map[key]; + xE->u.u.detail = key; if (xE->u.u.detail == 0) return; if (xE->u.u.detail <= 5) @@ -288,7 +298,7 @@ ProcessOtherEvent(xEventPtr xE, register DeviceIntPtr other, int count) int InitProximityClassDeviceStruct(DeviceIntPtr dev) { - register ProximityClassPtr proxc; + ProximityClassPtr proxc; proxc = (ProximityClassPtr) malloc(sizeof(ProximityClassRec)); if (!proxc) @@ -301,7 +311,12 @@ void InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, int minval, int maxval, int resolution, int min_res, int max_res) { - register AxisInfoPtr ax = dev->valuator->axes + axnum; + AxisInfoPtr ax; + + if (!dev || !dev->valuator) + return; + + ax = dev->valuator->axes + axnum; ax->min_value = minval; ax->max_value = maxval; @@ -373,7 +388,7 @@ FixDeviceValuator(DeviceIntPtr dev, deviceValuator * ev, ValuatorClassPtr v, void DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail, - register WindowPtr pWin) + WindowPtr pWin) { deviceFocus event; @@ -698,9 +713,9 @@ MakeInputMasks(WindowPtr pWin) void RecalculateDeviceDeliverableEvents(WindowPtr pWin) { - register InputClientsPtr others; + InputClientsPtr others; struct _OtherInputMasks *inputMasks; /* default: NULL */ - register WindowPtr pChild, tmp; + WindowPtr pChild, tmp; int i; pChild = pWin; @@ -734,9 +749,9 @@ RecalculateDeviceDeliverableEvents(WindowPtr pWin) } int -InputClientGone(register WindowPtr pWin, XID id) +InputClientGone(WindowPtr pWin, XID id) { - register InputClientsPtr other, prev; + InputClientsPtr other, prev; if (!wOtherInputMasks(pWin)) return (Success); @@ -835,7 +850,7 @@ SendEvent(ClientPtr client, DeviceIntPtr d, Window dest, Bool propagate, int SetButtonMapping(ClientPtr client, DeviceIntPtr dev, int nElts, BYTE * map) { - register int i; + int i; ButtonClassPtr b = dev->button; if (b == NULL) @@ -861,7 +876,7 @@ SetModifierMapping(ClientPtr client, DeviceIntPtr dev, int len, int rlen, { KeyCode *map = NULL; int inputMapLen; - register int i; + int i; *k = dev->key; if (*k == NULL) @@ -900,7 +915,7 @@ SetModifierMapping(ClientPtr client, DeviceIntPtr dev, int len, int rlen, return MappingBusy; } else { for (i = 0; i < inputMapLen; i++) { - if (inputMap[i] && !LegalModifier(inputMap[i], (DevicePtr) dev)) { + if (inputMap[i] && !LegalModifier(inputMap[i], dev)) { return MappingFailed; } } @@ -936,7 +951,7 @@ SetModifierMapping(ClientPtr client, DeviceIntPtr dev, int len, int rlen, } void -SendDeviceMappingNotify(CARD8 request, +SendDeviceMappingNotify(ClientPtr client, CARD8 request, KeyCode firstKeyCode, CARD8 count, DeviceIntPtr dev) { xEvent event; @@ -951,6 +966,11 @@ SendDeviceMappingNotify(CARD8 request, ev->count = count; } +#ifdef XKB + if (request == MappingKeyboard || request == MappingModifier) + XkbApplyMappingChange(dev, request, firstKeyCode, count, client); +#endif + SendEventToAllWindows(dev, DeviceMappingNotifyMask, (xEvent *) ev, 1); } @@ -986,37 +1006,11 @@ ChangeKeyMapping(ClientPtr client, keysyms.map = map; if (!SetKeySymsMap(&k->curKeySyms, &keysyms)) return BadAlloc; - SendDeviceMappingNotify(MappingKeyboard, firstKeyCode, keyCodes, dev); + SendDeviceMappingNotify(client, MappingKeyboard, firstKeyCode, keyCodes, dev); return client->noClientException; } -void -DeleteWindowFromAnyExtEvents(WindowPtr pWin, Bool freeResources) -{ - int i; - DeviceIntPtr dev; - InputClientsPtr ic; - struct _OtherInputMasks *inputMasks; - - for (dev = inputInfo.devices; dev; dev = dev->next) { - if (dev == inputInfo.pointer || dev == inputInfo.keyboard) - continue; - DeleteDeviceFromAnyExtEvents(pWin, dev); - } - - for (dev = inputInfo.off_devices; dev; dev = dev->next) - DeleteDeviceFromAnyExtEvents(pWin, dev); - - if (freeResources) - while ((inputMasks = wOtherInputMasks(pWin)) != 0) { - ic = inputMasks->inputClients; - for (i = 0; i < EMASKSIZE; i++) - inputMasks->dontPropagateMask[i] = 0; - FreeResource(ic->resource, RT_NONE); - } -} - -void +static void DeleteDeviceFromAnyExtEvents(WindowPtr pWin, DeviceIntPtr dev) { WindowPtr parent; @@ -1081,6 +1075,32 @@ DeleteDeviceFromAnyExtEvents(WindowPtr pWin, DeviceIntPtr dev) dev->valuator->motionHintWindow = NullWindow; } +void +DeleteWindowFromAnyExtEvents(WindowPtr pWin, Bool freeResources) +{ + int i; + DeviceIntPtr dev; + InputClientsPtr ic; + struct _OtherInputMasks *inputMasks; + + for (dev = inputInfo.devices; dev; dev = dev->next) { + if (dev == inputInfo.pointer || dev == inputInfo.keyboard) + continue; + DeleteDeviceFromAnyExtEvents(pWin, dev); + } + + for (dev = inputInfo.off_devices; dev; dev = dev->next) + DeleteDeviceFromAnyExtEvents(pWin, dev); + + if (freeResources) + while ((inputMasks = wOtherInputMasks(pWin)) != 0) { + ic = inputMasks->inputClients; + for (i = 0; i < EMASKSIZE; i++) + inputMasks->dontPropagateMask[i] = 0; + FreeResource(ic->resource, RT_NONE); + } +} + int MaybeSendDeviceMotionNotifyHint(deviceKeyButtonPointer * pEvents, Mask mask) { @@ -1134,10 +1154,10 @@ CheckDeviceGrabAndHintWindow(WindowPtr pWin, int type, } } -Mask +static Mask DeviceEventMaskForClient(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client) { - register InputClientsPtr other; + InputClientsPtr other; if (!wOtherInputMasks(pWin)) return 0; @@ -1150,7 +1170,7 @@ DeviceEventMaskForClient(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client) } void -MaybeStopDeviceHint(register DeviceIntPtr dev, ClientPtr client) +MaybeStopDeviceHint(DeviceIntPtr dev, ClientPtr client) { WindowPtr pWin; GrabPtr grab = dev->grab; @@ -1211,3 +1231,44 @@ ShouldFreeInputMasks(WindowPtr pWin, Bool ignoreSelectedEvents) else return FALSE; } + +/*********************************************************************** + * + * Walk through the window tree, finding all clients that want to know + * about the Event. + * + */ + +static void +FindInterestedChildren(DeviceIntPtr dev, WindowPtr p1, Mask mask, + xEvent * ev, int count) +{ + WindowPtr p2; + + while (p1) { + p2 = p1->firstChild; + (void)DeliverEventsToWindow(p1, ev, count, mask, NullGrab, dev->id); + FindInterestedChildren(dev, p2, mask, ev, count); + p1 = p1->nextSib; + } +} + +/*********************************************************************** + * + * Send an event to interested clients in all windows on all screens. + * + */ + +void +SendEventToAllWindows(DeviceIntPtr dev, Mask mask, xEvent * ev, int count) +{ + int i; + WindowPtr pWin, p1; + + for (i = 0; i < screenInfo.numScreens; i++) { + pWin = screenInfo.screens[i]->root; + (void)DeliverEventsToWindow(pWin, ev, count, mask, NullGrab, dev->id); + p1 = pWin->firstChild; + FindInterestedChildren(dev, p1, mask, ev, count); + } +} diff --git a/nx-X11/programs/Xserver/Xi/exglobals.h b/nx-X11/programs/Xserver/Xi/exglobals.h index c64b84875d..50bb33fdcc 100644 --- a/nx-X11/programs/Xserver/Xi/exglobals.h +++ b/nx-X11/programs/Xserver/Xi/exglobals.h @@ -37,7 +37,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. extern int IReqCode; extern int BadDevice; -extern int BadEvent; extern int BadMode; extern int DeviceBusy; extern int BadClass; @@ -46,11 +45,11 @@ extern Mask DevicePointerMotionMask; extern Mask DevicePointerMotionHintMask; extern Mask DeviceFocusChangeMask; extern Mask DeviceStateNotifyMask; -extern Mask ChangeDeviceNotifyMask; extern Mask DeviceMappingNotifyMask; extern Mask DeviceOwnerGrabButtonMask; extern Mask DeviceButtonGrabMask; extern Mask DeviceButtonMotionMask; +extern Mask DevicePresenceNotifyMask; extern Mask PropagateMask[]; extern int DeviceValuator; @@ -68,12 +67,8 @@ extern int DeviceKeyStateNotify; extern int DeviceButtonStateNotify; extern int DeviceMappingNotify; extern int ChangeDeviceNotify; +extern int DevicePresenceNotify; extern int RT_INPUTCLIENT; -#if 0 -/* FIXME: in dix */ -extern InputInfo inputInfo; -#endif - #endif /* EXGLOBALS_H */ diff --git a/nx-X11/programs/Xserver/Xi/extinit.c b/nx-X11/programs/Xserver/Xi/extinit.c index adf69b00b8..b746fd3d07 100644 --- a/nx-X11/programs/Xserver/Xi/extinit.c +++ b/nx-X11/programs/Xserver/Xi/extinit.c @@ -115,7 +115,7 @@ int ExtEventIndex; Mask ExtValidMasks[EMASKSIZE]; Mask ExtExclusiveMasks[EMASKSIZE]; -struct dev_type +static struct dev_type { Atom type; char *name; @@ -151,7 +151,7 @@ XExtEventInfo EventInfo[32]; int IReqCode = 0; int BadDevice = 0; -int BadEvent = 1; +static int BadEvent = 1; int BadMode = 2; int DeviceBusy = 3; int BadClass = 4; @@ -160,11 +160,12 @@ Mask DevicePointerMotionMask; Mask DevicePointerMotionHintMask; Mask DeviceFocusChangeMask; Mask DeviceStateNotifyMask; -Mask ChangeDeviceNotifyMask; +static Mask ChangeDeviceNotifyMask; Mask DeviceMappingNotifyMask; Mask DeviceOwnerGrabButtonMask; Mask DeviceButtonGrabMask; Mask DeviceButtonMotionMask; +Mask DevicePresenceNotifyMask; int DeviceValuator; int DeviceKeyPress; @@ -181,6 +182,7 @@ int DeviceKeyStateNotify; int DeviceButtonStateNotify; int DeviceMappingNotify; int ChangeDeviceNotify; +int DevicePresenceNotify; int RT_INPUTCLIENT; @@ -206,51 +208,6 @@ static XExtensionVersion thisversion = SERVER_XI_MINOR_VERSION, }; -/********************************************************************** - * - * IExtensionInit - initialize the input extension. - * - * Called from InitExtensions in main() or from QueryExtension() if the - * extension is dynamically loaded. - * - * This extension has several events and errors. - * - */ - -void -XInputExtensionInit(void) -{ - ExtensionEntry *extEntry; - - extEntry = AddExtension(INAME, IEVENTS, IERRORS, ProcIDispatch, - SProcIDispatch, IResetProc, StandardMinorOpcode); - if (extEntry) { - IReqCode = extEntry->base; - AllExtensionVersions[IReqCode - 128] = thisversion; - MakeDeviceTypeAtoms(); - RT_INPUTCLIENT = CreateNewResourceType((DeleteType) InputClientGone); - FixExtensionEvents(extEntry); - ReplySwapVector[IReqCode] = (ReplySwapPtr) SReplyIDispatch; - EventSwapVector[DeviceValuator] = SEventIDispatch; - EventSwapVector[DeviceKeyPress] = SEventIDispatch; - EventSwapVector[DeviceKeyRelease] = SEventIDispatch; - EventSwapVector[DeviceButtonPress] = SEventIDispatch; - EventSwapVector[DeviceButtonRelease] = SEventIDispatch; - EventSwapVector[DeviceMotionNotify] = SEventIDispatch; - EventSwapVector[DeviceFocusIn] = SEventIDispatch; - EventSwapVector[DeviceFocusOut] = SEventIDispatch; - EventSwapVector[ProximityIn] = SEventIDispatch; - EventSwapVector[ProximityOut] = SEventIDispatch; - EventSwapVector[DeviceStateNotify] = SEventIDispatch; - EventSwapVector[DeviceKeyStateNotify] = SEventIDispatch; - EventSwapVector[DeviceButtonStateNotify] = SEventIDispatch; - EventSwapVector[DeviceMappingNotify] = SEventIDispatch; - EventSwapVector[ChangeDeviceNotify] = SEventIDispatch; - } else { - FatalError("IExtensionInit: AddExtensions failed\n"); - } -} - /************************************************************************* * * ProcIDispatch - main dispatch routine for requests to this extension. @@ -258,8 +215,8 @@ XInputExtensionInit(void) * */ -int -ProcIDispatch(register ClientPtr client) +static int +ProcIDispatch(ClientPtr client) { REQUEST(xReq); if (stuff->data == X_GetExtensionVersion) @@ -347,8 +304,8 @@ ProcIDispatch(register ClientPtr client) * */ -int -SProcIDispatch(register ClientPtr client) +static int +SProcIDispatch(ClientPtr client) { REQUEST(xReq); if (stuff->data == X_GetExtensionVersion) @@ -439,7 +396,7 @@ SProcIDispatch(register ClientPtr client) if (rep->RepType == X_##code) \ SRepX##code (client, len, (x##code##Reply *) rep) -void +static void SReplyIDispatch(ClientPtr client, int len, xGrabDeviceReply * rep) /* All we look at is the type field */ { /* This is common to all replies */ @@ -463,12 +420,6 @@ SReplyIDispatch(ClientPtr client, int len, xGrabDeviceReply * rep) else if (rep->RepType == X_GetDeviceMotionEvents) SRepXGetDeviceMotionEvents(client, len, (xGetDeviceMotionEventsReply *) rep); - else if (rep->RepType == X_ChangeKeyboardDevice) - SRepXChangeKeyboardDevice(client, len, - (xChangeKeyboardDeviceReply *) rep); - else if (rep->RepType == X_ChangePointerDevice) - SRepXChangePointerDevice(client, len, - (xChangePointerDeviceReply *) rep); else if (rep->RepType == X_GrabDevice) SRepXGrabDevice(client, len, (xGrabDeviceReply *) rep); else if (rep->RepType == X_GetDeviceFocus) @@ -504,71 +455,16 @@ SReplyIDispatch(ClientPtr client, int len, xGrabDeviceReply * rep) } } -/***************************************************************************** - * - * SEventIDispatch - * - * Swap any events defined in this extension. - */ -#define DO_SWAP(func,type) func ((type *)from, (type *)to) - -void -SEventIDispatch(xEvent * from, xEvent * to) -{ - int type = from->u.u.type & 0177; - - if (type == DeviceValuator) - DO_SWAP(SEventDeviceValuator, deviceValuator); - else if (type == DeviceKeyPress) { - SKeyButtonPtrEvent(from, to); - to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; - } else if (type == DeviceKeyRelease) { - SKeyButtonPtrEvent(from, to); - to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; - } else if (type == DeviceButtonPress) { - SKeyButtonPtrEvent(from, to); - to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; - } else if (type == DeviceButtonRelease) { - SKeyButtonPtrEvent(from, to); - to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; - } else if (type == DeviceMotionNotify) { - SKeyButtonPtrEvent(from, to); - to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; - } else if (type == DeviceFocusIn) - DO_SWAP(SEventFocus, deviceFocus); - else if (type == DeviceFocusOut) - DO_SWAP(SEventFocus, deviceFocus); - else if (type == ProximityIn) { - SKeyButtonPtrEvent(from, to); - to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; - } else if (type == ProximityOut) { - SKeyButtonPtrEvent(from, to); - to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; - } else if (type == DeviceStateNotify) - DO_SWAP(SDeviceStateNotifyEvent, deviceStateNotify); - else if (type == DeviceKeyStateNotify) - DO_SWAP(SDeviceKeyStateNotifyEvent, deviceKeyStateNotify); - else if (type == DeviceButtonStateNotify) - DO_SWAP(SDeviceButtonStateNotifyEvent, deviceButtonStateNotify); - else if (type == DeviceMappingNotify) - DO_SWAP(SDeviceMappingNotifyEvent, deviceMappingNotify); - else if (type == ChangeDeviceNotify) - DO_SWAP(SChangeDeviceNotifyEvent, changeDeviceNotify); - else { - FatalError("XInputExtension: Impossible event!\n"); - } -} - /************************************************************************ * * This function swaps the DeviceValuator event. * */ -void +static void SEventDeviceValuator(deviceValuator * from, deviceValuator * to) { - register int i; + int i; INT32 *ip B32; *to = *from; @@ -580,7 +476,7 @@ SEventDeviceValuator(deviceValuator * from, deviceValuator * to) } } -void +static void SEventFocus(deviceFocus * from, deviceFocus * to) { *to = *from; @@ -589,10 +485,10 @@ SEventFocus(deviceFocus * from, deviceFocus * to) swapl(&to->window); } -void +static void SDeviceStateNotifyEvent(deviceStateNotify * from, deviceStateNotify * to) { - register int i; + int i; INT32 *ip B32; *to = *from; @@ -604,7 +500,7 @@ SDeviceStateNotifyEvent(deviceStateNotify * from, deviceStateNotify * to) } } -void +static void SDeviceKeyStateNotifyEvent(deviceKeyStateNotify * from, deviceKeyStateNotify * to) { @@ -612,7 +508,7 @@ SDeviceKeyStateNotifyEvent(deviceKeyStateNotify * from, swaps(&to->sequenceNumber); } -void +static void SDeviceButtonStateNotifyEvent(deviceButtonStateNotify * from, deviceButtonStateNotify * to) { @@ -620,7 +516,7 @@ SDeviceButtonStateNotifyEvent(deviceButtonStateNotify * from, swaps(&to->sequenceNumber); } -void +static void SChangeDeviceNotifyEvent(changeDeviceNotify * from, changeDeviceNotify * to) { *to = *from; @@ -628,7 +524,7 @@ SChangeDeviceNotifyEvent(changeDeviceNotify * from, changeDeviceNotify * to) swapl(&to->time); } -void +static void SDeviceMappingNotifyEvent(deviceMappingNotify * from, deviceMappingNotify * to) { *to = *from; @@ -636,13 +532,115 @@ SDeviceMappingNotifyEvent(deviceMappingNotify * from, deviceMappingNotify * to) swapl(&to->time); } +static void +SDevicePresenceNotifyEvent (devicePresenceNotify *from, devicePresenceNotify *to) +{ + *to = *from; + swaps(&to->sequenceNumber); + swapl(&to->time); + swaps(&to->control); +} + +/************************************************************************** + * + * Allow the specified event to have its propagation suppressed. + * The default is to not allow suppression of propagation. + * + */ + +static void +AllowPropagateSuppress(Mask mask) +{ + int i; + + for (i = 0; i < MAX_DEVICES; i++) + PropagateMask[i] |= mask; +} + +/************************************************************************** + * + * Return the next available extension event mask. + * + */ + +static Mask +GetNextExtEventMask(void) +{ + int i; + Mask mask = lastExtEventMask; + + if (lastExtEventMask == 0) { + FatalError("GetNextExtEventMask: no more events are available."); + } + lastExtEventMask <<= 1; + + for (i = 0; i < MAX_DEVICES; i++) + ExtValidMasks[i] |= mask; + return mask; +} + +/************************************************************************** + * + * Record an event mask where there is no unique corresponding event type. + * We can't call SetMaskForEvent, since that would clobber the existing + * mask for that event. MotionHint and ButtonMotion are examples. + * + * Since extension event types will never be less than 64, we can use + * 0-63 in the EventInfo array as the "type" to be used to look up this + * mask. This means that the corresponding macros such as + * DevicePointerMotionHint must have access to the same constants. + * + */ + +static void +SetEventInfo(Mask mask, int constant) +{ + EventInfo[ExtEventIndex].mask = mask; + EventInfo[ExtEventIndex++].type = constant; +} + +/************************************************************************** + * + * Allow the specified event to be restricted to being selected by one + * client at a time. + * The default is to allow more than one client to select the event. + * + */ + +static void +SetExclusiveAccess(Mask mask) +{ + int i; + + for (i = 0; i < MAX_DEVICES; i++) + ExtExclusiveMasks[i] |= mask; +} + +/************************************************************************** + * + * Assign the specified mask to the specified event. + * + */ + +static void +SetMaskForExtEvent(Mask mask, int event) +{ + + EventInfo[ExtEventIndex].mask = mask; + EventInfo[ExtEventIndex++].type = event; + + if ((event < LASTEvent) || (event >= 128)) + FatalError("MaskForExtensionEvent: bogus event number"); + SetMaskForEvent(mask, event); +} + /************************************************************************ * * This function sets up extension event types and masks. * */ -void +static void FixExtensionEvents(ExtensionEntry * extEntry) { Mask mask; @@ -662,6 +660,7 @@ FixExtensionEvents(ExtensionEntry * extEntry) ChangeDeviceNotify = DeviceMappingNotify + 1; DeviceKeyStateNotify = ChangeDeviceNotify + 1; DeviceButtonStateNotify = DeviceKeyStateNotify + 1; + DevicePresenceNotify = DeviceButtonStateNotify + 1; event_base[KeyClass] = DeviceKeyPress; event_base[ButtonClass] = DeviceButtonPress; @@ -734,6 +733,9 @@ FixExtensionEvents(ExtensionEntry * extEntry) DeviceOwnerGrabButtonMask = GetNextExtEventMask(); SetEventInfo(DeviceOwnerGrabButtonMask, _deviceOwnerGrabButton); + + DevicePresenceNotifyMask = GetNextExtEventMask(); + SetEventInfo(DevicePresenceNotifyMask, _devicePresence); SetEventInfo(0, _noExtensionEvent); } @@ -744,7 +746,7 @@ FixExtensionEvents(ExtensionEntry * extEntry) * */ -void +static void RestoreExtensionEvents(void) { int i; @@ -774,6 +776,7 @@ RestoreExtensionEvents(void) ChangeDeviceNotify = 12; DeviceKeyStateNotify = 13; DeviceButtonStateNotify = 13; + DevicePresenceNotify = 14; BadDevice = 0; BadEvent = 1; @@ -791,7 +794,7 @@ RestoreExtensionEvents(void) * */ -void +static void IResetProc(ExtensionEntry * unused) { @@ -811,6 +814,7 @@ IResetProc(ExtensionEntry * unused) EventSwapVector[DeviceButtonStateNotify] = NotImplemented; EventSwapVector[DeviceMappingNotify] = NotImplemented; EventSwapVector[ChangeDeviceNotify] = NotImplemented; + EventSwapVector[DevicePresenceNotify] = NotImplemented; RestoreExtensionEvents(); } @@ -834,7 +838,7 @@ AssignTypeAndName(DeviceIntPtr dev, Atom type, char *name) * */ -void +static void MakeDeviceTypeAtoms(void) { int i; @@ -845,9 +849,7 @@ MakeDeviceTypeAtoms(void) } /************************************************************************** - * * Return a DeviceIntPtr corresponding to a specified device id. - * This will not return the pointer or keyboard, or devices that are not on. * */ @@ -857,104 +859,117 @@ LookupDeviceIntRec(CARD8 id) DeviceIntPtr dev; for (dev = inputInfo.devices; dev; dev = dev->next) { - if (dev->id == id) { - if (id == inputInfo.pointer->id || id == inputInfo.keyboard->id) - return (NULL); - return (dev); - } + if (dev->id == id) + return dev; } - return (NULL); -} -/************************************************************************** - * - * Allow the specified event to be restricted to being selected by one - * client at a time. - * The default is to allow more than one client to select the event. - * - */ - -void -SetExclusiveAccess(Mask mask) -{ - int i; - - for (i = 0; i < MAX_DEVICES; i++) - ExtExclusiveMasks[i] |= mask; -} - -/************************************************************************** - * - * Allow the specified event to have its propagation suppressed. - * The default is to not allow suppression of propagation. - * - */ - -void -AllowPropagateSuppress(Mask mask) -{ - int i; + for (dev = inputInfo.off_devices; dev; dev = dev->next) { + if (dev->id == id) + return dev; + } - for (i = 0; i < MAX_DEVICES; i++) - PropagateMask[i] |= mask; + return NULL; } -/************************************************************************** +/***************************************************************************** * - * Return the next available extension event mask. + * SEventIDispatch * + * Swap any events defined in this extension. */ +#define DO_SWAP(func,type) func ((type *)from, (type *)to) -Mask -GetNextExtEventMask(void) +static void +SEventIDispatch(xEvent * from, xEvent * to) { - int i; - Mask mask = lastExtEventMask; + int type = from->u.u.type & 0177; - if (lastExtEventMask == 0) { - FatalError("GetNextExtEventMask: no more events are available."); + if (type == DeviceValuator) + DO_SWAP(SEventDeviceValuator, deviceValuator); + else if (type == DeviceKeyPress) { + SKeyButtonPtrEvent(from, to); + to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; + } else if (type == DeviceKeyRelease) { + SKeyButtonPtrEvent(from, to); + to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; + } else if (type == DeviceButtonPress) { + SKeyButtonPtrEvent(from, to); + to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; + } else if (type == DeviceButtonRelease) { + SKeyButtonPtrEvent(from, to); + to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; + } else if (type == DeviceMotionNotify) { + SKeyButtonPtrEvent(from, to); + to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; + } else if (type == DeviceFocusIn) + DO_SWAP(SEventFocus, deviceFocus); + else if (type == DeviceFocusOut) + DO_SWAP(SEventFocus, deviceFocus); + else if (type == ProximityIn) { + SKeyButtonPtrEvent(from, to); + to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; + } else if (type == ProximityOut) { + SKeyButtonPtrEvent(from, to); + to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; + } else if (type == DeviceStateNotify) + DO_SWAP(SDeviceStateNotifyEvent, deviceStateNotify); + else if (type == DeviceKeyStateNotify) + DO_SWAP(SDeviceKeyStateNotifyEvent, deviceKeyStateNotify); + else if (type == DeviceButtonStateNotify) + DO_SWAP(SDeviceButtonStateNotifyEvent, deviceButtonStateNotify); + else if (type == DeviceMappingNotify) + DO_SWAP(SDeviceMappingNotifyEvent, deviceMappingNotify); + else if (type == ChangeDeviceNotify) + DO_SWAP(SChangeDeviceNotifyEvent, changeDeviceNotify); + else if (type == DevicePresenceNotify) + DO_SWAP(SDevicePresenceNotifyEvent, devicePresenceNotify); + else { + FatalError("XInputExtension: Impossible event!\n"); } - lastExtEventMask <<= 1; - - for (i = 0; i < MAX_DEVICES; i++) - ExtValidMasks[i] |= mask; - return mask; } -/************************************************************************** - * - * Assign the specified mask to the specified event. +/********************************************************************** * - */ - -void -SetMaskForExtEvent(Mask mask, int event) -{ - - EventInfo[ExtEventIndex].mask = mask; - EventInfo[ExtEventIndex++].type = event; - - if ((event < LASTEvent) || (event >= 128)) - FatalError("MaskForExtensionEvent: bogus event number"); - SetMaskForEvent(mask, event); -} - -/************************************************************************** + * IExtensionInit - initialize the input extension. * - * Record an event mask where there is no unique corresponding event type. - * We can't call SetMaskForEvent, since that would clobber the existing - * mask for that event. MotionHint and ButtonMotion are examples. + * Called from InitExtensions in main() or from QueryExtension() if the + * extension is dynamically loaded. * - * Since extension event types will never be less than 64, we can use - * 0-63 in the EventInfo array as the "type" to be used to look up this - * mask. This means that the corresponding macros such as - * DevicePointerMotionHint must have access to the same constants. + * This extension has several events and errors. * */ void -SetEventInfo(Mask mask, int constant) +XInputExtensionInit(void) { - EventInfo[ExtEventIndex].mask = mask; - EventInfo[ExtEventIndex++].type = constant; + ExtensionEntry *extEntry; + + extEntry = AddExtension(INAME, IEVENTS, IERRORS, ProcIDispatch, + SProcIDispatch, IResetProc, StandardMinorOpcode); + if (extEntry) { + IReqCode = extEntry->base; + AllExtensionVersions[IReqCode - 128] = thisversion; + MakeDeviceTypeAtoms(); + RT_INPUTCLIENT = CreateNewResourceType((DeleteType) InputClientGone); + FixExtensionEvents(extEntry); + ReplySwapVector[IReqCode] = (ReplySwapPtr) SReplyIDispatch; + EventSwapVector[DeviceValuator] = SEventIDispatch; + EventSwapVector[DeviceKeyPress] = SEventIDispatch; + EventSwapVector[DeviceKeyRelease] = SEventIDispatch; + EventSwapVector[DeviceButtonPress] = SEventIDispatch; + EventSwapVector[DeviceButtonRelease] = SEventIDispatch; + EventSwapVector[DeviceMotionNotify] = SEventIDispatch; + EventSwapVector[DeviceFocusIn] = SEventIDispatch; + EventSwapVector[DeviceFocusOut] = SEventIDispatch; + EventSwapVector[ProximityIn] = SEventIDispatch; + EventSwapVector[ProximityOut] = SEventIDispatch; + EventSwapVector[DeviceStateNotify] = SEventIDispatch; + EventSwapVector[DeviceKeyStateNotify] = SEventIDispatch; + EventSwapVector[DeviceButtonStateNotify] = SEventIDispatch; + EventSwapVector[DeviceMappingNotify] = SEventIDispatch; + EventSwapVector[ChangeDeviceNotify] = SEventIDispatch; + EventSwapVector[DevicePresenceNotify] = SEventIDispatch; + } else { + FatalError("IExtensionInit: AddExtensions failed\n"); + } } diff --git a/nx-X11/programs/Xserver/Xi/getbmap.c b/nx-X11/programs/Xserver/Xi/getbmap.c index 45f976423d..2010ec6acc 100644 --- a/nx-X11/programs/Xserver/Xi/getbmap.c +++ b/nx-X11/programs/Xserver/Xi/getbmap.c @@ -72,7 +72,7 @@ SOFTWARE. */ int -SProcXGetDeviceButtonMapping(register ClientPtr client) +SProcXGetDeviceButtonMapping(ClientPtr client) { REQUEST(xGetDeviceButtonMappingReq); swaps(&stuff->length); @@ -86,7 +86,7 @@ SProcXGetDeviceButtonMapping(register ClientPtr client) */ int -ProcXGetDeviceButtonMapping(register ClientPtr client) +ProcXGetDeviceButtonMapping(ClientPtr client) { DeviceIntPtr dev; xGetDeviceButtonMappingReply rep; diff --git a/nx-X11/programs/Xserver/Xi/getdctl.c b/nx-X11/programs/Xserver/Xi/getdctl.c index e050e36ac0..94bfc4ada8 100644 --- a/nx-X11/programs/Xserver/Xi/getdctl.c +++ b/nx-X11/programs/Xserver/Xi/getdctl.c @@ -73,7 +73,7 @@ SOFTWARE. */ int -SProcXGetDeviceControl(register ClientPtr client) +SProcXGetDeviceControl(ClientPtr client) { REQUEST(xGetDeviceControlReq); swaps(&stuff->length); @@ -82,6 +82,143 @@ SProcXGetDeviceControl(register ClientPtr client) return (ProcXGetDeviceControl(client)); } +/*********************************************************************** + * + * This procedure copies DeviceResolution data, swapping if necessary. + * + */ + +static void +CopySwapDeviceResolution(ClientPtr client, ValuatorClassPtr v, char *buf, + int length) +{ + AxisInfoPtr a; + xDeviceResolutionState *r; + int i, *iptr; + + r = (xDeviceResolutionState *) buf; + r->control = DEVICE_RESOLUTION; + r->length = length; + r->num_valuators = v->numAxes; + buf += sizeof(xDeviceResolutionState); + iptr = (int *)buf; + for (i = 0, a = v->axes; i < v->numAxes; i++, a++) + *iptr++ = a->resolution; + for (i = 0, a = v->axes; i < v->numAxes; i++, a++) + *iptr++ = a->min_resolution; + for (i = 0, a = v->axes; i < v->numAxes; i++, a++) + *iptr++ = a->max_resolution; + if (client->swapped) { + swaps(&r->control); + swaps(&r->length); + swapl(&r->num_valuators); + iptr = (int *)buf; + for (i = 0; i < (3 * v->numAxes); i++, iptr++) { + swapl(iptr); + } + } +} + +static void CopySwapDeviceAbsCalib (ClientPtr client, AbsoluteClassPtr dts, + char *buf) +{ + xDeviceAbsCalibState *calib = (xDeviceAbsCalibState *) buf; + + calib->control = DEVICE_ABS_CALIB; + calib->length = sizeof(calib); + calib->min_x = dts->min_x; + calib->max_x = dts->max_x; + calib->min_y = dts->min_y; + calib->max_y = dts->max_y; + calib->flip_x = dts->flip_x; + calib->flip_y = dts->flip_y; + calib->rotation = dts->rotation; + calib->button_threshold = dts->button_threshold; + + if (client->swapped) { + swaps(&calib->control); + swaps(&calib->length); + swapl(&calib->min_x); + swapl(&calib->max_x); + swapl(&calib->min_y); + swapl(&calib->max_y); + swapl(&calib->flip_x); + swapl(&calib->flip_y); + swapl(&calib->rotation); + swapl(&calib->button_threshold); + } +} + +static void CopySwapDeviceAbsArea (ClientPtr client, AbsoluteClassPtr dts, + char *buf) +{ + xDeviceAbsAreaState *area = (xDeviceAbsAreaState *) buf; + + area->control = DEVICE_ABS_AREA; + area->length = sizeof(area); + area->offset_x = dts->offset_x; + area->offset_y = dts->offset_y; + area->width = dts->width; + area->height = dts->height; + area->screen = dts->screen; + area->following = dts->following; + + if (client->swapped) { + swaps(&area->control); + swaps(&area->length); + swapl(&area->offset_x); + swapl(&area->offset_y); + swapl(&area->width); + swapl(&area->height); + swapl(&area->screen); + swapl(&area->following); + } +} + +static void CopySwapDeviceCore (ClientPtr client, DeviceIntPtr dev, char *buf) +{ + xDeviceCoreState *c = (xDeviceCoreState *) buf; + + c->control = DEVICE_CORE; + c->length = sizeof(c); + c->status = dev->coreEvents; + c->iscore = (dev == inputInfo.keyboard || dev == inputInfo.pointer); + + if (client->swapped) { + swaps(&c->control); + swaps(&c->length); + } +} + +static void CopySwapDeviceEnable (ClientPtr client, DeviceIntPtr dev, char *buf) +{ + xDeviceEnableState *e = (xDeviceEnableState *) buf; + + e->control = DEVICE_ENABLE; + e->length = sizeof(e); + e->enable = dev->enabled; + + if (client->swapped) { + swaps(&e->control); + swaps(&e->length); + } +} + +/*********************************************************************** + * + * This procedure writes the reply for the xGetDeviceControl function, + * if the client and server have a different byte ordering. + * + */ + +void +SRepXGetDeviceControl(ClientPtr client, int size, xGetDeviceControlReply * rep) +{ + swaps(&rep->sequenceNumber); + swapl(&rep->length); + WriteToClient(client, size, rep); +} + /*********************************************************************** * * Get the state of the specified device control. @@ -93,7 +230,7 @@ ProcXGetDeviceControl(ClientPtr client) { int total_length = 0; char *buf, *savbuf; - register DeviceIntPtr dev; + DeviceIntPtr dev; xGetDeviceControlReply rep; REQUEST(xGetDeviceControlReq); @@ -120,6 +257,30 @@ ProcXGetDeviceControl(ClientPtr client) total_length = sizeof(xDeviceResolutionState) + (3 * sizeof(int) * dev->valuator->numAxes); break; + case DEVICE_ABS_CALIB: + if (!dev->absolute) { + SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0, + BadMatch); + return Success; + } + + total_length = sizeof(xDeviceAbsCalibCtl); + break; + case DEVICE_ABS_AREA: + if (!dev->absolute) { + SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0, + BadMatch); + return Success; + } + + total_length = sizeof(xDeviceAbsAreaCtl); + break; + case DEVICE_CORE: + total_length = sizeof(xDeviceCoreCtl); + break; + case DEVICE_ENABLE: + total_length = sizeof(xDeviceEnableCtl); + break; default: SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0, BadValue); return Success; @@ -136,6 +297,18 @@ ProcXGetDeviceControl(ClientPtr client) case DEVICE_RESOLUTION: CopySwapDeviceResolution(client, dev->valuator, buf, total_length); break; + case DEVICE_ABS_CALIB: + CopySwapDeviceAbsCalib(client, dev->absolute, buf); + break; + case DEVICE_ABS_AREA: + CopySwapDeviceAbsArea(client, dev->absolute, buf); + break; + case DEVICE_CORE: + CopySwapDeviceCore(client, dev, buf); + break; + case DEVICE_ENABLE: + CopySwapDeviceEnable(client, dev, buf); + break; default: break; } @@ -146,55 +319,3 @@ ProcXGetDeviceControl(ClientPtr client) free(savbuf); return Success; } - -/*********************************************************************** - * - * This procedure copies DeviceResolution data, swapping if necessary. - * - */ - -void -CopySwapDeviceResolution(ClientPtr client, ValuatorClassPtr v, char *buf, - int length) -{ - AxisInfoPtr a; - xDeviceResolutionState *r; - int i, *iptr; - - r = (xDeviceResolutionState *) buf; - r->control = DEVICE_RESOLUTION; - r->length = length; - r->num_valuators = v->numAxes; - buf += sizeof(xDeviceResolutionState); - iptr = (int *)buf; - for (i = 0, a = v->axes; i < v->numAxes; i++, a++) - *iptr++ = a->resolution; - for (i = 0, a = v->axes; i < v->numAxes; i++, a++) - *iptr++ = a->min_resolution; - for (i = 0, a = v->axes; i < v->numAxes; i++, a++) - *iptr++ = a->max_resolution; - if (client->swapped) { - swaps(&r->control); - swaps(&r->length); - swapl(&r->num_valuators); - iptr = (int *)buf; - for (i = 0; i < (3 * v->numAxes); i++, iptr++) { - swapl(iptr); - } - } -} - -/*********************************************************************** - * - * This procedure writes the reply for the xGetDeviceControl function, - * if the client and server have a different byte ordering. - * - */ - -void -SRepXGetDeviceControl(ClientPtr client, int size, xGetDeviceControlReply * rep) -{ - swaps(&rep->sequenceNumber); - swapl(&rep->length); - WriteToClient(client, size, rep); -} diff --git a/nx-X11/programs/Xserver/Xi/getdctl.h b/nx-X11/programs/Xserver/Xi/getdctl.h index c7cfb19d24..19c189f36d 100644 --- a/nx-X11/programs/Xserver/Xi/getdctl.h +++ b/nx-X11/programs/Xserver/Xi/getdctl.h @@ -36,12 +36,6 @@ int SProcXGetDeviceControl(ClientPtr /* client */ int ProcXGetDeviceControl(ClientPtr /* client */ ); -void CopySwapDeviceResolution(ClientPtr /* client */ , - ValuatorClassPtr /* v */ , - char * /* buf */ , - int /* length */ - ); - void SRepXGetDeviceControl(ClientPtr /* client */ , int /* size */ , xGetDeviceControlReply * /* rep */ diff --git a/nx-X11/programs/Xserver/Xi/getfctl.c b/nx-X11/programs/Xserver/Xi/getfctl.c index 82de179444..0373fd8533 100644 --- a/nx-X11/programs/Xserver/Xi/getfctl.c +++ b/nx-X11/programs/Xserver/Xi/getfctl.c @@ -73,113 +73,20 @@ SOFTWARE. */ int -SProcXGetFeedbackControl(register ClientPtr client) +SProcXGetFeedbackControl(ClientPtr client) { REQUEST(xGetFeedbackControlReq); swaps(&stuff->length); return (ProcXGetFeedbackControl(client)); } -/*********************************************************************** - * - * Get the feedback control state. - * - */ - -int -ProcXGetFeedbackControl(ClientPtr client) -{ - int total_length = 0; - char *buf, *savbuf; - register DeviceIntPtr dev; - KbdFeedbackPtr k; - PtrFeedbackPtr p; - IntegerFeedbackPtr i; - StringFeedbackPtr s; - BellFeedbackPtr b; - LedFeedbackPtr l; - xGetFeedbackControlReply rep; - - REQUEST(xGetFeedbackControlReq); - REQUEST_SIZE_MATCH(xGetFeedbackControlReq); - - dev = LookupDeviceIntRec(stuff->deviceid); - if (dev == NULL) { - SendErrorToClient(client, IReqCode, X_GetFeedbackControl, 0, BadDevice); - return Success; - } - - rep.repType = X_Reply; - rep.RepType = X_GetFeedbackControl; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.num_feedbacks = 0; - - for (k = dev->kbdfeed; k; k = k->next) { - rep.num_feedbacks++; - total_length += sizeof(xKbdFeedbackState); - } - for (p = dev->ptrfeed; p; p = p->next) { - rep.num_feedbacks++; - total_length += sizeof(xPtrFeedbackState); - } - for (s = dev->stringfeed; s; s = s->next) { - rep.num_feedbacks++; - total_length += sizeof(xStringFeedbackState) + - (s->ctrl.num_symbols_supported * sizeof(KeySym)); - } - for (i = dev->intfeed; i; i = i->next) { - rep.num_feedbacks++; - total_length += sizeof(xIntegerFeedbackState); - } - for (l = dev->leds; l; l = l->next) { - rep.num_feedbacks++; - total_length += sizeof(xLedFeedbackState); - } - for (b = dev->bell; b; b = b->next) { - rep.num_feedbacks++; - total_length += sizeof(xBellFeedbackState); - } - - if (total_length == 0) { - SendErrorToClient(client, IReqCode, X_GetFeedbackControl, 0, BadMatch); - return Success; - } - - buf = (char *)malloc(total_length); - if (!buf) { - SendErrorToClient(client, IReqCode, X_GetFeedbackControl, 0, BadAlloc); - return Success; - } - savbuf = buf; - - for (k = dev->kbdfeed; k; k = k->next) - CopySwapKbdFeedback(client, k, &buf); - for (p = dev->ptrfeed; p; p = p->next) - CopySwapPtrFeedback(client, p, &buf); - for (s = dev->stringfeed; s; s = s->next) - CopySwapStringFeedback(client, s, &buf); - for (i = dev->intfeed; i; i = i->next) - CopySwapIntegerFeedback(client, i, &buf); - for (l = dev->leds; l; l = l->next) - CopySwapLedFeedback(client, l, &buf); - for (b = dev->bell; b; b = b->next) - CopySwapBellFeedback(client, b, &buf); - - rep.length = (total_length + 3) >> 2; - WriteReplyToClient(client, sizeof(xGetFeedbackControlReply), &rep); - WriteToClient(client, total_length, savbuf); - free(savbuf); - return Success; -} - /*********************************************************************** * * This procedure copies KbdFeedbackClass data, swapping if necessary. * */ -void +static void CopySwapKbdFeedback(ClientPtr client, KbdFeedbackPtr k, char **buf) { int i; @@ -213,7 +120,7 @@ CopySwapKbdFeedback(ClientPtr client, KbdFeedbackPtr k, char **buf) * */ -void +static void CopySwapPtrFeedback(ClientPtr client, PtrFeedbackPtr p, char **buf) { xPtrFeedbackState *p2; @@ -240,7 +147,7 @@ CopySwapPtrFeedback(ClientPtr client, PtrFeedbackPtr p, char **buf) * */ -void +static void CopySwapIntegerFeedback(ClientPtr client, IntegerFeedbackPtr i, char **buf) { xIntegerFeedbackState *i2; @@ -267,7 +174,7 @@ CopySwapIntegerFeedback(ClientPtr client, IntegerFeedbackPtr i, char **buf) * */ -void +static void CopySwapStringFeedback(ClientPtr client, StringFeedbackPtr s, char **buf) { int i; @@ -303,7 +210,7 @@ CopySwapStringFeedback(ClientPtr client, StringFeedbackPtr s, char **buf) * */ -void +static void CopySwapLedFeedback(ClientPtr client, LedFeedbackPtr l, char **buf) { xLedFeedbackState *l2; @@ -328,7 +235,7 @@ CopySwapLedFeedback(ClientPtr client, LedFeedbackPtr l, char **buf) * */ -void +static void CopySwapBellFeedback(ClientPtr client, BellFeedbackPtr b, char **buf) { xBellFeedbackState *b2; @@ -364,3 +271,96 @@ SRepXGetFeedbackControl(ClientPtr client, int size, swaps(&rep->num_feedbacks); WriteToClient(client, size, rep); } + +/*********************************************************************** + * + * Get the feedback control state. + * + */ + +int +ProcXGetFeedbackControl(ClientPtr client) +{ + int total_length = 0; + char *buf, *savbuf; + DeviceIntPtr dev; + KbdFeedbackPtr k; + PtrFeedbackPtr p; + IntegerFeedbackPtr i; + StringFeedbackPtr s; + BellFeedbackPtr b; + LedFeedbackPtr l; + xGetFeedbackControlReply rep; + + REQUEST(xGetFeedbackControlReq); + REQUEST_SIZE_MATCH(xGetFeedbackControlReq); + + dev = LookupDeviceIntRec(stuff->deviceid); + if (dev == NULL) { + SendErrorToClient(client, IReqCode, X_GetFeedbackControl, 0, BadDevice); + return Success; + } + + rep.repType = X_Reply; + rep.RepType = X_GetFeedbackControl; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.num_feedbacks = 0; + + for (k = dev->kbdfeed; k; k = k->next) { + rep.num_feedbacks++; + total_length += sizeof(xKbdFeedbackState); + } + for (p = dev->ptrfeed; p; p = p->next) { + rep.num_feedbacks++; + total_length += sizeof(xPtrFeedbackState); + } + for (s = dev->stringfeed; s; s = s->next) { + rep.num_feedbacks++; + total_length += sizeof(xStringFeedbackState) + + (s->ctrl.num_symbols_supported * sizeof(KeySym)); + } + for (i = dev->intfeed; i; i = i->next) { + rep.num_feedbacks++; + total_length += sizeof(xIntegerFeedbackState); + } + for (l = dev->leds; l; l = l->next) { + rep.num_feedbacks++; + total_length += sizeof(xLedFeedbackState); + } + for (b = dev->bell; b; b = b->next) { + rep.num_feedbacks++; + total_length += sizeof(xBellFeedbackState); + } + + if (total_length == 0) { + SendErrorToClient(client, IReqCode, X_GetFeedbackControl, 0, BadMatch); + return Success; + } + + buf = (char *)malloc(total_length); + if (!buf) { + SendErrorToClient(client, IReqCode, X_GetFeedbackControl, 0, BadAlloc); + return Success; + } + savbuf = buf; + + for (k = dev->kbdfeed; k; k = k->next) + CopySwapKbdFeedback(client, k, &buf); + for (p = dev->ptrfeed; p; p = p->next) + CopySwapPtrFeedback(client, p, &buf); + for (s = dev->stringfeed; s; s = s->next) + CopySwapStringFeedback(client, s, &buf); + for (i = dev->intfeed; i; i = i->next) + CopySwapIntegerFeedback(client, i, &buf); + for (l = dev->leds; l; l = l->next) + CopySwapLedFeedback(client, l, &buf); + for (b = dev->bell; b; b = b->next) + CopySwapBellFeedback(client, b, &buf); + + rep.length = (total_length + 3) >> 2; + WriteReplyToClient(client, sizeof(xGetFeedbackControlReply), &rep); + WriteToClient(client, total_length, savbuf); + free(savbuf); + return Success; +} diff --git a/nx-X11/programs/Xserver/Xi/getfctl.h b/nx-X11/programs/Xserver/Xi/getfctl.h index 7d2d17ab14..0ad58aa2ba 100644 --- a/nx-X11/programs/Xserver/Xi/getfctl.h +++ b/nx-X11/programs/Xserver/Xi/getfctl.h @@ -36,36 +36,6 @@ int SProcXGetFeedbackControl(ClientPtr /* client */ int ProcXGetFeedbackControl(ClientPtr /* client */ ); -void CopySwapKbdFeedback(ClientPtr /* client */ , - KbdFeedbackPtr /* k */ , - char ** /* buf */ - ); - -void CopySwapPtrFeedback(ClientPtr /* client */ , - PtrFeedbackPtr /* p */ , - char ** /* buf */ - ); - -void CopySwapIntegerFeedback(ClientPtr /* client */ , - IntegerFeedbackPtr /* i */ , - char ** /* buf */ - ); - -void CopySwapStringFeedback(ClientPtr /* client */ , - StringFeedbackPtr /* s */ , - char ** /* buf */ - ); - -void CopySwapLedFeedback(ClientPtr /* client */ , - LedFeedbackPtr /* l */ , - char ** /* buf */ - ); - -void CopySwapBellFeedback(ClientPtr /* client */ , - BellFeedbackPtr /* b */ , - char ** /* buf */ - ); - void SRepXGetFeedbackControl(ClientPtr /* client */ , int /* size */ , xGetFeedbackControlReply * /* rep */ diff --git a/nx-X11/programs/Xserver/Xi/getfocus.c b/nx-X11/programs/Xserver/Xi/getfocus.c index 8d0850d736..cb083fb504 100644 --- a/nx-X11/programs/Xserver/Xi/getfocus.c +++ b/nx-X11/programs/Xserver/Xi/getfocus.c @@ -73,7 +73,7 @@ SOFTWARE. */ int -SProcXGetDeviceFocus(register ClientPtr client) +SProcXGetDeviceFocus(ClientPtr client) { REQUEST(xGetDeviceFocusReq); swaps(&stuff->length); diff --git a/nx-X11/programs/Xserver/Xi/getkmap.c b/nx-X11/programs/Xserver/Xi/getkmap.c index 87fd4ba0e3..1931dd1f11 100644 --- a/nx-X11/programs/Xserver/Xi/getkmap.c +++ b/nx-X11/programs/Xserver/Xi/getkmap.c @@ -74,7 +74,7 @@ SOFTWARE. */ int -SProcXGetDeviceKeyMapping(register ClientPtr client) +SProcXGetDeviceKeyMapping(ClientPtr client) { REQUEST(xGetDeviceKeyMappingReq); swaps(&stuff->length); @@ -88,7 +88,7 @@ SProcXGetDeviceKeyMapping(register ClientPtr client) */ int -ProcXGetDeviceKeyMapping(register ClientPtr client) +ProcXGetDeviceKeyMapping(ClientPtr client) { xGetDeviceKeyMappingReply rep; DeviceIntPtr dev; diff --git a/nx-X11/programs/Xserver/Xi/getmmap.c b/nx-X11/programs/Xserver/Xi/getmmap.c index 74b6d02b77..d96eb4bcda 100644 --- a/nx-X11/programs/Xserver/Xi/getmmap.c +++ b/nx-X11/programs/Xserver/Xi/getmmap.c @@ -73,7 +73,7 @@ SOFTWARE. */ int -SProcXGetDeviceModifierMapping(register ClientPtr client) +SProcXGetDeviceModifierMapping(ClientPtr client) { REQUEST(xGetDeviceModifierMappingReq); swaps(&stuff->length); diff --git a/nx-X11/programs/Xserver/Xi/getprop.c b/nx-X11/programs/Xserver/Xi/getprop.c index 0782194dae..bfa823424e 100644 --- a/nx-X11/programs/Xserver/Xi/getprop.c +++ b/nx-X11/programs/Xserver/Xi/getprop.c @@ -77,7 +77,7 @@ extern int ExtEventIndex; */ int -SProcXGetDeviceDontPropagateList(register ClientPtr client) +SProcXGetDeviceDontPropagateList(ClientPtr client) { REQUEST(xGetDeviceDontPropagateListReq); swaps(&stuff->length); @@ -93,7 +93,7 @@ SProcXGetDeviceDontPropagateList(register ClientPtr client) */ int -ProcXGetDeviceDontPropagateList(register ClientPtr client) +ProcXGetDeviceDontPropagateList(ClientPtr client) { CARD16 count = 0; int i; diff --git a/nx-X11/programs/Xserver/Xi/getselev.c b/nx-X11/programs/Xserver/Xi/getselev.c index 010cc83086..3ee8a5f3cc 100644 --- a/nx-X11/programs/Xserver/Xi/getselev.c +++ b/nx-X11/programs/Xserver/Xi/getselev.c @@ -75,7 +75,7 @@ SOFTWARE. */ int -SProcXGetSelectedExtensionEvents(register ClientPtr client) +SProcXGetSelectedExtensionEvents(ClientPtr client) { REQUEST(xGetSelectedExtensionEventsReq); swaps(&stuff->length); @@ -92,7 +92,7 @@ SProcXGetSelectedExtensionEvents(register ClientPtr client) */ int -ProcXGetSelectedExtensionEvents(register ClientPtr client) +ProcXGetSelectedExtensionEvents(ClientPtr client) { int i; int total_length = 0; diff --git a/nx-X11/programs/Xserver/Xi/getvers.c b/nx-X11/programs/Xserver/Xi/getvers.c index 93d9c25328..8696843692 100644 --- a/nx-X11/programs/Xserver/Xi/getvers.c +++ b/nx-X11/programs/Xserver/Xi/getvers.c @@ -74,7 +74,7 @@ XExtensionVersion AllExtensionVersions[128]; */ int -SProcXGetExtensionVersion(register ClientPtr client) +SProcXGetExtensionVersion(ClientPtr client) { REQUEST(xGetExtensionVersionReq); swaps(&stuff->length); @@ -90,7 +90,7 @@ SProcXGetExtensionVersion(register ClientPtr client) */ int -ProcXGetExtensionVersion(register ClientPtr client) +ProcXGetExtensionVersion(ClientPtr client) { xGetExtensionVersionReply rep; diff --git a/nx-X11/programs/Xserver/Xi/grabdev.c b/nx-X11/programs/Xserver/Xi/grabdev.c index 654775da38..7cfacc590a 100644 --- a/nx-X11/programs/Xserver/Xi/grabdev.c +++ b/nx-X11/programs/Xserver/Xi/grabdev.c @@ -77,7 +77,7 @@ extern int ExtEventIndex; */ int -SProcXGrabDevice(register ClientPtr client) +SProcXGrabDevice(ClientPtr client) { REQUEST(xGrabDeviceReq); swaps(&stuff->length); diff --git a/nx-X11/programs/Xserver/Xi/grabdevb.c b/nx-X11/programs/Xserver/Xi/grabdevb.c index 55336fb622..67a515042f 100644 --- a/nx-X11/programs/Xserver/Xi/grabdevb.c +++ b/nx-X11/programs/Xserver/Xi/grabdevb.c @@ -75,7 +75,7 @@ SOFTWARE. */ int -SProcXGrabDeviceButton(register ClientPtr client) +SProcXGrabDeviceButton(ClientPtr client) { REQUEST(xGrabDeviceButtonReq); swaps(&stuff->length); diff --git a/nx-X11/programs/Xserver/Xi/grabdevk.c b/nx-X11/programs/Xserver/Xi/grabdevk.c index 428452d7ef..bccae88921 100644 --- a/nx-X11/programs/Xserver/Xi/grabdevk.c +++ b/nx-X11/programs/Xserver/Xi/grabdevk.c @@ -75,7 +75,7 @@ SOFTWARE. */ int -SProcXGrabDeviceKey(register ClientPtr client) +SProcXGrabDeviceKey(ClientPtr client) { REQUEST(xGrabDeviceKeyReq); swaps(&stuff->length); diff --git a/nx-X11/programs/Xserver/Xi/gtmotion.c b/nx-X11/programs/Xserver/Xi/gtmotion.c index 2be719b4a3..aaa98e9a56 100644 --- a/nx-X11/programs/Xserver/Xi/gtmotion.c +++ b/nx-X11/programs/Xserver/Xi/gtmotion.c @@ -73,7 +73,7 @@ SOFTWARE. */ int -SProcXGetDeviceMotionEvents(register ClientPtr client) +SProcXGetDeviceMotionEvents(ClientPtr client) { REQUEST(xGetDeviceMotionEventsReq); swaps(&stuff->length); diff --git a/nx-X11/programs/Xserver/Xi/listdev.c b/nx-X11/programs/Xserver/Xi/listdev.c index 44f1286d15..ac4f7860c1 100644 --- a/nx-X11/programs/Xserver/Xi/listdev.c +++ b/nx-X11/programs/Xserver/Xi/listdev.c @@ -75,70 +75,13 @@ SOFTWARE. */ int -SProcXListInputDevices(register ClientPtr client) +SProcXListInputDevices(ClientPtr client) { REQUEST(xListInputDevicesReq); swaps(&stuff->length); return (ProcXListInputDevices(client)); } -/*********************************************************************** - * - * This procedure lists the input devices available to the server. - * - */ - -int -ProcXListInputDevices(register ClientPtr client) -{ - xListInputDevicesReply rep; - int numdevs; - int namesize = 1; /* need 1 extra byte for strcpy */ - int size = 0; - int total_length; - char *devbuf; - char *classbuf; - char *namebuf; - char *savbuf; - xDeviceInfo *dev; - DeviceIntPtr d; - - REQUEST_SIZE_MATCH(xListInputDevicesReq); - - memset(&rep, 0, sizeof(xListInputDevicesReply)); - rep.repType = X_Reply; - rep.RepType = X_ListInputDevices; - rep.length = 0; - rep.sequenceNumber = client->sequence; - - AddOtherInputDevices(); - numdevs = inputInfo.numDevices; - - for (d = inputInfo.devices; d; d = d->next) - SizeDeviceInfo(d, &namesize, &size); - for (d = inputInfo.off_devices; d; d = d->next) - SizeDeviceInfo(d, &namesize, &size); - - total_length = numdevs * sizeof(xDeviceInfo) + size + namesize; - devbuf = (char *) calloc (1, total_length); - classbuf = devbuf + (numdevs * sizeof(xDeviceInfo)); - namebuf = classbuf + size; - savbuf = devbuf; - - dev = (xDeviceInfoPtr) devbuf; - for (d = inputInfo.devices; d; d = d->next, dev++) - ListDeviceInfo(client, d, dev, &devbuf, &classbuf, &namebuf); - for (d = inputInfo.off_devices; d; d = d->next, dev++) - ListDeviceInfo(client, d, dev, &devbuf, &classbuf, &namebuf); - - rep.ndevices = numdevs; - rep.length = (total_length + 3) >> 2; - WriteReplyToClient(client, sizeof(xListInputDevicesReply), &rep); - WriteToClient(client, total_length, savbuf); - free(savbuf); - return Success; -} - /*********************************************************************** * * This procedure calculates the size of the information to be returned @@ -146,7 +89,7 @@ ProcXListInputDevices(register ClientPtr client) * */ -void +static void SizeDeviceInfo(DeviceIntPtr d, int *namesize, int *size) { int chunks; @@ -165,32 +108,6 @@ SizeDeviceInfo(DeviceIntPtr d, int *namesize, int *size) } } -/*********************************************************************** - * - * This procedure lists information to be returned for an input device. - * - */ - -void -ListDeviceInfo(ClientPtr client, DeviceIntPtr d, xDeviceInfoPtr dev, - char **devbuf, char **classbuf, char **namebuf) -{ - CopyDeviceName(namebuf, d->name); - CopySwapDevice(client, d, 0, devbuf); - if (d->key != NULL) { - CopySwapKeyClass(client, d->key, classbuf); - dev->num_classes++; - } - if (d->button != NULL) { - CopySwapButtonClass(client, d->button, classbuf); - dev->num_classes++; - } - if (d->valuator != NULL) { - dev->num_classes += - CopySwapValuatorClass(client, d->valuator, classbuf); - } -} - /*********************************************************************** * * This procedure copies data to the DeviceInfo struct, swapping if necessary. @@ -201,7 +118,7 @@ ListDeviceInfo(ClientPtr client, DeviceIntPtr d, xDeviceInfoPtr dev, * */ -void +static void CopyDeviceName(char **namebuf, char *name) { char *nameptr = (char *)*namebuf; @@ -216,14 +133,35 @@ CopyDeviceName(char **namebuf, char *name) } } +/*********************************************************************** + * + * This procedure copies ButtonClass information, swapping if necessary. + * + */ + +static void +CopySwapButtonClass(ClientPtr client, ButtonClassPtr b, char **buf) +{ + xButtonInfoPtr b2; + + b2 = (xButtonInfoPtr) * buf; + b2->class = ButtonClass; + b2->length = sizeof(xButtonInfo); + b2->num_buttons = b->numButtons; + if (client->swapped) { + swaps(&b2->num_buttons); /* macro - braces are required */ + } + *buf += sizeof(xButtonInfo); +} + /*********************************************************************** * * This procedure copies data to the DeviceInfo struct, swapping if necessary. * */ -void -CopySwapDevice(register ClientPtr client, DeviceIntPtr d, int num_classes, +static void +CopySwapDevice(ClientPtr client, DeviceIntPtr d, int num_classes, char **buf) { xDeviceInfoPtr dev; @@ -237,6 +175,10 @@ CopySwapDevice(register ClientPtr client, DeviceIntPtr d, int num_classes, dev->use = IsXKeyboard; else if (d == inputInfo.pointer) dev->use = IsXPointer; + else if (d->key && d->kbdfeed) + dev->use = IsXExtensionKeyboard; + else if (d->valuator && d->button) + dev->use = IsXExtensionPointer; else dev->use = IsXExtensionDevice; if (client->swapped) { @@ -251,8 +193,8 @@ CopySwapDevice(register ClientPtr client, DeviceIntPtr d, int num_classes, * */ -void -CopySwapKeyClass(register ClientPtr client, KeyClassPtr k, char **buf) +static void +CopySwapKeyClass(ClientPtr client, KeyClassPtr k, char **buf) { xKeyInfoPtr k2; @@ -268,27 +210,6 @@ CopySwapKeyClass(register ClientPtr client, KeyClassPtr k, char **buf) *buf += sizeof(xKeyInfo); } -/*********************************************************************** - * - * This procedure copies ButtonClass information, swapping if necessary. - * - */ - -void -CopySwapButtonClass(register ClientPtr client, ButtonClassPtr b, char **buf) -{ - xButtonInfoPtr b2; - - b2 = (xButtonInfoPtr) * buf; - b2->class = ButtonClass; - b2->length = sizeof(xButtonInfo); - b2->num_buttons = b->numButtons; - if (client->swapped) { - swaps(&b2->num_buttons); /* macro - braces are required */ - } - *buf += sizeof(xButtonInfo); -} - /*********************************************************************** * * This procedure copies ValuatorClass information, swapping if necessary. @@ -301,8 +222,8 @@ CopySwapButtonClass(register ClientPtr client, ButtonClassPtr b, char **buf) * */ -int -CopySwapValuatorClass(register ClientPtr client, ValuatorClassPtr v, char **buf) +static int +CopySwapValuatorClass(ClientPtr client, ValuatorClassPtr v, char **buf) { int i, j, axes, t_axes; xValuatorInfoPtr v2; @@ -343,6 +264,92 @@ CopySwapValuatorClass(register ClientPtr client, ValuatorClassPtr v, char **buf) return (i); } +/*********************************************************************** + * + * This procedure lists information to be returned for an input device. + * + */ + +static void +ListDeviceInfo(ClientPtr client, DeviceIntPtr d, xDeviceInfoPtr dev, + char **devbuf, char **classbuf, char **namebuf) +{ + CopyDeviceName(namebuf, d->name); + CopySwapDevice(client, d, 0, devbuf); + if (d->key != NULL) { + CopySwapKeyClass(client, d->key, classbuf); + dev->num_classes++; + } + if (d->button != NULL) { + CopySwapButtonClass(client, d->button, classbuf); + dev->num_classes++; + } + if (d->valuator != NULL) { + dev->num_classes += + CopySwapValuatorClass(client, d->valuator, classbuf); + } +} + +/*********************************************************************** + * + * This procedure lists the input devices available to the server. + * + */ + +int +ProcXListInputDevices(ClientPtr client) +{ + xListInputDevicesReply rep; + int numdevs = 0; + int namesize = 1; /* need 1 extra byte for strcpy */ + int size = 0; + int total_length; + char *devbuf; + char *classbuf; + char *namebuf; + char *savbuf; + xDeviceInfo *dev; + DeviceIntPtr d; + + REQUEST_SIZE_MATCH(xListInputDevicesReq); + + memset(&rep, 0, sizeof(xListInputDevicesReply)); + rep.repType = X_Reply; + rep.RepType = X_ListInputDevices; + rep.length = 0; + rep.sequenceNumber = client->sequence; + + AddOtherInputDevices(); + + for (d = inputInfo.devices; d; d = d->next) { + SizeDeviceInfo(d, &namesize, &size); + numdevs++; + } + for (d = inputInfo.off_devices; d; d = d->next) { + SizeDeviceInfo(d, &namesize, &size); + numdevs++; + } + + total_length = numdevs * sizeof(xDeviceInfo) + size + namesize; + devbuf = (char *) calloc (1, total_length); + classbuf = devbuf + (numdevs * sizeof(xDeviceInfo)); + namebuf = classbuf + size; + savbuf = devbuf; + + dev = (xDeviceInfoPtr) devbuf; + for (d = inputInfo.devices; d; d = d->next, dev++) + ListDeviceInfo(client, d, dev, &devbuf, &classbuf, &namebuf); + for (d = inputInfo.off_devices; d; d = d->next, dev++) + ListDeviceInfo(client, d, dev, &devbuf, &classbuf, &namebuf); + + rep.ndevices = numdevs; + rep.length = (total_length + 3) >> 2; + WriteReplyToClient(client, sizeof(xListInputDevicesReply), &rep); + WriteToClient(client, total_length, savbuf); + free(savbuf); + return Success; +} + /*********************************************************************** * * This procedure writes the reply for the XListInputDevices function, diff --git a/nx-X11/programs/Xserver/Xi/listdev.h b/nx-X11/programs/Xserver/Xi/listdev.h index bdd67ce704..db376decf4 100644 --- a/nx-X11/programs/Xserver/Xi/listdev.h +++ b/nx-X11/programs/Xserver/Xi/listdev.h @@ -36,44 +36,6 @@ int SProcXListInputDevices(ClientPtr /* client */ int ProcXListInputDevices(ClientPtr /* client */ ); -void SizeDeviceInfo(DeviceIntPtr /* d */ , - int * /* namesize */ , - int * /* size */ - ); - -void ListDeviceInfo(ClientPtr /* client */ , - DeviceIntPtr /* d */ , - xDeviceInfoPtr /* dev */ , - char ** /* devbuf */ , - char ** /* classbuf */ , - char ** /* namebuf */ - ); - -void CopyDeviceName(char ** /* namebuf */ , - char * /* name */ - ); - -void CopySwapDevice(ClientPtr /* client */ , - DeviceIntPtr /* d */ , - int /* num_classes */ , - char ** /* buf */ - ); - -void CopySwapKeyClass(ClientPtr /* client */ , - KeyClassPtr /* k */ , - char ** /* buf */ - ); - -void CopySwapButtonClass(ClientPtr /* client */ , - ButtonClassPtr /* b */ , - char ** /* buf */ - ); - -int CopySwapValuatorClass(ClientPtr /* client */ , - ValuatorClassPtr /* v */ , - char ** /* buf */ - ); - void SRepXListInputDevices(ClientPtr /* client */ , int /* size */ , xListInputDevicesReply * /* rep */ diff --git a/nx-X11/programs/Xserver/Xi/opendev.c b/nx-X11/programs/Xserver/Xi/opendev.c index e3ad4dad0a..6ff9c00833 100644 --- a/nx-X11/programs/Xserver/Xi/opendev.c +++ b/nx-X11/programs/Xserver/Xi/opendev.c @@ -77,7 +77,7 @@ extern CARD8 event_base[]; */ int -SProcXOpenDevice(register ClientPtr client) +SProcXOpenDevice(ClientPtr client) { REQUEST(xOpenDeviceReq); swaps(&stuff->length); @@ -91,10 +91,9 @@ SProcXOpenDevice(register ClientPtr client) */ int -ProcXOpenDevice(register ClientPtr client) +ProcXOpenDevice(ClientPtr client) { xInputClassInfo evbase[numInputClasses]; - Bool enableit = FALSE; int j = 0; int status = Success; xOpenDeviceReply rep; @@ -117,7 +116,6 @@ ProcXOpenDevice(register ClientPtr client) SendErrorToClient(client, IReqCode, X_OpenDevice, 0, BadDevice); return Success; } - enableit = TRUE; } OpenInputDevice(dev, client, &status); @@ -125,8 +123,6 @@ ProcXOpenDevice(register ClientPtr client) SendErrorToClient(client, IReqCode, X_OpenDevice, 0, status); return Success; } - if (enableit && dev->inited && dev->startup) - (void)EnableDevice(dev); memset(&rep, 0, sizeof(xOpenDeviceReply)); rep.repType = X_Reply; diff --git a/nx-X11/programs/Xserver/Xi/queryst.c b/nx-X11/programs/Xserver/Xi/queryst.c index f7392f9fef..fcab2f05d6 100644 --- a/nx-X11/programs/Xserver/Xi/queryst.c +++ b/nx-X11/programs/Xserver/Xi/queryst.c @@ -56,7 +56,7 @@ from The Open Group. */ int -SProcXQueryDeviceState(register ClientPtr client) +SProcXQueryDeviceState(ClientPtr client) { REQUEST(xQueryDeviceStateReq); swaps(&stuff->length); @@ -70,7 +70,7 @@ SProcXQueryDeviceState(register ClientPtr client) */ int -ProcXQueryDeviceState(register ClientPtr client) +ProcXQueryDeviceState(ClientPtr client) { int i; int num_classes = 0; diff --git a/nx-X11/programs/Xserver/Xi/selectev.c b/nx-X11/programs/Xserver/Xi/selectev.c index 5c06465894..97901a3880 100644 --- a/nx-X11/programs/Xserver/Xi/selectev.c +++ b/nx-X11/programs/Xserver/Xi/selectev.c @@ -72,6 +72,53 @@ SOFTWARE. extern Mask ExtExclusiveMasks[]; extern Mask ExtValidMasks[]; +static int +HandleDevicePresenceMask(ClientPtr client, WindowPtr win, + XEventClass *cls, CARD16 *count) +{ + int i, j; + Mask mask; + + /* We use the device ID 256 to select events that aren't bound to + * any device. For now we only handle the device presence event, + * but this could be extended to other events that aren't bound to + * a device. + * + * In order not to break in CreateMaskFromList() we remove the + * entries with device ID 256 from the XEventClass array. + */ + + mask = 0; + for (i = 0, j = 0; i < *count; i++) { + if (cls[i] >> 8 != 256) { + cls[j] = cls[i]; + j++; + continue; + } + + switch (cls[i] & 0xff) { + case _devicePresence: + mask |= DevicePresenceNotifyMask; + break; + } + } + + *count = j; + + if (mask == 0) + return Success; + + /* We always only use mksidx = 0 for events not bound to + * devices */ + + if (AddExtensionClient (win, client, mask, 0) != Success) + return BadAlloc; + + RecalculateDeviceDeliverableEvents(win); + + return Success; +} + /*********************************************************************** * * Handle requests from clients with a different byte order. @@ -79,7 +126,7 @@ extern Mask ExtValidMasks[]; */ int -SProcXSelectExtensionEvent(register ClientPtr client) +SProcXSelectExtensionEvent(ClientPtr client) { REQUEST(xSelectExtensionEventReq); swaps(&stuff->length); @@ -100,7 +147,7 @@ SProcXSelectExtensionEvent(register ClientPtr client) */ int -ProcXSelectExtensionEvent(register ClientPtr client) +ProcXSelectExtensionEvent(ClientPtr client) { int ret; int i; @@ -124,6 +171,13 @@ ProcXSelectExtensionEvent(register ClientPtr client) return Success; } + if (HandleDevicePresenceMask(client, pWin, (XEventClass *) & stuff[1], + &stuff->count) != Success) { + SendErrorToClient(client, IReqCode, X_SelectExtensionEvent, 0, + BadAlloc); + return Success; + } + if ((ret = CreateMaskFromList(client, (XEventClass *) & stuff[1], stuff->count, tmp, NULL, X_SelectExtensionEvent)) != Success) diff --git a/nx-X11/programs/Xserver/Xi/sendexev.c b/nx-X11/programs/Xserver/Xi/sendexev.c index a86829f5f5..1fb124ec54 100644 --- a/nx-X11/programs/Xserver/Xi/sendexev.c +++ b/nx-X11/programs/Xserver/Xi/sendexev.c @@ -78,10 +78,10 @@ extern int lastEvent; /* Defined in extension.c */ */ int -SProcXSendExtensionEvent(register ClientPtr client) +SProcXSendExtensionEvent(ClientPtr client) { CARD32 *p; - register int i; + int i; xEvent eventT; xEvent *eventP; EventSwapPtr proc; @@ -118,7 +118,7 @@ SProcXSendExtensionEvent(register ClientPtr client) */ int -ProcXSendExtensionEvent(register ClientPtr client) +ProcXSendExtensionEvent(ClientPtr client) { int ret; DeviceIntPtr dev; diff --git a/nx-X11/programs/Xserver/Xi/setbmap.c b/nx-X11/programs/Xserver/Xi/setbmap.c index 7f67ef7821..88333b512f 100644 --- a/nx-X11/programs/Xserver/Xi/setbmap.c +++ b/nx-X11/programs/Xserver/Xi/setbmap.c @@ -76,7 +76,7 @@ SOFTWARE. */ int -SProcXSetDeviceButtonMapping(register ClientPtr client) +SProcXSetDeviceButtonMapping(ClientPtr client) { REQUEST(xSetDeviceButtonMappingReq); swaps(&stuff->length); @@ -90,7 +90,7 @@ SProcXSetDeviceButtonMapping(register ClientPtr client) */ int -ProcXSetDeviceButtonMapping(register ClientPtr client) +ProcXSetDeviceButtonMapping(ClientPtr client) { int ret; xSetDeviceButtonMappingReply rep; @@ -130,7 +130,7 @@ ProcXSetDeviceButtonMapping(register ClientPtr client) } if (ret != MappingBusy) - SendDeviceMappingNotify(MappingPointer, 0, 0, dev); + SendDeviceMappingNotify(client, MappingPointer, 0, 0, dev); return Success; } diff --git a/nx-X11/programs/Xserver/Xi/setdval.c b/nx-X11/programs/Xserver/Xi/setdval.c index 909f03fbea..00bf1d7355 100644 --- a/nx-X11/programs/Xserver/Xi/setdval.c +++ b/nx-X11/programs/Xserver/Xi/setdval.c @@ -73,7 +73,7 @@ SOFTWARE. */ int -SProcXSetDeviceValuators(register ClientPtr client) +SProcXSetDeviceValuators(ClientPtr client) { REQUEST(xSetDeviceValuatorsReq); swaps(&stuff->length); @@ -87,7 +87,7 @@ SProcXSetDeviceValuators(register ClientPtr client) */ int -ProcXSetDeviceValuators(register ClientPtr client) +ProcXSetDeviceValuators(ClientPtr client) { DeviceIntPtr dev; xSetDeviceValuatorsReply rep; diff --git a/nx-X11/programs/Xserver/Xi/setfocus.c b/nx-X11/programs/Xserver/Xi/setfocus.c index b561832e15..1aacbc2abd 100644 --- a/nx-X11/programs/Xserver/Xi/setfocus.c +++ b/nx-X11/programs/Xserver/Xi/setfocus.c @@ -76,7 +76,7 @@ SOFTWARE. */ int -SProcXSetDeviceFocus(register ClientPtr client) +SProcXSetDeviceFocus(ClientPtr client) { REQUEST(xSetDeviceFocusReq); swaps(&stuff->length); @@ -93,10 +93,10 @@ SProcXSetDeviceFocus(register ClientPtr client) */ int -ProcXSetDeviceFocus(register ClientPtr client) +ProcXSetDeviceFocus(ClientPtr client) { int ret; - register DeviceIntPtr dev; + DeviceIntPtr dev; REQUEST(xSetDeviceFocusReq); REQUEST_SIZE_MATCH(xSetDeviceFocusReq); diff --git a/nx-X11/programs/Xserver/Xi/setmmap.c b/nx-X11/programs/Xserver/Xi/setmmap.c index cfc0819a73..7c74e0f89c 100644 --- a/nx-X11/programs/Xserver/Xi/setmmap.c +++ b/nx-X11/programs/Xserver/Xi/setmmap.c @@ -74,7 +74,7 @@ SOFTWARE. */ int -SProcXSetDeviceModifierMapping(register ClientPtr client) +SProcXSetDeviceModifierMapping(ClientPtr client) { REQUEST(xSetDeviceModifierMappingReq); swaps(&stuff->length); @@ -118,7 +118,7 @@ ProcXSetDeviceModifierMapping(ClientPtr client) if (ret == MappingSuccess || ret == MappingBusy || ret == MappingFailed) { rep.success = ret; if (ret == MappingSuccess) - SendDeviceMappingNotify(MappingModifier, 0, 0, dev); + SendDeviceMappingNotify(client, MappingModifier, 0, 0, dev); WriteReplyToClient(client, sizeof(xSetDeviceModifierMappingReply), &rep); } else { diff --git a/nx-X11/programs/Xserver/Xi/setmode.c b/nx-X11/programs/Xserver/Xi/setmode.c index da2c634feb..412171db7f 100644 --- a/nx-X11/programs/Xserver/Xi/setmode.c +++ b/nx-X11/programs/Xserver/Xi/setmode.c @@ -73,7 +73,7 @@ SOFTWARE. */ int -SProcXSetDeviceMode(register ClientPtr client) +SProcXSetDeviceMode(ClientPtr client) { REQUEST(xSetDeviceModeReq); swaps(&stuff->length); @@ -87,7 +87,7 @@ SProcXSetDeviceMode(register ClientPtr client) */ int -ProcXSetDeviceMode(register ClientPtr client) +ProcXSetDeviceMode(ClientPtr client) { DeviceIntPtr dev; xSetDeviceModeReply rep; diff --git a/nx-X11/programs/Xserver/Xi/stubs.c b/nx-X11/programs/Xserver/Xi/stubs.c index 0ba8a40011..f44d96b037 100644 --- a/nx-X11/programs/Xserver/Xi/stubs.c +++ b/nx-X11/programs/Xserver/Xi/stubs.c @@ -65,86 +65,6 @@ SOFTWARE. #include #include "XIstubs.h" -/*********************************************************************** - * - * Caller: ProcXChangeKeyboardDevice - * - * This procedure does the implementation-dependent portion of the work - * needed to change the keyboard device. - * - * The X keyboard device has a FocusRec. If the device that has been - * made into the new X keyboard did not have a FocusRec, - * ProcXChangeKeyboardDevice will allocate one for it. - * - * If you do not want clients to be able to focus the old X keyboard - * device, call DeleteFocusClassDeviceStruct to free the FocusRec. - * - * If you support input devices with keys that you do not want to be - * used as the X keyboard, you need to check for them here and return - * a BadDevice error. - * - * The default implementation is to do nothing (assume you do want - * clients to be able to focus the old X keyboard). The commented-out - * sample code shows what you might do if you don't want the default. - * - */ - -int -ChangeKeyboardDevice(DeviceIntPtr old_dev, DeviceIntPtr new_dev) -{ - /*********************************************************************** - DeleteFocusClassDeviceStruct(old_dev); * defined in xchgptr.c * - **********************************************************************/ - return BadMatch; -} - -/*********************************************************************** - * - * Caller: ProcXChangePointerDevice - * - * This procedure does the implementation-dependent portion of the work - * needed to change the pointer device. - * - * The X pointer device does not have a FocusRec. If the device that - * has been made into the new X pointer had a FocusRec, - * ProcXChangePointerDevice will free it. - * - * If you want clients to be able to focus the old pointer device that - * has now become accessible through the input extension, you need to - * add a FocusRec to it here. - * - * The XChangePointerDevice protocol request also allows the client - * to choose which axes of the new pointer device are used to move - * the X cursor in the X- and Y- directions. If the axes are different - * than the default ones, you need to keep track of that here. - * - * If you support input devices with valuators that you do not want to be - * used as the X pointer, you need to check for them here and return a - * BadDevice error. - * - * The default implementation is to do nothing (assume you don't want - * clients to be able to focus the old X pointer). The commented-out - * sample code shows what you might do if you don't want the default. - * - */ - -int -ChangePointerDevice(DeviceIntPtr old_dev, - DeviceIntPtr new_dev, unsigned char x, unsigned char y) -{ - /*********************************************************************** - InitFocusClassDeviceStruct(old_dev); * allow focusing old ptr* - - x_axis = x; * keep track of new x-axis* - y_axis = y; * keep track of new y-axis* - if (x_axis != 0 || y_axis != 1) - axes_changed = TRUE; * remember axes have changed* - else - axes_changed = FALSE; - *************************************************************************/ - return BadMatch; -} - /*********************************************************************** * * Caller: ProcXCloseDevice @@ -247,7 +167,7 @@ OpenInputDevice(DeviceIntPtr dev, ClientPtr client, int *status) */ int -SetDeviceMode(register ClientPtr client, DeviceIntPtr dev, int mode) +SetDeviceMode(ClientPtr client, DeviceIntPtr dev, int mode) { return BadMatch; } @@ -265,7 +185,7 @@ SetDeviceMode(register ClientPtr client, DeviceIntPtr dev, int mode) */ int -SetDeviceValuators(register ClientPtr client, DeviceIntPtr dev, +SetDeviceValuators(ClientPtr client, DeviceIntPtr dev, int *valuators, int first_valuator, int num_valuators) { return BadMatch; @@ -280,13 +200,44 @@ SetDeviceValuators(register ClientPtr client, DeviceIntPtr dev, */ int -ChangeDeviceControl(register ClientPtr client, DeviceIntPtr dev, +ChangeDeviceControl(ClientPtr client, DeviceIntPtr dev, xDeviceCtl * control) { switch (control->control) { case DEVICE_RESOLUTION: return (BadMatch); + case DEVICE_ABS_CALIB: + case DEVICE_ABS_AREA: + return (BadMatch); + case DEVICE_CORE: + return (BadMatch); default: return (BadMatch); } } + + +/**************************************************************************** + * + * Caller: configAddDevice (and others) + * + * Add a new device with the specified options. + * + */ +int +NewInputDeviceRequest(InputOption *options, DeviceIntPtr *pdev) +{ + return BadValue; +} + +/**************************************************************************** + * + * Caller: configRemoveDevice (and others) + * + * Remove the specified device previously added. + * + */ +void +DeleteInputDeviceRequest(DeviceIntPtr dev) +{ +} diff --git a/nx-X11/programs/Xserver/Xi/ungrdev.c b/nx-X11/programs/Xserver/Xi/ungrdev.c index f095fd1664..84d9a28cba 100644 --- a/nx-X11/programs/Xserver/Xi/ungrdev.c +++ b/nx-X11/programs/Xserver/Xi/ungrdev.c @@ -72,7 +72,7 @@ SOFTWARE. */ int -SProcXUngrabDevice(register ClientPtr client) +SProcXUngrabDevice(ClientPtr client) { REQUEST(xUngrabDeviceReq); swaps(&stuff->length); @@ -88,7 +88,7 @@ SProcXUngrabDevice(register ClientPtr client) */ int -ProcXUngrabDevice(register ClientPtr client) +ProcXUngrabDevice(ClientPtr client) { DeviceIntPtr dev; GrabPtr grab; diff --git a/nx-X11/programs/Xserver/Xi/ungrdevb.c b/nx-X11/programs/Xserver/Xi/ungrdevb.c index 9cd07555dc..1a0b24be8d 100644 --- a/nx-X11/programs/Xserver/Xi/ungrdevb.c +++ b/nx-X11/programs/Xserver/Xi/ungrdevb.c @@ -78,7 +78,7 @@ SOFTWARE. */ int -SProcXUngrabDeviceButton(register ClientPtr client) +SProcXUngrabDeviceButton(ClientPtr client) { REQUEST(xUngrabDeviceButtonReq); swaps(&stuff->length); diff --git a/nx-X11/programs/Xserver/Xi/ungrdevk.c b/nx-X11/programs/Xserver/Xi/ungrdevk.c index 8829fccc29..d8b13eef07 100644 --- a/nx-X11/programs/Xserver/Xi/ungrdevk.c +++ b/nx-X11/programs/Xserver/Xi/ungrdevk.c @@ -78,7 +78,7 @@ SOFTWARE. */ int -SProcXUngrabDeviceKey(register ClientPtr client) +SProcXUngrabDeviceKey(ClientPtr client) { REQUEST(xUngrabDeviceKeyReq); swaps(&stuff->length); diff --git a/nx-X11/programs/Xserver/code-versions.txt b/nx-X11/programs/Xserver/code-versions.txt index f5bb33621f..44958d000d 100644 --- a/nx-X11/programs/Xserver/code-versions.txt +++ b/nx-X11/programs/Xserver/code-versions.txt @@ -5,18 +5,19 @@ are at (roughly): module xorg version composite 1.12 (~ 9838b70 2012-03-21 Introduce a consistent coding style [Keith Packard]) -damageext 6.9/7.0 +damageext 1.4.2 dbe 1.4.2 -dix 1.3.0.0 -fb 7.1/1.1 +dix 1.4.2 +fb 1.4.2 GL 6.9/7.0 -mi 7.1/1.1 -miext 7.1/1.1 -os ? 7.1/1.1 + many backports, some of them from 2017 +mi 1.4.2 +miext 1.4.2 +os 1.4.2 + many backports, some of them from 2019 randr 1.18.0 record 1.4.2 -render 6.9/7.0 +render 1.4.2 Xext 1.4.2 xfixes 1.4.2 -Xi 1.3.0.0 -xkb 1.3.0.0 +Xi 1.4.2 +xkb 1.4.2 + diff --git a/nx-X11/programs/Xserver/damageext/damageext.c b/nx-X11/programs/Xserver/damageext/damageext.c index 56677e320c..3f5485bd53 100644 --- a/nx-X11/programs/Xserver/damageext/damageext.c +++ b/nx-X11/programs/Xserver/damageext/damageext.c @@ -1,6 +1,4 @@ /* - * $Id: damageext.c,v 1.6 2005/07/03 07:37:35 daniels Exp $ - * * Copyright © 2002 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its @@ -29,12 +27,12 @@ #include "damageextint.h" #include "protocol-versions.h" -unsigned char DamageReqCode; -int DamageEventBase; -int DamageErrorBase; -int DamageClientPrivateIndex; -RESTYPE DamageExtType; -RESTYPE DamageExtWinType; +static unsigned char DamageReqCode; +static int DamageEventBase; +static int DamageErrorBase; +static int DamageClientPrivateIndex; +static RESTYPE DamageExtType; +static RESTYPE DamageExtWinType; #define prScreen screenInfo.screens[0] @@ -273,20 +271,44 @@ ProcDamageSubtract (ClientPtr client) return (client->noClientException); } +static int +ProcDamageAdd (ClientPtr client) +{ + REQUEST(xDamageAddReq); + DrawablePtr pDrawable; + RegionPtr pRegion; + + REQUEST_SIZE_MATCH(xDamageAddReq); + VERIFY_REGION(pRegion, stuff->region, client, DixWriteAccess); + SECURITY_VERIFY_DRAWABLE (pDrawable, stuff->drawable, client, + DixReadAccess); + + /* The region is relative to the drawable origin, so translate it out to + * screen coordinates like damage expects. + */ + RegionTranslate(pRegion, pDrawable->x, pDrawable->y); + DamageDamageRegion(pDrawable, pRegion); + RegionTranslate(pRegion, -pDrawable->x, -pDrawable->y); + + return (client->noClientException); +} + /* Major version controls available requests */ static const int version_requests[] = { X_DamageQueryVersion, /* before client sends QueryVersion */ - X_DamageSubtract, /* Version 1 */ + X_DamageAdd, /* Version 1 */ }; #define NUM_VERSION_REQUESTS (sizeof (version_requests) / sizeof (version_requests[0])) -int (*ProcDamageVector[XDamageNumberRequests])(ClientPtr) = { +static int (*ProcDamageVector[XDamageNumberRequests])(ClientPtr) = { /*************** Version 1 ******************/ ProcDamageQueryVersion, ProcDamageCreate, ProcDamageDestroy, ProcDamageSubtract, +/*************** Version 1.1 ****************/ + ProcDamageAdd, }; @@ -351,12 +373,26 @@ SProcDamageSubtract (ClientPtr client) return (*ProcDamageVector[stuff->damageReqType]) (client); } -int (*SProcDamageVector[XDamageNumberRequests])(ClientPtr) = { +static int +SProcDamageAdd (ClientPtr client) +{ + REQUEST(xDamageAddReq); + + swaps (&stuff->length); + REQUEST_SIZE_MATCH(xDamageSubtractReq); + swapl (&stuff->drawable); + swapl (&stuff->region); + return (*ProcDamageVector[stuff->damageReqType]) (client); +} + +static int (*SProcDamageVector[XDamageNumberRequests])(ClientPtr) = { /*************** Version 1 ******************/ SProcDamageQueryVersion, SProcDamageCreate, SProcDamageDestroy, SProcDamageSubtract, +/*************** Version 1.1 ****************/ + SProcDamageAdd, }; static int @@ -419,7 +455,7 @@ FreeDamageExtWin (void * value, XID wid) return Success; } -void +static void SDamageNotifyEvent (xDamageNotifyEvent *from, xDamageNotifyEvent *to) { diff --git a/nx-X11/programs/Xserver/damageext/damageext.h b/nx-X11/programs/Xserver/damageext/damageext.h index 3d748eedf3..642800bd2e 100644 --- a/nx-X11/programs/Xserver/damageext/damageext.h +++ b/nx-X11/programs/Xserver/damageext/damageext.h @@ -1,6 +1,4 @@ /* - * $Id: damageext.h,v 1.5 2005/07/03 07:01:17 daniels Exp $ - * * Copyright © 2002 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its diff --git a/nx-X11/programs/Xserver/damageext/damageextint.h b/nx-X11/programs/Xserver/damageext/damageextint.h index ba9212ebaf..ef6eee8dd4 100644 --- a/nx-X11/programs/Xserver/damageext/damageextint.h +++ b/nx-X11/programs/Xserver/damageext/damageextint.h @@ -1,6 +1,4 @@ /* - * $Id: damageextint.h,v 1.6 2005/07/03 08:53:38 daniels Exp $ - * * Copyright © 2002 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its @@ -43,13 +41,6 @@ #include "damage.h" #include "xfixes.h" -extern unsigned char DamageReqCode; -extern int DamageEventBase; -extern int DamageErrorBase; -extern int DamageClientPrivateIndex; -extern RESTYPE DamageExtType; -extern RESTYPE DamageExtWinType; - typedef struct _DamageClient { CARD32 major_version; CARD32 minor_version; @@ -66,9 +57,6 @@ typedef struct _DamageExt { XID id; } DamageExtRec, *DamageExtPtr; -extern int (*ProcDamageVector[/*XDamageNumberRequests*/])(ClientPtr); -extern int (*SProcDamageVector[/*XDamageNumberRequests*/])(ClientPtr); - #define VERIFY_DAMAGEEXT(pDamageExt, rid, client, mode) { \ pDamageExt = SecurityLookupIDByType (client, rid, DamageExtType, mode); \ if (!pDamageExt) { \ @@ -77,10 +65,6 @@ extern int (*SProcDamageVector[/*XDamageNumberRequests*/])(ClientPtr); } \ } -void -SDamageNotifyEvent (xDamageNotifyEvent *from, - xDamageNotifyEvent *to); - void DamageExtSetCritical (ClientPtr pClient, Bool critical); diff --git a/nx-X11/programs/Xserver/dix/Imakefile b/nx-X11/programs/Xserver/dix/Imakefile index d153805df7..7f8c5a31c9 100644 --- a/nx-X11/programs/Xserver/dix/Imakefile +++ b/nx-X11/programs/Xserver/dix/Imakefile @@ -37,6 +37,7 @@ SRCS = \ dixutils.c \ extension.c \ gc.c \ + getevents.c \ globals.c \ grabs.c \ main.c \ @@ -59,6 +60,7 @@ OBJS = \ dixutils.o \ extension.o \ gc.o \ + getevents.o \ globals.o \ grabs.o \ main.o \ @@ -76,6 +78,8 @@ OBJS = \ INCLUDES = -I../include \ -I$(XINCLUDESRC) \ -I$(EXTINCSRC) \ + -I$(SERVERSRC)/Xi \ + -I$(SERVERSRC)/mi \ -I$(SERVERSRC)/Xext \ -I$(SERVERSRC)/lbx \ `pkg-config --cflags-only-I pixman-1` \ diff --git a/nx-X11/programs/Xserver/dix/atom.c b/nx-X11/programs/Xserver/dix/atom.c index c15a05bb7a..20e7d43053 100644 --- a/nx-X11/programs/Xserver/dix/atom.c +++ b/nx-X11/programs/Xserver/dix/atom.c @@ -27,13 +27,13 @@ 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, +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 +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. +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 @@ -74,13 +74,13 @@ static NodePtr *nodeTable; void FreeAtom(NodePtr patom); -Atom +Atom MakeAtom(const char *string, unsigned len, Bool makeit) { - register NodePtr * np; + NodePtr * np; unsigned i; - int comp; - register unsigned int fp = 0; + int comp; + unsigned int fp = 0; np = &atomRoot; for (i = 0; i < (len+1)/2; i++) @@ -107,7 +107,7 @@ MakeAtom(const char *string, unsigned len, Bool makeit) } if (makeit) { - register NodePtr nd; + NodePtr nd; nd = (NodePtr) malloc(sizeof(NodeRec)); if (!nd) @@ -166,7 +166,7 @@ NameForAtom(Atom atom) } void -AtomError() +AtomError(void) { FatalError("initializing atoms"); } @@ -184,7 +184,7 @@ FreeAtom(NodePtr patom) } void -FreeAllAtoms() +FreeAllAtoms(void) { if(atomRoot == (NodePtr)NULL) return; @@ -196,7 +196,7 @@ FreeAllAtoms() } void -InitAtoms() +InitAtoms(void) { FreeAllAtoms(); tableLength = InitialTableSize; @@ -209,4 +209,4 @@ InitAtoms() AtomError (); } - + diff --git a/nx-X11/programs/Xserver/dix/colormap.c b/nx-X11/programs/Xserver/dix/colormap.c index db2b64714e..f843eeac26 100644 --- a/nx-X11/programs/Xserver/dix/colormap.c +++ b/nx-X11/programs/Xserver/dix/colormap.c @@ -27,13 +27,13 @@ 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, +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 +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. +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 @@ -94,8 +94,8 @@ static int BlueComp( ); static void FreePixels( - register ColormapPtr /*pmap*/, - register int /*client*/ + ColormapPtr /*pmap*/, + int /*client*/ ); static void CopyFree( @@ -199,11 +199,11 @@ static void FindColorInRootCmap ( #define RGBMASK(vis) (vis->redMask | vis->greenMask | vis->blueMask | ALPHAMASK(vis)) -/* GetNextBitsOrBreak(bits, mask, base) -- +/* GetNextBitsOrBreak(bits, mask, base) -- * (Suggestion: First read the macro, then read this explanation. * * Either generate the next value to OR in to a pixel or break out of this - * while loop + * while loop * * This macro is used when we're trying to generate all 2^n combinations of * bits in mask. What we're doing here is counting in binary, except that @@ -215,11 +215,11 @@ static void FindColorInRootCmap ( * base has 1 bit set where the least significant bit of mask is set * * For example,if mask is 01010, base should be 0010 and we count like this: - * 00010 (see this isn't so hard), + * 00010 (see this isn't so hard), * then we add base to bits and get 0100. (bits & ~mask) is (0100 & 0100) so * we add that to bits getting (0100 + 0100) = * 01000 for our next value. - * then we add 0010 to get + * then we add 0010 to get * 01010 and we're done (easy as 1, 2, 3) */ #define GetNextBitsOrBreak(bits, mask, base) \ @@ -245,22 +245,22 @@ typedef struct _colorResource */ -/** - * Create and initialize the color map - * +/** + * Create and initialize the color map + * * \param mid resource to use for this colormap * \param alloc 1 iff all entries are allocated writable */ -int -CreateColormap (Colormap mid, ScreenPtr pScreen, VisualPtr pVisual, +int +CreateColormap (Colormap mid, ScreenPtr pScreen, VisualPtr pVisual, ColormapPtr *ppcmap, int alloc, int client) { int class, size; unsigned long sizebytes; ColormapPtr pmap; - register EntryPtr pent; + EntryPtr pent; int i; - register Pixel *ppix, **pptr; + Pixel *ppix, **pptr; class = pVisual->class; if(!(class & DynamicClass) && (alloc != AllocNone) && (client != SERVER_ID)) @@ -283,7 +283,7 @@ CreateColormap (Colormap mid, ScreenPtr pScreen, VisualPtr pVisual, pmap->pad2 = 0; #endif #endif - pmap->red = (EntryPtr)((char *)pmap + sizeof(ColormapRec)); + pmap->red = (EntryPtr)((char *)pmap + sizeof(ColormapRec)); sizebytes = size * sizeof(Entry); pmap->clientPixelsRed = (Pixel **)((char *)pmap->red + sizebytes); pmap->numPixelsRed = (int *)((char *)pmap->clientPixelsRed + @@ -427,8 +427,8 @@ CreateColormap (Colormap mid, ScreenPtr pScreen, VisualPtr pVisual, int FreeColormap (void * value, XID mid) { - int i; - register EntryPtr pent; + int i; + EntryPtr pent; ColormapPtr pmap = (ColormapPtr)value; if(CLIENT_ID(mid) != SERVER_ID) @@ -557,7 +557,7 @@ TellGainedMap (WindowPtr pwin, void * value) return (WT_WALKCHILDREN); } - + int CopyColormapAndFree (Colormap mid, ColormapPtr pSrc, int client) { @@ -743,9 +743,9 @@ static void UpdateColors (ColormapPtr pmap) { xColorItem *defs; - register xColorItem *pdef; - register EntryPtr pent; - register VisualPtr pVisual; + xColorItem *pdef; + EntryPtr pent; + VisualPtr pVisual; int i, n, size; pVisual = pmap->pVisual; @@ -807,8 +807,8 @@ UpdateColors (ColormapPtr pmap) * Returns by changing the value in pred, pgreen, pblue and pPix */ int -AllocColor (ColormapPtr pmap, - unsigned short *pred, unsigned short *pgreen, unsigned short *pblue, +AllocColor (ColormapPtr pmap, + unsigned short *pred, unsigned short *pgreen, unsigned short *pblue, Pixel *pPix, int client) { Pixel pixR, pixG, pixB; @@ -905,7 +905,7 @@ AllocColor (ColormapPtr pmap, RT_COLORMAP, DixReadAccess); if (pmap->class == prootmap->class) - FindColorInRootCmap (prootmap, prootmap->red, entries, &rgb, + FindColorInRootCmap (prootmap, prootmap->red, entries, &rgb, pPix, PSEUDOMAP, AllComp); } if (FindColor(pmap, pmap->red, entries, &rgb, pPix, PSEUDOMAP, @@ -923,31 +923,31 @@ AllocColor (ColormapPtr pmap, if (pmap->class == prootmap->class) { - pixR = (*pPix & pVisual->redMask) >> pVisual->offsetRed; - FindColorInRootCmap (prootmap, prootmap->red, entries, &rgb, + pixR = (*pPix & pVisual->redMask) >> pVisual->offsetRed; + FindColorInRootCmap (prootmap, prootmap->red, entries, &rgb, &pixR, REDMAP, RedComp); - pixG = (*pPix & pVisual->greenMask) >> pVisual->offsetGreen; - FindColorInRootCmap (prootmap, prootmap->green, entries, &rgb, + pixG = (*pPix & pVisual->greenMask) >> pVisual->offsetGreen; + FindColorInRootCmap (prootmap, prootmap->green, entries, &rgb, &pixG, GREENMAP, GreenComp); - pixB = (*pPix & pVisual->blueMask) >> pVisual->offsetBlue; - FindColorInRootCmap (prootmap, prootmap->blue, entries, &rgb, + pixB = (*pPix & pVisual->blueMask) >> pVisual->offsetBlue; + FindColorInRootCmap (prootmap, prootmap->blue, entries, &rgb, &pixB, BLUEMAP, BlueComp); *pPix = pixR | pixG | pixB; } } - pixR = (*pPix & pVisual->redMask) >> pVisual->offsetRed; + pixR = (*pPix & pVisual->redMask) >> pVisual->offsetRed; if (FindColor(pmap, pmap->red, NUMRED(pVisual), &rgb, &pixR, REDMAP, client, RedComp) != Success) return (BadAlloc); - pixG = (*pPix & pVisual->greenMask) >> pVisual->offsetGreen; + pixG = (*pPix & pVisual->greenMask) >> pVisual->offsetGreen; if (FindColor(pmap, pmap->green, NUMGREEN(pVisual), &rgb, &pixG, GREENMAP, client, GreenComp) != Success) { (void)FreeCo(pmap, client, REDMAP, 1, &pixR, (Pixel)0); return (BadAlloc); } - pixB = (*pPix & pVisual->blueMask) >> pVisual->offsetBlue; + pixB = (*pPix & pVisual->blueMask) >> pVisual->offsetBlue; if (FindColor(pmap, pmap->blue, NUMBLUE(pVisual), &rgb, &pixB, BLUEMAP, client, BlueComp) != Success) { @@ -992,14 +992,14 @@ AllocColor (ColormapPtr pmap, */ void -FakeAllocColor (register ColormapPtr pmap, register xColorItem *item) +FakeAllocColor (ColormapPtr pmap, xColorItem *item) { - Pixel pixR, pixG, pixB; - Pixel temp; - int entries; - xrgb rgb; - int class; - register VisualPtr pVisual; + Pixel pixR, pixG, pixB; + Pixel temp; + int entries; + xrgb rgb; + int class; + VisualPtr pVisual; pVisual = pmap->pVisual; rgb.red = item->red; @@ -1026,9 +1026,9 @@ FakeAllocColor (register ColormapPtr pmap, register xColorItem *item) case DirectColor: /* Look up each component in its own map, then OR them together */ - pixR = (item->pixel & pVisual->redMask) >> pVisual->offsetRed; - pixG = (item->pixel & pVisual->greenMask) >> pVisual->offsetGreen; - pixB = (item->pixel & pVisual->blueMask) >> pVisual->offsetBlue; + pixR = (item->pixel & pVisual->redMask) >> pVisual->offsetRed; + pixG = (item->pixel & pVisual->greenMask) >> pVisual->offsetGreen; + pixB = (item->pixel & pVisual->blueMask) >> pVisual->offsetBlue; if (FindColor(pmap, pmap->red, NUMRED(pVisual), &rgb, &pixR, REDMAP, -1, RedComp) != Success) pixR = FindBestPixel(pmap->red, NUMRED(pVisual), &rgb, REDMAP) @@ -1058,9 +1058,9 @@ FakeAllocColor (register ColormapPtr pmap, register xColorItem *item) /* free a pixel value obtained from FakeAllocColor */ void -FakeFreeColor(register ColormapPtr pmap, Pixel pixel) +FakeFreeColor(ColormapPtr pmap, Pixel pixel) { - register VisualPtr pVisual; + VisualPtr pVisual; Pixel pixR, pixG, pixB; switch (pmap->class) { @@ -1071,9 +1071,9 @@ FakeFreeColor(register ColormapPtr pmap, Pixel pixel) break; case DirectColor: pVisual = pmap->pVisual; - pixR = (pixel & pVisual->redMask) >> pVisual->offsetRed; - pixG = (pixel & pVisual->greenMask) >> pVisual->offsetGreen; - pixB = (pixel & pVisual->blueMask) >> pVisual->offsetBlue; + pixR = (pixel & pVisual->redMask) >> pVisual->offsetRed; + pixG = (pixel & pVisual->greenMask) >> pVisual->offsetGreen; + pixB = (pixel & pVisual->blueMask) >> pVisual->offsetBlue; if (pmap->red[pixR].refcnt == AllocTemporary) pmap->red[pixR].refcnt = 0; if (pmap->green[pixG].refcnt == AllocTemporary) @@ -1170,8 +1170,8 @@ FindBestPixel(EntryPtr pentFirst, int size, xrgb *prgb, int channel) } static void -FindColorInRootCmap (ColormapPtr pmap, EntryPtr pentFirst, int size, - xrgb *prgb, Pixel *pPixel, int channel, +FindColorInRootCmap (ColormapPtr pmap, EntryPtr pentFirst, int size, + xrgb *prgb, Pixel *pPixel, int channel, ColorCompareProcPtr comp) { EntryPtr pent; @@ -1209,8 +1209,8 @@ FindColorInRootCmap (ColormapPtr pmap, EntryPtr pentFirst, int size, * load *pPixel with that value, otherwise set it to 0 */ int -FindColor (ColormapPtr pmap, EntryPtr pentFirst, int size, xrgb *prgb, - Pixel *pPixel, int channel, int client, +FindColor (ColormapPtr pmap, EntryPtr pentFirst, int size, xrgb *prgb, + Pixel *pPixel, int channel, int client, ColorCompareProcPtr comp) { EntryPtr pent; @@ -1396,7 +1396,7 @@ AllComp (EntryPtr pent, xrgb *prgb) static int RedComp (EntryPtr pent, xrgb *prgb) { - if (pent->co.local.red == prgb->red) + if (pent->co.local.red == prgb->red) return (1); return (0); } @@ -1404,7 +1404,7 @@ RedComp (EntryPtr pent, xrgb *prgb) static int GreenComp (EntryPtr pent, xrgb *prgb) { - if (pent->co.local.green == prgb->green) + if (pent->co.local.green == prgb->green) return (1); return (0); } @@ -1412,7 +1412,7 @@ GreenComp (EntryPtr pent, xrgb *prgb) static int BlueComp (EntryPtr pent, xrgb *prgb) { - if (pent->co.local.blue == prgb->blue) + if (pent->co.local.blue == prgb->blue) return (1); return (0); } @@ -1506,11 +1506,11 @@ QueryColors (ColormapPtr pmap, int count, Pixel *ppixIn, xrgb *prgbList) } static void -FreePixels(register ColormapPtr pmap, register int client) +FreePixels(ColormapPtr pmap, int client) { - register Pixel *ppix, *ppixStart; - register int n; - int class; + Pixel *ppix, *ppixStart; + int n; + int class; class = pmap->class; ppixStart = pmap->clientPixelsRed[client]; @@ -1527,7 +1527,7 @@ FreePixels(register ColormapPtr pmap, register int client) free(ppixStart); pmap->clientPixelsRed[client] = (Pixel *) NULL; pmap->numPixelsRed[client] = 0; - if ((class | DynamicClass) == DirectColor) + if ((class | DynamicClass) == DirectColor) { ppixStart = pmap->clientPixelsGreen[client]; if (class & DynamicClass) @@ -1547,7 +1547,7 @@ FreePixels(register ColormapPtr pmap, register int client) } } -/** +/** * Frees all of a client's colors and cells. * * \param value must conform to DeleteType @@ -1567,7 +1567,7 @@ FreeClientPixels (void * value, XID fakeid) } int -AllocColorCells (int client, ColormapPtr pmap, int colors, int planes, +AllocColorCells (int client, ColormapPtr pmap, int colors, int planes, Bool contig, Pixel *ppix, Pixel *masks) { Pixel rmask, gmask, bmask, *ppixFirst, r, g, b; @@ -1639,14 +1639,14 @@ AllocColorCells (int client, ColormapPtr pmap, int colors, int planes, int -AllocColorPlanes (int client, ColormapPtr pmap, int colors, - int r, int g, int b, Bool contig, Pixel *pixels, +AllocColorPlanes (int client, ColormapPtr pmap, int colors, + int r, int g, int b, Bool contig, Pixel *pixels, Pixel *prmask, Pixel *pgmask, Pixel *pbmask) { int ok; Pixel mask, *ppixFirst; - register Pixel shift; - register int i; + Pixel shift; + int i; int class; int oldcount; colorResource *pcr = (colorResource *)NULL; @@ -1674,7 +1674,7 @@ AllocColorPlanes (int client, ColormapPtr pmap, int colors, /* Allocate the proper pixels */ /* XXX This is sort of bad, because of contig is set, we force all * r + g + b bits to be contiguous. Should only force contiguity - * per mask + * per mask */ ok = AllocPseudo (client, pmap, colors, r + g + b, contig, pixels, &mask, &ppixFirst); @@ -1729,7 +1729,7 @@ AllocColorPlanes (int client, ColormapPtr pmap, int colors, } static int -AllocDirect (int client, ColormapPtr pmap, int c, int r, int g, int b, Bool contig, +AllocDirect (int client, ColormapPtr pmap, int c, int r, int g, int b, Bool contig, Pixel *pixels, Pixel *prmask, Pixel *pgmask, Pixel *pbmask) { Pixel *ppixRed, *ppixGreen, *ppixBlue; @@ -1848,7 +1848,7 @@ AllocDirect (int client, ColormapPtr pmap, int c, int r, int g, int b, Bool cont } static int -AllocPseudo (int client, ColormapPtr pmap, int c, int r, Bool contig, +AllocPseudo (int client, ColormapPtr pmap, int c, int r, Bool contig, Pixel *pixels, Pixel *pmask, Pixel **pppixFirst) { Pixel *ppix, *p, *pDst, *ppixTemp; @@ -1898,12 +1898,12 @@ AllocPseudo (int client, ColormapPtr pmap, int c, int r, Bool contig, * pixels are the unique pixels. *pMask has the mask to Or with the * unique pixels to get the rest of them. * - * Returns True iff all pixels could be allocated + * Returns True iff all pixels could be allocated * All cells allocated will have refcnt set to AllocPrivate and shared to FALSE * (see AllocShared for why we care) */ static Bool -AllocCP (ColormapPtr pmap, EntryPtr pentFirst, int count, int planes, +AllocCP (ColormapPtr pmap, EntryPtr pentFirst, int count, int planes, Bool contig, Pixel *pixels, Pixel *pMask) { EntryPtr ent; @@ -2016,7 +2016,7 @@ AllocCP (ColormapPtr pmap, EntryPtr pentFirst, int count, int planes, If dplanes = 32, then we can't calculate (1<>> */ @@ -2078,7 +2078,7 @@ AllocCP (ColormapPtr pmap, EntryPtr pentFirst, int count, int planes, * \param ppixFirst First of the client's new pixels */ static Bool -AllocShared (ColormapPtr pmap, Pixel *ppix, int c, int r, int g, int b, +AllocShared (ColormapPtr pmap, Pixel *ppix, int c, int r, int g, int b, Pixel rmask, Pixel gmask, Pixel bmask, Pixel *ppixFirst) { Pixel *pptr, *cptr; @@ -2209,7 +2209,7 @@ AllocShared (ColormapPtr pmap, Pixel *ppix, int c, int r, int g, int b, /** FreeColors - * Free colors and/or cells (probably slow for large numbers) + * Free colors and/or cells (probably slow for large numbers) */ int FreeColors (ColormapPtr pmap, int client, int count, Pixel *pixels, Pixel mask) @@ -2253,7 +2253,7 @@ FreeColors (ColormapPtr pmap, int client, int count, Pixel *pixels, Pixel mask) /** * Helper for FreeColors -- frees all combinations of *newpixels and mask bits * which the client has allocated in channel colormap cells of pmap. - * doesn't change newpixels if it doesn't need to + * doesn't change newpixels if it doesn't need to * * \param pmap which colormap head * \param color which sub-map, eg, RED, BLUE, PSEUDO @@ -2407,10 +2407,10 @@ FreeCo (ColormapPtr pmap, int client, int color, int npixIn, Pixel *ppixIn, Pixe int StoreColors (ColormapPtr pmap, int count, xColorItem *defs) { - register Pixel pix; - register xColorItem *pdef; - register EntryPtr pent, pentT, pentLast; - register VisualPtr pVisual; + Pixel pix; + xColorItem *pdef; + EntryPtr pent, pentT, pentLast; + VisualPtr pVisual; SHAREDCOLOR *pred, *pgreen, *pblue; int n, ChgRed, ChgGreen, ChgBlue, idef; int class, errVal = Success; diff --git a/nx-X11/programs/Xserver/dix/cursor.c b/nx-X11/programs/Xserver/dix/cursor.c index 658edcb876..20ed62da66 100644 --- a/nx-X11/programs/Xserver/dix/cursor.c +++ b/nx-X11/programs/Xserver/dix/cursor.c @@ -27,13 +27,13 @@ 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, +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 +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. +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 @@ -86,7 +86,7 @@ FreeCursorBits(CursorBitsPtr bits) #endif if (bits->refcnt == 0) { - register GlyphSharePtr *prev, this; + GlyphSharePtr *prev, this; for (prev = &sharedGlyphs; (this = *prev) && (this->bits != bits); @@ -135,11 +135,11 @@ FreeCursor(void * value, XID cid) static void CheckForEmptyMask(CursorBitsPtr bits) { - register unsigned char *msk = bits->mask; + unsigned char *msk = bits->mask; int n = BitmapBytePad(bits->width) * bits->height; bits->emptyMask = FALSE; - while(n--) + while(n--) if(*(msk++) != 0) return; #ifdef ARGB_CURSOR if (bits->argb) @@ -161,10 +161,10 @@ CheckForEmptyMask(CursorBitsPtr bits) * \param pmaskbits server-defined padding * \param argb no padding */ -CursorPtr -AllocCursorARGB(unsigned char *psrcbits, unsigned char *pmaskbits, CARD32 *argb, +CursorPtr +AllocCursorARGB(unsigned char *psrcbits, unsigned char *pmaskbits, CARD32 *argb, CursorMetricPtr cm, - unsigned foreRed, unsigned foreGreen, unsigned foreBlue, + unsigned foreRed, unsigned foreGreen, unsigned foreBlue, unsigned backRed, unsigned backGreen, unsigned backBlue) { CursorBitsPtr bits; @@ -233,8 +233,8 @@ AllocCursorARGB(unsigned char *psrcbits, unsigned char *pmaskbits, CARD32 *argb, * \param psrcbits server-defined padding * \param pmaskbits server-defined padding */ -CursorPtr -AllocCursor(unsigned char *psrcbits, unsigned char *pmaskbits, +CursorPtr +AllocCursor(unsigned char *psrcbits, unsigned char *pmaskbits, CursorMetricPtr cm, unsigned foreRed, unsigned foreGreen, unsigned foreBlue, unsigned backRed, unsigned backGreen, unsigned backBlue) @@ -246,7 +246,7 @@ AllocCursor(unsigned char *psrcbits, unsigned char *pmaskbits, int AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar, - unsigned foreRed, unsigned foreGreen, unsigned foreBlue, + unsigned foreRed, unsigned foreGreen, unsigned foreBlue, unsigned backRed, unsigned backGreen, unsigned backBlue, CursorPtr *ppCurs, ClientPtr client) { @@ -305,8 +305,8 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar, } if (!maskfont) { - register long n; - register unsigned char *mskptr; + long n; + unsigned char *mskptr; n = BitmapBytePad(cm.width)*(long)cm.height; mskptr = mskbits = (unsigned char *)malloc(n); @@ -430,26 +430,42 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar, * add the cursor to the resource table *************************************************************/ -CursorPtr -CreateRootCursor(char *pfilename, unsigned glyph) +CursorPtr +CreateRootCursor(char *unused1, unsigned int unused2) { CursorPtr curs; +#ifdef NULL_ROOT_CURSOR + CursorMetricRec cm; +#else FontPtr cursorfont; int err; XID fontID; +#endif + +#ifdef NULL_ROOT_CURSOR + cm.width = 0; + cm.height = 0; + cm.xhot = 0; + cm.yhot = 0; + curs = AllocCursor(NULL, NULL, &cm, 0, 0, 0, 0, 0, 0); + + if (curs == NullCursor) + return NullCursor; +#else fontID = FakeClientID(0); err = OpenFont(serverClient, fontID, FontLoadAll | FontOpenSync, - (unsigned)strlen( pfilename), pfilename); + (unsigned)strlen(defaultCursorFont), defaultCursorFont); if (err != Success) return NullCursor; cursorfont = (FontPtr)LookupIDByType(fontID, RT_FONT); if (!cursorfont) return NullCursor; - if (AllocGlyphCursor(fontID, glyph, fontID, glyph + 1, + if (AllocGlyphCursor(fontID, 0, fontID, 1, 0, 0, 0, ~0, ~0, ~0, &curs, serverClient) != Success) return NullCursor; +#endif if (!AddResource(FakeClientID(0), RT_CURSOR, (void *)curs)) return NullCursor; diff --git a/nx-X11/programs/Xserver/dix/devices.c b/nx-X11/programs/Xserver/dix/devices.c index 37047a2aa2..4553d27c80 100644 --- a/nx-X11/programs/Xserver/dix/devices.c +++ b/nx-X11/programs/Xserver/dix/devices.c @@ -27,13 +27,13 @@ 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, +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 +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. +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 @@ -73,19 +73,52 @@ SOFTWARE. #include "swaprep.h" #include "dixevents.h" +extern void XkbFreePrivates(DeviceIntPtr device); + +#include +#include +#include "exglobals.h" +#include "exevents.h" + +/** @file + * This file handles input device-related stuff. + */ + +int CoreDevicePrivatesIndex = 0; +static int CoreDevicePrivatesGeneration = -1; + +/** + * Create a new input device and init it to sane values. The device is added + * to the server's off_devices list. + * + * @param deviceProc Callback for device control function (switch dev on/off). + * @return The newly created device. + */ DeviceIntPtr AddInputDevice(DeviceProc deviceProc, Bool autoStart) { - register DeviceIntPtr dev; + DeviceIntPtr dev, *prev; /* not a typo */ + DeviceIntPtr devtmp; + int devid; + char devind[MAX_DEVICES]; + + /* Find next available id */ + memset(devind, 0, sizeof(char)*MAX_DEVICES); + for (devtmp = inputInfo.devices; devtmp; devtmp = devtmp->next) + devind[devtmp->id]++; + for (devtmp = inputInfo.off_devices; devtmp; devtmp = devtmp->next) + devind[devtmp->id]++; + for (devid = 0; devid < MAX_DEVICES && devind[devid]; devid++) + ; - if (inputInfo.numDevices >= MAX_DEVICES) + if (devid >= MAX_DEVICES) return (DeviceIntPtr)NULL; - dev = (DeviceIntPtr) calloc(1, sizeof(DeviceIntRec)); + dev = (DeviceIntPtr) calloc(sizeof(DeviceIntRec), 1); if (!dev) return (DeviceIntPtr)NULL; dev->name = (char *)NULL; dev->type = 0; - dev->id = inputInfo.numDevices; + dev->id = devid; inputInfo.numDevices++; dev->public.on = FALSE; dev->public.processInputProc = (ProcessInputProc)NoopDDA; @@ -106,45 +139,90 @@ AddInputDevice(DeviceProc deviceProc, Bool autoStart) dev->button = (ButtonClassPtr)NULL; dev->focus = (FocusClassPtr)NULL; dev->proximity = (ProximityClassPtr)NULL; + dev->absolute = (AbsoluteClassPtr)NULL; dev->kbdfeed = (KbdFeedbackPtr)NULL; dev->ptrfeed = (PtrFeedbackPtr)NULL; dev->intfeed = (IntegerFeedbackPtr)NULL; dev->stringfeed = (StringFeedbackPtr)NULL; dev->bell = (BellFeedbackPtr)NULL; dev->leds = (LedFeedbackPtr)NULL; - dev->next = inputInfo.off_devices; #ifdef XKB - dev->xkb_interest= NULL; + dev->xkb_interest = NULL; #endif + dev->config_info = NULL; dev->nPrivates = 0; dev->devPrivates = NULL; dev->unwrapProc = NULL; - inputInfo.off_devices = dev; + dev->coreEvents = TRUE; + dev->inited = FALSE; + dev->enabled = FALSE; + + for (prev = &inputInfo.off_devices; *prev; prev = &(*prev)->next) + ; + *prev = dev; + dev->next = NULL; + return dev; } +/** + * Switch device ON through the driver and push it onto the global device + * list. All clients are notified about the device being enabled. + * + * A device will send events once enabled. + * + * @param The device to be enabled. + * @return TRUE on success or FALSE otherwise. + */ Bool -EnableDevice(register DeviceIntPtr dev) +EnableDevice(DeviceIntPtr dev) { - register DeviceIntPtr *prev; + DeviceIntPtr *prev; + int ret; + DeviceIntRec dummyDev; + devicePresenceNotify ev; for (prev = &inputInfo.off_devices; *prev && (*prev != dev); prev = &(*prev)->next) ; if ((*prev != dev) || !dev->inited || - ((*dev->deviceProc)(dev, DEVICE_ON) != Success)) + ((ret = (*dev->deviceProc)(dev, DEVICE_ON)) != Success)) { + ErrorF("couldn't enable device %d\n", dev->id); return FALSE; + } + dev->enabled = TRUE; *prev = dev->next; - dev->next = inputInfo.devices; - inputInfo.devices = dev; + + for (prev = &inputInfo.devices; *prev; prev = &(*prev)->next) + ; + *prev = dev; + dev->next = NULL; + + ev.type = DevicePresenceNotify; + ev.time = currentTime.milliseconds; + ev.devchange = DeviceEnabled; + ev.deviceid = dev->id; + dummyDev.id = 0; + SendEventToAllWindows(&dummyDev, DevicePresenceNotifyMask, + (xEvent *) &ev, 1); + return TRUE; } +/** + * Switch a device off through the driver and push it onto the off_devices + * list. A device will not send events while disabled. All clients are + * notified about the device being disabled. + * + * @return TRUE on success or FALSE otherwise. + */ Bool -DisableDevice(register DeviceIntPtr dev) +DisableDevice(DeviceIntPtr dev) { - register DeviceIntPtr *prev; + DeviceIntPtr *prev; + DeviceIntRec dummyDev; + devicePresenceNotify ev; for (prev = &inputInfo.devices; *prev && (*prev != dev); @@ -153,21 +231,274 @@ DisableDevice(register DeviceIntPtr dev) if (*prev != dev) return FALSE; (void)(*dev->deviceProc)(dev, DEVICE_OFF); + dev->enabled = FALSE; *prev = dev->next; dev->next = inputInfo.off_devices; inputInfo.off_devices = dev; + + ev.type = DevicePresenceNotify; + ev.time = currentTime.milliseconds; + ev.devchange = DeviceDisabled; + ev.deviceid = dev->id; + dummyDev.id = 0; + SendEventToAllWindows(&dummyDev, DevicePresenceNotifyMask, + (xEvent *) &ev, 1); + return TRUE; } +/** + * Initialise a new device through the driver and tell all clients about the + * new device. + * + * The device will NOT send events until it is enabled! + * + * @return Success or an error code on failure. + */ +int +ActivateDevice(DeviceIntPtr dev) +{ + int ret = Success; + devicePresenceNotify ev; + DeviceIntRec dummyDev; + + if (!dev || !dev->deviceProc) + return BadImplementation; + + ret = (*dev->deviceProc) (dev, DEVICE_INIT); + dev->inited = (ret == Success); + + ev.type = DevicePresenceNotify; + ev.time = currentTime.milliseconds; + ev.devchange = DeviceAdded; + ev.deviceid = dev->id; + dummyDev.id = 0; + SendEventToAllWindows(&dummyDev, DevicePresenceNotifyMask, + (xEvent *) &ev, 1); + + return ret; +} + +/** + * Ring the bell. + * The actual task of ringing the bell is the job of the DDX. + */ +static void +CoreKeyboardBell(int volume, DeviceIntPtr pDev, void * arg, int something) +{ + KeybdCtrl *ctrl = arg; + + DDXRingBell(volume, ctrl->bell_pitch, ctrl->bell_duration); +} + +static void +CoreKeyboardCtl(DeviceIntPtr pDev, KeybdCtrl *ctrl) +{ + return; +} + +/** + * Device control function for the Virtual Core Keyboard. + */ +static int +CoreKeyboardProc(DeviceIntPtr pDev, int what) +{ + CARD8 *modMap; + KeySymsRec keySyms; +#ifdef XKB + XkbComponentNamesRec names; +#endif + + switch (what) { + case DEVICE_INIT: + keySyms.minKeyCode = 8; + keySyms.maxKeyCode = 255; + keySyms.mapWidth = 4; + keySyms.map = (KeySym *)calloc(sizeof(KeySym), + (keySyms.maxKeyCode - + keySyms.minKeyCode + 1) * + keySyms.mapWidth); + if (!keySyms.map) { + ErrorF("Couldn't allocate core keymap\n"); + return BadAlloc; + } + + modMap = (CARD8 *)malloc(MAP_LENGTH); + if (!modMap) { + ErrorF("Couldn't allocate core modifier map\n"); + return BadAlloc; + } + bzero((char *)modMap, MAP_LENGTH); + +#ifdef XKB + if (!noXkbExtension) { + bzero(&names, sizeof(names)); + XkbSetRulesDflts("base", "pc105", "us", NULL, NULL); + XkbInitKeyboardDeviceStruct(pDev, &names, &keySyms, modMap, + CoreKeyboardBell, CoreKeyboardCtl); + } + else +#endif + { + /* FIXME Our keymap here isn't exactly useful. */ + InitKeyboardDeviceStruct((DevicePtr)pDev, &keySyms, modMap, + CoreKeyboardBell, CoreKeyboardCtl); + } + + free(keySyms.map); + free(modMap); + + break; + + case DEVICE_CLOSE: + #ifdef DEBUG + fprintf(stderr, "%s: DEVICE_CLOSE: device [%p] nPrivates [%d] name [%s] \n", + __func__, pDev, pDev->nPrivates, pDev->name); + #endif + +#ifdef XKB + if (!noXkbExtension) + { + XkbFreePrivates(pDev); + } +#endif + pDev->devPrivates[CoreDevicePrivatesIndex].ptr = NULL; + break; + + default: + break; + } + return Success; +} + +/** + * Device control function for the Virtual Core Pointer. + */ +static int +CorePointerProc(DeviceIntPtr pDev, int what) +{ + BYTE map[33]; + int i = 0; + + switch (what) { + case DEVICE_INIT: + for (i = 1; i <= 32; i++) + map[i] = i; + InitPointerDeviceStruct((DevicePtr)pDev, map, 32, + GetMotionHistory, (PtrCtrlProcPtr)NoopDDA, + GetMotionHistorySize(), 2); + pDev->valuator->axisVal[0] = screenInfo.screens[0]->width / 2; + pDev->valuator->lastx = pDev->valuator->axisVal[0]; + pDev->valuator->axisVal[1] = screenInfo.screens[0]->height / 2; + pDev->valuator->lasty = pDev->valuator->axisVal[1]; + break; + + case DEVICE_CLOSE: + #ifdef DEBUG + fprintf(stderr, "%s: DEVICE_CLOSE: device [%p] nPrivates [%d] name [%s] \n", + __func__, pDev, pDev->nPrivates, pDev->name); + #endif + +#ifdef XKB + if (!noXkbExtension) + { + XkbFreePrivates(pDev); + } +#endif + pDev->devPrivates[CoreDevicePrivatesIndex].ptr = NULL; + break; + + default: + break; + } + + return Success; +} + +/** + * Initialise the two core devices, VCP and VCK (see events.c). + * The devices are activated but not enabled. + * Note that the server MUST have two core devices at all times, even if there + * is no physical device connected. + */ +void +InitCoreDevices(void) +{ + DeviceIntPtr dev; + + if (CoreDevicePrivatesGeneration != serverGeneration) { + CoreDevicePrivatesIndex = AllocateDevicePrivateIndex(); + CoreDevicePrivatesGeneration = serverGeneration; + } + + if (!inputInfo.keyboard) { + dev = AddInputDevice(CoreKeyboardProc, TRUE); + if (!dev) + FatalError("Failed to allocate core keyboard"); + dev->name = strdup("Virtual core keyboard"); +#ifdef XKB + dev->public.processInputProc = CoreProcessKeyboardEvent; + dev->public.realInputProc = CoreProcessKeyboardEvent; + if (!noXkbExtension) + XkbSetExtension(dev, ProcessKeyboardEvent); +#else + dev->public.processInputProc = ProcessKeyboardEvent; + dev->public.realInputProc = ProcessKeyboardEvent; +#endif + dev->ActivateGrab = ActivateKeyboardGrab; + dev->DeactivateGrab = DeactivateKeyboardGrab; + dev->coreEvents = FALSE; + if (!AllocateDevicePrivate(dev, CoreDevicePrivatesIndex)) + FatalError("Couldn't allocate keyboard devPrivates\n"); + dev->devPrivates[CoreDevicePrivatesIndex].ptr = NULL; + inputInfo.keyboard = dev; + } + + if (!inputInfo.pointer) { + dev = AddInputDevice(CorePointerProc, TRUE); + if (!dev) + FatalError("Failed to allocate core pointer"); + dev->name = strdup("Virtual core pointer"); +#ifdef XKB + dev->public.processInputProc = CoreProcessPointerEvent; + dev->public.realInputProc = CoreProcessPointerEvent; + if (!noXkbExtension) + XkbSetExtension(dev, ProcessPointerEvent); +#else + dev->public.processInputProc = ProcessPointerEvent; + dev->public.realInputProc = ProcessPointerEvent; +#endif + dev->ActivateGrab = ActivatePointerGrab; + dev->DeactivateGrab = DeactivatePointerGrab; + dev->coreEvents = FALSE; + if (!AllocateDevicePrivate(dev, CoreDevicePrivatesIndex)) + FatalError("Couldn't allocate void * devPrivates\n"); + dev->devPrivates[CoreDevicePrivatesIndex].ptr = NULL; + inputInfo.pointer = dev; + } +} + +/** + * Activate all switched-off devices and then enable all those devices. + * + * Will return an error if no core keyboard or core void * is present. + * In theory this should never happen if you call InitCoreDevices() first. + * + * @return Success or error code on failure. + */ int -InitAndStartDevices() +InitAndStartDevices(void) { - register DeviceIntPtr dev, next; + DeviceIntPtr dev, next; - for (dev = inputInfo.off_devices; dev; dev = dev->next) - dev->inited = ((*dev->deviceProc)(dev, DEVICE_INIT) == Success); + for (dev = inputInfo.off_devices; dev; dev = dev->next) { + DebugF("(dix) initialising device %d\n", dev->id); + if (!dev->inited) + ActivateDevice(dev); + } for (dev = inputInfo.off_devices; dev; dev = next) { + DebugF("(dix) enabling device %d\n", dev->id); next = dev->next; if (dev->inited && dev->startup) (void)EnableDevice(dev); @@ -191,8 +522,15 @@ InitAndStartDevices() return Success; } +/** + * Close down a device and free all resources. + * Once closed down, the driver will probably not expect you that you'll ever + * enable it again and free associated structs. If you want the device to just + * be disabled, DisableDevice(). + * Don't call this function directly, use RemoveDevice() instead. + */ static void -CloseDevice(register DeviceIntPtr dev) +CloseDevice(DeviceIntPtr dev) { KbdFeedbackPtr k, knext; PtrFeedbackPtr p, pnext; @@ -218,25 +556,37 @@ CloseDevice(register DeviceIntPtr dev) if (dev->key->xkbInfo) XkbFreeInfo(dev->key->xkbInfo); #endif - dev->key->xkbInfo = NULL; + dev->key->xkbInfo = NULL; free(dev->key->curKeySyms.map); free(dev->key->modifierKeyMap); free(dev->key); } - free(dev->valuator); + + if (dev->valuator) { + /* Counterpart to 'biggest hack ever' in init. */ + if (dev->valuator->motion && + dev->valuator->GetMotionProc == GetMotionHistory) + free(dev->valuator->motion); + free(dev->valuator); + } + + if (dev->button) { #ifdef XKB - if ((dev->button)&&(dev->button->xkb_acts)) - free(dev->button->xkb_acts); + if (dev->button->xkb_acts) + free(dev->button->xkb_acts); #endif - free(dev->button); - if (dev->focus) - { + free(dev->button); + } + + if (dev->focus) { free(dev->focus->trace); free(dev->focus); } - free(dev->proximity); - for (k=dev->kbdfeed; k; k=knext) - { + + if (dev->proximity) + free(dev->proximity); + + for (k = dev->kbdfeed; k; k = knext) { knext = k->next; #ifdef XKB if (k->xkb_sli) @@ -244,30 +594,30 @@ CloseDevice(register DeviceIntPtr dev) #endif free(k); } - for (p=dev->ptrfeed; p; p=pnext) - { + + for (p = dev->ptrfeed; p; p = pnext) { pnext = p->next; free(p); } - for (i=dev->intfeed; i; i=inext) - { + + for (i = dev->intfeed; i; i = inext) { inext = i->next; free(i); } - for (s=dev->stringfeed; s; s=snext) - { + + for (s = dev->stringfeed; s; s = snext) { snext = s->next; free(s->ctrl.symbols_supported); free(s->ctrl.symbols_displayed); free(s); } - for (b=dev->bell; b; b=bnext) - { + + for (b = dev->bell; b; b = bnext) { bnext = b->next; free(b); } - for (l=dev->leds; l; l=lnext) - { + + for (l = dev->leds; l; l = lnext) { lnext = l->next; #ifdef XKB if (l->xkb_sli) @@ -281,15 +631,18 @@ CloseDevice(register DeviceIntPtr dev) #endif free(dev->devPrivates); - free(dev->sync.event); free(dev); } +/** + * Shut down all devices, free all resources, etc. + * Only useful if you're shutting down the server! + */ void -CloseDownDevices() +CloseDownDevices(void) { - register DeviceIntPtr dev, next; + DeviceIntPtr dev, next; for (dev = inputInfo.devices; dev; dev = next) { @@ -307,52 +660,75 @@ CloseDownDevices() inputInfo.pointer = NULL; } -void -RemoveDevice(register DeviceIntPtr dev) +/** + * Remove a device from the device list, closes it and thus frees all + * resources. + * Removes both enabled and disabled devices and notifies all devices about + * the removal of the device. + */ +int +RemoveDevice(DeviceIntPtr dev) { - register DeviceIntPtr prev,tmp,next; + DeviceIntPtr prev,tmp,next; + int ret = BadMatch; + devicePresenceNotify ev; + DeviceIntRec dummyDev; + int deviceid; + + DebugF("(dix) removing device %d\n", dev->id); + + if (!dev || dev == inputInfo.keyboard || dev == inputInfo.pointer) + return BadImplementation; + + deviceid = dev->id; + DisableDevice(dev); - prev= NULL; - for (tmp= inputInfo.devices; tmp; (prev = tmp), (tmp = next)) { + prev = NULL; + for (tmp = inputInfo.devices; tmp; (prev = tmp), (tmp = next)) { next = tmp->next; - if (tmp==dev) { + if (tmp == dev) { CloseDevice(tmp); + if (prev==NULL) inputInfo.devices = next; else prev->next = next; - inputInfo.numDevices--; - if (inputInfo.keyboard == tmp) - inputInfo.keyboard = NULL; - else if (inputInfo.pointer == tmp) - inputInfo.pointer = NULL; - return; + + ret = Success; } } - prev= NULL; - for (tmp= inputInfo.off_devices; tmp; (prev = tmp), (tmp = next)) { + prev = NULL; + for (tmp = inputInfo.off_devices; tmp; (prev = tmp), (tmp = next)) { next = tmp->next; - if (tmp==dev) { + if (tmp == dev) { CloseDevice(tmp); - if (prev==NULL) + + if (prev == NULL) inputInfo.off_devices = next; else prev->next = next; - inputInfo.numDevices--; - if (inputInfo.keyboard == tmp) - inputInfo.keyboard = NULL; - else if (inputInfo.pointer == tmp) - inputInfo.pointer = NULL; - return; + + ret = Success; } } - ErrorF("Internal Error! Attempt to remove a non-existent device\n"); - return; + + if (ret == Success) { + inputInfo.numDevices--; + ev.type = DevicePresenceNotify; + ev.time = currentTime.milliseconds; + ev.devchange = DeviceRemoved; + ev.deviceid = deviceid; + dummyDev.id = 0; + SendEventToAllWindows(&dummyDev, DevicePresenceNotifyMask, + (xEvent *) &ev, 1); + } + + return ret; } int -NumMotionEvents() +NumMotionEvents(void) { return inputInfo.pointer->valuator->numMotionEvents; } @@ -360,57 +736,23 @@ NumMotionEvents() void RegisterPointerDevice(DeviceIntPtr device) { - inputInfo.pointer = device; -#ifdef XKB - device->public.processInputProc = CoreProcessPointerEvent; - device->public.realInputProc = CoreProcessPointerEvent; - if (!noXkbExtension) - XkbSetExtension(device,ProcessPointerEvent); -#else - device->public.processInputProc = ProcessPointerEvent; - device->public.realInputProc = ProcessPointerEvent; -#endif - device->ActivateGrab = ActivatePointerGrab; - device->DeactivateGrab = DeactivatePointerGrab; - if (!device->name) - { - char *p = "pointer"; - device->name = (char *)malloc(strlen(p) + 1); - strcpy(device->name, p); - } + RegisterOtherDevice(device); } void RegisterKeyboardDevice(DeviceIntPtr device) { - inputInfo.keyboard = device; -#ifdef XKB - device->public.processInputProc = CoreProcessKeyboardEvent; - device->public.realInputProc = CoreProcessKeyboardEvent; - if (!noXkbExtension) - XkbSetExtension(device,ProcessKeyboardEvent); -#else - device->public.processInputProc = ProcessKeyboardEvent; - device->public.realInputProc = ProcessKeyboardEvent; -#endif - device->ActivateGrab = ActivateKeyboardGrab; - device->DeactivateGrab = DeactivateKeyboardGrab; - if (!device->name) - { - char *k = "keyboard"; - device->name = (char *)malloc(strlen(k) + 1); - strcpy(device->name, k); - } + RegisterOtherDevice(device); } DevicePtr -LookupKeyboardDevice() +LookupKeyboardDevice(void) { return inputInfo.keyboard ? &inputInfo.keyboard->public : NULL; } DevicePtr -LookupPointerDevice() +LookupPointerDevice(void) { return inputInfo.pointer ? &inputInfo.pointer->public : NULL; } @@ -441,12 +783,12 @@ QueryMinMaxKeyCodes(KeyCode *minCode, KeyCode *maxCode) } Bool -SetKeySymsMap(register KeySymsPtr dst, register KeySymsPtr src) +SetKeySymsMap(KeySymsPtr dst, KeySymsPtr src) { int i, j; int rowDif = src->minKeyCode - dst->minKeyCode; - /* if keysym map size changes, grow map first */ + /* if keysym map size changes, grow map first */ if (src->mapWidth < dst->mapWidth) { for (i = src->minKeyCode; i <= src->maxKeyCode; i++) @@ -490,7 +832,7 @@ SetKeySymsMap(register KeySymsPtr dst, register KeySymsPtr src) } static Bool -InitModMap(register KeyClassPtr keyc) +InitModMap(KeyClassPtr keyc) { int i, j; CARD8 keysPerModifier[8]; @@ -534,7 +876,7 @@ Bool InitKeyClassDeviceStruct(DeviceIntPtr dev, KeySymsPtr pKeySyms, CARD8 pModifiers[]) { int i; - register KeyClassPtr keyc; + KeyClassPtr keyc; keyc = (KeyClassPtr)calloc(1, sizeof(KeyClassRec)); if (!keyc) @@ -569,10 +911,10 @@ InitKeyClassDeviceStruct(DeviceIntPtr dev, KeySymsPtr pKeySyms, CARD8 pModifiers } Bool -InitButtonClassDeviceStruct(register DeviceIntPtr dev, int numButtons, +InitButtonClassDeviceStruct(DeviceIntPtr dev, int numButtons, CARD8 *map) { - register ButtonClassPtr butc; + ButtonClassPtr butc; int i; butc = (ButtonClassPtr)calloc(1, sizeof(ButtonClassRec)); @@ -593,35 +935,85 @@ InitButtonClassDeviceStruct(register DeviceIntPtr dev, int numButtons, } Bool -InitValuatorClassDeviceStruct(DeviceIntPtr dev, int numAxes, - ValuatorMotionProcPtr motionProc, +InitValuatorClassDeviceStruct(DeviceIntPtr dev, int numAxes, + ValuatorMotionProcPtr motionProc, int numMotionEvents, int mode) { int i; - register ValuatorClassPtr valc; + ValuatorClassPtr valc; + + if (!dev) + return FALSE; - valc = (ValuatorClassPtr)calloc(1, sizeof(ValuatorClassRec) + + valc = (ValuatorClassPtr)malloc(sizeof(ValuatorClassRec) + numAxes * sizeof(AxisInfo) + numAxes * sizeof(unsigned int)); if (!valc) return FALSE; + + valc->motion = NULL; + valc->first_motion = 0; + valc->last_motion = 0; valc->GetMotionProc = motionProc; + valc->numMotionEvents = numMotionEvents; valc->motionHintWindow = NullWindow; valc->numAxes = numAxes; valc->mode = mode; valc->axes = (AxisInfoPtr)(valc + 1); valc->axisVal = (int *)(valc->axes + numAxes); - for (i=0; iaxisVal[i]=0; + valc->lastx = 0; + valc->lasty = 0; + valc->dxremaind = 0; + valc->dyremaind = 0; dev->valuator = valc; + + /* biggest hack ever. */ + if (motionProc == GetMotionHistory) + AllocateMotionHistory(dev); + + for (i=0; iaxisVal[i]=0; + } + return TRUE; +} + +Bool +InitAbsoluteClassDeviceStruct(DeviceIntPtr dev) +{ + AbsoluteClassPtr abs; + + abs = (AbsoluteClassPtr)malloc(sizeof(AbsoluteClassRec)); + if (!abs) + return FALSE; + + /* we don't do anything sensible with these, but should */ + abs->min_x = -1; + abs->min_y = -1; + abs->max_x = -1; + abs->max_y = -1; + abs->flip_x = 0; + abs->flip_y = 0; + abs->rotation = 0; + abs->button_threshold = 0; + + abs->offset_x = 0; + abs->offset_y = 0; + abs->width = -1; + abs->height = -1; + abs->following = 0; + abs->screen = 0; + + dev->absolute = abs; + return TRUE; } Bool InitFocusClassDeviceStruct(DeviceIntPtr dev) { - register FocusClassPtr focc; + FocusClassPtr focc; focc = (FocusClassPtr)calloc(1, sizeof(FocusClassRec)); if (!focc) @@ -637,10 +1029,10 @@ InitFocusClassDeviceStruct(DeviceIntPtr dev) } Bool -InitKbdFeedbackClassDeviceStruct(DeviceIntPtr dev, BellProcPtr bellProc, +InitKbdFeedbackClassDeviceStruct(DeviceIntPtr dev, BellProcPtr bellProc, KbdCtrlProcPtr controlProc) { - register KbdFeedbackPtr feedc; + KbdFeedbackPtr feedc; feedc = (KbdFeedbackPtr)calloc(1, sizeof(KbdFeedbackClassRec)); if (!feedc) @@ -667,7 +1059,7 @@ InitKbdFeedbackClassDeviceStruct(DeviceIntPtr dev, BellProcPtr bellProc, Bool InitPtrFeedbackClassDeviceStruct(DeviceIntPtr dev, PtrCtrlProcPtr controlProc) { - register PtrFeedbackPtr feedc; + PtrFeedbackPtr feedc; feedc = (PtrFeedbackPtr)calloc(1, sizeof(PtrFeedbackClassRec)); if (!feedc) @@ -683,16 +1075,16 @@ InitPtrFeedbackClassDeviceStruct(DeviceIntPtr dev, PtrCtrlProcPtr controlProc) } -LedCtrl defaultLedControl = { +static LedCtrl defaultLedControl = { DEFAULT_LEDS, DEFAULT_LEDS_MASK, 0}; -BellCtrl defaultBellControl = { +static BellCtrl defaultBellControl = { DEFAULT_BELL, DEFAULT_BELL_PITCH, DEFAULT_BELL_DURATION, 0}; -IntegerCtrl defaultIntegerControl = { +static IntegerCtrl defaultIntegerControl = { DEFAULT_INT_RESOLUTION, DEFAULT_INT_MIN_VALUE, DEFAULT_INT_MAX_VALUE, @@ -701,22 +1093,22 @@ IntegerCtrl defaultIntegerControl = { Bool InitStringFeedbackClassDeviceStruct ( - DeviceIntPtr dev, StringCtrlProcPtr controlProc, + DeviceIntPtr dev, StringCtrlProcPtr controlProc, int max_symbols, int num_symbols_supported, KeySym *symbols) { int i; - register StringFeedbackPtr feedc; + StringFeedbackPtr feedc; - feedc = (StringFeedbackPtr)calloc(1, sizeof(StringFeedbackClassRec)); + feedc = (StringFeedbackPtr)malloc(sizeof(StringFeedbackClassRec)); if (!feedc) return FALSE; feedc->CtrlProc = controlProc; feedc->ctrl.num_symbols_supported = num_symbols_supported; feedc->ctrl.num_symbols_displayed = 0; feedc->ctrl.max_symbols = max_symbols; - feedc->ctrl.symbols_supported = (KeySym *) + feedc->ctrl.symbols_supported = (KeySym *) calloc (num_symbols_supported, sizeof (KeySym)); - feedc->ctrl.symbols_displayed = (KeySym *) + feedc->ctrl.symbols_displayed = (KeySym *) calloc (max_symbols, sizeof (KeySym)); if (!feedc->ctrl.symbols_supported || !feedc->ctrl.symbols_displayed) { @@ -740,10 +1132,10 @@ InitStringFeedbackClassDeviceStruct ( } Bool -InitBellFeedbackClassDeviceStruct (DeviceIntPtr dev, BellProcPtr bellProc, +InitBellFeedbackClassDeviceStruct (DeviceIntPtr dev, BellProcPtr bellProc, BellCtrlProcPtr controlProc) { - register BellFeedbackPtr feedc; + BellFeedbackPtr feedc; feedc = (BellFeedbackPtr)calloc(1, sizeof(BellFeedbackClassRec)); if (!feedc) @@ -762,7 +1154,7 @@ InitBellFeedbackClassDeviceStruct (DeviceIntPtr dev, BellProcPtr bellProc, Bool InitLedFeedbackClassDeviceStruct (DeviceIntPtr dev, LedCtrlProcPtr controlProc) { - register LedFeedbackPtr feedc; + LedFeedbackPtr feedc; feedc = (LedFeedbackPtr)calloc(1, sizeof(LedFeedbackClassRec)); if (!feedc) @@ -783,7 +1175,7 @@ InitLedFeedbackClassDeviceStruct (DeviceIntPtr dev, LedCtrlProcPtr controlProc) Bool InitIntegerFeedbackClassDeviceStruct (DeviceIntPtr dev, IntegerCtrlProcPtr controlProc) { - register IntegerFeedbackPtr feedc; + IntegerFeedbackPtr feedc; feedc = (IntegerFeedbackPtr)calloc(1, sizeof(IntegerFeedbackClassRec)); if (!feedc) @@ -799,22 +1191,23 @@ InitIntegerFeedbackClassDeviceStruct (DeviceIntPtr dev, IntegerCtrlProcPtr contr } Bool -InitPointerDeviceStruct(DevicePtr device, CARD8 *map, int numButtons, - ValuatorMotionProcPtr motionProc, - PtrCtrlProcPtr controlProc, int numMotionEvents) +InitPointerDeviceStruct(DevicePtr device, CARD8 *map, int numButtons, + ValuatorMotionProcPtr motionProc, + PtrCtrlProcPtr controlProc, int numMotionEvents, + int numAxes) { DeviceIntPtr dev = (DeviceIntPtr)device; return(InitButtonClassDeviceStruct(dev, numButtons, map) && - InitValuatorClassDeviceStruct(dev, 2, motionProc, + InitValuatorClassDeviceStruct(dev, numAxes, motionProc, numMotionEvents, 0) && InitPtrFeedbackClassDeviceStruct(dev, controlProc)); } Bool -InitKeyboardDeviceStruct(DevicePtr device, KeySymsPtr pKeySyms, - CARD8 pModifiers[], BellProcPtr bellProc, - KbdCtrlProcPtr controlProc) +InitKeyboardDeviceStruct(DevicePtr device, KeySymsPtr pKeySyms, + CARD8 pModifiers[], BellProcPtr bellProc, + KbdCtrlProcPtr controlProc) { DeviceIntPtr dev = (DeviceIntPtr)device; @@ -824,7 +1217,7 @@ InitKeyboardDeviceStruct(DevicePtr device, KeySymsPtr pKeySyms, } void -SendMappingNotify(unsigned request, unsigned firstKeyCode, unsigned count, +SendMappingNotify(unsigned request, unsigned firstKeyCode, unsigned count, ClientPtr client) { int i; @@ -839,10 +1232,9 @@ SendMappingNotify(unsigned request, unsigned firstKeyCode, unsigned count, } #ifdef XKB if (!noXkbExtension && - ((request == MappingKeyboard) || (request == MappingModifier))) { - XkbApplyMappingChange(inputInfo.keyboard,request,firstKeyCode,count, - client); - } + ((request == MappingKeyboard) || (request == MappingModifier))) + XkbApplyMappingChange(inputInfo.keyboard, request, firstKeyCode, count, + client); #endif /* 0 is the server client */ @@ -868,9 +1260,9 @@ SendMappingNotify(unsigned request, unsigned firstKeyCode, unsigned count, * sort it to do the checking. How often is it called? Just being lazy? */ Bool -BadDeviceMap(register BYTE *buff, int length, unsigned low, unsigned high, XID *errval) +BadDeviceMap(BYTE *buff, int length, unsigned low, unsigned high, XID *errval) { - register int i, j; + int i, j; for (i = 0; i < length; i++) if (buff[i]) /* only check non-zero elements */ @@ -892,12 +1284,12 @@ BadDeviceMap(register BYTE *buff, int length, unsigned low, unsigned high, XID * Bool AllModifierKeysAreUp(dev, map1, per1, map2, per2) - register DeviceIntPtr dev; - register CARD8 *map1, *map2; + DeviceIntPtr dev; + CARD8 *map1, *map2; int per1, per2; { - register int i, j, k; - register CARD8 *down = dev->key->down; + int i, j, k; + CARD8 *down = dev->key->down; for (i = 8; --i >= 0; map2 += per2) { @@ -915,119 +1307,112 @@ AllModifierKeysAreUp(dev, map1, per1, map2, per2) return TRUE; } -int +static int +DoSetModifierMapping(ClientPtr client, KeyCode *inputMap, + int numKeyPerModifier) +{ + DeviceIntPtr pDev = NULL; + int i = 0, inputMapLen = numKeyPerModifier * 8; + + for (pDev = inputInfo.devices; pDev; pDev = pDev->next) { + if ((pDev->coreEvents || pDev == inputInfo.keyboard) && pDev->key) { + for (i = 0; i < inputMapLen; i++) { + /* Check that all the new modifiers fall within the advertised + * keycode range, and are okay with the DDX. */ + if (inputMap[i] && ((inputMap[i] < pDev->key->curKeySyms.minKeyCode || + inputMap[i] > pDev->key->curKeySyms.maxKeyCode) || + !LegalModifier(inputMap[i], pDev))) { + client->errorValue = inputMap[i]; + return BadValue; + } + } + +#ifdef XCSECURITY + if (!SecurityCheckDeviceAccess(client, pDev, TRUE)) + return BadAccess; +#endif + + /* None of the modifiers (old or new) may be down while we change + * the map. */ + if (!AllModifierKeysAreUp(pDev, pDev->key->modifierKeyMap, + pDev->key->maxKeysPerModifier, + inputMap, numKeyPerModifier) || + !AllModifierKeysAreUp(pDev, inputMap, numKeyPerModifier, + pDev->key->modifierKeyMap, + pDev->key->maxKeysPerModifier)) { + return MappingBusy; + } + } + } + + for (pDev = inputInfo.devices; pDev; pDev = pDev->next) { + + if ((pDev->coreEvents || pDev == inputInfo.keyboard) && pDev->key) { + bzero(pDev->key->modifierMap, MAP_LENGTH); + + /* Annoyingly, we lack a modifierKeyMap size, so we have to just free + * and re-alloc it every time. */ + if (pDev->key->modifierKeyMap) + free(pDev->key->modifierKeyMap); + + if (inputMapLen) { + pDev->key->modifierKeyMap = (KeyCode *) malloc(inputMapLen); + if (!pDev->key->modifierKeyMap) + return BadAlloc; + + memcpy(pDev->key->modifierKeyMap, inputMap, inputMapLen); + pDev->key->maxKeysPerModifier = numKeyPerModifier; + + for (i = 0; i < inputMapLen; i++) { + if (inputMap[i]) { + pDev->key->modifierMap[inputMap[i]] |= + (1 << (((unsigned int)i) / numKeyPerModifier)); + } + } + } + else { + pDev->key->modifierKeyMap = NULL; + pDev->key->maxKeysPerModifier = 0; + } + } + } + + return Success; +} + +int ProcSetModifierMapping(ClientPtr client) { xSetModifierMappingReply rep = {0}; + DeviceIntPtr dev; REQUEST(xSetModifierMappingReq); - KeyCode *inputMap; - int inputMapLen; - register int i; - DeviceIntPtr keybd = inputInfo.keyboard; - register KeyClassPtr keyc = keybd->key; - + REQUEST_AT_LEAST_SIZE(xSetModifierMappingReq); - if (client->req_len != ((stuff->numKeyPerModifier<<1) + - (sizeof (xSetModifierMappingReq)>>2))) + if (client->req_len != ((stuff->numKeyPerModifier << 1) + + (sizeof (xSetModifierMappingReq) >> 2))) return BadLength; - inputMapLen = 8*stuff->numKeyPerModifier; - inputMap = (KeyCode *)&stuff[1]; - - /* - * Now enforce the restriction that "all of the non-zero keycodes must be - * in the range specified by min-keycode and max-keycode in the - * connection setup (else a Value error)" - */ - i = inputMapLen; - while (i--) - { - if (inputMap[i] - && (inputMap[i] < keyc->curKeySyms.minKeyCode - || inputMap[i] > keyc->curKeySyms.maxKeyCode)) - { - client->errorValue = inputMap[i]; - return BadValue; - } - } - -#ifdef XCSECURITY - if (!SecurityCheckDeviceAccess(client, keybd, TRUE)) - return BadAccess; -#endif - rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; - rep.success = MappingSuccess; - - /* - * Now enforce the restriction that none of the old or new - * modifier keys may be down while we change the mapping, and - * that the DDX layer likes the choice. - */ - if (!AllModifierKeysAreUp(keybd, keyc->modifierKeyMap, - (int)keyc->maxKeysPerModifier, - inputMap, (int)stuff->numKeyPerModifier) - || - !AllModifierKeysAreUp(keybd, inputMap, (int)stuff->numKeyPerModifier, - keyc->modifierKeyMap, - (int)keyc->maxKeysPerModifier)) - { - rep.success = MappingBusy; - } - else - { - for (i = 0; i < inputMapLen; i++) - { - if (inputMap[i] && !LegalModifier(inputMap[i], (DevicePtr)keybd)) - { - rep.success = MappingFailed; - break; - } - } - } - - if (rep.success == MappingSuccess) - { - KeyCode *map; - /* - * Now build the keyboard's modifier bitmap from the - * list of keycodes. - */ - map = (KeyCode *)malloc(inputMapLen); - if (!map && inputMapLen) - return BadAlloc; - if (keyc->modifierKeyMap) - free(keyc->modifierKeyMap); - keyc->modifierKeyMap = map; - memmove((char *)map, (char *)inputMap, inputMapLen); - - keyc->maxKeysPerModifier = stuff->numKeyPerModifier; - for (i = 0; i < MAP_LENGTH; i++) - keyc->modifierMap[i] = 0; - for (i = 0; i < inputMapLen; i++) - { - if (inputMap[i]) - keyc->modifierMap[inputMap[i]] |= - (1<<(((unsigned int)i)/keyc->maxKeysPerModifier)); - } - } - if (rep.success == MappingSuccess) - SendMappingNotify(MappingModifier, 0, 0, client); + rep.success = DoSetModifierMapping(client, (KeyCode *)&stuff[1], + stuff->numKeyPerModifier); + SendMappingNotify(MappingModifier, 0, 0, client); + for (dev = inputInfo.devices; dev; dev = dev->next) + if (dev->key && dev->coreEvents) + SendDeviceMappingNotify(client, MappingModifier, 0, 0, dev); WriteReplyToClient(client, sizeof(xSetModifierMappingReply), &rep); - - return(client->noClientException); + return client->noClientException; } int ProcGetModifierMapping(ClientPtr client) { xGetModifierMappingReply rep = {0}; - register KeyClassPtr keyc = inputInfo.keyboard->key; + KeyClassPtr keyc = inputInfo.keyboard->key; REQUEST_SIZE_MATCH(xReq); rep.type = X_Reply; @@ -1050,40 +1435,83 @@ ProcChangeKeyboardMapping(ClientPtr client) REQUEST(xChangeKeyboardMappingReq); unsigned len; KeySymsRec keysyms; - register KeySymsPtr curKeySyms = &inputInfo.keyboard->key->curKeySyms; + KeySymsPtr curKeySyms = &inputInfo.keyboard->key->curKeySyms; + DeviceIntPtr pDev = NULL; REQUEST_AT_LEAST_SIZE(xChangeKeyboardMappingReq); - len = client->req_len - (sizeof(xChangeKeyboardMappingReq) >> 2); + len = client->req_len - (sizeof(xChangeKeyboardMappingReq) >> 2); if (len != (stuff->keyCodes * stuff->keySymsPerKeyCode)) return BadLength; + if ((stuff->firstKeyCode < curKeySyms->minKeyCode) || - (stuff->firstKeyCode > curKeySyms->maxKeyCode)) - { + (stuff->firstKeyCode > curKeySyms->maxKeyCode)) { client->errorValue = stuff->firstKeyCode; return BadValue; + } - if ( ((unsigned)(stuff->firstKeyCode + stuff->keyCodes - 1) > - curKeySyms->maxKeyCode) || - (stuff->keySymsPerKeyCode == 0)) - { + if (((unsigned)(stuff->firstKeyCode + stuff->keyCodes - 1) > + curKeySyms->maxKeyCode) || (stuff->keySymsPerKeyCode == 0)) { client->errorValue = stuff->keySymsPerKeyCode; return BadValue; } + + for (pDev = inputInfo.devices; pDev; pDev = pDev->next) { + if ((pDev->coreEvents || pDev == inputInfo.keyboard) && pDev->key) { #ifdef XCSECURITY - if (!SecurityCheckDeviceAccess(client, inputInfo.keyboard, - TRUE)) - return BadAccess; -#endif + if (!SecurityCheckDeviceAccess(client, pDev, TRUE)) + return BadAccess; +#endif + } + } + keysyms.minKeyCode = stuff->firstKeyCode; keysyms.maxKeyCode = stuff->firstKeyCode + stuff->keyCodes - 1; keysyms.mapWidth = stuff->keySymsPerKeyCode; keysyms.map = (KeySym *)&stuff[1]; - if (!SetKeySymsMap(curKeySyms, &keysyms)) - return BadAlloc; + for (pDev = inputInfo.devices; pDev; pDev = pDev->next) + if ((pDev->coreEvents || pDev == inputInfo.keyboard) && pDev->key) + if (!SetKeySymsMap(&pDev->key->curKeySyms, &keysyms)) + return BadAlloc; + SendMappingNotify(MappingKeyboard, stuff->firstKeyCode, stuff->keyCodes, - client); + client); + for (pDev = inputInfo.devices; pDev; pDev = pDev->next) + if (pDev->key && pDev->coreEvents) + SendDeviceMappingNotify(client, MappingKeyboard, + stuff->firstKeyCode, stuff->keyCodes, + pDev); + return client->noClientException; +} + +static int +DoSetPointerMapping(DeviceIntPtr device, BYTE *map, int n) +{ + int i = 0; + DeviceIntPtr dev = NULL; + + if (!device || !device->button) + return BadDevice; + + for (dev = inputInfo.devices; dev; dev = dev->next) { + if ((dev->coreEvents || dev == inputInfo.pointer) && dev->button) { + for (i = 0; i < n; i++) { + if ((device->button->map[i + 1] != map[i]) && + BitIsOn(device->button->down, i + 1)) { + return MappingBusy; + } + } + } + } + for (dev = inputInfo.devices; dev; dev = dev->next) { + if ((dev->coreEvents || dev == inputInfo.pointer) && dev->button) { + for (i = 0; i < n; i++) + dev->button->map[i + 1] = map[i]; + } + } + + return Success; } int @@ -1091,9 +1519,8 @@ ProcSetPointerMapping(ClientPtr client) { REQUEST(xSetPointerMappingReq); BYTE *map; + int ret; xSetPointerMappingReply rep = {0}; - register unsigned int i; - DeviceIntPtr mouse = inputInfo.pointer; REQUEST_AT_LEAST_SIZE(xSetPointerMappingReq); if (client->req_len != (sizeof(xSetPointerMappingReq)+stuff->nElts+3) >> 2) @@ -1103,23 +1530,24 @@ ProcSetPointerMapping(ClientPtr client) rep.sequenceNumber = client->sequence; rep.success = MappingSuccess; map = (BYTE *)&stuff[1]; - if (stuff->nElts != mouse->button->numButtons) - { + + /* So we're bounded here by the number of core buttons. This check + * probably wants disabling through XFixes. */ + if (stuff->nElts != inputInfo.pointer->button->numButtons) { client->errorValue = stuff->nElts; return BadValue; } if (BadDeviceMap(&map[0], (int)stuff->nElts, 1, 255, &client->errorValue)) return BadValue; - for (i=0; i < stuff->nElts; i++) - if ((mouse->button->map[i + 1] != map[i]) && - BitIsOn(mouse->button->down, i + 1)) - { - rep.success = MappingBusy; - WriteReplyToClient(client, sizeof(xSetPointerMappingReply), &rep); - return Success; - } - for (i = 0; i < stuff->nElts; i++) - mouse->button->map[i + 1] = map[i]; + + ret = DoSetPointerMapping(inputInfo.pointer, map, stuff->nElts); + if (ret != Success) { + rep.success = ret; + WriteReplyToClient(client, sizeof(xSetPointerMappingReply), &rep); + return Success; + } + + /* FIXME: Send mapping notifies for all the extended devices as well. */ SendMappingNotify(MappingPointer, 0, 0, client); WriteReplyToClient(client, sizeof(xSetPointerMappingReply), &rep); return Success; @@ -1135,14 +1563,12 @@ ProcGetKeyboardMapping(ClientPtr client) REQUEST_SIZE_MATCH(xGetKeyboardMappingReq); if ((stuff->firstKeyCode < curKeySyms->minKeyCode) || - (stuff->firstKeyCode > curKeySyms->maxKeyCode)) - { + (stuff->firstKeyCode > curKeySyms->maxKeyCode)) { client->errorValue = stuff->firstKeyCode; return BadValue; } if (stuff->firstKeyCode + stuff->count > - (unsigned)(curKeySyms->maxKeyCode + 1)) - { + (unsigned)(curKeySyms->maxKeyCode + 1)) { client->errorValue = stuff->count; return BadValue; } @@ -1196,50 +1622,37 @@ NoteLedState(DeviceIntPtr keybd, int led, Bool on) int Ones(unsigned long mask) /* HACKMEM 169 */ { - register unsigned long y; + unsigned long y; y = (mask >> 1) &033333333333; y = mask - y - ((y >>1) & 033333333333); return (((y + (y >> 3)) & 030707070707) % 077); } -int -ProcChangeKeyboardControl (ClientPtr client) +static int +DoChangeKeyboardControl (ClientPtr client, DeviceIntPtr keybd, XID *vlist, + BITS32 vmask) { #define DO_ALL (-1) KeybdCtrl ctrl; - DeviceIntPtr keybd = inputInfo.keyboard; - XID *vlist; int t; int led = DO_ALL; int key = DO_ALL; - BITS32 vmask, index2; - int mask, i; - REQUEST(xChangeKeyboardControlReq); + BITS32 index2; + int mask = vmask, i; - REQUEST_AT_LEAST_SIZE(xChangeKeyboardControlReq); - vmask = stuff->mask; - if (client->req_len != (sizeof(xChangeKeyboardControlReq)>>2)+Ones(vmask)) - return BadLength; -#ifdef XCSECURITY - if (!SecurityCheckDeviceAccess(client, keybd, TRUE)) - return BadAccess; -#endif - vlist = (XID *)&stuff[1]; /* first word of values */ ctrl = keybd->kbdfeed->ctrl; - while (vmask) - { + while (vmask) { index2 = (BITS32) lowbit (vmask); vmask &= ~index2; - switch (index2) - { - case KBKeyClickPercent: + switch (index2) { + case KBKeyClickPercent: t = (INT8)*vlist; vlist++; - if (t == -1) + if (t == -1) { t = defaultKeyboardControl.click; - else if (t < 0 || t > 100) - { + } + else if (t < 0 || t > 100) { client->errorValue = t; return BadValue; } @@ -1248,10 +1661,10 @@ ProcChangeKeyboardControl (ClientPtr client) case KBBellPercent: t = (INT8)*vlist; vlist++; - if (t == -1) + if (t == -1) { t = defaultKeyboardControl.bell; - else if (t < 0 || t > 100) - { + } + else if (t < 0 || t > 100) { client->errorValue = t; return BadValue; } @@ -1260,10 +1673,10 @@ ProcChangeKeyboardControl (ClientPtr client) case KBBellPitch: t = (INT16)*vlist; vlist++; - if (t == -1) + if (t == -1) { t = defaultKeyboardControl.bell_pitch; - else if (t < 0) - { + } + else if (t < 0) { client->errorValue = t; return BadValue; } @@ -1274,8 +1687,7 @@ ProcChangeKeyboardControl (ClientPtr client) vlist++; if (t == -1) t = defaultKeyboardControl.bell_duration; - else if (t < 0) - { + else if (t < 0) { client->errorValue = t; return BadValue; } @@ -1284,56 +1696,51 @@ ProcChangeKeyboardControl (ClientPtr client) case KBLed: led = (CARD8)*vlist; vlist++; - if (led < 1 || led > 32) - { + if (led < 1 || led > 32) { client->errorValue = led; return BadValue; } - if (!(stuff->mask & KBLedMode)) + if (!(mask & KBLedMode)) return BadMatch; break; case KBLedMode: t = (CARD8)*vlist; vlist++; - if (t == LedModeOff) - { + if (t == LedModeOff) { if (led == DO_ALL) ctrl.leds = 0x0; else ctrl.leds &= ~(((Leds)(1)) << (led - 1)); } - else if (t == LedModeOn) - { + else if (t == LedModeOn) { if (led == DO_ALL) ctrl.leds = ~0L; else ctrl.leds |= (((Leds)(1)) << (led - 1)); } - else - { + else { client->errorValue = t; return BadValue; } #ifdef XKB - if (!noXkbExtension) { - XkbEventCauseRec cause; - XkbSetCauseCoreReq(&cause,X_ChangeKeyboardControl,client); - XkbSetIndicators(keybd,((led == DO_ALL) ? ~0L : (1L<<(led-1))), + if (!noXkbExtension) { + XkbEventCauseRec cause; + XkbSetCauseCoreReq(&cause,X_ChangeKeyboardControl,client); + XkbSetIndicators(keybd,((led == DO_ALL) ? ~0L : (1L<<(led-1))), ctrl.leds, &cause); - ctrl.leds = keybd->kbdfeed->ctrl.leds; - } + ctrl.leds = keybd->kbdfeed->ctrl.leds; + } #endif break; case KBKey: key = (KeyCode)*vlist; vlist++; if ((KeyCode)key < inputInfo.keyboard->key->curKeySyms.minKeyCode || - (KeyCode)key > inputInfo.keyboard->key->curKeySyms.maxKeyCode) - { + (KeyCode)key > inputInfo.keyboard->key->curKeySyms.maxKeyCode) { client->errorValue = key; return BadValue; } - if (!(stuff->mask & KBAutoRepeatMode)) + if (!(mask & KBAutoRepeatMode)) return BadMatch; break; case KBAutoRepeatMode: @@ -1342,25 +1749,22 @@ ProcChangeKeyboardControl (ClientPtr client) t = (CARD8)*vlist; vlist++; #ifdef XKB - if (!noXkbExtension && key != DO_ALL) - XkbDisableComputedAutoRepeats(keybd,key); + if (!noXkbExtension && key != DO_ALL) + XkbDisableComputedAutoRepeats(keybd,key); #endif - if (t == AutoRepeatModeOff) - { + if (t == AutoRepeatModeOff) { if (key == DO_ALL) ctrl.autoRepeat = FALSE; else ctrl.autoRepeats[i] &= ~mask; } - else if (t == AutoRepeatModeOn) - { + else if (t == AutoRepeatModeOn) { if (key == DO_ALL) ctrl.autoRepeat = TRUE; else ctrl.autoRepeats[i] |= mask; } - else if (t == AutoRepeatModeDefault) - { + else if (t == AutoRepeatModeDefault) { if (key == DO_ALL) ctrl.autoRepeat = defaultKeyboardControl.autoRepeat; else @@ -1368,36 +1772,76 @@ ProcChangeKeyboardControl (ClientPtr client) (ctrl.autoRepeats[i] & ~mask) | (defaultKeyboardControl.autoRepeats[i] & mask); } - else - { + else { client->errorValue = t; return BadValue; } break; default: - client->errorValue = stuff->mask; + client->errorValue = mask; return BadValue; } } keybd->kbdfeed->ctrl = ctrl; + #ifdef XKB /* The XKB RepeatKeys control and core protocol global autorepeat */ /* value are linked */ - if (!noXkbExtension) { - XkbSetRepeatKeys(keybd,key,keybd->kbdfeed->ctrl.autoRepeat); - } + if (!noXkbExtension) + XkbSetRepeatKeys(keybd, key, keybd->kbdfeed->ctrl.autoRepeat); else #endif - (*keybd->kbdfeed->CtrlProc)(keybd, &keybd->kbdfeed->ctrl); + (*keybd->kbdfeed->CtrlProc)(keybd, &keybd->kbdfeed->ctrl); + return Success; + #undef DO_ALL -} +} + +int +ProcChangeKeyboardControl (ClientPtr client) +{ + XID *vlist; + BITS32 vmask; + int ret = Success, error = Success; + DeviceIntPtr pDev = NULL; + REQUEST(xChangeKeyboardControlReq); + + REQUEST_AT_LEAST_SIZE(xChangeKeyboardControlReq); + + vmask = stuff->mask; + vlist = (XID *)&stuff[1]; + + if (client->req_len != (sizeof(xChangeKeyboardControlReq)>>2)+Ones(vmask)) + return BadLength; + + for (pDev = inputInfo.devices; pDev; pDev = pDev->next) { + if ((pDev->coreEvents || pDev == inputInfo.keyboard) && + pDev->kbdfeed && pDev->kbdfeed->CtrlProc) { +#ifdef XCSECURITY + if (!SecurityCheckDeviceAccess(client, pDev, TRUE)) + return BadAccess; +#endif + } + } + + for (pDev = inputInfo.devices; pDev; pDev = pDev->next) { + if ((pDev->coreEvents || pDev == inputInfo.keyboard) && + pDev->kbdfeed && pDev->kbdfeed->CtrlProc) { + ret = DoChangeKeyboardControl(client, pDev, vlist, vmask); + if (ret != Success) + error = ret; + } + } + + return error; +} int ProcGetKeyboardControl (ClientPtr client) { int i; - register KeybdCtrl *ctrl = &inputInfo.keyboard->kbdfeed->ctrl; + KeybdCtrl *ctrl = &inputInfo.keyboard->kbdfeed->ctrl; xGetKeyboardControlReply rep = {0}; REQUEST_SIZE_MATCH(xReq); @@ -1414,36 +1858,47 @@ ProcGetKeyboardControl (ClientPtr client) rep.map[i] = ctrl->autoRepeats[i]; WriteReplyToClient(client, sizeof(xGetKeyboardControlReply), &rep); return Success; -} +} int ProcBell(ClientPtr client) { - register DeviceIntPtr keybd = inputInfo.keyboard; + DeviceIntPtr keybd = inputInfo.keyboard; int base = keybd->kbdfeed->ctrl.bell; int newpercent; REQUEST(xBellReq); REQUEST_SIZE_MATCH(xBellReq); - if (stuff->percent < -100 || stuff->percent > 100) - { + + if (!keybd->kbdfeed->BellProc) + return BadDevice; + + if (stuff->percent < -100 || stuff->percent > 100) { client->errorValue = stuff->percent; return BadValue; } + newpercent = (base * stuff->percent) / 100; if (stuff->percent < 0) newpercent = base + newpercent; else newpercent = base - newpercent + stuff->percent; + + for (keybd = inputInfo.devices; keybd; keybd = keybd->next) { + if ((keybd->coreEvents || keybd == inputInfo.keyboard) && + keybd->kbdfeed && keybd->kbdfeed->BellProc) { #ifdef XKB - if (!noXkbExtension) - XkbHandleBell(FALSE,FALSE, keybd, newpercent, &keybd->kbdfeed->ctrl, 0, - None, NULL, client); - else + if (!noXkbExtension) + XkbHandleBell(FALSE, FALSE, keybd, newpercent, + &keybd->kbdfeed->ctrl, 0, None, NULL, client); + else #endif - (*keybd->kbdfeed->BellProc)(newpercent, keybd, - (void *) &keybd->kbdfeed->ctrl, 0); + (*keybd->kbdfeed->BellProc)(newpercent, keybd, + &keybd->kbdfeed->ctrl, 0); + } + } + return Success; -} +} int ProcChangePointerControl(ClientPtr client) @@ -1453,56 +1908,71 @@ ProcChangePointerControl(ClientPtr client) REQUEST(xChangePointerControlReq); REQUEST_SIZE_MATCH(xChangePointerControlReq); + + if (!mouse->ptrfeed->CtrlProc) + return BadDevice; + ctrl = mouse->ptrfeed->ctrl; - if ((stuff->doAccel != xTrue) && (stuff->doAccel != xFalse)) - { + if ((stuff->doAccel != xTrue) && (stuff->doAccel != xFalse)) { client->errorValue = stuff->doAccel; return(BadValue); } - if ((stuff->doThresh != xTrue) && (stuff->doThresh != xFalse)) - { + if ((stuff->doThresh != xTrue) && (stuff->doThresh != xFalse)) { client->errorValue = stuff->doThresh; return(BadValue); } - if (stuff->doAccel) - { - if (stuff->accelNum == -1) + if (stuff->doAccel) { + if (stuff->accelNum == -1) { ctrl.num = defaultPointerControl.num; - else if (stuff->accelNum < 0) - { + } + else if (stuff->accelNum < 0) { client->errorValue = stuff->accelNum; return BadValue; } - else ctrl.num = stuff->accelNum; - if (stuff->accelDenum == -1) + else { + ctrl.num = stuff->accelNum; + } + + if (stuff->accelDenum == -1) { ctrl.den = defaultPointerControl.den; - else if (stuff->accelDenum <= 0) - { + } + else if (stuff->accelDenum <= 0) { client->errorValue = stuff->accelDenum; return BadValue; } - else ctrl.den = stuff->accelDenum; + else { + ctrl.den = stuff->accelDenum; + } } - if (stuff->doThresh) - { - if (stuff->threshold == -1) + if (stuff->doThresh) { + if (stuff->threshold == -1) { ctrl.threshold = defaultPointerControl.threshold; - else if (stuff->threshold < 0) - { + } + else if (stuff->threshold < 0) { client->errorValue = stuff->threshold; return BadValue; } - else ctrl.threshold = stuff->threshold; + else { + ctrl.threshold = stuff->threshold; + } } - mouse->ptrfeed->ctrl = ctrl; - (*mouse->ptrfeed->CtrlProc)(mouse, &mouse->ptrfeed->ctrl); + + + for (mouse = inputInfo.devices; mouse; mouse = mouse->next) { + if ((mouse->coreEvents || mouse == inputInfo.pointer) && + mouse->ptrfeed && mouse->ptrfeed->CtrlProc) { + mouse->ptrfeed->ctrl = ctrl; + (*mouse->ptrfeed->CtrlProc)(mouse, &mouse->ptrfeed->ctrl); + } + } + return Success; -} +} int ProcGetPointerControl(ClientPtr client) { - register PtrCtrl *ctrl = &inputInfo.pointer->ptrfeed->ctrl; + PtrCtrl *ctrl = &inputInfo.pointer->ptrfeed->ctrl; xGetPointerControlReply rep = {0}; REQUEST_SIZE_MATCH(xReq); @@ -1517,7 +1987,7 @@ ProcGetPointerControl(ClientPtr client) } void -MaybeStopHint(register DeviceIntPtr dev, ClientPtr client) +MaybeStopHint(DeviceIntPtr dev, ClientPtr client) { GrabPtr grab = dev->grab; @@ -1538,7 +2008,7 @@ ProcGetMotionEvents(ClientPtr client) WindowPtr pWin; xTimecoord * coords = (xTimecoord *) NULL; xGetMotionEventsReply rep = {0}; - int i, count, xmin, xmax, ymin, ymax; + int i, count, xmin, xmax, ymin, ymax; unsigned long nEvents; DeviceIntPtr mouse = inputInfo.pointer; TimeStamp start, stop; @@ -1617,8 +2087,8 @@ ProcQueryKeymap(ClientPtr client) } else #endif - for (i = 0; i<32; i++) - rep.map[i] = down[i]; + for (i = 0; i<32; i++) + rep.map[i] = down[i]; WriteReplyToClient(client, sizeof(xQueryKeymapReply), &rep); return Success; } diff --git a/nx-X11/programs/Xserver/dix/dispatch.c b/nx-X11/programs/Xserver/dix/dispatch.c index 6c18c5b599..4eba8987d2 100644 --- a/nx-X11/programs/Xserver/dix/dispatch.c +++ b/nx-X11/programs/Xserver/dix/dispatch.c @@ -27,13 +27,13 @@ Copyright 1987, 1989 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, +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 +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. +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 @@ -117,6 +117,17 @@ int ProcInitialConnection(); #include "inputstr.h" #include "xkbsrv.h" #endif + +#ifdef XSERVER_DTRACE +#include +typedef const char *string; +#include "Xserver-dtrace.h" + +char *RequestNames[256]; +static void LoadRequestNames(void); +static void FreeRequestNames(void); +#define GetRequestName(i) (RequestNames[i]) +#endif #include "client.h" #define mskcnt ((MAXCLIENTS + 31) / 32) @@ -182,7 +193,7 @@ SetInputCheck(HWEventQueuePtr c0, HWEventQueuePtr c1) } void -UpdateCurrentTime() +UpdateCurrentTime(void) { TimeStamp systime; @@ -201,7 +212,7 @@ UpdateCurrentTime() /* Like UpdateCurrentTime, but can't call ProcessInputEvents */ void -UpdateCurrentTimeIf() +UpdateCurrentTimeIf(void) { TimeStamp systime; @@ -240,9 +251,8 @@ long SmartScheduleSlice = SMART_SCHEDULE_DEFAULT_INTERVAL; long SmartScheduleInterval = SMART_SCHEDULE_DEFAULT_INTERVAL; long SmartScheduleMaxSlice = SMART_SCHEDULE_MAX_SLICE; long SmartScheduleTime; -ClientPtr SmartLastClient; -int SmartLastIndex[SMART_MAX_PRIORITY-SMART_MIN_PRIORITY+1]; -int SmartScheduleClient(int *clientReady, int nready); +static ClientPtr SmartLastClient; +static int SmartLastIndex[SMART_MAX_PRIORITY-SMART_MIN_PRIORITY+1]; #ifdef SMART_DEBUG long SmartLastPrint; @@ -251,7 +261,7 @@ long SmartLastPrint; void Dispatch(void); void InitProcVectors(void); -int +static int SmartScheduleClient (int *clientReady, int nready) { int i; @@ -340,11 +350,11 @@ SmartScheduleClient (int *clientReady, int nready) void Dispatch(void) { - register int *clientReady; /* array of request ready clients */ - register int result; - register ClientPtr client; - register int nready; - register HWEventQueuePtr* icheck = checkForInput; + int *clientReady; /* array of request ready clients */ + int result; + ClientPtr client; + int nready; + HWEventQueuePtr* icheck = checkForInput; long start_tick; nextFreeClientID = 1; @@ -355,6 +365,10 @@ Dispatch(void) if (!clientReady) return; +#ifdef XSERVER_DTRACE + LoadRequestNames(); +#endif + while (!dispatchException) { if (*icheck[0] != *icheck[1]) @@ -370,9 +384,9 @@ Dispatch(void) clientReady[0] = SmartScheduleClient (clientReady, nready); nready = 1; } - /***************** - * Handle events in round robin fashion, doing input between - * each round + /***************** + * Handle events in round robin fashion, doing input between + * each round *****************/ while (!dispatchException && (--nready >= 0)) @@ -412,7 +426,7 @@ Dispatch(void) * device grabs, are calculated correctly */ UpdateCurrentTimeIf(); result = ReadRequestFromClient(client); - if (result <= 0) + if (result <= 0) { if (result < 0) CloseDownClient(client); @@ -420,15 +434,26 @@ Dispatch(void) } client->sequence++; +#ifdef XSERVER_DTRACE + XSERVER_REQUEST_START(GetRequestName(MAJOROP), MAJOROP, + ((xReq *)client->requestBuffer)->length, + client->index, client->requestBuffer); +#endif if (result > (maxBigRequestSize << 2)) result = BadLength; - else + else { result = (* client->requestVector[MAJOROP])(client); + } +#ifdef XSERVER_DTRACE + XSERVER_REQUEST_DONE(GetRequestName(MAJOROP), MAJOROP, + client->sequence, client->index, result); +#endif - if (!SmartScheduleSignalEnable) - SmartScheduleTime = GetTimeInMillis(); - if (result != Success) + if (!SmartScheduleSignalEnable) + SmartScheduleTime = GetTimeInMillis(); + + if (result != Success) { if (client->noClientException != Success) CloseDownClient(client); @@ -455,6 +480,9 @@ Dispatch(void) KillAllClients(); free(clientReady); dispatchException &= ~DE_RESET; +#ifdef XSERVER_DTRACE + FreeRequestNames(); +#endif } #undef MAJOROP @@ -469,13 +497,13 @@ ProcBadRequest(ClientPtr client) int ProcCreateWindow(ClientPtr client) { - register WindowPtr pParent, pWin; + WindowPtr pParent, pWin; REQUEST(xCreateWindowReq); int result; int len; REQUEST_AT_LEAST_SIZE(xCreateWindowReq); - + LEGAL_NEW_RESOURCE(stuff->wid, client); if (!(pParent = (WindowPtr)SecurityLookupWindow(stuff->parent, client, DixWriteAccess))) @@ -489,10 +517,10 @@ ProcCreateWindow(ClientPtr client) return BadValue; } pWin = CreateWindow(stuff->wid, pParent, stuff->x, - stuff->y, stuff->width, stuff->height, + stuff->y, stuff->width, stuff->height, stuff->borderWidth, stuff->class, - stuff->mask, (XID *) &stuff[1], - (int)stuff->depth, + stuff->mask, (XID *) &stuff[1], + (int)stuff->depth, client, stuff->visual, &result); if (pWin) { @@ -510,11 +538,11 @@ ProcCreateWindow(ClientPtr client) } int -ProcChangeWindowAttributes(register ClientPtr client) +ProcChangeWindowAttributes(ClientPtr client) { - register WindowPtr pWin; + WindowPtr pWin; REQUEST(xChangeWindowAttributesReq); - register int result; + int result; int len; REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq); @@ -525,9 +553,9 @@ ProcChangeWindowAttributes(register ClientPtr client) len = client->req_len - (sizeof(xChangeWindowAttributesReq) >> 2); if (len != Ones(stuff->valueMask)) return BadLength; - result = ChangeWindowAttributes(pWin, - stuff->valueMask, - (XID *) &stuff[1], + result = ChangeWindowAttributes(pWin, + stuff->valueMask, + (XID *) &stuff[1], client); if (client->noClientException != Success) return(client->noClientException); @@ -536,9 +564,9 @@ ProcChangeWindowAttributes(register ClientPtr client) } int -ProcGetWindowAttributes(register ClientPtr client) +ProcGetWindowAttributes(ClientPtr client) { - register WindowPtr pWin; + WindowPtr pWin; REQUEST(xResourceReq); xGetWindowAttributesReply wa; @@ -554,9 +582,9 @@ ProcGetWindowAttributes(register ClientPtr client) } int -ProcDestroyWindow(register ClientPtr client) +ProcDestroyWindow(ClientPtr client) { - register WindowPtr pWin; + WindowPtr pWin; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); @@ -570,9 +598,9 @@ ProcDestroyWindow(register ClientPtr client) } int -ProcDestroySubwindows(register ClientPtr client) +ProcDestroySubwindows(ClientPtr client) { - register WindowPtr pWin; + WindowPtr pWin; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); @@ -585,12 +613,12 @@ ProcDestroySubwindows(register ClientPtr client) } int -ProcChangeSaveSet(register ClientPtr client) +ProcChangeSaveSet(ClientPtr client) { - register WindowPtr pWin; + WindowPtr pWin; REQUEST(xChangeSaveSetReq); - register int result; - + int result; + REQUEST_SIZE_MATCH(xChangeSaveSetReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, DixReadAccess); @@ -615,11 +643,11 @@ ProcChangeSaveSet(register ClientPtr client) #ifndef NXAGENT_SERVER int -ProcReparentWindow(register ClientPtr client) +ProcReparentWindow(ClientPtr client) { - register WindowPtr pWin, pParent; + WindowPtr pWin, pParent; REQUEST(xReparentWindowReq); - register int result; + int result; REQUEST_SIZE_MATCH(xReparentWindowReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, @@ -638,22 +666,22 @@ ProcReparentWindow(register ClientPtr client) if ((pWin->drawable.class != InputOnly) && (pParent->drawable.class == InputOnly)) return BadMatch; - result = ReparentWindow(pWin, pParent, + result = ReparentWindow(pWin, pParent, (short)stuff->x, (short)stuff->y, client); if (client->noClientException != Success) return(client->noClientException); else return(result); } - else + else return (BadMatch); } #endif /* NXAGENT_SERVER */ int -ProcMapWindow(register ClientPtr client) +ProcMapWindow(ClientPtr client) { - register WindowPtr pWin; + WindowPtr pWin; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); @@ -667,9 +695,9 @@ ProcMapWindow(register ClientPtr client) } int -ProcMapSubwindows(register ClientPtr client) +ProcMapSubwindows(ClientPtr client) { - register WindowPtr pWin; + WindowPtr pWin; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); @@ -683,9 +711,9 @@ ProcMapSubwindows(register ClientPtr client) } int -ProcUnmapWindow(register ClientPtr client) +ProcUnmapWindow(ClientPtr client) { - register WindowPtr pWin; + WindowPtr pWin; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); @@ -699,9 +727,9 @@ ProcUnmapWindow(register ClientPtr client) } int -ProcUnmapSubwindows(register ClientPtr client) +ProcUnmapSubwindows(ClientPtr client) { - register WindowPtr pWin; + WindowPtr pWin; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); @@ -714,11 +742,11 @@ ProcUnmapSubwindows(register ClientPtr client) } int -ProcConfigureWindow(register ClientPtr client) +ProcConfigureWindow(ClientPtr client) { - register WindowPtr pWin; + WindowPtr pWin; REQUEST(xConfigureWindowReq); - register int result; + int result; int len; REQUEST_AT_LEAST_SIZE(xConfigureWindowReq); @@ -729,7 +757,7 @@ ProcConfigureWindow(register ClientPtr client) len = client->req_len - (sizeof(xConfigureWindowReq) >> 2); if (Ones((Mask)stuff->mask) != len) return BadLength; - result = ConfigureWindow(pWin, (Mask)stuff->mask, (XID *) &stuff[1], + result = ConfigureWindow(pWin, (Mask)stuff->mask, (XID *) &stuff[1], client); if (client->noClientException != Success) return(client->noClientException); @@ -738,9 +766,9 @@ ProcConfigureWindow(register ClientPtr client) } int -ProcCirculateWindow(register ClientPtr client) +ProcCirculateWindow(ClientPtr client) { - register WindowPtr pWin; + WindowPtr pWin; REQUEST(xCirculateWindowReq); REQUEST_SIZE_MATCH(xCirculateWindowReq); @@ -759,9 +787,9 @@ ProcCirculateWindow(register ClientPtr client) } int -GetGeometry(register ClientPtr client, xGetGeometryReply *rep) +GetGeometry(ClientPtr client, xGetGeometryReply *rep) { - register DrawablePtr pDraw; + DrawablePtr pDraw; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); @@ -775,7 +803,7 @@ GetGeometry(register ClientPtr client, xGetGeometryReply *rep) rep->width = pDraw->width; rep->height = pDraw->height; - /* XXX - Because the pixmap-implementation of the multibuffer extension + /* XXX - Because the pixmap-implementation of the multibuffer extension * may have the buffer-id's drawable resource value be a pointer * to the buffer's window instead of the buffer itself * (this happens if the buffer is the displayed buffer), @@ -786,7 +814,7 @@ GetGeometry(register ClientPtr client, xGetGeometryReply *rep) if ((pDraw->type == UNDRAWABLE_WINDOW) || ((pDraw->type == DRAWABLE_WINDOW) && (stuff->id == pDraw->id))) { - register WindowPtr pWin = (WindowPtr)pDraw; + WindowPtr pWin = (WindowPtr)pDraw; rep->x = pWin->origin.x - wBorderWidth (pWin); rep->y = pWin->origin.y - wBorderWidth (pWin); rep->borderWidth = pWin->borderWidth; @@ -801,7 +829,7 @@ GetGeometry(register ClientPtr client, xGetGeometryReply *rep) int -ProcGetGeometry(register ClientPtr client) +ProcGetGeometry(ClientPtr client) { xGetGeometryReply rep = {0}; int status; @@ -816,11 +844,11 @@ ProcGetGeometry(register ClientPtr client) #ifndef NXAGENT_SERVER int -ProcQueryTree(register ClientPtr client) +ProcQueryTree(ClientPtr client) { xQueryTreeReply reply = {0}; int numChildren = 0; - register WindowPtr pChild, pWin, pHead; + WindowPtr pChild, pWin, pHead; Window *childIDs = (Window *)NULL; REQUEST(xResourceReq); @@ -849,10 +877,10 @@ ProcQueryTree(register ClientPtr client) for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib) childIDs[curChild++] = pChild->drawable.id; } - + reply.nChildren = numChildren; reply.length = (numChildren * sizeof(Window)) >> 2; - + WriteReplyToClient(client, sizeof(xQueryTreeReply), &reply); if (numChildren) { @@ -867,7 +895,7 @@ ProcQueryTree(register ClientPtr client) int -ProcInternAtom(register ClientPtr client) +ProcInternAtom(ClientPtr client) { Atom atom; char *tchar; @@ -896,7 +924,7 @@ ProcInternAtom(register ClientPtr client) } int -ProcGetAtomName(register ClientPtr client) +ProcGetAtomName(ClientPtr client) { const char *str; int len; @@ -915,15 +943,15 @@ ProcGetAtomName(register ClientPtr client) WriteToClient(client, len, str); return(client->noClientException); } - else - { + else + { client->errorValue = stuff->id; return (BadAtom); } } int -ProcSetSelectionOwner(register ClientPtr client) +ProcSetSelectionOwner(ClientPtr client) { WindowPtr pWin; TimeStamp time; @@ -951,16 +979,16 @@ ProcSetSelectionOwner(register ClientPtr client) int i = 0; /* - * First, see if the selection is already set... + * First, see if the selection is already set... */ - while ((i < NumCurrentSelections) && - CurrentSelections[i].selection != stuff->selection) + while ((i < NumCurrentSelections) && + CurrentSelections[i].selection != stuff->selection) i++; if (i < NumCurrentSelections) - { + { /* If the timestamp in client's request is in the past relative to the time stamp indicating the last time the owner of the - selection was set, do not set the selection, just return + selection was set, do not set the selection, just return success. */ if (CompareTimeStamps(time, CurrentSelections[i].lastTimeChanged) == EARLIER) @@ -1010,7 +1038,7 @@ ProcSetSelectionOwner(register ClientPtr client) } return (client->noClientException); } - else + else { client->errorValue = stuff->selection; return (BadAtom); @@ -1018,7 +1046,7 @@ ProcSetSelectionOwner(register ClientPtr client) } int -ProcGetSelectionOwner(register ClientPtr client) +ProcGetSelectionOwner(ClientPtr client) { REQUEST(xResourceReq); @@ -1029,7 +1057,7 @@ ProcGetSelectionOwner(register ClientPtr client) xGetSelectionOwnerReply reply; i = 0; - while ((i < NumCurrentSelections) && + while ((i < NumCurrentSelections) && CurrentSelections[i].selection != stuff->id) i++; memset(&reply, 0, sizeof(xGetSelectionOwnerReply)); reply.type = X_Reply; @@ -1042,16 +1070,16 @@ ProcGetSelectionOwner(register ClientPtr client) WriteReplyToClient(client, sizeof(xGetSelectionOwnerReply), &reply); return(client->noClientException); } - else + else { client->errorValue = stuff->id; - return (BadAtom); + return (BadAtom); } } #ifndef NXAGENT_SERVER int -ProcConvertSelection(register ClientPtr client) +ProcConvertSelection(ClientPtr client) { Bool paramsOkay; xEvent event; @@ -1072,9 +1100,9 @@ ProcConvertSelection(register ClientPtr client) int i; i = 0; - while ((i < NumCurrentSelections) && + while ((i < NumCurrentSelections) && CurrentSelections[i].selection != stuff->selection) i++; - if ((i < NumCurrentSelections) && + if ((i < NumCurrentSelections) && (CurrentSelections[i].window != None) #ifdef XCSECURITY && (!client->CheckAccess || @@ -1083,11 +1111,11 @@ ProcConvertSelection(register ClientPtr client) CurrentSelections[i].pWin)) #endif ) - { + { memset(&event, 0, sizeof(xEvent)); event.u.u.type = SelectionRequest; event.u.selectionRequest.time = stuff->time; - event.u.selectionRequest.owner = + event.u.selectionRequest.owner = CurrentSelections[i].window; event.u.selectionRequest.requestor = stuff->requestor; event.u.selectionRequest.selection = stuff->selection; @@ -1109,7 +1137,7 @@ ProcConvertSelection(register ClientPtr client) NoEventMask /* CantBeFiltered */, NullGrab); return (client->noClientException); } - else + else { client->errorValue = stuff->property; return (BadAtom); @@ -1118,7 +1146,7 @@ ProcConvertSelection(register ClientPtr client) #endif /* NXAGENT_SERVER */ int -ProcGrabServer(register ClientPtr client) +ProcGrabServer(ClientPtr client) { REQUEST_SIZE_MATCH(xReq); if (grabState != GrabNone && client != grabClient) @@ -1172,7 +1200,7 @@ UngrabServer(ClientPtr client) } int -ProcUngrabServer(register ClientPtr client) +ProcUngrabServer(ClientPtr client) { REQUEST_SIZE_MATCH(xReq); UngrabServer(client); @@ -1180,11 +1208,11 @@ ProcUngrabServer(register ClientPtr client) } int -ProcTranslateCoords(register ClientPtr client) +ProcTranslateCoords(ClientPtr client) { REQUEST(xTranslateCoordsReq); - register WindowPtr pWin, pDst; + WindowPtr pWin, pDst; xTranslateCoordsReply rep = {0}; REQUEST_SIZE_MATCH(xTranslateCoordsReq); @@ -1259,7 +1287,7 @@ ProcTranslateCoords(register ClientPtr client) #ifndef NXAGENT_SERVER int -ProcOpenFont(register ClientPtr client) +ProcOpenFont(ClientPtr client) { int err; REQUEST(xOpenFontReq); @@ -1278,7 +1306,7 @@ ProcOpenFont(register ClientPtr client) } int -ProcCloseFont(register ClientPtr client) +ProcCloseFont(ClientPtr client) { FontPtr pFont; REQUEST(xResourceReq); @@ -1300,16 +1328,15 @@ ProcCloseFont(register ClientPtr client) #endif /* NXAGENT_SERVER */ int -ProcQueryFont(register ClientPtr client) +ProcQueryFont(ClientPtr client) { xQueryFontReply *reply; FontPtr pFont; - register GC *pGC; + GC *pGC; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); client->errorValue = stuff->id; /* EITHER font or gc */ - pFont = (FontPtr)SecurityLookupIDByType(client, stuff->id, RT_FONT, DixReadAccess); if (!pFont) @@ -1342,7 +1369,6 @@ ProcQueryFont(register ClientPtr client) rlength = sizeof(xQueryFontReply) + FONTINFONPROPS(FONTCHARSET(pFont)) * sizeof(xFontProp) + nprotoxcistructs * sizeof(xCharInfo); - reply = (xQueryFontReply *)calloc(1, rlength); if(!reply) { @@ -1361,7 +1387,7 @@ ProcQueryFont(register ClientPtr client) } int -ProcQueryTextExtents(register ClientPtr client) +ProcQueryTextExtents(ClientPtr client) { REQUEST(xQueryTextExtentsReq); xQueryTextExtentsReply reply = {0}; @@ -1371,7 +1397,7 @@ ProcQueryTextExtents(register ClientPtr client) unsigned long length; REQUEST_AT_LEAST_SIZE(xQueryTextExtentsReq); - + pFont = (FontPtr)SecurityLookupIDByType(client, stuff->fid, RT_FONT, DixReadAccess); if (!pFont) @@ -1416,18 +1442,18 @@ ProcQueryTextExtents(register ClientPtr client) #ifndef NXAGENT_SERVER int -ProcListFonts(register ClientPtr client) +ProcListFonts(ClientPtr client) { REQUEST(xListFontsReq); REQUEST_FIXED_SIZE(xListFontsReq, stuff->nbytes); - return ListFonts(client, (unsigned char *) &stuff[1], stuff->nbytes, + return ListFonts(client, (unsigned char *) &stuff[1], stuff->nbytes, stuff->maxNames); } int -ProcListFontsWithInfo(register ClientPtr client) +ProcListFontsWithInfo(ClientPtr client) { REQUEST(xListFontsWithInfoReq); @@ -1450,13 +1476,13 @@ dixDestroyPixmap(void * value, XID pid) } int -ProcCreatePixmap(register ClientPtr client) +ProcCreatePixmap(ClientPtr client) { PixmapPtr pMap; - register DrawablePtr pDraw; + DrawablePtr pDraw; REQUEST(xCreatePixmapReq); DepthPtr pDepth; - register int i; + int i; REQUEST_SIZE_MATCH(xCreatePixmapReq); client->errorValue = stuff->pid; @@ -1510,7 +1536,7 @@ ProcCreatePixmap(register ClientPtr client) #ifndef NXAGENT_SERVER int -ProcFreePixmap(register ClientPtr client) +ProcFreePixmap(ClientPtr client) { PixmapPtr pMap; @@ -1519,12 +1545,12 @@ ProcFreePixmap(register ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); pMap = (PixmapPtr)SecurityLookupIDByType(client, stuff->id, RT_PIXMAP, DixDestroyAccess); - if (pMap) + if (pMap) { FreeResource(stuff->id, RT_NONE); return(client->noClientException); } - else + else { client->errorValue = stuff->id; return (BadPixmap); @@ -1533,11 +1559,11 @@ ProcFreePixmap(register ClientPtr client) #endif /* NXAGENT_SERVER */ int -ProcCreateGC(register ClientPtr client) +ProcCreateGC(ClientPtr client) { int error; GC *pGC; - register DrawablePtr pDraw; + DrawablePtr pDraw; unsigned len; REQUEST(xCreateGCReq); @@ -1549,7 +1575,7 @@ ProcCreateGC(register ClientPtr client) len = client->req_len - (sizeof(xCreateGCReq) >> 2); if (len != Ones(stuff->mask)) return BadLength; - pGC = (GC *)CreateGC(pDraw, stuff->mask, + pGC = (GC *)CreateGC(pDraw, stuff->mask, (XID *) &stuff[1], &error); if (error != Success) return error; @@ -1559,13 +1585,12 @@ ProcCreateGC(register ClientPtr client) } int -ProcChangeGC(register ClientPtr client) +ProcChangeGC(ClientPtr client) { GC *pGC; - REQUEST(xChangeGCReq); int result; unsigned len; - + REQUEST(xChangeGCReq); REQUEST_AT_LEAST_SIZE(xChangeGCReq); SECURITY_VERIFY_GC(pGC, stuff->gc, client, DixWriteAccess); len = client->req_len - (sizeof(xChangeGCReq) >> 2); @@ -1583,18 +1608,18 @@ ProcChangeGC(register ClientPtr client) } int -ProcCopyGC(register ClientPtr client) +ProcCopyGC(ClientPtr client) { - register GC *dstGC; - register GC *pGC; + GC *dstGC; + GC *pGC; int result; REQUEST(xCopyGCReq); - REQUEST_SIZE_MATCH(xCopyGCReq); + SECURITY_VERIFY_GC( pGC, stuff->srcGC, client, DixReadAccess); SECURITY_VERIFY_GC( dstGC, stuff->dstGC, client, DixWriteAccess); if ((dstGC->pScreen != pGC->pScreen) || (dstGC->depth != pGC->depth)) - return (BadMatch); + return (BadMatch); result = CopyGC(pGC, dstGC, stuff->mask); if (client->noClientException != Success) return(client->noClientException); @@ -1606,9 +1631,9 @@ ProcCopyGC(register ClientPtr client) } int -ProcSetDashes(register ClientPtr client) +ProcSetDashes(ClientPtr client) { - register GC *pGC; + GC *pGC; int result; REQUEST(xSetDashesReq); @@ -1633,11 +1658,10 @@ ProcSetDashes(register ClientPtr client) } int -ProcSetClipRectangles(register ClientPtr client) +ProcSetClipRectangles(ClientPtr client) { - int nr; - int result; - register GC *pGC; + int nr, result; + GC *pGC; REQUEST(xSetClipRectanglesReq); REQUEST_AT_LEAST_SIZE(xSetClipRectanglesReq); @@ -1648,7 +1672,7 @@ ProcSetClipRectangles(register ClientPtr client) return BadValue; } SECURITY_VERIFY_GC(pGC,stuff->gc, client, DixWriteAccess); - + nr = (client->req_len << 2) - sizeof(xSetClipRectanglesReq); if (nr & 4) return(BadLength); @@ -1662,9 +1686,9 @@ ProcSetClipRectangles(register ClientPtr client) } int -ProcFreeGC(register ClientPtr client) +ProcFreeGC(ClientPtr client) { - register GC *pGC; + GC *pGC; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); @@ -1674,10 +1698,10 @@ ProcFreeGC(register ClientPtr client) } int -ProcClearToBackground(register ClientPtr client) +ProcClearToBackground(ClientPtr client) { REQUEST(xClearAreaReq); - register WindowPtr pWin; + WindowPtr pWin; REQUEST_SIZE_MATCH(xClearAreaReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, @@ -1688,7 +1712,7 @@ ProcClearToBackground(register ClientPtr client) { client->errorValue = stuff->window; return (BadMatch); - } + } if ((stuff->exposures != xTrue) && (stuff->exposures != xFalse)) { client->errorValue = stuff->exposures; @@ -1701,17 +1725,17 @@ ProcClearToBackground(register ClientPtr client) } int -ProcCopyArea(register ClientPtr client) +ProcCopyArea(ClientPtr client) { - register DrawablePtr pDst; - register DrawablePtr pSrc; - register GC *pGC; + DrawablePtr pDst; + DrawablePtr pSrc; + GC *pGC; REQUEST(xCopyAreaReq); RegionPtr pRgn; REQUEST_SIZE_MATCH(xCopyAreaReq); - VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pDst, pGC, client); + VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pDst, pGC, client); if (stuff->dstDrawable != stuff->srcDrawable) { SECURITY_VERIFY_DRAWABLE(pSrc, stuff->srcDrawable, client, @@ -1728,7 +1752,7 @@ ProcCopyArea(register ClientPtr client) SET_DBE_SRCBUF(pSrc, stuff->srcDrawable); pRgn = (*pGC->ops->CopyArea)(pSrc, pDst, pGC, stuff->srcX, stuff->srcY, - stuff->width, stuff->height, + stuff->width, stuff->height, stuff->dstX, stuff->dstY); if (pGC->graphicsExposures) { @@ -1742,10 +1766,10 @@ ProcCopyArea(register ClientPtr client) } int -ProcCopyPlane(register ClientPtr client) +ProcCopyPlane(ClientPtr client) { - register DrawablePtr psrcDraw, pdstDraw; - register GC *pGC; + DrawablePtr psrcDraw, pdstDraw; + GC *pGC; REQUEST(xCopyPlaneReq); RegionPtr pRgn; @@ -1776,7 +1800,7 @@ ProcCopyPlane(register ClientPtr client) } pRgn = (*pGC->ops->CopyPlane)(psrcDraw, pdstDraw, pGC, stuff->srcX, stuff->srcY, - stuff->width, stuff->height, + stuff->width, stuff->height, stuff->dstX, stuff->dstY, stuff->bitPlane); if (pGC->graphicsExposures) { @@ -1789,21 +1813,21 @@ ProcCopyPlane(register ClientPtr client) } int -ProcPolyPoint(register ClientPtr client) +ProcPolyPoint(ClientPtr client) { int npoint; - register GC *pGC; - register DrawablePtr pDraw; + GC *pGC; + DrawablePtr pDraw; REQUEST(xPolyPointReq); REQUEST_AT_LEAST_SIZE(xPolyPointReq); - if ((stuff->coordMode != CoordModeOrigin) && + if ((stuff->coordMode != CoordModeOrigin) && (stuff->coordMode != CoordModePrevious)) { client->errorValue = stuff->coordMode; return BadValue; } - VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client); + VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client); npoint = ((client->req_len << 2) - sizeof(xPolyPointReq)) >> 2; if (npoint) (*pGC->ops->PolyPoint)(pDraw, pGC, stuff->coordMode, npoint, @@ -1812,15 +1836,15 @@ ProcPolyPoint(register ClientPtr client) } int -ProcPolyLine(register ClientPtr client) +ProcPolyLine(ClientPtr client) { int npoint; - register GC *pGC; - register DrawablePtr pDraw; + GC *pGC; + DrawablePtr pDraw; REQUEST(xPolyLineReq); REQUEST_AT_LEAST_SIZE(xPolyLineReq); - if ((stuff->coordMode != CoordModeOrigin) && + if ((stuff->coordMode != CoordModeOrigin) && (stuff->coordMode != CoordModePrevious)) { client->errorValue = stuff->coordMode; @@ -1829,17 +1853,17 @@ ProcPolyLine(register ClientPtr client) VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client); npoint = ((client->req_len << 2) - sizeof(xPolyLineReq)) >> 2; if (npoint > 1) - (*pGC->ops->Polylines)(pDraw, pGC, stuff->coordMode, npoint, + (*pGC->ops->Polylines)(pDraw, pGC, stuff->coordMode, npoint, (DDXPointPtr) &stuff[1]); return(client->noClientException); } int -ProcPolySegment(register ClientPtr client) +ProcPolySegment(ClientPtr client) { int nsegs; - register GC *pGC; - register DrawablePtr pDraw; + GC *pGC; + DrawablePtr pDraw; REQUEST(xPolySegmentReq); REQUEST_AT_LEAST_SIZE(xPolySegmentReq); @@ -1854,11 +1878,11 @@ ProcPolySegment(register ClientPtr client) } int -ProcPolyRectangle (register ClientPtr client) +ProcPolyRectangle (ClientPtr client) { int nrects; - register GC *pGC; - register DrawablePtr pDraw; + GC *pGC; + DrawablePtr pDraw; REQUEST(xPolyRectangleReq); REQUEST_AT_LEAST_SIZE(xPolyRectangleReq); @@ -1868,17 +1892,17 @@ ProcPolyRectangle (register ClientPtr client) return(BadLength); nrects >>= 3; if (nrects) - (*pGC->ops->PolyRectangle)(pDraw, pGC, + (*pGC->ops->PolyRectangle)(pDraw, pGC, nrects, (xRectangle *) &stuff[1]); return(client->noClientException); } int -ProcPolyArc(register ClientPtr client) +ProcPolyArc(ClientPtr client) { int narcs; - register GC *pGC; - register DrawablePtr pDraw; + GC *pGC; + DrawablePtr pDraw; REQUEST(xPolyArcReq); REQUEST_AT_LEAST_SIZE(xPolyArcReq); @@ -1893,21 +1917,21 @@ ProcPolyArc(register ClientPtr client) } int -ProcFillPoly(register ClientPtr client) +ProcFillPoly(ClientPtr client) { int things; - register GC *pGC; - register DrawablePtr pDraw; + GC *pGC; + DrawablePtr pDraw; REQUEST(xFillPolyReq); REQUEST_AT_LEAST_SIZE(xFillPolyReq); - if ((stuff->shape != Complex) && (stuff->shape != Nonconvex) && + if ((stuff->shape != Complex) && (stuff->shape != Nonconvex) && (stuff->shape != Convex)) { client->errorValue = stuff->shape; return BadValue; } - if ((stuff->coordMode != CoordModeOrigin) && + if ((stuff->coordMode != CoordModeOrigin) && (stuff->coordMode != CoordModePrevious)) { client->errorValue = stuff->coordMode; @@ -1924,11 +1948,11 @@ ProcFillPoly(register ClientPtr client) } int -ProcPolyFillRectangle(register ClientPtr client) +ProcPolyFillRectangle(ClientPtr client) { int things; - register GC *pGC; - register DrawablePtr pDraw; + GC *pGC; + DrawablePtr pDraw; REQUEST(xPolyFillRectangleReq); REQUEST_AT_LEAST_SIZE(xPolyFillRectangleReq); @@ -1945,11 +1969,11 @@ ProcPolyFillRectangle(register ClientPtr client) } int -ProcPolyFillArc(register ClientPtr client) +ProcPolyFillArc(ClientPtr client) { int narcs; - register GC *pGC; - register DrawablePtr pDraw; + GC *pGC; + DrawablePtr pDraw; REQUEST(xPolyFillArcReq); REQUEST_AT_LEAST_SIZE(xPolyFillArcReq); @@ -2018,10 +2042,10 @@ ReformatImage (char *base, int nbytes, int bpp, int order) * boundary, even if the scanlines are padded to our satisfaction. */ int -ProcPutImage(register ClientPtr client) +ProcPutImage(ClientPtr client) { - register GC *pGC; - register DrawablePtr pDraw; + GC *pGC; + DrawablePtr pDraw; long length; /* length of scanline server padded */ long lengthProto; /* length of scanline protocol padded */ char *tmpImage; @@ -2038,7 +2062,7 @@ ProcPutImage(register ClientPtr client) } else if (stuff->format == XYPixmap) { - if ((pDraw->depth != stuff->depth) || + if ((pDraw->depth != stuff->depth) || (stuff->leftPad >= (unsigned int)screenInfo.bitmapScanlinePad)) return BadMatch; length = BitmapBytePad(stuff->width + stuff->leftPad); @@ -2061,30 +2085,29 @@ ProcPutImage(register ClientPtr client) if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; - if (((((lengthProto * stuff->height) + (unsigned)3) >> 2) + + if (((((lengthProto * stuff->height) + (unsigned)3) >> 2) + (sizeof(xPutImageReq) >> 2)) != client->req_len) return BadLength; - ReformatImage (tmpImage, lengthProto * stuff->height, + ReformatImage (tmpImage, lengthProto * stuff->height, stuff->format == ZPixmap ? BitsPerPixel (stuff->depth) : 1, ClientOrder(client)); - + (*pGC->ops->PutImage) (pDraw, pGC, stuff->depth, stuff->dstX, stuff->dstY, - stuff->width, stuff->height, + stuff->width, stuff->height, stuff->leftPad, stuff->format, tmpImage); return (client->noClientException); } - -int -DoGetImage(register ClientPtr client, int format, Drawable drawable, - int x, int y, int width, int height, +static int +DoGetImage(ClientPtr client, int format, Drawable drawable, + int x, int y, int width, int height, Mask planemask, xGetImageReply **im_return) { - register DrawablePtr pDraw; + DrawablePtr pDraw; int nlines, linesPerBuf; - register int linesDone; + int linesDone; long widthBytesLine, length; Mask plane = 0; char *pBuf; @@ -2140,7 +2163,7 @@ DoGetImage(register ClientPtr client, int format, Drawable drawable, length = widthBytesLine * height; } - else + else { widthBytesLine = BitmapBytePad(width); plane = ((Mask)1) << (pDraw->depth - 1); @@ -2222,7 +2245,7 @@ DoGetImage(register ClientPtr client, int format, Drawable drawable, (*pDraw->pScreen->GetImage) (pDraw, x, y + linesDone, - width, + width, nlines, format, planemask, @@ -2230,7 +2253,7 @@ DoGetImage(register ClientPtr client, int format, Drawable drawable, #ifdef XCSECURITY if (pVisibleRegion) SecurityCensorImage(client, pVisibleRegion, widthBytesLine, - pDraw, x, y + linesDone, width, + pDraw, x, y + linesDone, width, nlines, format, pBuf); #endif @@ -2263,7 +2286,7 @@ DoGetImage(register ClientPtr client, int format, Drawable drawable, (*pDraw->pScreen->GetImage) (pDraw, x, y + linesDone, - width, + width, nlines, format, plane, @@ -2272,7 +2295,7 @@ DoGetImage(register ClientPtr client, int format, Drawable drawable, if (pVisibleRegion) SecurityCensorImage(client, pVisibleRegion, widthBytesLine, - pDraw, x, y + linesDone, width, + pDraw, x, y + linesDone, width, nlines, format, pBuf); #endif @@ -2281,8 +2304,8 @@ DoGetImage(register ClientPtr client, int format, Drawable drawable, if (im_return) { pBuf += nlines * widthBytesLine; } else { - ReformatImage (pBuf, - (int)(nlines * widthBytesLine), + ReformatImage (pBuf, + (int)(nlines * widthBytesLine), 1, ClientOrder (client)); @@ -2306,7 +2329,7 @@ DoGetImage(register ClientPtr client, int format, Drawable drawable, } int -ProcGetImage(register ClientPtr client) +ProcGetImage(ClientPtr client) { REQUEST(xGetImageReq); @@ -2319,7 +2342,7 @@ ProcGetImage(register ClientPtr client) } int -ProcPolyText(register ClientPtr client) +ProcPolyText(ClientPtr client) { int err; REQUEST(xPolyTextReq); @@ -2348,11 +2371,11 @@ ProcPolyText(register ClientPtr client) } int -ProcImageText8(register ClientPtr client) +ProcImageText8(ClientPtr client) { int err; - register DrawablePtr pDraw; - register GC *pGC; + DrawablePtr pDraw; + GC *pGC; REQUEST(xImageTextReq); @@ -2378,11 +2401,11 @@ ProcImageText8(register ClientPtr client) } int -ProcImageText16(register ClientPtr client) +ProcImageText16(ClientPtr client) { int err; - register DrawablePtr pDraw; - register GC *pGC; + DrawablePtr pDraw; + GC *pGC; REQUEST(xImageTextReq); @@ -2409,12 +2432,12 @@ ProcImageText16(register ClientPtr client) int -ProcCreateColormap(register ClientPtr client) +ProcCreateColormap(ClientPtr client) { VisualPtr pVisual; ColormapPtr pmap; Colormap mid; - register WindowPtr pWin; + WindowPtr pWin; ScreenPtr pScreen; REQUEST(xCreateColormapReq); int i, result; @@ -2452,7 +2475,7 @@ ProcCreateColormap(register ClientPtr client) } int -ProcFreeColormap(register ClientPtr client) +ProcFreeColormap(ClientPtr client) { ColormapPtr pmap; REQUEST(xResourceReq); @@ -2460,14 +2483,14 @@ ProcFreeColormap(register ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); pmap = (ColormapPtr )SecurityLookupIDByType(client, stuff->id, RT_COLORMAP, DixDestroyAccess); - if (pmap) + if (pmap) { /* Freeing a default colormap is a no-op */ if (!(pmap->flags & IsDefault)) FreeResource(stuff->id, RT_NONE); return (client->noClientException); } - else + else { client->errorValue = stuff->id; return (BadColor); @@ -2476,7 +2499,7 @@ ProcFreeColormap(register ClientPtr client) int -ProcCopyColormapAndFree(register ClientPtr client) +ProcCopyColormapAndFree(ClientPtr client) { Colormap mid; ColormapPtr pSrcMap; @@ -2503,7 +2526,7 @@ ProcCopyColormapAndFree(register ClientPtr client) } int -ProcInstallColormap(register ClientPtr client) +ProcInstallColormap(ClientPtr client) { ColormapPtr pcmp; REQUEST(xResourceReq); @@ -2514,7 +2537,7 @@ ProcInstallColormap(register ClientPtr client) if (pcmp) { (*(pcmp->pScreen->InstallColormap)) (pcmp); - return (client->noClientException); + return (client->noClientException); } else { @@ -2524,7 +2547,7 @@ ProcInstallColormap(register ClientPtr client) } int -ProcUninstallColormap(register ClientPtr client) +ProcUninstallColormap(ClientPtr client) { ColormapPtr pcmp; REQUEST(xResourceReq); @@ -2536,7 +2559,7 @@ ProcUninstallColormap(register ClientPtr client) { if(pcmp->mid != pcmp->pScreen->defColormap) (*(pcmp->pScreen->UninstallColormap)) (pcmp); - return (client->noClientException); + return (client->noClientException); } else { @@ -2546,9 +2569,9 @@ ProcUninstallColormap(register ClientPtr client) } int -ProcListInstalledColormaps(register ClientPtr client) +ProcListInstalledColormaps(ClientPtr client) { - xListInstalledColormapsReply *preply; + xListInstalledColormapsReply *preply; int nummaps; WindowPtr pWin; REQUEST(xResourceReq); @@ -2560,7 +2583,7 @@ ProcListInstalledColormaps(register ClientPtr client) if (!pWin) return(BadWindow); - preply = (xListInstalledColormapsReply *) + preply = (xListInstalledColormapsReply *) malloc(sizeof(xListInstalledColormapsReply) + pWin->drawable.pScreen->maxInstalledCmaps * sizeof(Colormap)); @@ -2581,7 +2604,7 @@ ProcListInstalledColormaps(register ClientPtr client) } int -ProcAllocColor (register ClientPtr client) +ProcAllocColor (ClientPtr client) { ColormapPtr pmap; int retval; @@ -2623,7 +2646,7 @@ ProcAllocColor (register ClientPtr client) } int -ProcAllocNamedColor (register ClientPtr client) +ProcAllocNamedColor (ClientPtr client) { ColormapPtr pcmp; REQUEST(xAllocNamedColorReq); @@ -2675,7 +2698,7 @@ ProcAllocNamedColor (register ClientPtr client) } int -ProcAllocColorCells (register ClientPtr client) +ProcAllocColorCells (ClientPtr client) { ColormapPtr pcmp; REQUEST(xAllocColorCellsReq); @@ -2708,7 +2731,7 @@ ProcAllocColorCells (register ClientPtr client) return(BadAlloc); pmasks = ppixels + npixels; - if( (retval = AllocColorCells(client->index, pcmp, npixels, nmasks, + if( (retval = AllocColorCells(client->index, pcmp, npixels, nmasks, (Bool)stuff->contiguous, ppixels, pmasks)) ) { free(ppixels); @@ -2731,7 +2754,7 @@ ProcAllocColorCells (register ClientPtr client) WriteSwappedDataToClient(client, length, ppixels); } free(ppixels); - return (client->noClientException); + return (client->noClientException); } else { @@ -2741,7 +2764,7 @@ ProcAllocColorCells (register ClientPtr client) } int -ProcAllocColorPlanes(register ClientPtr client) +ProcAllocColorPlanes(ClientPtr client) { ColormapPtr pcmp; REQUEST(xAllocColorPlanesReq); @@ -2795,7 +2818,7 @@ ProcAllocColorPlanes(register ClientPtr client) WriteSwappedDataToClient(client, length, ppixels); } free(ppixels); - return (client->noClientException); + return (client->noClientException); } else { @@ -2805,7 +2828,7 @@ ProcAllocColorPlanes(register ClientPtr client) } int -ProcFreeColors(register ClientPtr client) +ProcFreeColors(ClientPtr client) { ColormapPtr pcmp; REQUEST(xFreeColorsReq); @@ -2874,7 +2897,7 @@ ProcStoreColors (ClientPtr client) } int -ProcStoreNamedColor (register ClientPtr client) +ProcStoreNamedColor (ClientPtr client) { ColormapPtr pcmp; REQUEST(xStoreNamedColorReq); @@ -2898,7 +2921,7 @@ ProcStoreNamedColor (register ClientPtr client) else return(retval); } - return (BadName); + return (BadName); } else { @@ -2908,7 +2931,7 @@ ProcStoreNamedColor (register ClientPtr client) } int -ProcQueryColors(register ClientPtr client) +ProcQueryColors(ClientPtr client) { ColormapPtr pcmp; REQUEST(xQueryColorsReq); @@ -2959,10 +2982,10 @@ ProcQueryColors(register ClientPtr client) client->errorValue = stuff->cmap; return (BadColor); } -} +} int -ProcLookupColor(register ClientPtr client) +ProcLookupColor(ClientPtr client) { ColormapPtr pcmp; REQUEST(xLookupColorReq); @@ -2990,7 +3013,7 @@ ProcLookupColor(register ClientPtr client) WriteReplyToClient(client, sizeof(xLookupColorReply), &lcr); return(client->noClientException); } - return (BadName); + return (BadName); } else { @@ -3000,12 +3023,11 @@ ProcLookupColor(register ClientPtr client) } int -ProcCreateCursor (register ClientPtr client) +ProcCreateCursor (ClientPtr client) { - CursorPtr pCursor; - - register PixmapPtr src; - register PixmapPtr msk; + CursorPtr pCursor; + PixmapPtr src; + PixmapPtr msk; unsigned char * srcbits; unsigned char * mskbits; unsigned short width, height; @@ -3044,7 +3066,7 @@ ProcCreateCursor (register ClientPtr client) width = src->drawable.width; height = src->drawable.height; - if ( stuff->x > width + if ( stuff->x > width || stuff->y > height ) return (BadMatch); @@ -3065,7 +3087,7 @@ ProcCreateCursor (register ClientPtr client) XYPixmap, 1, (void *)srcbits); if ( msk == (PixmapPtr)NULL) { - register unsigned char *bits = mskbits; + unsigned char *bits = mskbits; while (--n >= 0) *bits++ = ~0; } @@ -3090,7 +3112,7 @@ ProcCreateCursor (register ClientPtr client) } int -ProcCreateGlyphCursor (register ClientPtr client) +ProcCreateGlyphCursor (ClientPtr client) { CursorPtr pCursor; int res; @@ -3114,7 +3136,7 @@ ProcCreateGlyphCursor (register ClientPtr client) int -ProcFreeCursor (register ClientPtr client) +ProcFreeCursor (ClientPtr client) { CursorPtr pCursor; REQUEST(xResourceReq); @@ -3122,12 +3144,12 @@ ProcFreeCursor (register ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); pCursor = (CursorPtr)SecurityLookupIDByType(client, stuff->id, RT_CURSOR, DixDestroyAccess); - if (pCursor) + if (pCursor) { FreeResource(stuff->id, RT_NONE); return (client->noClientException); } - else + else { client->errorValue = stuff->id; return (BadCursor); @@ -3135,16 +3157,16 @@ ProcFreeCursor (register ClientPtr client) } int -ProcQueryBestSize (register ClientPtr client) +ProcQueryBestSize (ClientPtr client) { xQueryBestSizeReply reply = {0}; - register DrawablePtr pDraw; + DrawablePtr pDraw; ScreenPtr pScreen; REQUEST(xQueryBestSizeReq); - REQUEST_SIZE_MATCH(xQueryBestSizeReq); - if ((stuff->class != CursorShape) && - (stuff->class != TileShape) && + + if ((stuff->class != CursorShape) && + (stuff->class != TileShape) && (stuff->class != StippleShape)) { client->errorValue = stuff->class; @@ -3170,7 +3192,7 @@ ProcQueryBestSize (register ClientPtr client) #ifndef NXAGENT_SERVER int -ProcSetScreenSaver (register ClientPtr client) +ProcSetScreenSaver (ClientPtr client) { int blankingOption, exposureOption; REQUEST(xSetScreenSaverReq); @@ -3206,7 +3228,7 @@ ProcSetScreenSaver (register ClientPtr client) if (blankingOption == DefaultBlanking) ScreenSaverBlanking = defaultScreenSaverBlanking; else - ScreenSaverBlanking = blankingOption; + ScreenSaverBlanking = blankingOption; if (exposureOption == DefaultExposures) ScreenSaverAllowExposures = defaultScreenSaverAllowExposures; else @@ -3214,7 +3236,7 @@ ProcSetScreenSaver (register ClientPtr client) if (stuff->timeout >= 0) ScreenSaverTime = stuff->timeout * MILLI_PER_SECOND; - else + else ScreenSaverTime = defaultScreenSaverTime; if (stuff->interval >= 0) ScreenSaverInterval = stuff->interval * MILLI_PER_SECOND; @@ -3227,7 +3249,7 @@ ProcSetScreenSaver (register ClientPtr client) #endif /* NXAGENT_SERVER */ int -ProcGetScreenSaver(register ClientPtr client) +ProcGetScreenSaver(ClientPtr client) { xGetScreenSaverReply rep = {0}; @@ -3244,7 +3266,7 @@ ProcGetScreenSaver(register ClientPtr client) } int -ProcChangeHosts(register ClientPtr client) +ProcChangeHosts(ClientPtr client) { REQUEST(xChangeHostsReq); int result; @@ -3255,8 +3277,8 @@ ProcChangeHosts(register ClientPtr client) result = AddHost(client, (int)stuff->hostFamily, stuff->hostLength, (void *)&stuff[1]); else if (stuff->mode == HostDelete) - result = RemoveHost(client, (int)stuff->hostFamily, - stuff->hostLength, (void *)&stuff[1]); + result = RemoveHost(client, (int)stuff->hostFamily, + stuff->hostLength, (void *)&stuff[1]); else { client->errorValue = stuff->mode; @@ -3268,7 +3290,7 @@ ProcChangeHosts(register ClientPtr client) } int -ProcListHosts(register ClientPtr client) +ProcListHosts(ClientPtr client) { xListHostsReply reply = {0}; int len, nHosts, result; @@ -3302,7 +3324,7 @@ ProcListHosts(register ClientPtr client) } int -ProcChangeAccessControl(register ClientPtr client) +ProcChangeAccessControl(ClientPtr client) { int result; REQUEST(xSetAccessControlReq); @@ -3319,8 +3341,30 @@ ProcChangeAccessControl(register ClientPtr client) return (result); } +/********************* + * CloseDownRetainedResources + * + * Find all clients that are gone and have terminated in RetainTemporary + * and destroy their resources. + *********************/ + +static void +CloseDownRetainedResources(void) +{ + int i; + ClientPtr client; + + for (i=1; icloseDownMode == RetainTemporary) + && (client->clientGone)) + CloseDownClient(client); + } +} + int -ProcKillClient(register ClientPtr client) +ProcKillClient(ClientPtr client) { REQUEST(xResourceReq); ClientPtr killclient; @@ -3354,16 +3398,16 @@ ProcKillClient(register ClientPtr client) } int -ProcSetFontPath(register ClientPtr client) +ProcSetFontPath(ClientPtr client) { unsigned char *ptr; unsigned long nbytes, total; long nfonts; int n, result; REQUEST(xSetFontPathReq); - + REQUEST_AT_LEAST_SIZE(xSetFontPathReq); - + nbytes = (client->req_len << 2) - sizeof(xSetFontPathReq); total = nbytes; ptr = (unsigned char *)&stuff[1]; @@ -3384,7 +3428,7 @@ ProcSetFontPath(register ClientPtr client) } int -ProcGetFontPath(register ClientPtr client) +ProcGetFontPath(ClientPtr client) { xGetFontPathReply reply = {0}; int stringLens, numpaths; @@ -3406,7 +3450,7 @@ ProcGetFontPath(register ClientPtr client) } int -ProcChangeCloseDownMode(register ClientPtr client) +ProcChangeCloseDownMode(ClientPtr client) { REQUEST(xSetCloseDownModeReq); @@ -3418,7 +3462,7 @@ ProcChangeCloseDownMode(register ClientPtr client) client->closeDownMode = stuff->mode; return (client->noClientException); } - else + else { client->errorValue = stuff->mode; return (BadValue); @@ -3426,13 +3470,13 @@ ProcChangeCloseDownMode(register ClientPtr client) } #ifndef NXAGENT_SERVER -int ProcForceScreenSaver(register ClientPtr client) -{ +int ProcForceScreenSaver(ClientPtr client) +{ REQUEST(xForceScreenSaverReq); REQUEST_SIZE_MATCH(xForceScreenSaverReq); - - if ((stuff->mode != ScreenSaverReset) && + + if ((stuff->mode != ScreenSaverReset) && (stuff->mode != ScreenSaverActive)) { client->errorValue = stuff->mode; @@ -3443,10 +3487,10 @@ int ProcForceScreenSaver(register ClientPtr client) } #endif /* NXAGENT_SERVER */ -int ProcNoOperation(register ClientPtr client) +int ProcNoOperation(ClientPtr client) { REQUEST_AT_LEAST_SIZE(xReq); - + /* noop -- don't do anything */ return(client->noClientException); } @@ -3467,9 +3511,8 @@ InitProcVectors(void) { EventSwapVector[i] = NotImplemented; } - -} +} /********************** * CloseDownClient @@ -3517,11 +3560,11 @@ CloseDownClient(ClientPtr client) { NewClientInfoRec clientinfo; - clientinfo.client = client; - clientinfo.prefix = (xConnSetupPrefix *)NULL; + 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)) @@ -3551,11 +3594,11 @@ CloseDownClient(ClientPtr client) { NewClientInfoRec clientinfo; - clientinfo.client = client; - clientinfo.prefix = (xConnSetupPrefix *)NULL; + 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. */ @@ -3572,39 +3615,17 @@ CloseDownClient(ClientPtr client) } static void -KillAllClients() +KillAllClients(void) { int i; for (i=1; icloseDownMode = DestroyAll; - CloseDownClient(clients[i]); + CloseDownClient(clients[i]); } } -/********************* - * CloseDownRetainedResources - * - * Find all clients that are gone and have terminated in RetainTemporary - * and destroy their resources. - *********************/ - -void -CloseDownRetainedResources() -{ - register int i; - register ClientPtr client; - - for (i=1; icloseDownMode == RetainTemporary) - && (client->clientGone)) - CloseDownClient(client); - } -} - extern int clientPrivateLen; extern unsigned *clientPrivateSizes; extern unsigned totalClientSize; @@ -3612,7 +3633,7 @@ extern unsigned totalClientSize; void InitClient(ClientPtr client, int i, void * ospriv) { client->index = i; - client->sequence = 0; + client->sequence = 0; client->clientAsMask = ((Mask)i) << CLIENTOFFSET; client->clientGone = FALSE; client->closeDownMode = i ? DestroyAll : RetainPermanent; @@ -3653,11 +3674,11 @@ xorg_InitClientPrivates(ClientPtr client) InitClientPrivates(ClientPtr client) #endif { - register char *ptr; + char *ptr; DevUnion *ppriv; - register unsigned *sizes; - register unsigned size; - register int i; + unsigned *sizes; + unsigned size; + int i; if (totalClientSize == sizeof(ClientRec)) ppriv = (DevUnion *)NULL; @@ -3672,6 +3693,8 @@ InitClientPrivates(ClientPtr client) client->devPrivates = ppriv; sizes = clientPrivateSizes; ptr = (char *)(ppriv + clientPrivateLen); + if (ppriv) + bzero(ppriv, totalClientSize - sizeof(ClientRec)); for (i = clientPrivateLen; --i >= 0; ppriv++, sizes++) { if ( (size = *sizes) ) @@ -3705,8 +3728,8 @@ InitClientPrivates(ClientPtr client) ClientPtr NextAvailableClient(void * ospriv) { - register int i; - register ClientPtr client; + int i; + ClientPtr client; xReq data; i = nextFreeClientID; @@ -3752,10 +3775,10 @@ ClientPtr NextAvailableClient(void * ospriv) } int -ProcInitialConnection(register ClientPtr client) +ProcInitialConnection(ClientPtr client) { REQUEST(xReq); - register xConnClientPrefix *prefix; + xConnClientPrefix *prefix; int whichbyte = 1; char order; @@ -3785,10 +3808,10 @@ ProcInitialConnection(register ClientPtr client) } int -SendConnSetup(register ClientPtr client, char *reason) +SendConnSetup(ClientPtr client, char *reason) { - register xWindowRoot *root; - register int i; + xWindowRoot *root; + int i; int numScreens; char* lConnectionInfo; xConnSetupPrefix* lconnSetupPrefix; @@ -3834,14 +3857,14 @@ SendConnSetup(register ClientPtr client, char *reason) #ifdef PANORAMIX if (noPanoramiXExtension) numScreens = screenInfo.numScreens; - else + else numScreens = ((xConnSetup *)ConnectionInfo)->numRoots; #endif - for (i=0; icurrentInputMask = screenInfo.screens[i]->root->eventMask | wOtherEventMasks (screenInfo.screens[i]->root); @@ -3882,10 +3905,10 @@ SendConnSetup(register ClientPtr client, char *reason) } int -ProcEstablishConnection(register ClientPtr client) +ProcEstablishConnection(ClientPtr client) { char *reason, *auth_proto, *auth_string; - register xConnClientPrefix *prefix; + xConnClientPrefix *prefix; REQUEST(xReq); prefix = (xConnClientPrefix *)((char *)stuff + sz_xReq); @@ -3916,7 +3939,7 @@ ProcEstablishConnection(register ClientPtr client) } void -SendErrorToClient(ClientPtr client, unsigned majorCode, unsigned minorCode, +SendErrorToClient(ClientPtr client, unsigned majorCode, unsigned minorCode, XID resId, int errorCode) { xError rep = {0}; @@ -3933,7 +3956,7 @@ SendErrorToClient(ClientPtr client, unsigned majorCode, unsigned minorCode, void DeleteWindowFromAnySelections(WindowPtr pWin) { - register int i; + int i; for (i = 0; i< NumCurrentSelections; i++) if (CurrentSelections[i].pWin == pWin) @@ -3955,7 +3978,7 @@ DeleteWindowFromAnySelections(WindowPtr pWin) static void DeleteClientFromAnySelections(ClientPtr client) { - register int i; + int i; for (i = 0; i< NumCurrentSelections; i++) if (CurrentSelections[i].client == client) @@ -3980,6 +4003,63 @@ MarkClientException(ClientPtr client) client->noClientException = -1; } +#ifdef XSERVER_DTRACE +#include + +/* Load table of request names for dtrace probes */ +static void LoadRequestNames(void) +{ + int i; + FILE *xedb; + extern void LoadExtensionNames(char **RequestNames); + + bzero(RequestNames, 256 * sizeof(char *)); + + xedb = fopen(XERRORDB_PATH, "r"); + if (xedb != NULL) { + char buf[256]; + while (fgets(buf, sizeof(buf), xedb)) { + if ((strncmp("XRequest.", buf, 9) == 0) && (isdigit(buf[9]))) { + char *name; + i = strtol(buf + 9, &name, 10); + if (RequestNames[i] == 0) { + char *end = strchr(name, '\n'); + if (end) { *end = '\0'; } + RequestNames[i] = strdup(name + 1); + } + } + } + fclose(xedb); + } + + LoadExtensionNames(RequestNames); + + for (i = 0; i < 256; i++) { + if (RequestNames[i] == 0) { +#define RN_SIZE 12 /* "Request#' + up to 3 digits + \0 */ + RequestNames[i] = malloc(RN_SIZE); + if (RequestNames[i]) { + snprintf(RequestNames[i], RN_SIZE, "Request#%d", i); + } + } + /* fprintf(stderr, "%d: %s\n", i, RequestNames[i]); */ + } +} + +static void FreeRequestNames(void) +{ + int i; + + for (i = 0; i < 256; i++) { + if (RequestNames[i] != 0) { + free(RequestNames[i]); + RequestNames[i] = 0; + } + } +} + +#endif + /* * This array encodes the answer to the question "what is the log base 2 * of the number of pixels that fit in a scanline pad unit?" diff --git a/nx-X11/programs/Xserver/dix/dispatch.h b/nx-X11/programs/Xserver/dix/dispatch.h index dd07096af1..c8c8dede5c 100644 --- a/nx-X11/programs/Xserver/dix/dispatch.h +++ b/nx-X11/programs/Xserver/dix/dispatch.h @@ -26,7 +26,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. /* * This prototypes the dispatch.c module (except for functions declared in * global headers), plus related dispatch procedures from devices.c, events.c, - * extension.c, property.c. + * extension.c, property.c. */ #ifdef HAVE_DIX_CONFIG_H diff --git a/nx-X11/programs/Xserver/dix/dixfonts.c b/nx-X11/programs/Xserver/dix/dixfonts.c index f1fa53f696..436f6834f2 100644 --- a/nx-X11/programs/Xserver/dix/dixfonts.c +++ b/nx-X11/programs/Xserver/dix/dixfonts.c @@ -84,7 +84,7 @@ Equipment Corporation. #define QUERYCHARINFO(pci, pr) *(pr) = (pci)->metrics #ifndef HAS_XFONT2 -extern void register_fpe_functions(void); +extern void _fpe_functions(void); #endif extern void * fosNaturalParams; @@ -265,7 +265,7 @@ doOpenFont(ClientPtr client, OFclosurePtr c) /* * Decide at runtime what FontFormat to use. */ - Mask FontFormat = + Mask FontFormat = ((screenInfo.imageByteOrder == LSBFirst) ? BitmapFormatByteOrderLSB : BitmapFormatByteOrderMSB) | @@ -609,7 +609,7 @@ QueryFont(FontPtr pFont, xQueryFontReply *pReply, int nProtoCCIStructs) chars[i++] = r; chars[i++] = c; } - (*pFont->get_metrics) (pFont, ncols, chars, + (*pFont->get_metrics) (pFont, ncols, chars, TwoD16Bit, &count, charInfos); i = 0; for (i = 0; i < (int) count && ninfos < nProtoCCIStructs; i++) { @@ -915,13 +915,13 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) } int -ListFonts(ClientPtr client, unsigned char *pattern, unsigned length, +ListFonts(ClientPtr client, unsigned char *pattern, unsigned length, unsigned max_names) { int i; LFclosurePtr c; - /* + /* * The right error to return here would be BadName, however the * specification does not allow for a Name error on this request. * Perhaps a better solution would be to return a nil list, i.e. @@ -1208,13 +1208,13 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) #endif /* NXAGENT_SERVER */ int -StartListFontsWithInfo(ClientPtr client, int length, unsigned char *pattern, +StartListFontsWithInfo(ClientPtr client, int length, unsigned char *pattern, int max_names) { int i; LFWIclosurePtr c; - /* + /* * The right error to return here would be BadName, however the * specification does not allow for a Name error on this request. * Perhaps a better solution would be to return a nil list, i.e. @@ -1263,9 +1263,9 @@ static XID clearGC[] = { CT_NONE }; #define clearGCmask (GCClipMask) int -doPolyText(ClientPtr client, register PTclosurePtr c) +doPolyText(ClientPtr client, PTclosurePtr c) { - register FontPtr pFont = c->pGC->font, oldpFont; + FontPtr pFont = c->pGC->font, oldpFont; Font fid, oldfid; int err = Success, lgerr; /* err is in X error, not font error, space */ enum { NEVER_SLEPT, START_SLEEP, SLEEPING } client_state = NEVER_SLEPT; @@ -1478,7 +1478,7 @@ doPolyText(ClientPtr client, register PTclosurePtr c) origGC = c->pGC; c->pGC = pGC; ValidateGC(c->pDraw, c->pGC); - + c->slept = TRUE; ClientSleep(client, (ClientSleepProcPtr)doPolyText, @@ -1545,7 +1545,7 @@ doPolyText(ClientPtr client, register PTclosurePtr c) } int -PolyText(ClientPtr client, DrawablePtr pDraw, GC *pGC, unsigned char *pElt, +PolyText(ClientPtr client, DrawablePtr pDraw, GC *pGC, unsigned char *pElt, unsigned char *endReq, int xorg, int yorg, int reqType, XID did) { PTclosureRec local_closure; @@ -1580,7 +1580,7 @@ PolyText(ClientPtr client, DrawablePtr pDraw, GC *pGC, unsigned char *pElt, #undef FontShiftSize int -doImageText(ClientPtr client, register ITclosurePtr c) +doImageText(ClientPtr client, ITclosurePtr c) { int err = Success, lgerr; /* err is in X error, not font error, space */ FontPathElementPtr fpe; @@ -1721,7 +1721,7 @@ doImageText(ClientPtr client, register ITclosurePtr c) } int -ImageText(ClientPtr client, DrawablePtr pDraw, GC *pGC, int nChars, +ImageText(ClientPtr client, DrawablePtr pDraw, GC *pGC, int nChars, unsigned char *data, int xorg, int yorg, int reqType, XID did) { ITclosureRec local_closure; @@ -1834,11 +1834,11 @@ SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist) (*fpe_functions[i].set_path_hook) (); #endif /* HAS_XFONT2 */ } - for (i = 0; i < npaths; i++) + for (i = 0; i < npaths; i++) { len = (unsigned int) (*cp++); - if (len == 0) + if (len == 0) { if (persist) ErrorF ("Removing empty element from the valid list of fontpaths\n"); @@ -1852,14 +1852,14 @@ SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist) * them, though it'd muck up refcounting */ fpe = find_existing_fpe(font_path_elements, num_fpes, cp, len); - if (fpe) + if (fpe) { #ifdef HAS_XFONT2 err = (*fpe_functions[fpe->type]->reset_fpe) (fpe); #else err = (*fpe_functions[fpe->type].reset_fpe) (fpe); #endif /* HAS_XFONT2 */ - if (err == Successful) + if (err == Successful) { UseFPE(fpe);/* since it'll be decref'd later when freed * from the old list */ @@ -1871,20 +1871,20 @@ SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist) if (!fpe) { fpe = (FontPathElementPtr) malloc(sizeof(FontPathElementRec)); - if (!fpe) + if (!fpe) { err = BadAlloc; goto bail; } fpe->name = (char *) malloc(len + 1); - if (!fpe->name) + if (!fpe->name) { free(fpe); err = BadAlloc; goto bail; } fpe->refcount = 1; - + strncpy(fpe->name, (char *) cp, (int) len); fpe->name[len] = '\0'; fpe->name_length = len; @@ -2131,7 +2131,7 @@ register_fpe_funcs(const xfont2_fpe_funcs_rec *funcs) } #else void -InitFonts () +InitFonts (void) { patternCache = MakeFontPatternCache(); @@ -2209,20 +2209,20 @@ GetClientResolutions (int *num) */ int -RegisterFPEFunctions(NameCheckFunc name_func, - InitFpeFunc init_func, - FreeFpeFunc free_func, - ResetFpeFunc reset_func, - OpenFontFunc open_func, - CloseFontFunc close_func, - ListFontsFunc list_func, - StartLfwiFunc start_lfwi_func, - NextLfwiFunc next_lfwi_func, - WakeupFpeFunc wakeup_func, - ClientDiedFunc client_died, - LoadGlyphsFunc load_glyphs, - StartLaFunc start_list_alias_func, - NextLaFunc next_list_alias_func, +RegisterFPEFunctions(NameCheckFunc name_func, + InitFpeFunc init_func, + FreeFpeFunc free_func, + ResetFpeFunc reset_func, + OpenFontFunc open_func, + CloseFontFunc close_func, + ListFontsFunc list_func, + StartLfwiFunc start_lfwi_func, + NextLfwiFunc next_lfwi_func, + WakeupFpeFunc wakeup_func, + ClientDiedFunc client_died, + LoadGlyphsFunc load_glyphs, + StartLaFunc start_list_alias_func, + NextLaFunc next_list_alias_func, SetPathFunc set_path_func) { FPEFunctions *new; @@ -2259,7 +2259,7 @@ RegisterFPEFunctions(NameCheckFunc name_func, #endif /* !HAS_XFONT2 */ void -FreeFonts() +FreeFonts(void) { if (patternCache) { #ifdef HAS_XFONT2 diff --git a/nx-X11/programs/Xserver/dix/dixutils.c b/nx-X11/programs/Xserver/dix/dixutils.c index 3ccc90d718..175745be25 100644 --- a/nx-X11/programs/Xserver/dix/dixutils.c +++ b/nx-X11/programs/Xserver/dix/dixutils.c @@ -27,13 +27,13 @@ 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, +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 +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. +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 @@ -171,7 +171,7 @@ ISOLatin1ToLower (unsigned char source) void CopyISOLatin1Lowered(char *dest, const char *source, int length) { - register int i; + int i; for (i = 0; i < length; i++, source++, dest++) *dest = ISOLatin1ToLower (*source); @@ -179,18 +179,18 @@ CopyISOLatin1Lowered(char *dest, const char *source, int length) } int -CompareISOLatin1Lowered(unsigned char *s1, int s1len, +CompareISOLatin1Lowered(unsigned char *s1, int s1len, unsigned char *s2, int s2len) { unsigned char c1, c2; - - for (;;) + + for (;;) { /* note -- compare against zero so that -1 ignores len */ c1 = s1len-- ? *s1++ : '\0'; c2 = s2len-- ? *s2++ : '\0'; - if (!c1 || - (c1 != c2 && + if (!c1 || + (c1 != c2 && (c1 = ISOLatin1ToLower (c1)) != (c2 = ISOLatin1ToLower (c2)))) break; } @@ -220,7 +220,7 @@ SecurityLookupWindow(XID rid, ClientPtr client, Mask access_mode) void * SecurityLookupDrawable(XID rid, ClientPtr client, Mask access_mode) { - register DrawablePtr pDraw; + DrawablePtr pDraw; if(rid == INVALID) return (void *) NULL; @@ -264,7 +264,7 @@ LookupWindow(XID rid, ClientPtr client) void * LookupDrawable(XID rid, ClientPtr client) { - register DrawablePtr pDraw; + DrawablePtr pDraw; if(rid == INVALID) return (void *) NULL; @@ -350,11 +350,11 @@ AlterSaveSetForClient(ClientPtr client, WindowPtr pWin, unsigned mode, void DeleteWindowFromAnySaveSet(WindowPtr pWin) { - register int i; - register ClientPtr client; - + int i; + ClientPtr client; + for (i = 0; i< currentMaxClients; i++) - { + { client = clients[i]; if (client && client->numSaved) (void)AlterSaveSetForClient(client, pWin, SetModeDelete, FALSE, TRUE); @@ -364,7 +364,7 @@ DeleteWindowFromAnySaveSet(WindowPtr pWin) /* No-op Don't Do Anything : sometimes we need to be able to call a procedure * that doesn't do anything. For example, on screen with only static * colormaps, if someone calls install colormap, it's easier to have a dummy - * procedure to call than to check if there's a procedure + * procedure to call than to check if there's a procedure */ void NoopDDA(void) @@ -385,18 +385,18 @@ static Bool inHandler; static Bool handlerDeleted; /** - * + * * \param pTimeout DIX doesn't want to know how OS represents time * \param pReadMask nor how it represents the det of descriptors */ void BlockHandler(void * pTimeout, void * pReadmask) { - register int i, j; - + int i, j; + ++inHandler; for (i = 0; i < screenInfo.numScreens; i++) - (* screenInfo.screens[i]->BlockHandler)(i, + (* screenInfo.screens[i]->BlockHandler)(i, screenInfo.screens[i]->blockData, pTimeout, pReadmask); for (i = 0; i < numHandlers; i++) @@ -426,14 +426,14 @@ BlockHandler(void * pTimeout, void * pReadmask) void WakeupHandler(int result, void * pReadmask) { - register int i, j; + int i, j; ++inHandler; for (i = numHandlers - 1; i >= 0; i--) (*handlers[i].WakeupHandler) (handlers[i].blockData, result, pReadmask); for (i = 0; i < screenInfo.numScreens; i++) - (* screenInfo.screens[i]->WakeupHandler)(i, + (* screenInfo.screens[i]->WakeupHandler)(i, screenInfo.screens[i]->wakeupData, result, pReadmask); if (handlerDeleted) @@ -457,8 +457,8 @@ WakeupHandler(int result, void * pReadmask) * get called until next time */ Bool -RegisterBlockAndWakeupHandlers (BlockHandlerProcPtr blockHandler, - WakeupHandlerProcPtr wakeupHandler, +RegisterBlockAndWakeupHandlers (BlockHandlerProcPtr blockHandler, + WakeupHandlerProcPtr wakeupHandler, void * blockData) { BlockHandlerPtr new; @@ -481,8 +481,8 @@ RegisterBlockAndWakeupHandlers (BlockHandlerProcPtr blockHandler, } void -RemoveBlockAndWakeupHandlers (BlockHandlerProcPtr blockHandler, - WakeupHandlerProcPtr wakeupHandler, +RemoveBlockAndWakeupHandlers (BlockHandlerProcPtr blockHandler, + WakeupHandlerProcPtr wakeupHandler, void * blockData) { int i; @@ -508,7 +508,7 @@ RemoveBlockAndWakeupHandlers (BlockHandlerProcPtr blockHandler, } void -InitBlockAndWakeupHandlers () +InitBlockAndWakeupHandlers (void) { free (handlers); handlers = (BlockHandlerPtr) 0; @@ -688,7 +688,7 @@ ClientIsAsleep (ClientPtr client) static int numCallbackListsToCleanup = 0; static CallbackListPtr **listsToCleanup = NULL; -static Bool +static Bool _AddCallback( CallbackListPtr *pcbl, CallbackProcPtr callback, @@ -707,7 +707,7 @@ _AddCallback( return TRUE; } -static Bool +static Bool _DeleteCallback( CallbackListPtr *pcbl, CallbackProcPtr callback, @@ -743,7 +743,7 @@ _DeleteCallback( return FALSE; } -static void +static void _CallCallbacks( CallbackListPtr *pcbl, void *call_data) @@ -864,7 +864,7 @@ CreateCallbackList(CallbackListPtr *pcbl, CallbackFuncsPtr cbfuncs) { listsToCleanup[i] = pcbl; return TRUE; - } + } } listsToCleanup = (CallbackListPtr **)xnfrealloc(listsToCleanup, @@ -874,7 +874,7 @@ CreateCallbackList(CallbackListPtr *pcbl, CallbackFuncsPtr cbfuncs) return TRUE; } -Bool +Bool AddCallback(CallbackListPtr *pcbl, CallbackProcPtr callback, void * data) { if (!pcbl) return FALSE; @@ -886,14 +886,14 @@ AddCallback(CallbackListPtr *pcbl, CallbackProcPtr callback, void * data) return ((*(*pcbl)->funcs.AddCallback) (pcbl, callback, data)); } -Bool +Bool DeleteCallback(CallbackListPtr *pcbl, CallbackProcPtr callback, void * data) { if (!pcbl || !*pcbl) return FALSE; return ((*(*pcbl)->funcs.DeleteCallback) (pcbl, callback, data)); } -void +void CallCallbacks(CallbackListPtr *pcbl, void * call_data) { if (!pcbl || !*pcbl) return; @@ -907,8 +907,8 @@ DeleteCallbackList(CallbackListPtr *pcbl) (*(*pcbl)->funcs.DeleteCallbackList) (pcbl); } -void -InitCallbackManager() +void +InitCallbackManager(void) { int i; diff --git a/nx-X11/programs/Xserver/dix/events.c b/nx-X11/programs/Xserver/dix/events.c index b296888578..b61f1d0463 100644 --- a/nx-X11/programs/Xserver/dix/events.c +++ b/nx-X11/programs/Xserver/dix/events.c @@ -27,13 +27,13 @@ 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, +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 +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. +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 @@ -107,12 +107,17 @@ of the copyright holder. ******************************************************************/ +/** @file + * This file handles event delivery and a big part of the server-side protocol + * handling (the parts for input devices). + */ #ifdef HAVE_DIX_CONFIG_H #include #endif #include +#include #include "misc.h" #include "resource.h" #include @@ -138,14 +143,23 @@ extern Bool XkbFilterEvents(ClientPtr, int, xEvent *); #include #endif +#ifdef XSERVER_DTRACE +#include +typedef const char *string; +#include "Xserver-dtrace.h" +#endif + #include +#include "exglobals.h" #include "exevents.h" #include "extnsionst.h" #include "dixevents.h" #include "dixgrabs.h" #include "dispatch.h" - +/** + * Extension events type numbering starts at EXTENSION_EVENT_BASE. + */ #define EXTENSION_EVENT_BASE 64 #define NoSuchEvent 0x80000000 /* so doesn't match NoEventMask */ @@ -194,6 +208,28 @@ static int DontPropagateRefCnts[DNPMCOUNT]; #ifdef DEBUG static debug_events = 0; #endif +/** + * Main input device struct. + * inputInfo.void * + * is the core pointer. Referred to as "virtual core pointer", "VCP", + * "core pointer" or inputInfo.pointer. There is exactly one core pointer, + * but multiple devices may send core events. If a device generates core + * events, those events will appear to originate from the core pointer. + * + * inputInfo.keyboard + * is the core keyboard ("virtual core keyboard", "VCK", "core keyboard"). + * See inputInfo.pointer. + * + * inputInfo.devices + * linked list containing all devices including VCK and VCP. The VCK will + * always be the first entry, the VCP the second entry in the device list. + * + * inputInfo.off_devices + * Devices that have not been initialized and are thus turned off. + * + * inputInfo.numDevices + * Total number of devices. + */ InputInfo inputInfo; static struct { @@ -208,12 +244,19 @@ static struct { * The window trace information is used to avoid having to compute all the * windows between the root and the current pointer window each time a button * or key goes down. The grabs on each of those windows must be checked. + * + * @see XYToWindow() for a documentation on how the array is set up. */ static WindowPtr *spriteTrace = (WindowPtr *)NULL; #define ROOT spriteTrace[0] static int spriteTraceSize = 0; static int spriteTraceGood; +/** + * DIX sprite information. This is the sprite as seen from the DIX. It does + * not represent the actual sprite rendered to the screen. + * + */ static struct { CursorPtr current; BoxRec hotLimits; /* logical constraints of hot spot */ @@ -230,7 +273,7 @@ static struct { RegionRec Reg1; /* Region 1 for confining motion */ RegionRec Reg2; /* Region 2 for confining virtual motion */ WindowPtr windows[MAXSCREENS]; - WindowPtr confineWin; /* confine window */ + WindowPtr confineWin; /* confine window */ #endif } sprite; /* info about the cursor sprite */ @@ -247,6 +290,10 @@ static WindowPtr XYToWindow( static Bool CheckMotion(xEvent *xE); +/** + * Max event opcode. + */ + extern int lastEvent; static Mask lastEventMask; @@ -301,15 +348,20 @@ static CARD8 criticalEvents[32] = }; #ifdef PANORAMIX - static void ConfineToShape(RegionPtr shape, int *px, int *py); -static void SyntheticMotion(int x, int y); static void PostNewCursor(void); +#define SyntheticMotion(x, y) \ + PostSyntheticMotion(x, y, noPanoramiXExtension ? 0 : \ + sprite.screen->myNum, \ + syncEvents.playingEvents ? \ + syncEvents.time.milliseconds : \ + currentTime.milliseconds); + static Bool XineramaSetCursorPosition( - int x, - int y, + int x, + int y, Bool generateEvent ){ ScreenPtr pScreen; @@ -317,7 +369,7 @@ XineramaSetCursorPosition( int i; /* x,y are in Screen 0 coordinates. We need to decide what Screen - to send the message too and what the coordinates relative to + to send the message too and what the coordinates relative to that screen are. */ pScreen = sprite.screen; @@ -325,11 +377,11 @@ XineramaSetCursorPosition( y += panoramiXdataPtr[0].y; if(!RegionContainsPoint(&XineramaScreenRegions[pScreen->myNum], - x, y, &box)) + x, y, &box)) { - FOR_NSCREENS(i) + FOR_NSCREENS(i) { - if(i == pScreen->myNum) + if(i == pScreen->myNum) continue; if(RegionContainsPoint(&XineramaScreenRegions[i], x, y, &box)) { @@ -374,7 +426,7 @@ XineramaCheckPhysLimits( if (!cursor) return; - + new = sprite.hotPhys; /* I don't care what the DDX has to say about it */ @@ -455,9 +507,9 @@ XineramaCheckVirtualMotion( return; i = PanoramiXNumScreens - 1; - + RegionCopy(&sprite.Reg2, - &sprite.windows[i]->borderSize); + &sprite.windows[i]->borderSize); off_x = panoramiXdataPtr[i].x; off_y = panoramiXdataPtr[i].y; @@ -467,7 +519,7 @@ XineramaCheckVirtualMotion( if(x || y) RegionTranslate(&sprite.Reg2, x, y); - + RegionUnion(&sprite.Reg2, &sprite.Reg2, &sprite.windows[i]->borderSize); @@ -486,7 +538,7 @@ XineramaCheckVirtualMotion( else if (sprite.hot.y >= lims.y2) sprite.hot.y = lims.y2 - 1; - if (RegionNumRects(&sprite.Reg2) > 1) + if (RegionNumRects(&sprite.Reg2) > 1) ConfineToShape(&sprite.Reg2, &sprite.hot.x, &sprite.hot.y); if (qe) @@ -507,7 +559,7 @@ XineramaCheckMotion(xEvent *xE) if (xE && !syncEvents.playingEvents) { /* Motion events entering DIX get translated to Screen 0 - coordinates. Replayed events have already been + coordinates. Replayed events have already been translated since they've entered DIX before */ XE_KBPTR.rootX += panoramiXdataPtr[sprite.screen->myNum].x - panoramiXdataPtr[0].x; @@ -524,7 +576,7 @@ XineramaCheckMotion(xEvent *xE) else if (sprite.hot.y >= sprite.physLimits.y2) sprite.hot.y = sprite.physLimits.y2 - 1; - if (sprite.hotShape) + if (sprite.hotShape) ConfineToShape(sprite.hotShape, &sprite.hot.x, &sprite.hot.y); sprite.hotPhys = sprite.hot; @@ -571,9 +623,9 @@ XineramaConfineCursorToWindow(WindowPtr pWin, Bool generateEvents) return; i = PanoramiXNumScreens - 1; - + RegionCopy(&sprite.Reg1, - &sprite.windows[i]->borderSize); + &sprite.windows[i]->borderSize); off_x = panoramiXdataPtr[i].x; off_y = panoramiXdataPtr[i].y; @@ -583,7 +635,7 @@ XineramaConfineCursorToWindow(WindowPtr pWin, Bool generateEvents) if(x || y) RegionTranslate(&sprite.Reg1, x, y); - + RegionUnion(&sprite.Reg1, &sprite.Reg1, &sprite.windows[i]->borderSize); @@ -597,7 +649,7 @@ XineramaConfineCursorToWindow(WindowPtr pWin, Bool generateEvents) sprite.hotShape = &sprite.Reg1; else sprite.hotShape = NullRegion; - + sprite.confined = FALSE; sprite.confineWin = (pWin == screenInfo.screens[0]->root) ? NullWindow : pWin; @@ -621,6 +673,13 @@ XineramaChangeToCursor(CursorPtr cursor) } } +#else +#define SyntheticMotion(x, y) \ + PostSyntheticMotion(x, y, \ + 0, \ + syncEvents.playingEvents ? \ + syncEvents.time.milliseconds : \ + currentTime.milliseconds); #endif /* PANORAMIX */ @@ -640,31 +699,6 @@ SetCriticalEvent(int event) criticalEvents[event >> 3] |= 1 << (event & 7); } -static void -SyntheticMotion(int x, int y) -{ - xEvent xE; - -#ifdef PANORAMIX - /* Translate back to the sprite screen since processInputProc - will translate from sprite screen to screen 0 upon reentry - to the DIX layer */ - if(!noPanoramiXExtension) { - x += panoramiXdataPtr[0].x - panoramiXdataPtr[sprite.screen->myNum].x; - y += panoramiXdataPtr[0].y - panoramiXdataPtr[sprite.screen->myNum].y; - } -#endif - memset(&xE, 0, sizeof(xEvent)); - xE.u.keyButtonPointer.rootX = x; - xE.u.keyButtonPointer.rootY = y; - if (syncEvents.playingEvents) - xE.u.keyButtonPointer.time = syncEvents.time.milliseconds; - else - xE.u.keyButtonPointer.time = currentTime.milliseconds; - xE.u.u.type = MotionNotify; - (*inputInfo.pointer->public.processInputProc)(&xE, inputInfo.pointer, 1); -} - #ifdef SHAPE static void ConfineToShape(RegionPtr shape, int *px, int *py) @@ -735,7 +769,7 @@ CheckPhysLimits( new.y = sprite.physLimits.y2 - 1; #ifdef SHAPE if (sprite.hotShape) - ConfineToShape(sprite.hotShape, &new.x, &new.y); + ConfineToShape(sprite.hotShape, &new.x, &new.y); #endif if ((pScreen != sprite.hotPhys.pScreen) || (new.x != sprite.hotPhys.x) || (new.y != sprite.hotPhys.y)) @@ -750,8 +784,8 @@ CheckPhysLimits( static void CheckVirtualMotion( - register QdEventPtr qe, - register WindowPtr pWin) + QdEventPtr qe, + WindowPtr pWin) { #ifdef PANORAMIX if(!noPanoramiXExtension) { @@ -808,7 +842,7 @@ ConfineCursorToWindow(WindowPtr pWin, Bool generateEvents, Bool confineToScreen) if(!noPanoramiXExtension) { XineramaConfineCursorToWindow(pWin, generateEvents); return; - } + } #endif if (syncEvents.playingEvents) @@ -829,11 +863,18 @@ ConfineCursorToWindow(WindowPtr pWin, Bool generateEvents, Bool confineToScreen) } Bool -PointerConfinedToScreen() +PointerConfinedToScreen(void) { return sprite.confined; } +/** + * Update the sprite cursor to the given cursor. + * + * ChangeToCursor() will display the new cursor and free the old cursor (if + * applicable). If the provided cursor is already the updated cursor, nothing + * happens. + */ static void ChangeToCursor(CursorPtr cursor) { @@ -858,20 +899,27 @@ ChangeToCursor(CursorPtr cursor) } } -/* returns true if b is a descendent of a */ +/** + * @returns true if b is a descendent of a + */ Bool -IsParent(register WindowPtr a, register WindowPtr b) +IsParent(WindowPtr a, WindowPtr b) { for (b = b->parent; b; b = b->parent) if (b == a) return TRUE; return FALSE; } +/** + * Update the cursor displayed on the screen. + * + * Called whenever a cursor may have changed shape or position. + */ static void PostNewCursor(void) { - register WindowPtr win; - register GrabPtr grab = inputInfo.pointer->grab; + WindowPtr win; + GrabPtr grab = inputInfo.pointer->grab; if (syncEvents.playingEvents) return; @@ -897,24 +945,36 @@ PostNewCursor(void) } } +/** + * @return root window of current active screen. + */ WindowPtr -GetCurrentRootWindow() +GetCurrentRootWindow(void) { return ROOT; } +/** + * @return window underneath the cursor sprite. + */ WindowPtr -GetSpriteWindow() +GetSpriteWindow(void) { return sprite.win; } +/** + * @return current sprite cursor. + */ CursorPtr -GetSpriteCursor() +GetSpriteCursor(void) { return sprite.current; } +/** + * Set x/y current sprite position in screen coordinates. + */ void GetSpritePosition(int *px, int *py) { @@ -924,7 +984,7 @@ GetSpritePosition(int *px, int *py) #ifdef PANORAMIX int -XineramaGetCursorScreen() +XineramaGetCursorScreen(void) { if(!noPanoramiXExtension) { return sprite.screen->myNum; @@ -937,7 +997,7 @@ XineramaGetCursorScreen() #define TIMESLOP (5 * 60 * 1000) /* 5 minutes */ static void -MonthChangedOrBadTime(register xEvent *xE) +MonthChangedOrBadTime(xEvent *xE) { /* If the ddx/OS is careless about not processing timestamped events from * different sources in sorted order, then it's possible for time to go @@ -956,7 +1016,7 @@ MonthChangedOrBadTime(register xEvent *xE) lastDeviceEventTime = currentTime; } void -NoticeEventTime(register xEvent *xE) +NoticeEventTime(xEvent *xE) { if (!syncEvents.playingEvents) NoticeTime(xE); @@ -969,15 +1029,15 @@ NoticeEventTime(register xEvent *xE) void EnqueueEvent(xEvent *xE, DeviceIntPtr device, int count) { - register QdEventPtr tail = *syncEvents.pendtail; - register QdEventPtr qe; + QdEventPtr tail = *syncEvents.pendtail; + QdEventPtr qe; xEvent *qxE; NoticeTime(xE); #ifdef XKB /* Fix for key repeating bug. */ - if (device->key != NULL && device->key->xkbInfo != NULL && + if (device->key != NULL && device->key->xkbInfo != NULL && xE->u.u.type == KeyRelease) AccessXCancelRepeatKey(device->key->xkbInfo, xE->u.u.detail); #endif @@ -1013,9 +1073,10 @@ EnqueueEvent(xEvent *xE, DeviceIntPtr device, int count) #endif sprite.hotPhys.x = XE_KBPTR.rootX; sprite.hotPhys.y = XE_KBPTR.rootY; - /* do motion compression */ + /* do motion compression, but not if from different devices */ if (tail && (tail->event->u.u.type == MotionNotify) && + (tail->device == device) && (tail->pScreen == sprite.hotPhys.pScreen)) { tail->event->u.keyButtonPointer.rootX = sprite.hotPhys.x; @@ -1044,8 +1105,8 @@ EnqueueEvent(xEvent *xE, DeviceIntPtr device, int count) static void PlayReleasedEvents(void) { - register QdEventPtr *prev, qe; - register DeviceIntPtr dev; + QdEventPtr *prev, qe; + DeviceIntPtr dev; prev = &syncEvents.pending; while ( (qe = *prev) ) @@ -1064,11 +1125,11 @@ PlayReleasedEvents(void) will translate from sprite screen to screen 0 upon reentry to the DIX layer */ if(!noPanoramiXExtension) { - qe->event->u.keyButtonPointer.rootX += - panoramiXdataPtr[0].x - + qe->event->u.keyButtonPointer.rootX += + panoramiXdataPtr[0].x - panoramiXdataPtr[sprite.screen->myNum].x; - qe->event->u.keyButtonPointer.rootY += - panoramiXdataPtr[0].y - + qe->event->u.keyButtonPointer.rootY += + panoramiXdataPtr[0].y - panoramiXdataPtr[sprite.screen->myNum].y; } #endif @@ -1085,11 +1146,11 @@ PlayReleasedEvents(void) } else prev = &qe->next; - } + } } static void -FreezeThaw(register DeviceIntPtr dev, Bool frozen) +FreezeThaw(DeviceIntPtr dev, Bool frozen) { dev->sync.frozen = frozen; if (frozen) @@ -1099,15 +1160,15 @@ FreezeThaw(register DeviceIntPtr dev, Bool frozen) } void -ComputeFreezes() +ComputeFreezes(void) { - register DeviceIntPtr replayDev = syncEvents.replayDev; - register int i; + DeviceIntPtr replayDev = syncEvents.replayDev; + int i; WindowPtr w; - register xEvent *xE; + xEvent *xE; int count; GrabPtr grab; - register DeviceIntPtr dev; + DeviceIntPtr dev; for (dev = inputInfo.devices; dev; dev = dev->next) FreezeThaw(dev, dev->sync.other || (dev->sync.state >= FROZEN)); @@ -1183,10 +1244,10 @@ ScreenRestructured (ScreenPtr pScreen) #endif void -CheckGrabForSyncs(register DeviceIntPtr thisDev, Bool thisMode, Bool otherMode) +CheckGrabForSyncs(DeviceIntPtr thisDev, Bool thisMode, Bool otherMode) { - register GrabPtr grab = thisDev->grab; - register DeviceIntPtr dev; + GrabPtr grab = thisDev->grab; + DeviceIntPtr dev; if (thisMode == GrabModeSync) thisDev->sync.state = FROZEN_NO_EVENT; @@ -1216,12 +1277,25 @@ CheckGrabForSyncs(register DeviceIntPtr thisDev, Bool thisMode, Bool otherMode) ComputeFreezes(); } +/** + * Activate a void * grab on the given device. A pointer grab will cause all + * core void * events to be delivered to the grabbing client only. Can cause + * the cursor to change if a grab cursor is set. + * + * As a void * grab can only be issued on the core devices, mouse is always + * inputInfo.pointer. Extension devices are set up for ActivateKeyboardGrab(). + * + * @param mouse The device to grab. + * @param grab The grab structure, needs to be setup. + * @param autoGrab True if the grab was caused by a button down event and not + * explicitely by a client. + */ void #ifdef NXAGENT_SERVER -xorg_ActivatePointerGrab(register DeviceIntPtr mouse, register GrabPtr grab, +xorg_ActivatePointerGrab(DeviceIntPtr mouse, GrabPtr grab, TimeStamp time, Bool autoGrab) #else -ActivatePointerGrab(register DeviceIntPtr mouse, register GrabPtr grab, +ActivatePointerGrab(DeviceIntPtr mouse, GrabPtr grab, TimeStamp time, Bool autoGrab) #endif { @@ -1249,15 +1323,21 @@ ActivatePointerGrab(register DeviceIntPtr mouse, register GrabPtr grab, CheckGrabForSyncs(mouse,(Bool)grab->pointerMode, (Bool)grab->keyboardMode); } +/** + * Delete grab on given device, update the sprite. + * + * As a void * grab can only be issued on the core devices, mouse is always + * inputInfo.pointer. Extension devices are set up for ActivateKeyboardGrab(). + */ void #ifdef NXAGENT_SERVER -xorg_DeactivatePointerGrab(register DeviceIntPtr mouse) +xorg_DeactivatePointerGrab(DeviceIntPtr mouse) #else -DeactivatePointerGrab(register DeviceIntPtr mouse) +DeactivatePointerGrab(DeviceIntPtr mouse) #endif { - register GrabPtr grab = mouse->grab; - register DeviceIntPtr dev; + GrabPtr grab = mouse->grab; + DeviceIntPtr dev; mouse->valuator->motionHintWindow = NullWindow; mouse->grab = NullGrab; @@ -1277,8 +1357,13 @@ DeactivatePointerGrab(register DeviceIntPtr mouse) ComputeFreezes(); } +/** + * Activate a keyboard grab on the given device. + * + * Extension devices have ActivateKeyboardGrab() set as their grabbing proc. + */ void -ActivateKeyboardGrab(register DeviceIntPtr keybd, GrabPtr grab, TimeStamp time, Bool passive) +ActivateKeyboardGrab(DeviceIntPtr keybd, GrabPtr grab, TimeStamp time, Bool passive) { WindowPtr oldWin; @@ -1303,12 +1388,15 @@ ActivateKeyboardGrab(register DeviceIntPtr keybd, GrabPtr grab, TimeStamp time, CheckGrabForSyncs(keybd, (Bool)grab->keyboardMode, (Bool)grab->pointerMode); } +/** + * Delete keyboard grab for the given device. + */ void -DeactivateKeyboardGrab(register DeviceIntPtr keybd) +DeactivateKeyboardGrab(DeviceIntPtr keybd) { - register GrabPtr grab = keybd->grab; - register DeviceIntPtr dev; - register WindowPtr focusWin = keybd->focus ? keybd->focus->win + GrabPtr grab = keybd->grab; + DeviceIntPtr dev; + WindowPtr focusWin = keybd->focus ? keybd->focus->win : sprite.win; if (focusWin == FollowKeyboardWin) @@ -1332,7 +1420,7 @@ AllowSome(ClientPtr client, TimeStamp time, DeviceIntPtr thisDev, int newState) { Bool thisGrabbed, otherGrabbed, othersFrozen, thisSynced; TimeStamp grabTime; - register DeviceIntPtr dev; + DeviceIntPtr dev; thisGrabbed = thisDev->grab && SameClient(thisDev->grab, client); thisSynced = FALSE; @@ -1435,11 +1523,16 @@ AllowSome(ClientPtr client, TimeStamp time, DeviceIntPtr thisDev, int newState) } } +/** + * Server-side protocol handling for AllowEvents request. + * + * Release some events from a frozen device. Only applicable for core devices. + */ int #ifdef NXAGENT_SERVER -xorg_ProcAllowEvents(register ClientPtr client) +xorg_ProcAllowEvents(ClientPtr client) #else -ProcAllowEvents(register ClientPtr client) +ProcAllowEvents(ClientPtr client) #endif { TimeStamp time; @@ -1454,19 +1547,19 @@ ProcAllowEvents(register ClientPtr client) case ReplayPointer: AllowSome(client, time, mouse, NOT_GRABBED); break; - case SyncPointer: + case SyncPointer: AllowSome(client, time, mouse, FREEZE_NEXT_EVENT); break; - case AsyncPointer: + case AsyncPointer: AllowSome(client, time, mouse, THAWED); break; - case ReplayKeyboard: + case ReplayKeyboard: AllowSome(client, time, keybd, NOT_GRABBED); break; - case SyncKeyboard: + case SyncKeyboard: AllowSome(client, time, keybd, FREEZE_NEXT_EVENT); break; - case AsyncKeyboard: + case AsyncKeyboard: AllowSome(client, time, keybd, THAWED); break; case SyncBoth: @@ -1475,17 +1568,20 @@ ProcAllowEvents(register ClientPtr client) case AsyncBoth: AllowSome(client, time, keybd, THAWED_BOTH); break; - default: + default: client->errorValue = stuff->mode; return BadValue; } return Success; } +/** + * Deactivate grabs from any device that has been grabbed by the client. + */ void ReleaseActiveGrabs(ClientPtr client) { - register DeviceIntPtr dev; + DeviceIntPtr dev; Bool done; /* XXX CloseDownClient should remove passive grabs before @@ -1508,15 +1604,38 @@ ReleaseActiveGrabs(ClientPtr client) * The following procedures deal with delivering events * **************************************************************************/ +/** + * Deliver the given events to the given client. + * + * More than one event may be delivered at a time. This is the case with + * DeviceMotionNotifies which may be followed by DeviceValuator events. + * + * TryClientEvents() is the last station before actually writing the events to + * the socket. Anything that is not filtered here, will get delivered to the + * client. + * An event is only delivered if + * - mask and filter match up. + * - no other client has a grab on the device that caused the event. + * + * + * @param client The target client to deliver to. + * @param pEvents The events to be delivered. + * @param count Number of elements in pEvents. + * @param mask Event mask as set by the window. + * @param filter Mask based on event type. + * @param grab Possible grab on the device that caused the event. + * + * @return 1 if event was delivered, 0 if not or -1 if grab was not set by the + * client. + */ int -TryClientEvents (ClientPtr client, xEvent *pEvents, int count, Mask mask, +TryClientEvents (ClientPtr client, xEvent *pEvents, int count, Mask mask, Mask filter, GrabPtr grab) { int type; -#ifdef DEBUG - if (debug_events) ErrorF( - "Event([%d, %d], mask=0x%x), client=%d", +#ifdef DEBUG_EVENTS + ErrorF("Event([%d, %d], mask=0x%x), client=%d", pEvents->u.u.type, pEvents->u.u.detail, mask, client->index); #endif if ((client) && (client != serverClient) && (!client->clientGone) && @@ -1532,9 +1651,9 @@ TryClientEvents (ClientPtr client, xEvent *pEvents, int count, Mask mask, if (WID(inputInfo.pointer->valuator->motionHintWindow) == pEvents->u.keyButtonPointer.event) { -#ifdef DEBUG - if (debug_events) ErrorF("\n"); - fprintf(stderr,"motionHintWindow == keyButtonPointer.event\n"); +#ifdef DEBUG_EVENTS + ErrorF("\n"); + ErrorF("motionHintWindow == keyButtonPointer.event\n"); #endif return 1; /* don't send, but pretend we did */ } @@ -1562,27 +1681,44 @@ TryClientEvents (ClientPtr client, xEvent *pEvents, int count, Mask mask, } WriteEventsToClient(client, count, pEvents); -#ifdef DEBUG - if (debug_events) ErrorF( " delivered\n"); +#ifdef DEBUG_EVENTS + ErrorF( " delivered\n"); #endif return 1; } else { -#ifdef DEBUG - if (debug_events) ErrorF("\n"); +#ifdef DEBUG_EVENTS + ErrorF("\n"); #endif return 0; } } +/** + * Deliver events to a window. At this point, we do not yet know if the event + * actually needs to be delivered. May activate a grab if the event is a + * button press. + * + * More than one event may be delivered at a time. This is the case with + * DeviceMotionNotifies which may be followed by DeviceValuator events. + * + * @param pWin The window that would get the event. + * @param pEvents The events to be delivered. + * @param count Number of elements in pEvents. + * @param filter Mask based on event type. + * @param grab Possible grab on the device that caused the event. + * @param mskidx Mask index, depending on device that caused event. + * + * @return Number of events delivered to various clients. + */ int -DeliverEventsToWindow(register WindowPtr pWin, xEvent *pEvents, int count, +DeliverEventsToWindow(WindowPtr pWin, xEvent *pEvents, int count, Mask filter, GrabPtr grab, int mskidx) { int deliveries = 0, nondeliveries = 0; int attempt; - register InputClients *other; + InputClients *other; ClientPtr client = NullClient; Mask deliveryMask = 0; /* If a grab occurs due to a button press, then this mask is the mask of the grab. */ @@ -1678,11 +1814,11 @@ DeliverEventsToWindow(register WindowPtr pWin, xEvent *pEvents, int count, */ #ifdef PANORAMIX -static int +static int XineramaTryClientEventsResult( ClientPtr client, GrabPtr grab, - Mask mask, + Mask mask, Mask filter ){ if ((client) && (client != serverClient) && (!client->clientGone) && @@ -1695,11 +1831,20 @@ XineramaTryClientEventsResult( } #endif +/** + * Try to deliver events to the interested parties. + * + * @param pWin The window that would get the event. + * @param pEvents The events to be delivered. + * @param count Number of elements in pEvents. + * @param filter Mask based on event type. + * @param dontClient Don't deliver to the dontClient. + */ int -MaybeDeliverEventsToClient(register WindowPtr pWin, xEvent *pEvents, +MaybeDeliverEventsToClient(WindowPtr pWin, xEvent *pEvents, int count, Mask filter, ClientPtr dontClient) { - register OtherClients *other; + OtherClients *other; if (pWin->eventMask & filter) @@ -1707,7 +1852,7 @@ MaybeDeliverEventsToClient(register WindowPtr pWin, xEvent *pEvents, if (wClient(pWin) == dontClient) return 0; #ifdef PANORAMIX - if(!noPanoramiXExtension && pWin->drawable.pScreen->myNum) + if(!noPanoramiXExtension && pWin->drawable.pScreen->myNum) return XineramaTryClientEventsResult( wClient(pWin), NullGrab, pWin->eventMask, filter); #endif @@ -1721,7 +1866,7 @@ MaybeDeliverEventsToClient(register WindowPtr pWin, xEvent *pEvents, if (SameClient(other, dontClient)) return 0; #ifdef PANORAMIX - if(!noPanoramiXExtension && pWin->drawable.pScreen->myNum) + if(!noPanoramiXExtension && pWin->drawable.pScreen->myNum) return XineramaTryClientEventsResult( rClient(other), NullGrab, other->mask, filter); #endif @@ -1732,6 +1877,14 @@ MaybeDeliverEventsToClient(register WindowPtr pWin, xEvent *pEvents, return 2; } +/** + * Adjust event fields to comply with the window properties. + * + * @param xE Event to be modified in place + * @param pWin The window to get the information from. + * @param child Child window setting for event (if applicable) + * @param calcChild If True, calculate the child window. + */ static void FixUpEventFromWindow( xEvent *xE, @@ -1742,29 +1895,29 @@ FixUpEventFromWindow( if (calcChild) { WindowPtr w=spriteTrace[spriteTraceGood-1]; - /* If the search ends up past the root should the child field be - set to none or should the value in the argument be passed - through. It probably doesn't matter since everyone calls + /* If the search ends up past the root should the child field be + set to none or should the value in the argument be passed + through. It probably doesn't matter since everyone calls this function with child == None anyway. */ - while (w) + while (w) { /* If the source window is same as event window, child should be none. Don't bother going all all the way back to the root. */ if (w == pWin) - { + { child = None; break; } - + if (w->parent == pWin) { child = w->drawable.id; break; } w = w->parent; - } + } } XE_KBPTR.root = ROOT->drawable.id; XE_KBPTR.event = pWin->drawable.id; @@ -1786,9 +1939,25 @@ FixUpEventFromWindow( } } +/** + * Deliver events caused by input devices. Called for all core input events + * and XI events. No filtering of events happens before DeliverDeviceEvents(), + * it will be called for any event that comes out of the event queue. + * + * For all core events, dev is either inputInfo.void * or inputInfo.keyboard. + * For all extension events, dev is the device that caused the event. + * + * @param pWin Window to deliver event to. + * @param xE Events to deliver. + * @param grab Possible grab on a device. + * @param stopAt Don't recurse up to the root window. + * @param dev The device that is responsible for the event. + * @param count number of events in xE. + * + */ int -DeliverDeviceEvents(register WindowPtr pWin, register xEvent *xE, GrabPtr grab, - register WindowPtr stopAt, DeviceIntPtr dev, int count) +DeliverDeviceEvents(WindowPtr pWin, xEvent *xE, GrabPtr grab, + WindowPtr stopAt, DeviceIntPtr dev, int count) { Window child = None; int type = xE->u.u.type; @@ -1797,7 +1966,7 @@ DeliverDeviceEvents(register WindowPtr pWin, register xEvent *xE, GrabPtr grab, if (type & EXTENSION_EVENT_BASE) { - register OtherInputMasks *inputMasks; + OtherInputMasks *inputMasks; int mskidx = dev->id; inputMasks = wOtherInputMasks(pWin); @@ -1849,10 +2018,22 @@ DeliverDeviceEvents(register WindowPtr pWin, register xEvent *xE, GrabPtr grab, return 0; } -/* not useful for events that propagate up the tree or extension events */ +/** + * Deliver event to a window and it's immediate parent. Used for most window + * events (CreateNotify, ConfigureNotify, etc.). Not useful for events that + * propagate up the tree or extension events + * + * In case of a ReparentNotify event, the event will be delivered to the + * otherParent as well. + * + * @param pWin Window to deliver events to. + * @param xE Events to deliver. + * @param count number of events in xE. + * @param otherParent Used for ReparentNotify events. + */ int -DeliverEvents(register WindowPtr pWin, register xEvent *xE, int count, - register WindowPtr otherParent) +DeliverEvents(WindowPtr pWin, xEvent *xE, int count, + WindowPtr otherParent) { Mask filter; int deliveries; @@ -1889,7 +2070,7 @@ DeliverEvents(register WindowPtr pWin, register xEvent *xE, int count, } -static Bool +static Bool PointInBorderSize(WindowPtr pWin, int x, int y) { BoxRec box; @@ -1903,9 +2084,9 @@ PointInBorderSize(WindowPtr pWin, int x, int y) for(i = 1; i < PanoramiXNumScreens; i++) { if(RegionContainsPoint( - &sprite.windows[i]->borderSize, - x + panoramiXdataPtr[0].x - panoramiXdataPtr[i].x, - y + panoramiXdataPtr[0].y - panoramiXdataPtr[i].y, + &sprite.windows[i]->borderSize, + x + panoramiXdataPtr[0].x - panoramiXdataPtr[i].x, + y + panoramiXdataPtr[0].y - panoramiXdataPtr[i].y, &box)) return TRUE; } @@ -1925,10 +2106,21 @@ static WindowPtr GetXYStartWindow(WindowPtr pWin) } #endif -static WindowPtr +/** + * Traversed from the root window to the window at the position x/y. While + * traversing, it sets up the traversal history in the spriteTrace array. + * After completing, the spriteTrace history is set in the following way: + * spriteTrace[0] ... root window + * spriteTrace[1] ... top level window that encloses x/y + * ... + * spriteTrace[spriteTraceGood - 1] ... window at x/y + * + * @returns the window at the given coordinates. + */ +static WindowPtr XYToWindow(int x, int y) { - register WindowPtr pWin; + WindowPtr pWin; BoxRec box; spriteTraceGood = 1; /* root window still there */ @@ -1972,6 +2164,13 @@ XYToWindow(int x, int y) } #ifndef NXAGENT_SERVER +/** + * Update the sprite coordinates based on the event. Update the cursor + * position, then update the event with the new coordinates that may have been + * changed. If the window underneath the sprite has changed, change to new + * cursor and send enter/leave events. + */ + static Bool CheckMotion(xEvent *xE) { @@ -2038,8 +2237,12 @@ CheckMotion(xEvent *xE) } #endif /* NXAGENT_SERVER */ +/** + * Windows have restructured, we need to update the sprite position and the + * sprite's cursor. + */ void -WindowsRestructured() +WindowsRestructured(void) { (void) CheckMotion((xEvent *)NULL); } @@ -2055,14 +2258,14 @@ void ReinitializeRootWindow(WindowPtr win, int xoff, int yoff) GrabPtr grab; if (noPanoramiXExtension) return; - + sprite.hot.x -= xoff; sprite.hot.y -= yoff; sprite.hotPhys.x -= xoff; sprite.hotPhys.y -= yoff; - sprite.hotLimits.x1 -= xoff; + sprite.hotLimits.x1 -= xoff; sprite.hotLimits.y1 -= yoff; sprite.hotLimits.x2 -= xoff; sprite.hotLimits.y2 -= yoff; @@ -2083,14 +2286,18 @@ void ReinitializeRootWindow(WindowPtr win, int xoff, int yoff) } #endif +/** + * Set the given window to sane values, display the cursor in the center of + * the screen. Called from main() with the root window on the first screen. + */ void #ifdef NXAGENT_SERVER -xorg_DefineInitialRootWindow(register WindowPtr win) +xorg_DefineInitialRootWindow(WindowPtr win) #else -DefineInitialRootWindow(register WindowPtr win) +DefineInitialRootWindow(WindowPtr win) #endif { - register ScreenPtr pScreen = win->drawable.pScreen; + ScreenPtr pScreen = win->drawable.pScreen; sprite.hotPhys.pScreen = pScreen; sprite.hotPhys.x = pScreen->width / 2; @@ -2149,9 +2356,9 @@ NewCurrentScreen(ScreenPtr newScreen, int x, int y) sprite.hotPhys.y = y; #ifdef PANORAMIX if(!noPanoramiXExtension) { - sprite.hotPhys.x += panoramiXdataPtr[newScreen->myNum].x - + sprite.hotPhys.x += panoramiXdataPtr[newScreen->myNum].x - panoramiXdataPtr[0].x; - sprite.hotPhys.y += panoramiXdataPtr[newScreen->myNum].y - + sprite.hotPhys.y += panoramiXdataPtr[newScreen->myNum].y - panoramiXdataPtr[0].y; if (newScreen != sprite.screen) { sprite.screen = newScreen; @@ -2160,16 +2367,16 @@ NewCurrentScreen(ScreenPtr newScreen, int x, int y) XineramaConfineCursorToWindow(sprite.confineWin, TRUE); else XineramaConfineCursorToWindow(screenInfo.screens[0]->root, TRUE); - /* if the pointer wasn't confined, the DDX won't get + /* if the pointer wasn't confined, the DDX won't get told of the pointer warp so we reposition it here */ if(!syncEvents.playingEvents) (*sprite.screen->SetCursorPosition)(sprite.screen, - sprite.hotPhys.x + panoramiXdataPtr[0].x - + sprite.hotPhys.x + panoramiXdataPtr[0].x - panoramiXdataPtr[sprite.screen->myNum].x, - sprite.hotPhys.y + panoramiXdataPtr[0].y - + sprite.hotPhys.y + panoramiXdataPtr[0].y - panoramiXdataPtr[sprite.screen->myNum].y, FALSE); } - } else + } else #endif if (newScreen != sprite.hotPhys.pScreen) ConfineCursorToWindow(newScreen->root, TRUE, FALSE); @@ -2191,11 +2398,11 @@ XineramaPointInWindowIsVisible( if (RegionContainsPoint(&pWin->borderClip, x, y, &box)) return TRUE; - + if(!XineramaSetWindowPntrs(pWin)) return FALSE; - xoff = x + panoramiXdataPtr[0].x; - yoff = y + panoramiXdataPtr[0].y; + xoff = x + panoramiXdataPtr[0].x; + yoff = y + panoramiXdataPtr[0].y; for(i = 1; i < PanoramiXNumScreens; i++) { pWin = sprite.windows[i]; @@ -2206,7 +2413,7 @@ XineramaPointInWindowIsVisible( && (!wInputShape(pWin) || RegionContainsPoint( wInputShape(pWin), - x - pWin->drawable.x, + x - pWin->drawable.x, y - pWin->drawable.y, &box))) return TRUE; @@ -2238,7 +2445,7 @@ XineramaWarpPointer(ClientPtr client) int winX, winY; XID winID = stuff->srcWid; WindowPtr source; - + source = SecurityLookupWindow(winID, client, DixReadAccess); if (!source) return BadWindow; @@ -2264,7 +2471,7 @@ XineramaWarpPointer(ClientPtr client) x -= panoramiXdataPtr[0].x; y -= panoramiXdataPtr[0].y; } - } + } x += stuff->dstX; y += stuff->dstY; @@ -2288,6 +2495,10 @@ XineramaWarpPointer(ClientPtr client) #endif +/** + * Server-side protocol handling for WarpPointer request. + * Warps the cursor position to the coordinates given in the request. + */ int ProcWarpPointer(ClientPtr client) { @@ -2318,7 +2529,7 @@ ProcWarpPointer(ClientPtr client) int winX, winY; XID winID = stuff->srcWid; WindowPtr source; - + source = SecurityLookupWindow(winID, client, DixReadAccess); if (!source) return BadWindow; @@ -2334,12 +2545,12 @@ ProcWarpPointer(ClientPtr client) !PointInWindowIsVisible(source, x, y)) return Success; } - if (dest) + if (dest) { x = dest->drawable.x; y = dest->drawable.y; newScreen = dest->drawable.pScreen; - } else + } else newScreen = sprite.hotPhys.pScreen; x += stuff->dstX; @@ -2377,7 +2588,7 @@ ProcWarpPointer(ClientPtr client) return Success; } -static Bool +static Bool BorderSizeNotEmpty(WindowPtr pWin) { if(RegionNotEmpty(&pWin->borderSize)) @@ -2396,19 +2607,27 @@ BorderSizeNotEmpty(WindowPtr pWin) return FALSE; } -/* "CheckPassiveGrabsOnWindow" checks to see if the event passed in causes a - passive grab set on the window to be activated. */ +/** + * "CheckPassiveGrabsOnWindow" checks to see if the event passed in causes a + * passive grab set on the window to be activated. + * If a passive grab is activated, the event will be delivered to the client. + * + * @param pWin The window that may be subject to a passive grab. + * @param device Device that caused the event. + * @param xE List of events (multiple ones for DeviceMotionNotify) + * @count number of elements in xE. + */ static Bool CheckPassiveGrabsOnWindow( WindowPtr pWin, - register DeviceIntPtr device, - register xEvent *xE, + DeviceIntPtr device, + xEvent *xE, int count) { - register GrabPtr grab = wPassiveGrabs(pWin); + GrabPtr grab = wPassiveGrabs(pWin); GrabRec tempGrab; - register xEvent *dxE; + xEvent *dxE; if (!grab) return FALSE; @@ -2449,7 +2668,7 @@ CheckPassiveGrabsOnWindow( #endif if (GrabMatchesSecond(&tempGrab, grab) && (!grab->confineTo || - (grab->confineTo->realized && + (grab->confineTo->realized && BorderSizeNotEmpty(grab->confineTo)))) { #ifdef XCSECURITY @@ -2464,7 +2683,7 @@ CheckPassiveGrabsOnWindow( } #endif (*device->ActivateGrab)(device, grab, currentTime, TRUE); - + FixUpEventFromWindow(xE, grab->window, None, TRUE); (void) TryClientEvents(rClient(grab), xE, count, @@ -2483,7 +2702,7 @@ CheckPassiveGrabsOnWindow( for (dxE = device->sync.event; --count >= 0; dxE++, xE++) *dxE = *xE; device->sync.state = FROZEN_WITH_EVENT; - } + } return TRUE; } } @@ -2491,25 +2710,35 @@ CheckPassiveGrabsOnWindow( } /** -"CheckDeviceGrabs" handles both keyboard and pointer events that may cause -a passive grab to be activated. If the event is a keyboard event, the -ancestors of the focus window are traced down and tried to see if they have -any passive grabs to be activated. If the focus window itself is reached and -its descendants contain the pointer, the ancestors of the window that the -pointer is in are then traced down starting at the focus window, otherwise no -grabs are activated. If the event is a pointer event, the ancestors of the -window that the pointer is in are traced down starting at the root until -CheckPassiveGrabs causes a passive grab to activate or all the windows are -tried. PRH + * CheckDeviceGrabs handles both keyboard and void * events that may cause + * a passive grab to be activated. + * + * If the event is a keyboard event, the ancestors of the focus window are + * traced down and tried to see if they have any passive grabs to be + * activated. If the focus window itself is reached and it's descendants + * contain the pointer, the ancestors of the window that the void * is in + * are then traced down starting at the focus window, otherwise no grabs are + * activated. + * If the event is a void * event, the ancestors of the window that the + * void * is in are traced down starting at the root until CheckPassiveGrabs + * causes a passive grab to activate or all the windows are + * tried. PRH + * + * If a grab is activated, the event has been sent to the client already! + * + * @param device The device that caused the event. + * @param xE The event to handle (most likely {Device}ButtonPress). + * @param count Number of events in list. + * @return TRUE if a grab has been activated or false otherwise. */ Bool -CheckDeviceGrabs(register DeviceIntPtr device, register xEvent *xE, +CheckDeviceGrabs(DeviceIntPtr device, xEvent *xE, int checkFirst, int count) { - register int i; - register WindowPtr pWin = NULL; - register FocusClassPtr focus = device->focus; + int i; + WindowPtr pWin = NULL; + FocusClassPtr focus = device->focus; if (((xE->u.u.type == ButtonPress) #if defined(XINPUT) && defined(XKB) @@ -2529,7 +2758,7 @@ CheckDeviceGrabs(register DeviceIntPtr device, register xEvent *xE, CheckPassiveGrabsOnWindow(pWin, device, xE, count)) return TRUE; } - + if ((focus->win == NoneWin) || (i >= spriteTraceGood) || ((i > checkFirst) && (pWin != spriteTrace[i-1]))) @@ -2547,6 +2776,16 @@ CheckDeviceGrabs(register DeviceIntPtr device, register xEvent *xE, return FALSE; } +/** + * Called for keyboard events to deliver event to whatever client owns the + * focus. Event is delivered to the keyboard's focus window, the root window + * or to the window owning the input focus. + * + * @param keybd The keyboard originating the event. + * @param xE The event list. + * @param window Window underneath the sprite. + * @param count number of events in xE. + */ void DeliverFocusedEvent(DeviceIntPtr keybd, xEvent *xE, WindowPtr window, int count) { @@ -2575,14 +2814,21 @@ DeliverFocusedEvent(DeviceIntPtr keybd, xEvent *xE, WindowPtr window, int count) NullGrab, mskidx); } +/** + * Deliver an event from a device that is currently grabbed. Uses + * DeliverDeviceEvents() for further delivery if a ownerEvents is set on the + * grab. If not, TryClientEvents() is used. + * + * @param deactivateGrab True if the device's grab should be deactivated. + */ void -DeliverGrabbedEvent(register xEvent *xE, register DeviceIntPtr thisDev, +DeliverGrabbedEvent(xEvent *xE, DeviceIntPtr thisDev, Bool deactivateGrab, int count) { - register GrabPtr grab = thisDev->grab; + GrabPtr grab = thisDev->grab; int deliveries = 0; - register DeviceIntPtr dev; - register xEvent *dxE; + DeviceIntPtr dev; + xEvent *dxE; if (grab->ownerEvents) { @@ -2655,21 +2901,32 @@ DeliverGrabbedEvent(register xEvent *xE, register DeviceIntPtr thisDev, } } +/** + * Main keyboard event processing function for core keyboard events. + * Updates the events fields from the current void * state and delivers the + * event. + * + * For key events, xE will always be a single event. + * + * @param xE Event list + * @param keybd The device that caused an event. + * @param count Number of elements in xE. + */ void #ifdef XKB -CoreProcessKeyboardEvent (register xEvent *xE, register DeviceIntPtr keybd, int count) +CoreProcessKeyboardEvent (xEvent *xE, DeviceIntPtr keybd, int count) #else -ProcessKeyboardEvent (register xEvent *xE, register DeviceIntPtr keybd, int count) +ProcessKeyboardEvent (xEvent *xE, DeviceIntPtr keybd, int count) #endif { int key, bit; - register BYTE *kptr; - register int i; - register CARD8 modifiers; - register CARD16 mask; + BYTE *kptr; + int i; + CARD8 modifiers; + CARD16 mask; GrabPtr grab = keybd->grab; Bool deactivateGrab = FALSE; - register KeyClassPtr keyc = keybd->key; + KeyClassPtr keyc = keybd->key; if (!syncEvents.playingEvents) { @@ -2699,9 +2956,9 @@ ProcessKeyboardEvent (register xEvent *xE, register DeviceIntPtr keybd, int coun #endif switch (xE->u.u.type) { - case KeyPress: + case KeyPress: if (*kptr & bit) /* allow ddx to generate multiple downs */ - { + { if (!modifiers) { xE->u.u.type = KeyRelease; @@ -2731,7 +2988,7 @@ ProcessKeyboardEvent (register xEvent *xE, register DeviceIntPtr keybd, int coun return; } break; - case KeyRelease: + case KeyRelease: if (!(*kptr & bit)) /* guard against duplicates */ return; inputInfo.pointer->valuator->motionHintWindow = NullWindow; @@ -2751,7 +3008,7 @@ ProcessKeyboardEvent (register xEvent *xE, register DeviceIntPtr keybd, int coun if (keybd->fromPassiveGrab && (key == keybd->activatingKey)) deactivateGrab = TRUE; break; - default: + default: FatalError("Impossible keyboard event"); } if (grab) @@ -2764,50 +3021,58 @@ ProcessKeyboardEvent (register xEvent *xE, register DeviceIntPtr keybd, int coun #ifdef XKB /* This function is used to set the key pressed or key released state - - this is only used when the pressing of keys does not cause - CoreProcessKeyEvent to be called, as in for example Mouse Keys. + this is only used when the pressing of keys does not cause + the device's processInputProc to be called, as in for example Mouse Keys. */ void -FixKeyState (register xEvent *xE, register DeviceIntPtr keybd) +FixKeyState (xEvent *xE, DeviceIntPtr keybd) { int key, bit; - register BYTE *kptr; - register KeyClassPtr keyc = keybd->key; + BYTE *kptr; + KeyClassPtr keyc = keybd->key; key = xE->u.u.detail; kptr = &keyc->down[key >> 3]; bit = 1 << (key & 7); -#ifdef DEBUG - if ((xkbDebugFlags&0x4)&& - ((xE->u.u.type==KeyPress)||(xE->u.u.type==KeyRelease))) { - ErrorF("FixKeyState: Key %d %s\n",key, - (xE->u.u.type==KeyPress?"down":"up")); + + if (((xE->u.u.type==KeyPress)||(xE->u.u.type==KeyRelease)|| + (xE->u.u.type==DeviceKeyPress)||(xE->u.u.type==DeviceKeyRelease)) + ) { + DebugF("FixKeyState: Key %d %s\n",key, + (((xE->u.u.type==KeyPress)||(xE->u.u.type==DeviceKeyPress))?"down":"up")); } -#endif - switch (xE->u.u.type) - { - case KeyPress: + + if (xE->u.u.type == KeyPress || xE->u.u.type == DeviceKeyPress) *kptr |= bit; - break; - case KeyRelease: + else if (xE->u.u.type == KeyRelease || xE->u.u.type == DeviceKeyRelease) *kptr &= ~bit; - break; - default: - FatalError("Impossible keyboard event"); - } + else + FatalError("Impossible keyboard event"); } #endif +/** + * Main void * event processing function for core pointer events. + * For motion events: update the sprite. + * For all other events: Update the event fields based on the current sprite + * state. + * + * For core void * events, xE will always be a single event. + * + * @param xE Event list + * @param mouse The device that caused an event. + * @param count Number of elements in xE. + */ void #ifdef XKB -CoreProcessPointerEvent (register xEvent *xE, register DeviceIntPtr mouse, int count) +CoreProcessPointerEvent (xEvent *xE, DeviceIntPtr mouse, int count) #else -ProcessPointerEvent (register xEvent *xE, register DeviceIntPtr mouse, int count) +ProcessPointerEvent (xEvent *xE, DeviceIntPtr mouse, int count) #endif { - register GrabPtr grab = mouse->grab; + GrabPtr grab = mouse->grab; Bool deactivateGrab = FALSE; - register ButtonClassPtr butc = mouse->button; + ButtonClassPtr butc = mouse->button; #ifdef XKB XkbSrvInfoPtr xkbi= inputInfo.keyboard->key->xkbInfo; #endif @@ -2839,8 +3104,8 @@ ProcessPointerEvent (register xEvent *xE, register DeviceIntPtr mouse, int count } if (xE->u.u.type != MotionNotify) { - register int key; - register BYTE *kptr; + int key; + BYTE *kptr; int bit; XE_KBPTR.rootX = sprite.hot.x; @@ -2851,7 +3116,7 @@ ProcessPointerEvent (register xEvent *xE, register DeviceIntPtr mouse, int count bit = 1 << (key & 7); switch (xE->u.u.type) { - case ButtonPress: + case ButtonPress: mouse->valuator->motionHintWindow = NullWindow; if (!(*kptr & bit)) butc->buttonsDown++; @@ -2866,7 +3131,7 @@ ProcessPointerEvent (register xEvent *xE, register DeviceIntPtr mouse, int count if (CheckDeviceGrabs(mouse, xE, 0, count)) return; break; - case ButtonRelease: + case ButtonRelease: mouse->valuator->motionHintWindow = NullWindow; if (*kptr & bit) --butc->buttonsDown; @@ -2881,7 +3146,7 @@ ProcessPointerEvent (register xEvent *xE, register DeviceIntPtr mouse, int count if (!butc->state && mouse->fromPassiveGrab) deactivateGrab = TRUE; break; - default: + default: FatalError("bogus pointer event from ddx"); } } @@ -2899,12 +3164,24 @@ ProcessPointerEvent (register xEvent *xE, register DeviceIntPtr mouse, int count #define AtMostOneClient \ (SubstructureRedirectMask | ResizeRedirectMask | ButtonPressMask) +/** + * Recalculate which events may be deliverable for the given window. + * Recalculated mask is used for quicker determination which events may be + * delivered to a window. + * + * The otherEventMasks on a WindowOptional is the combination of all event + * masks set by all clients on the window. + * deliverableEventMask is the combination of the eventMask and the + * otherEventMask. + * + * Traverses to siblings and parents of the window. + */ void RecalculateDeliverableEvents(pWin) - register WindowPtr pWin; + WindowPtr pWin; { - register OtherClients *others; - register WindowPtr pChild; + OtherClients *others; + WindowPtr pChild; pChild = pWin; while (1) @@ -2943,8 +3220,8 @@ RecalculateDeliverableEvents(pWin) int OtherClientGone(void * value, XID id) { - register OtherClientsPtr other, prev; - register WindowPtr pWin = (WindowPtr)value; + OtherClientsPtr other, prev; + WindowPtr pWin = (WindowPtr)value; prev = 0; for (other = wOtherClients(pWin); other; other = other->next) @@ -2970,7 +3247,7 @@ OtherClientGone(void * value, XID id) } int -EventSelectForWindow(register WindowPtr pWin, register ClientPtr client, Mask mask) +EventSelectForWindow(WindowPtr pWin, ClientPtr client, Mask mask) { Mask check; OtherClients * others; @@ -3031,7 +3308,7 @@ EventSelectForWindow(register WindowPtr pWin, register ClientPtr client, Mask ma if (!AddResource(others->resource, RT_OTHERCLIENT, (void *)pWin)) return BadAlloc; } -maskSet: +maskSet: if ((inputInfo.pointer->valuator->motionHintWindow == pWin) && (mask & PointerMotionHintMask) && !(check & PointerMotionHintMask) && @@ -3042,10 +3319,10 @@ EventSelectForWindow(register WindowPtr pWin, register ClientPtr client, Mask ma } int -EventSuppressForWindow(register WindowPtr pWin, register ClientPtr client, +EventSuppressForWindow(WindowPtr pWin, ClientPtr client, Mask mask, Bool *checkOptional) { - register int i, free; + int i, free; if (mask & ~PropagateMask) { @@ -3097,28 +3374,35 @@ EventSuppressForWindow(register WindowPtr pWin, register ClientPtr client, return Success; } -static WindowPtr +/** + * @return The window that is the first ancestor of both a and b. + */ +static WindowPtr CommonAncestor( - register WindowPtr a, - register WindowPtr b) + WindowPtr a, + WindowPtr b) { for (b = b->parent; b; b = b->parent) if (IsParent(b, a)) return b; return NullWindow; } +/** + * Assembles an EnterNotify or LeaveNotify and sends it event to the client. + * The core devices are used to fill in the event fields. + */ static void EnterLeaveEvent( int type, int mode, int detail, - register WindowPtr pWin, + WindowPtr pWin, Window child) { - register DeviceIntPtr keybd = inputInfo.keyboard; + DeviceIntPtr keybd = inputInfo.keyboard; WindowPtr focus; - register DeviceIntPtr mouse = inputInfo.pointer; - register GrabPtr grab = mouse->grab; + DeviceIntPtr mouse = inputInfo.pointer; + GrabPtr grab = mouse->grab; Mask mask; if ((pWin == mouse->valuator->motionHintWindow) && @@ -3152,7 +3436,7 @@ EnterLeaveEvent( #ifdef XKB if (!noXkbExtension) { event.u.enterLeave.state = mouse->button->state & 0x1f00; - event.u.enterLeave.state |= + event.u.enterLeave.state |= XkbGrabStateFromRec(&keybd->key->xkbInfo->state); } else #endif @@ -3194,6 +3478,10 @@ EnterLeaveEvent( } } +/** + * Send enter notifies to all parent windows up to ancestor. + * This function recurses. + */ static void EnterNotifies(WindowPtr ancestor, WindowPtr child, int mode, int detail) { @@ -3205,10 +3493,15 @@ EnterNotifies(WindowPtr ancestor, WindowPtr child, int mode, int detail) EnterLeaveEvent(EnterNotify, mode, detail, parent, child->drawable.id); } + +/** + * Send leave notifies to all parent windows up to ancestor. + * This function recurses. + */ static void LeaveNotifies(WindowPtr child, WindowPtr ancestor, int mode, int detail) { - register WindowPtr pWin; + WindowPtr pWin; if (ancestor == child) return; @@ -3219,6 +3512,13 @@ LeaveNotifies(WindowPtr child, WindowPtr ancestor, int mode, int detail) } } +/** + * Figure out if enter/leave events are necessary and send them to the + * appropriate windows. + * + * @param fromWin Window the sprite moved out of. + * @param toWin Window the sprite moved into. + */ static void DoEnterLeaveEvents(WindowPtr fromWin, WindowPtr toWin, int mode) { @@ -3248,7 +3548,7 @@ DoEnterLeaveEvents(WindowPtr fromWin, WindowPtr toWin, int mode) } static void -FocusEvent(DeviceIntPtr dev, int type, int mode, int detail, register WindowPtr pWin) +FocusEvent(DeviceIntPtr dev, int type, int mode, int detail, WindowPtr pWin) { xEvent event; @@ -3322,7 +3622,7 @@ FocusOutEvents( int mode, int detail, Bool doAncestor) { - register WindowPtr pWin; + WindowPtr pWin; for (pWin = child; pWin != ancestor; pWin = pWin->parent) FocusEvent(dev, FocusOut, mode, detail, pWin); @@ -3354,7 +3654,7 @@ DoFocusEvents(DeviceIntPtr dev, WindowPtr fromWin, WindowPtr toWin, int mode) #ifdef PANORAMIX if ( !noPanoramiXExtension ) FocusEvent(dev, FocusOut, mode, out, screenInfo.screens[0]->root); - else + else #endif for (i=0; iroot); @@ -3373,7 +3673,7 @@ DoFocusEvents(DeviceIntPtr dev, WindowPtr fromWin, WindowPtr toWin, int mode) #ifdef PANORAMIX if ( !noPanoramiXExtension ) FocusEvent(dev, FocusIn, mode, in, screenInfo.screens[0]->root); - else + else #endif for (i=0; iroot); @@ -3391,7 +3691,7 @@ DoFocusEvents(DeviceIntPtr dev, WindowPtr fromWin, WindowPtr toWin, int mode) #ifdef PANORAMIX if ( !noPanoramiXExtension ) FocusEvent(dev, FocusOut, mode, out, screenInfo.screens[0]->root); - else + else #endif for (i=0; iroot); @@ -3456,6 +3756,23 @@ DoFocusEvents(DeviceIntPtr dev, WindowPtr fromWin, WindowPtr toWin, int mode) } } +/** + * Set the input focus to the given window. Subsequent keyboard events will be + * delivered to the given window. + * + * Usually called from ProcSetInputFocus as result of a client request. If so, + * the device is the inputInfo.keyboard. + * If called from ProcXSetInputFocus as result of a client xinput request, the + * device is set to the device specified by the client. + * + * @param client Client that requested input focus change. + * @param dev Focus device. + * @param focusID The window to obtain the focus. Can be PointerRoot or None. + * @param revertTo Specifies where the focus reverts to when window becomes + * unviewable. + * @param ctime Specifies the time. + * @param followOK True if void * is allowed to follow the keyboard. + */ int SetInputFocus( ClientPtr client, @@ -3465,8 +3782,8 @@ SetInputFocus( Time ctime, Bool followOK) { - register FocusClassPtr focus; - register WindowPtr focusWin; + FocusClassPtr focus; + WindowPtr focusWin; int mode; TimeStamp time; @@ -3489,7 +3806,7 @@ SetInputFocus( return BadWindow; else { - /* It is a match error to try to set the input focus to an + /* It is a match error to try to set the input focus to an unviewable window. */ if(!focusWin->realized) @@ -3515,7 +3832,7 @@ SetInputFocus( else { int depth = 0; - register WindowPtr pWin; + WindowPtr pWin; for (pWin = focusWin; pWin; pWin = pWin->parent) depth++; if (depth > focus->traceSize) @@ -3525,12 +3842,17 @@ SetInputFocus( focus->traceSize * sizeof(WindowPtr)); } focus->traceGood = depth; - for (pWin = focusWin, depth--; pWin; pWin = pWin->parent, depth--) + for (pWin = focusWin, depth--; pWin; pWin = pWin->parent, depth--) focus->trace[depth] = pWin; } return Success; } +/** + * Server-side protocol handling for SetInputFocus request. + * + * Sets the input focus for the virtual core keyboard. + */ int ProcSetInputFocus(client) ClientPtr client; @@ -3546,6 +3868,12 @@ ProcSetInputFocus(client) stuff->revertTo, stuff->time, FALSE); } +/** + * Server-side protocol handling for GetInputFocus request. + * + * Sends the current input focus for the virtual core keyboard back to the + * client. + */ int ProcGetInputFocus(ClientPtr client) { @@ -3568,6 +3896,12 @@ ProcGetInputFocus(ClientPtr client) return Success; } +/** + * Server-side protocol handling for Grabvoid * request. + * + * Sets an active grab on the inputInfo.void * and returns success status to + * client. + */ int ProcGrabPointer(ClientPtr client) { @@ -3608,7 +3942,7 @@ ProcGrabPointer(ClientPtr client) return BadWindow; if (stuff->confineTo == None) confineTo = NullWindow; - else + else { confineTo = SecurityLookupWindow(stuff->confineTo, client, DixReadAccess); @@ -3675,11 +4009,19 @@ ProcGrabPointer(ClientPtr client) return Success; } +/** + * Server-side protocol handling for ChangeActivePointerGrab request. + * + * Changes properties of the grab hold by the client. If the client does not + * hold an active grab on the device, nothing happens. + * + * Works on the core void * only. + */ int ProcChangeActivePointerGrab(ClientPtr client) { DeviceIntPtr device = inputInfo.pointer; - register GrabPtr grab = device->grab; + GrabPtr grab = device->grab; CursorPtr newCursor, oldCursor; REQUEST(xChangeActivePointerGrabReq); TimeStamp time; @@ -3721,6 +4063,11 @@ ProcChangeActivePointerGrab(ClientPtr client) return Success; } +/** + * Server-side protocol handling for UngrabPointer request. + * + * Deletes the void * grab on the core pointer device. + */ int ProcUngrabPointer(ClientPtr client) { @@ -3740,13 +4087,31 @@ ProcUngrabPointer(ClientPtr client) return Success; } +/** + * Sets a grab on the given device. + * + * Called from ProcGrabKeyboard to work on the inputInfo.keyboard. + * Called from ProcXGrabDevice to work on the device specified by the client. + * + * The parameters this_mode and other_mode represent the keyboard_mode and + * pointer_mode parameters of XGrabKeyboard(). + * See man page for details on all the parameters + * + * @param client Client that owns the grab. + * @param dev The device to grab. + * @param this_mode GrabModeSync or GrabModeAsync + * @param other_mode GrabModeSync or GrabModeAsync + * @param status Return code to be returned to the caller. + * + * @returns Success or BadValue. + */ int -GrabDevice(register ClientPtr client, register DeviceIntPtr dev, - unsigned this_mode, unsigned other_mode, Window grabWindow, +GrabDevice(ClientPtr client, DeviceIntPtr dev, + unsigned this_mode, unsigned other_mode, Window grabWindow, unsigned ownerEvents, Time ctime, Mask mask, CARD8 *status) { - register WindowPtr pWin; - register GrabPtr grab; + WindowPtr pWin; + GrabPtr grab; TimeStamp time; UpdateCurrentTime(); @@ -3797,6 +4162,11 @@ GrabDevice(register ClientPtr client, register DeviceIntPtr dev, return Success; } +/** + * Server-side protocol handling for GrabKeyboard request. + * + * Grabs the inputInfo.keyboad and returns success status to client. + */ int ProcGrabKeyboard(ClientPtr client) { @@ -3827,6 +4197,11 @@ ProcGrabKeyboard(ClientPtr client) return Success; } +/** + * Server-side protocol handling for UngrabKeyboard request. + * + * Deletes a possible grab on the inputInfo.keyboard. + */ int ProcUngrabKeyboard(ClientPtr client) { @@ -3846,6 +4221,11 @@ ProcUngrabKeyboard(ClientPtr client) return Success; } +/** + * Server-side protocol handling for QueryPointer request. + * + * Returns the current state and position of the core void * to the client. + */ int ProcQueryPointer(ClientPtr client) { @@ -3901,11 +4281,15 @@ ProcQueryPointer(ClientPtr client) WriteReplyToClient(client, sizeof(xQueryPointerReply), &rep); - return(Success); + return(Success); } +/** + * Initializes the device list and the DIX sprite to sane values. Allocates + * trace memory used for quick window traversal. + */ void -InitEvents() +InitEvents(void) { int i; @@ -3962,6 +4346,11 @@ CloseDownEvents(void) spriteTraceSize = 0; } +/** + * Server-side protocol handling for SendEvent request. + * + * Locates the window to send the event to and forwards the event. + */ int #ifdef NXAGENT_SERVER xorg_ProcSendEvent(ClientPtr client) @@ -3979,7 +4368,7 @@ ProcSendEvent(ClientPtr client) extension. */ if ( ! ((stuff->event.u.u.type > X_Reply && - stuff->event.u.u.type < LASTEvent) || + stuff->event.u.u.type < LASTEvent) || (stuff->event.u.u.type >= EXTENSION_EVENT_BASE && stuff->event.u.u.type < (unsigned)lastEvent))) { @@ -4053,6 +4442,12 @@ ProcSendEvent(ClientPtr client) return Success; } +/** + * Server-side protocol handling for UngrabKey request. + * + * Deletes a passive grab for the given key. Only works on the + * inputInfo.keyboard. + */ int ProcUngrabKey(ClientPtr client) { @@ -4094,6 +4489,12 @@ ProcUngrabKey(ClientPtr client) return(Success); } +/** + * Server-side protocol handling for GrabKey request. + * + * Creates a grab for the inputInfo.keyboard and adds it to the list of + * passive grabs. + */ int ProcGrabKey(ClientPtr client) { @@ -4137,10 +4538,10 @@ ProcGrabKey(ClientPtr client) if (!pWin) return BadWindow; - grab = CreateGrab(client->index, keybd, pWin, + grab = CreateGrab(client->index, keybd, pWin, (Mask)(KeyPressMask | KeyReleaseMask), (Bool)stuff->ownerEvents, (Bool)stuff->keyboardMode, (Bool)stuff->pointerMode, - keybd, stuff->modifiers, KeyPress, stuff->key, + keybd, stuff->modifiers, KeyPress, stuff->key, NullWindow, NullCursor); if (!grab) return BadAlloc; @@ -4148,6 +4549,12 @@ ProcGrabKey(ClientPtr client) } +/** + * Server-side protocol handling for GrabButton request. + * + * Creates a grab for the inputInfo.void * and adds it as a passive grab to + * the list. + */ int ProcGrabButton(ClientPtr client) { @@ -4210,7 +4617,7 @@ ProcGrabButton(ClientPtr client) } - grab = CreateGrab(client->index, inputInfo.pointer, pWin, + grab = CreateGrab(client->index, inputInfo.pointer, pWin, (Mask)stuff->eventMask, (Bool)stuff->ownerEvents, (Bool) stuff->keyboardMode, (Bool)stuff->pointerMode, inputInfo.keyboard, stuff->modifiers, ButtonPress, @@ -4220,6 +4627,11 @@ ProcGrabButton(ClientPtr client) return AddPassiveGrabToList(grab); } +/** + * Server-side protocol handling for UngrabButton request. + * + * Deletes a passive grab on the inputInfo.void * from the list. + */ int ProcUngrabButton(ClientPtr client) { @@ -4252,6 +4664,17 @@ ProcUngrabButton(ClientPtr client) return(Success); } +/** + * Deactivate any grab that may be on the window, remove the focus. + * Delete any XInput extension events from the window too. Does not change the + * window mask. Use just before the window is deleted. + * + * If freeResources is set, passive grabs on the window are deleted. + * + * @param pWin The window to delete events from. + * @param freeResources True if resources associated with the window should be + * deleted. + */ void DeleteWindowFromAnyEvents(WindowPtr pWin, Bool freeResources) { @@ -4275,9 +4698,9 @@ DeleteWindowFromAnyEvents(WindowPtr pWin, Bool freeResources) if (keybd->grab && (keybd->grab->window == pWin)) (*keybd->DeactivateGrab)(keybd); - /* If the focus window is a root window (ie. has no parent) then don't + /* If the focus window is a root window (ie. has no parent) then don't delete the focus from it. */ - + if ((pWin == focus->win) && (pWin->parent != NullWindow)) { int focusEventMode = NotifyNormal; @@ -4341,7 +4764,9 @@ DeleteWindowFromAnyEvents(WindowPtr pWin, Bool freeResources) } /** - * Call this whenever some window at or below pWin has changed geometry + * Call this whenever some window at or below pWin has changed geometry. If + * there is a grab on the window, the cursor will be re-confined into the + * window. */ void CheckCursorConfinement(WindowPtr pWin) @@ -4365,7 +4790,7 @@ CheckCursorConfinement(WindowPtr pWin) Mask EventMaskForClient(WindowPtr pWin, ClientPtr client) { - register OtherClientsPtr other; + OtherClientsPtr other; if (wClient (pWin) == client) return pWin->eventMask; @@ -4377,6 +4802,9 @@ EventMaskForClient(WindowPtr pWin, ClientPtr client) return 0; } +/** + * Server-side protocol handling for RecolorCursor request. + */ int ProcRecolorCursor(ClientPtr client) { @@ -4389,7 +4817,7 @@ ProcRecolorCursor(ClientPtr client) REQUEST_SIZE_MATCH(xRecolorCursorReq); pCursor = (CursorPtr)SecurityLookupIDByType(client, stuff->cursor, RT_CURSOR, DixWriteAccess); - if ( !pCursor) + if ( !pCursor) { client->errorValue = stuff->cursor; return (BadCursor); @@ -4418,6 +4846,20 @@ ProcRecolorCursor(ClientPtr client) return (Success); } +/** + * Write the given events to a client, swapping the byte order if necessary. + * To swap the byte ordering, a callback is called that has to be set up for + * the given event type. + * + * In the case of DeviceMotionNotify trailed by DeviceValuators, the events + * can be more than one. Usually it's just one event. + * + * Do not modify the event structure passed in. See comment below. + * + * @param pClient Client to send events to. + * @param count Number of events. + * @param events The event list. + */ void WriteEventsToClient(ClientPtr pClient, int count, xEvent *events) { @@ -4440,8 +4882,8 @@ WriteEventsToClient(ClientPtr pClient, int count, xEvent *events) #endif #ifdef PANORAMIX - if(!noPanoramiXExtension && - (panoramiXdataPtr[0].x || panoramiXdataPtr[0].y)) + if(!noPanoramiXExtension && + (panoramiXdataPtr[0].x || panoramiXdataPtr[0].y)) { switch(events->u.u.type) { case MotionNotify: @@ -4451,17 +4893,17 @@ WriteEventsToClient(ClientPtr pClient, int count, xEvent *events) case KeyRelease: case EnterNotify: case LeaveNotify: - /* + /* When multiple clients want the same event DeliverEventsToWindow - passes the same event structure multiple times so we can't - modify the one passed to us + passes the same event structure multiple times so we can't + modify the one passed to us */ count = 1; /* should always be 1 */ memcpy(&eventCopy, events, sizeof(xEvent)); eventCopy.u.keyButtonPointer.rootX += panoramiXdataPtr[0].x; eventCopy.u.keyButtonPointer.rootY += panoramiXdataPtr[0].y; - if(eventCopy.u.keyButtonPointer.event == - eventCopy.u.keyButtonPointer.root) + if(eventCopy.u.keyButtonPointer.event == + eventCopy.u.keyButtonPointer.root) { eventCopy.u.keyButtonPointer.eventX += panoramiXdataPtr[0].x; eventCopy.u.keyButtonPointer.eventY += panoramiXdataPtr[0].y; @@ -4481,6 +4923,14 @@ WriteEventsToClient(ClientPtr pClient, int count, xEvent *events) eventinfo.count = count; CallCallbacks(&EventCallback, (void *)&eventinfo); } +#ifdef XSERVER_DTRACE + if (XSERVER_SEND_EVENT_ENABLED()) { + for (i = 0; i < count; i++) + { + XSERVER_SEND_EVENT(pClient->index, events[i].u.u.type, &events[i]); + } + } +#endif if(pClient->swapped) { for(i = 0; i < count; i++) diff --git a/nx-X11/programs/Xserver/dix/extension.c b/nx-X11/programs/Xserver/dix/extension.c index 74558dd077..d33975c128 100644 --- a/nx-X11/programs/Xserver/dix/extension.c +++ b/nx-X11/programs/Xserver/dix/extension.c @@ -27,13 +27,13 @@ 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, +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 +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. +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 @@ -67,8 +67,6 @@ SOFTWARE. #define LAST_EVENT 128 #define LAST_ERROR 255 -ScreenProcEntry AuxillaryScreenProcs[MAXSCREENS]; - static ExtensionEntry **extensions = (ExtensionEntry **)NULL; int lastEvent = EXTENSION_EVENT_BASE; @@ -82,11 +80,11 @@ extern unsigned totalExtensionSize; static void InitExtensionPrivates(ExtensionEntry *ext) { - register char *ptr; + char *ptr; DevUnion *ppriv; - register unsigned *sizes; - register unsigned size; - register int i; + unsigned *sizes; + unsigned size; + int i; if (totalExtensionSize == sizeof(ExtensionEntry)) ppriv = (DevUnion *)NULL; @@ -109,18 +107,18 @@ InitExtensionPrivates(ExtensionEntry *ext) } ExtensionEntry * -AddExtension(char *name, int NumEvents, int NumErrors, - int (*MainProc)(ClientPtr c1), - int (*SwappedMainProc)(ClientPtr c2), - void (*CloseDownProc)(ExtensionEntry *e), +AddExtension(char *name, int NumEvents, int NumErrors, + int (*MainProc)(ClientPtr c1), + int (*SwappedMainProc)(ClientPtr c2), + void (*CloseDownProc)(ExtensionEntry *e), unsigned short (*MinorOpcodeProc)(ClientPtr c3)) { int i; - register ExtensionEntry *ext, **newexts; + ExtensionEntry *ext, **newexts; if (!MainProc || !SwappedMainProc || !MinorOpcodeProc) return((ExtensionEntry *) NULL); - if ((lastEvent + NumEvents > LAST_EVENT) || + if ((lastEvent + NumEvents > LAST_EVENT) || (unsigned)(lastError + NumErrors > LAST_ERROR)) return((ExtensionEntry *) NULL); @@ -301,7 +299,7 @@ MinorOpcodeOfRequest(ClientPtr client) void CloseDownExtensions() { - register int i,j; + int i,j; for (i = NumExtensions - 1; i >= 0; i--) { @@ -318,18 +316,6 @@ CloseDownExtensions() extensions = (ExtensionEntry **)NULL; lastEvent = EXTENSION_EVENT_BASE; lastError = FirstExtensionError; - for (i=0; inum) - { - spentry->num--; - free(spentry->procList[spentry->num].name); - } - free(spentry->procList); - spentry->procList = (ProcEntryPtr)NULL; - } } int @@ -340,7 +326,7 @@ ProcQueryExtension(ClientPtr client) REQUEST(xQueryExtensionReq); REQUEST_FIXED_SIZE(xQueryExtensionReq, stuff->nbytes); - + memset(&reply, 0, sizeof(xQueryExtensionReply)); reply.type = X_Reply; reply.length = 0; @@ -361,7 +347,7 @@ ProcQueryExtension(ClientPtr client) ) reply.present = xFalse; else - { + { reply.present = xTrue; reply.major_opcode = extensions[i]->base; reply.first_event = extensions[i]->eventBase; @@ -390,7 +376,7 @@ ProcListExtensions(ClientPtr client) if ( NumExtensions ) { - register int i, j; + int i, j; for (i=0; inoClientException); } -ExtensionLookupProc -LookupProc(char *name, GCPtr pGC) -{ - register int i; - register ScreenProcEntry *spentry; - spentry = &AuxillaryScreenProcs[pGC->pScreen->myNum]; - if (spentry->num) - { - for (i = 0; i < spentry->num; i++) - if (strcmp(name, spentry->procList[i].name) == 0) - return(spentry->procList[i].proc); - } - return (ExtensionLookupProc)NULL; -} - -Bool -RegisterProc(char *name, GC *pGC, ExtensionLookupProc proc) -{ - return RegisterScreenProc(name, pGC->pScreen, proc); -} - -Bool -RegisterScreenProc(char *name, ScreenPtr pScreen, ExtensionLookupProc proc) -{ - register ScreenProcEntry *spentry; - register ProcEntryPtr procEntry = (ProcEntryPtr)NULL; - char *newname; +#ifdef XSERVER_DTRACE +void LoadExtensionNames(char **RequestNames) { int i; - spentry = &AuxillaryScreenProcs[pScreen->myNum]; - /* first replace duplicates */ - if (spentry->num) - { - for (i = 0; i < spentry->num; i++) - if (strcmp(name, spentry->procList[i].name) == 0) - { - procEntry = &spentry->procList[i]; - break; - } - } - if (procEntry) - procEntry->proc = proc; - else - { - newname = (char *)malloc(strlen(name)+1); - if (!newname) - return FALSE; - procEntry = (ProcEntryPtr) - realloc(spentry->procList, - sizeof(ProcEntryRec) * (spentry->num+1)); - if (!procEntry) - { - free(newname); - return FALSE; + for (i=0; ibase; + + if (RequestNames[r] == NULL) { + RequestNames[r] = strdup(extensions[i]->name); } - spentry->procList = procEntry; - procEntry += spentry->num; - procEntry->name = newname; - strcpy(newname, name); - procEntry->proc = proc; - spentry->num++; } - return TRUE; } +#endif diff --git a/nx-X11/programs/Xserver/dix/ffs.c b/nx-X11/programs/Xserver/dix/ffs.c index 80fbcc8a92..b75657d295 100644 --- a/nx-X11/programs/Xserver/dix/ffs.c +++ b/nx-X11/programs/Xserver/dix/ffs.c @@ -26,6 +26,12 @@ The Open Group. */ +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include "dix.h" + int ffs(int i) { diff --git a/nx-X11/programs/Xserver/dix/gc.c b/nx-X11/programs/Xserver/dix/gc.c index d40334f5f5..fbc47b2df3 100644 --- a/nx-X11/programs/Xserver/dix/gc.c +++ b/nx-X11/programs/Xserver/dix/gc.c @@ -27,13 +27,13 @@ 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, +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 +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. +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 @@ -69,7 +69,7 @@ extern FontPtr defaultFont; static Bool CreateDefaultTile(GCPtr pGC); -unsigned char DefaultDash[2] = {4, 4}; +static unsigned char DefaultDash[2] = {4, 4}; void ValidateGC(DrawablePtr pDraw, GC *pGC) @@ -81,27 +81,27 @@ ValidateGC(DrawablePtr pDraw, GC *pGC) /* dixChangeGC(client, pGC, mask, pC32, pUnion) - * + * * This function was created as part of the Security extension * implementation. The client performing the gc change must be passed so * that access checks can be performed on any tiles, stipples, or fonts * that are specified. ddxen can call this too; they should normally * pass NullClient for the client since any access checking should have * already been done at a higher level. - * + * * Since we had to create a new function anyway, we decided to change the * way the list of gc values is passed to eliminate the compiler warnings * caused by the DoChangeGC interface. You can pass the values via pC32 * or pUnion, but not both; one of them must be NULL. If you don't need * to pass any pointers, you can use either one: - * + * * example calling dixChangeGC using pC32 parameter * * CARD32 v[2]; * v[0] = foreground; * v[1] = background; * dixChangeGC(client, pGC, GCForeground|GCBackground, v, NULL); - * + * * example calling dixChangeGC using pUnion parameter; * same effect as above * @@ -109,10 +109,10 @@ ValidateGC(DrawablePtr pDraw, GC *pGC) * v[0].val = foreground; * v[1].val = background; * dixChangeGC(client, pGC, GCForeground|GCBackground, NULL, v); - * + * * However, if you need to pass a pointer to a pixmap or font, you MUST * use the pUnion parameter. - * + * * example calling dixChangeGC passing pointers in the value list * v[1].ptr is a pointer to a pixmap * @@ -120,16 +120,16 @@ ValidateGC(DrawablePtr pDraw, GC *pGC) * v[0].val = FillTiled; * v[1].ptr = pPixmap; * dixChangeGC(client, pGC, GCFillStyle|GCTile, NULL, v); - * + * * Note: we could have gotten by with just the pUnion parameter, but on * 64 bit machines that would have forced us to copy the value list that * comes in the ChangeGC request. - * + * * Ideally, we'd change all the DoChangeGC calls to dixChangeGC, but this * is far too many changes to consider at this time, so we've only * changed the ones that caused compiler warnings. New code should use * dixChangeGC. - * + * * dpw */ @@ -144,18 +144,18 @@ ValidateGC(DrawablePtr pDraw, GC *pGC) assert(pUnion); _var = (_type)pUnion->ptr; pUnion++; } int -dixChangeGC(ClientPtr client, register GC *pGC, register BITS32 mask, CARD32 *pC32, ChangeGCValPtr pUnion) +dixChangeGC(ClientPtr client, GC *pGC, BITS32 mask, CARD32 *pC32, ChangeGCValPtr pUnion) { - register BITS32 index2; - register int error = 0; - PixmapPtr pPixmap; - BITS32 maskQ; + BITS32 index2; + int error = 0; + PixmapPtr pPixmap; + BITS32 maskQ; assert( (pC32 && !pUnion) || (!pC32 && pUnion) ); pGC->serialNumber |= GC_CHANGE_SERIAL_BIT; maskQ = mask; /* save these for when we walk the GCque */ - while (mask && !error) + while (mask && !error) { index2 = (BITS32) lowbit (mask); mask &= ~index2; @@ -522,7 +522,7 @@ dixChangeGC(ClientPtr client, register GC *pGC, register BITS32 mask, CARD32 *pC /* Publically defined entry to ChangeGC. Just calls dixChangeGC and tells * it that all of the entries are constants or IDs */ int -ChangeGC(register GC *pGC, register BITS32 mask, XID *pval) +ChangeGC(GC *pGC, BITS32 mask, XID *pval) { return (dixChangeGC(NullClient, pGC, mask, pval, NULL)); } @@ -532,7 +532,7 @@ ChangeGC(register GC *pGC, register BITS32 mask, XID *pval) pval contains an appropriate value for each mask. fPointer is true if the values for tiles, stipples, fonts or clipmasks are pointers instead of IDs. Note: if you are passing pointers you - MUST declare the array of values as type void*! Other data types + MUST declare the array of values as type pointer! Other data types may not be large enough to hold pointers on some machines. Yes, this means you have to cast to (XID *) when you pass the array to DoChangeGC. Similarly, if you are not passing pointers (fPointer = 0) you @@ -540,7 +540,7 @@ ChangeGC(register GC *pGC, register BITS32 mask, XID *pval) size data type may be used. To avoid this cruftiness, use dixChangeGC above. - if there is an error, the value is marked as changed + if there is an error, the value is marked as changed anyway, which is probably wrong, but infrequent. NOTE: @@ -548,7 +548,7 @@ ChangeGC(register GC *pGC, register BITS32 mask, XID *pval) 32 bits long */ int -DoChangeGC(register GC *pGC, register BITS32 mask, XID *pval, int fPointer) +DoChangeGC(GC *pGC, BITS32 mask, XID *pval, int fPointer) { if (fPointer) /* XXX might be a problem on 64 bit big-endian servers */ @@ -572,11 +572,11 @@ static GCPtr AllocateGC(ScreenPtr pScreen) { GCPtr pGC; - register char *ptr; - register DevUnion *ppriv; - register unsigned *sizes; - register unsigned size; - register int i; + char *ptr; + DevUnion *ppriv; + unsigned *sizes; + unsigned size; + int i; pGC = (GCPtr)malloc(pScreen->totalGCSize); if (pGC) @@ -602,7 +602,7 @@ AllocateGC(ScreenPtr pScreen) GCPtr CreateGC(DrawablePtr pDrawable, BITS32 mask, XID *pval, int *pStatus) { - register GCPtr pGC; + GCPtr pGC; pGC = AllocateGC(pDrawable->pScreen); if (!pGC) @@ -707,7 +707,7 @@ CreateDefaultTile (GCPtr pGC) tmpval[0] = GXcopy; tmpval[1] = pGC->tile.pixel; tmpval[2] = FillSolid; - (void)ChangeGC(pgcScratch, GCFunction | GCForeground | GCFillStyle, + (void)ChangeGC(pgcScratch, GCFunction | GCForeground | GCFillStyle, tmpval); ValidateGC((DrawablePtr)pTile, pgcScratch); rect.x = 0; @@ -724,11 +724,11 @@ CreateDefaultTile (GCPtr pGC) } int -CopyGC(register GC *pgcSrc, register GC *pgcDst, register BITS32 mask) +CopyGC(GC *pgcSrc, GC *pgcDst, BITS32 mask) { - register BITS32 index2; - BITS32 maskQ; - int error = 0; + BITS32 index2; + BITS32 maskQ; + int error = 0; if (pgcSrc == pgcDst) return Success; @@ -907,24 +907,13 @@ FreeGC(void * value, XID gid) return(Success); } -void -SetGCMask(GCPtr pGC, Mask selectMask, Mask newDataMask) -{ - pGC->stateChanges = (~selectMask & pGC->stateChanges) | - (selectMask & newDataMask); - if (selectMask & newDataMask) - pGC->serialNumber |= GC_CHANGE_SERIAL_BIT; -} - - - /* CreateScratchGC(pScreen, depth) like CreateGC, but doesn't do the default tile or stipple, since we can't create them without already having a GC. any code using the tile or stipple has to set them explicitly anyway, since the state of the scratch gc is unknown. This is OK because ChangeGC() has to be able to deal with NULL tiles and -stipples anyway (in case the CreateGC() call has provided a +stipples anyway (in case the CreateGC() call has provided a value for them -- we can't set the default tile until the client-supplied attributes are installed, since the fgPixel is what fills the default tile. (maybe this comment should @@ -934,7 +923,7 @@ go with CreateGC() or ChangeGC().) GCPtr CreateScratchGC(ScreenPtr pScreen, unsigned depth) { - register GCPtr pGC; + GCPtr pGC; pGC = AllocateGC(pScreen); if (!pGC) @@ -986,8 +975,8 @@ CreateScratchGC(ScreenPtr pScreen, unsigned depth) void FreeGCperDepth(int screenNum) { - register int i; - register ScreenPtr pScreen; + int i; + ScreenPtr pScreen; GCPtr *ppGC; pScreen = screenInfo.screens[screenNum]; @@ -1002,8 +991,8 @@ FreeGCperDepth(int screenNum) Bool CreateGCperDepth(int screenNum) { - register int i; - register ScreenPtr pScreen; + int i; + ScreenPtr pScreen; DepthPtr pDepth; GCPtr *ppGC; @@ -1035,7 +1024,7 @@ CreateGCperDepth(int screenNum) Bool CreateDefaultStipple(int screenNum) { - register ScreenPtr pScreen; + ScreenPtr pScreen; XID tmpval[3]; xRectangle rect; CARD16 w, h; @@ -1063,7 +1052,7 @@ CreateDefaultStipple(int screenNum) rect.y = 0; rect.width = w; rect.height = h; - (*pgcScratch->ops->PolyFillRect)((DrawablePtr)pScreen->PixmapPerDepth[0], + (*pgcScratch->ops->PolyFillRect)((DrawablePtr)pScreen->PixmapPerDepth[0], pgcScratch, 1, &rect); FreeScratchGC(pgcScratch); return TRUE; @@ -1077,10 +1066,10 @@ FreeDefaultStipple(int screenNum) } int -SetDashes(register GCPtr pGC, unsigned offset, unsigned ndash, unsigned char *pdash) +SetDashes(GCPtr pGC, unsigned offset, unsigned ndash, unsigned char *pdash) { - register long i; - register unsigned char *p, *indash; + long i; + unsigned char *p, *indash; BITS32 maskQ = 0; i = ndash; @@ -1135,8 +1124,8 @@ SetDashes(register GCPtr pGC, unsigned offset, unsigned ndash, unsigned char *pd int VerifyRectOrder(int nrects, xRectangle *prects, int ordering) { - register xRectangle *prectP, *prectN; - register int i; + xRectangle *prectP, *prectN; + int i; switch(ordering) { @@ -1183,7 +1172,7 @@ VerifyRectOrder(int nrects, xRectangle *prects, int ordering) } int -SetClipRects(GCPtr pGC, int xOrigin, int yOrigin, int nrects, +SetClipRects(GCPtr pGC, int xOrigin, int yOrigin, int nrects, xRectangle *prects, int ordering) { int newct, size; @@ -1200,7 +1189,7 @@ SetClipRects(GCPtr pGC, int xOrigin, int yOrigin, int nrects, pGC->serialNumber |= GC_CHANGE_SERIAL_BIT; pGC->clipOrg.x = xOrigin; pGC->stateChanges |= GCClipXOrigin; - + pGC->clipOrg.y = yOrigin; pGC->stateChanges |= GCClipYOrigin; @@ -1214,16 +1203,16 @@ SetClipRects(GCPtr pGC, int xOrigin, int yOrigin, int nrects, /* - sets reasonable defaults + sets reasonable defaults if we can get a pre-allocated one, use it and mark it as used. if we can't, create one out of whole cloth (The Velveteen GC -- if you use it often enough it will become real.) */ GCPtr -GetScratchGC(register unsigned depth, register ScreenPtr pScreen) +GetScratchGC(unsigned depth, ScreenPtr pScreen) { - register int i; - register GCPtr pGC; + int i; + GCPtr pGC; for (i=0; i<=pScreen->numDepths; i++) if ( pScreen->GCperDepth[i]->depth == depth && @@ -1269,10 +1258,10 @@ mark it as available. if not, free it for real */ void -FreeScratchGC(register GCPtr pGC) +FreeScratchGC(GCPtr pGC) { - register ScreenPtr pScreen = pGC->pScreen; - register int i; + ScreenPtr pScreen = pGC->pScreen; + int i; for (i=0; i<=pScreen->numDepths; i++) { diff --git a/nx-X11/programs/Xserver/dix/getevents.c b/nx-X11/programs/Xserver/dix/getevents.c new file mode 100644 index 0000000000..24bc49b9d0 --- /dev/null +++ b/nx-X11/programs/Xserver/dix/getevents.c @@ -0,0 +1,928 @@ +/* + * Copyright © 2006 Nokia Corporation + * Copyright © 2006-2007 Daniel Stone + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. + * + * Author: Daniel Stone + */ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include +#include +#include + +#include "misc.h" +#include "resource.h" +#include "inputstr.h" +#include "scrnintstr.h" +#include "cursorstr.h" +#include "dixstruct.h" +#include "globals.h" +#include "dixevents.h" +#include "mipointer.h" + +#ifdef XKB +#include +extern Bool XkbCopyKeymap(XkbDescPtr src, XkbDescPtr dst, Bool sendNotifies); +#endif + +#ifdef PANORAMIX +#include "panoramiX.h" +#include "panoramiXsrv.h" +#endif + +#include +#include +#include "exglobals.h" +#include "exevents.h" +#include "extnsionst.h" + + +/* Maximum number of valuators, divided by six, rounded up, to get number + * of events. */ +#define MAX_VALUATOR_EVENTS 6 + +/* Number of motion history events to store. */ +#define MOTION_HISTORY_SIZE 256 + + +/** + * Pick some arbitrary size for Xi motion history. + */ +int +GetMotionHistorySize(void) +{ + return MOTION_HISTORY_SIZE; +} + +static void +set_key_down(DeviceIntPtr pDev, int key_code) +{ + pDev->key->postdown[key_code >> 3] |= (1 << (key_code & 7)); +} + +static void +set_key_up(DeviceIntPtr pDev, int key_code) +{ + pDev->key->postdown[key_code >> 3] &= ~(1 << (key_code & 7)); +} + +static Bool +key_is_down(DeviceIntPtr pDev, int key_code) +{ + return !!(pDev->key->postdown[key_code >> 3] & (1 << (key_code & 7))); +} + +static Bool +key_autorepeats(DeviceIntPtr pDev, int key_code) +{ + return !!(pDev->kbdfeed->ctrl.autoRepeats[key_code >> 3] & + (1 << (key_code & 7))); +} + +/** + * Allocate the motion history buffer. + */ +void +AllocateMotionHistory(DeviceIntPtr pDev) +{ + if (pDev->valuator->motion) + free(pDev->valuator->motion); + + if (pDev->valuator->numMotionEvents < 1) + return; + + pDev->valuator->motion = malloc(((sizeof(INT32) * pDev->valuator->numAxes) + + sizeof(Time)) * + pDev->valuator->numMotionEvents); + pDev->valuator->first_motion = 0; + pDev->valuator->last_motion = 0; +} + + +/** + * Dump the motion history between start and stop into the supplied buffer. + * Only records the event for a given screen in theory, but in practice, we + * sort of ignore this. + */ +int +GetMotionHistory(DeviceIntPtr pDev, xTimecoord *buff, unsigned long start, + unsigned long stop, ScreenPtr pScreen) +{ + char *ibuff = NULL, *obuff = (char *) buff; + int i = 0, ret = 0; + Time current; + /* The size of a single motion event. */ + int size = (sizeof(INT32) * pDev->valuator->numAxes) + sizeof(Time); + + if (!pDev->valuator || !pDev->valuator->numMotionEvents) + return 0; + + for (i = pDev->valuator->first_motion; + i != pDev->valuator->last_motion; + i = (i + 1) % pDev->valuator->numMotionEvents) { + /* We index the input buffer by which element we're accessing, which + * is not monotonic, and the output buffer by how many events we've + * written so far. */ + ibuff = (char *) pDev->valuator->motion + (i * size); + memcpy(¤t, ibuff, sizeof(Time)); + + if (current > stop) { + return ret; + } + else if (current >= start) { + memcpy(obuff, ibuff, size); + obuff += size; + ret++; + } + } + + return ret; +} + + +/** + * Update the motion history for a specific device, with the list of + * valuators. + */ +static void +updateMotionHistory(DeviceIntPtr pDev, CARD32 ms, int first_valuator, + int num_valuators, int *valuators) +{ + char *buff = (char *) pDev->valuator->motion; + + if (!pDev->valuator->numMotionEvents) + return; + + buff += ((sizeof(INT32) * pDev->valuator->numAxes) + sizeof(CARD32)) * + pDev->valuator->last_motion; + memcpy(buff, &ms, sizeof(Time)); + + buff += sizeof(Time); + bzero(buff, sizeof(INT32) * pDev->valuator->numAxes); + + buff += sizeof(INT32) * first_valuator; + memcpy(buff, valuators, sizeof(INT32) * num_valuators); + + pDev->valuator->last_motion = (pDev->valuator->last_motion + 1) % + pDev->valuator->numMotionEvents; + + /* If we're wrapping around, just keep the circular buffer going. */ + if (pDev->valuator->first_motion == pDev->valuator->last_motion) + pDev->valuator->first_motion = (pDev->valuator->first_motion + 1) % + pDev->valuator->numMotionEvents; + + return; +} + + +/** + * Returns the maximum number of events GetKeyboardEvents, + * GetKeyboardValuatorEvents, and GetPointerEvents will ever return. + * + * Should be used in DIX as: + * xEvent *events = calloc(sizeof(xEvent), GetMaximumEventsNum()); + */ +int +GetMaximumEventsNum(void) { + /* Two base events -- core and device, plus valuator events. Multiply + * by two if we're doing key repeats. */ + int ret = 2 + MAX_VALUATOR_EVENTS; + +#ifdef XKB + if (noXkbExtension) +#endif + ret *= 2; + + return ret; +} + + +/* Originally a part of xf86PostMotionEvent; modifies valuators + * in-place. */ +static void +acceleratePointer(DeviceIntPtr pDev, int first_valuator, int num_valuators, + int *valuators) +{ + float mult = 0.0; + int dx = 0, dy = 0; + int *px = NULL, *py = NULL; + + if (!num_valuators || !valuators) + return; + + if (first_valuator == 0) { + dx = valuators[0]; + px = &valuators[0]; + } + if (first_valuator <= 1 && num_valuators >= (2 - first_valuator)) { + dy = valuators[1 - first_valuator]; + py = &valuators[1 - first_valuator]; + } + + if (!dx && !dy) + return; + + if (pDev->ptrfeed && pDev->ptrfeed->ctrl.num) { + /* modeled from xf86Events.c */ + if (pDev->ptrfeed->ctrl.threshold) { + if ((abs(dx) + abs(dy)) >= pDev->ptrfeed->ctrl.threshold) { + pDev->valuator->dxremaind = ((float)dx * + (float)(pDev->ptrfeed->ctrl.num)) / + (float)(pDev->ptrfeed->ctrl.den) + + pDev->valuator->dxremaind; + if (px) { + *px = (int)pDev->valuator->dxremaind; + pDev->valuator->dxremaind = pDev->valuator->dxremaind - + (float)(*px); + } + + pDev->valuator->dyremaind = ((float)dy * + (float)(pDev->ptrfeed->ctrl.num)) / + (float)(pDev->ptrfeed->ctrl.den) + + pDev->valuator->dyremaind; + if (py) { + *py = (int)pDev->valuator->dyremaind; + pDev->valuator->dyremaind = pDev->valuator->dyremaind - + (float)(*py); + } + } + } + else { + mult = pow((float)dx * (float)dx + (float)dy * (float)dy, + ((float)(pDev->ptrfeed->ctrl.num) / + (float)(pDev->ptrfeed->ctrl.den) - 1.0) / + 2.0) / 2.0; + if (dx) { + pDev->valuator->dxremaind = mult * (float)dx + + pDev->valuator->dxremaind; + *px = (int)pDev->valuator->dxremaind; + pDev->valuator->dxremaind = pDev->valuator->dxremaind - + (float)(*px); + } + if (dy) { + pDev->valuator->dyremaind = mult * (float)dy + + pDev->valuator->dyremaind; + *py = (int)pDev->valuator->dyremaind; + pDev->valuator->dyremaind = pDev->valuator->dyremaind - + (float)(*py); + } + } + } +} + + +/** + * Clip an axis to its bounds, which are declared in the call to + * InitValuatorAxisClassStruct. + */ +static void +clipAxis(DeviceIntPtr pDev, int axisNum, int *val) +{ + AxisInfoPtr axes = pDev->valuator->axes + axisNum; + + /* Don't clip if min_value and max_value are the same, or if an invalid + range is specified. */ + if(axes->min_value < axes->max_value) { + if (*val < axes->min_value) + *val = axes->min_value; + if (*val > axes->max_value) + *val = axes->max_value; + } +} + +/** + * Clip every axis in the list of valuators to its bounds. + */ +static void +clipValuators(DeviceIntPtr pDev, int first_valuator, int num_valuators, + int *valuators) +{ + AxisInfoPtr axes = pDev->valuator->axes + first_valuator; + int i; + + for (i = 0; i < num_valuators; i++, axes++) + clipAxis(pDev, i + first_valuator, &(valuators[i])); +} + + +/** + * Fills events with valuator events for pDev, as given by the other + * parameters. + * + * FIXME: Need to fix ValuatorClassRec to store all the valuators as + * last posted, not just x and y; otherwise relative non-x/y + * valuators, though a very narrow use case, will be broken. + */ +static xEvent * +getValuatorEvents(xEvent *events, DeviceIntPtr pDev, int first_valuator, + int num_valuators, int *valuators) { + deviceValuator *xv = (deviceValuator *) events; + int i = 0, final_valuator = first_valuator + num_valuators; + + for (i = first_valuator; i < final_valuator; i += 6, xv++, events++) { + xv->type = DeviceValuator; + xv->first_valuator = i; + xv->num_valuators = ((final_valuator - i) > 6) ? 6 : (final_valuator - i); + xv->deviceid = pDev->id; + switch (final_valuator - i) { + case 6: + xv->valuator5 = valuators[i + 5]; + case 5: + xv->valuator4 = valuators[i + 4]; + case 4: + xv->valuator3 = valuators[i + 3]; + case 3: + xv->valuator2 = valuators[i + 2]; + case 2: + xv->valuator1 = valuators[i + 1]; + case 1: + xv->valuator0 = valuators[i]; + } + + if (i + 6 < final_valuator) + xv->deviceid |= MORE_EVENTS; + } + + return events; +} + + +/** + * Convenience wrapper around GetKeyboardValuatorEvents, that takes no + * valuators. + */ +int +GetKeyboardEvents(xEvent *events, DeviceIntPtr pDev, int type, int key_code) { + return GetKeyboardValuatorEvents(events, pDev, type, key_code, 0, 0, NULL); +} + + +/** + * Returns a set of keyboard events for KeyPress/KeyRelease, optionally + * also with valuator events. Handles Xi and XKB. + * + * events is not NULL-terminated; the return value is the number of events. + * The DDX is responsible for allocating the event structure in the first + * place via GetMaximumEventsNum(), and for freeing it. + * + * This function does not change the core keymap to that of the device; + * that is done by SwitchCoreKeyboard, which is called from + * mieqProcessInputEvents. If replacing that function, take care to call + * SetCoreKeyboard before processInputProc, so keymaps are altered to suit. + * + * Note that this function recurses! If called for non-XKB, a repeating + * key press will trigger a matching KeyRelease, as well as the + * KeyPresses. + */ +int +GetKeyboardValuatorEvents(xEvent *events, DeviceIntPtr pDev, int type, + int key_code, int first_valuator, + int num_valuators, int *valuators) { + int numEvents = 0; + CARD32 ms = 0; + KeySym *map = pDev->key->curKeySyms.map; + KeySym sym = map[key_code * pDev->key->curKeySyms.mapWidth]; + deviceKeyButtonPointer *kbp = NULL; + + if (!events) + return 0; + + /* DO NOT WANT */ + if (type != KeyPress && type != KeyRelease) + return 0; + + if (!pDev->key || !pDev->focus || !pDev->kbdfeed || + (pDev->coreEvents && !inputInfo.keyboard->key)) + return 0; + + if (key_code < 8 || key_code > 255) + return 0; + + if (pDev->coreEvents) + numEvents = 2; + else + numEvents = 1; + + if (num_valuators) { + if ((num_valuators / 6) + 1 > MAX_VALUATOR_EVENTS) + num_valuators = MAX_VALUATOR_EVENTS; + numEvents += (num_valuators / 6) + 1; + } + +#ifdef XKB + if (noXkbExtension) +#endif + { + switch (sym) { + case XK_Num_Lock: + case XK_Caps_Lock: + case XK_Scroll_Lock: + case XK_Shift_Lock: + if (type == KeyRelease) + return 0; + else if (type == KeyPress && key_is_down(pDev, key_code)) + type = KeyRelease; + } + } + + /* Handle core repeating, via press/release/press/release. + * FIXME: In theory, if you're repeating with two keyboards in non-XKB, + * you could get unbalanced events here. */ + if (type == KeyPress && key_is_down(pDev, key_code)) { + /* If autorepeating is disabled either globally or just for that key, + * or we have a modifier, don't generate a repeat event. */ + if (!pDev->kbdfeed->ctrl.autoRepeat || + !key_autorepeats(pDev, key_code) || + pDev->key->modifierMap[key_code]) + return 0; + +#ifdef XKB + if (noXkbExtension) +#endif + { + numEvents += GetKeyboardValuatorEvents(events, pDev, + KeyRelease, key_code, + first_valuator, num_valuators, + valuators); + events += numEvents; + } + } + + ms = GetTimeInMillis(); + + if (pDev->coreEvents) { + events->u.keyButtonPointer.time = ms; + events->u.u.type = type; + events->u.u.detail = key_code; + if (type == KeyPress) + set_key_down(inputInfo.keyboard, key_code); + else if (type == KeyRelease) + set_key_up(inputInfo.keyboard, key_code); + events++; + } + + kbp = (deviceKeyButtonPointer *) events; + kbp->time = ms; + kbp->deviceid = pDev->id; + kbp->detail = key_code; + if (type == KeyPress) { + kbp->type = DeviceKeyPress; + set_key_down(pDev, key_code); + } + else if (type == KeyRelease) { + kbp->type = DeviceKeyRelease; + set_key_up(pDev, key_code); + } + + events++; + if (num_valuators) { + kbp->deviceid |= MORE_EVENTS; + clipValuators(pDev, first_valuator, num_valuators, valuators); + events = getValuatorEvents(events, pDev, first_valuator, + num_valuators, valuators); + } + + return numEvents; +} + + +/** + * Generate a series of xEvents (returned in xE) representing pointer + * motion, or button presses. Xi and XKB-aware. + * + * events is not NULL-terminated; the return value is the number of events. + * The DDX is responsible for allocating the event structure in the first + * place via GetMaximumEventsNum(), and for freeing it. + */ +int +GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons, + int flags, int first_valuator, int num_valuators, + int *valuators) { + int num_events = 0, final_valuator = 0; + CARD32 ms = 0; + deviceKeyButtonPointer *kbp = NULL; + DeviceIntPtr cp = inputInfo.pointer; + int x = 0, y = 0; + Bool coreOnly = (pDev == inputInfo.pointer); + ScreenPtr scr = miPointerGetScreen(pDev); + + /* Sanity checks. */ + if (type != MotionNotify && type != ButtonPress && type != ButtonRelease) + return 0; + + if ((type == ButtonPress || type == ButtonRelease) && !pDev->button) + return 0; + + /* FIXME: I guess it should, in theory, be possible to post button events + * from devices without valuators. */ + if (!pDev->valuator) + return 0; + + if (!coreOnly && pDev->coreEvents) + num_events = 2; + else + num_events = 1; + + if (type == MotionNotify && num_valuators <= 0) + return 0; + + /* Do we need to send a DeviceValuator event? */ + if (!coreOnly && num_valuators) { + if ((((num_valuators - 1) / 6) + 1) > MAX_VALUATOR_EVENTS) + num_valuators = MAX_VALUATOR_EVENTS * 6; + num_events += ((num_valuators - 1) / 6) + 1; + } + + final_valuator = num_valuators + first_valuator; + + /* You fail. */ + if (first_valuator < 0 || final_valuator > pDev->valuator->numAxes) + return 0; + + ms = GetTimeInMillis(); + + /* Set x and y based on whether this is absolute or relative, and + * accelerate if we need to. */ + if (flags & POINTER_ABSOLUTE) { + if (num_valuators >= 1 && first_valuator == 0) { + x = valuators[0]; + } + else { + /* If we're sending core events but didn't provide a value, + * translate the core value (but use the device coord if + * it translates to the same coord to preserve sub-pixel + * coord information). If we're not sending core events use + * whatever value we have */ + x = pDev->valuator->lastx; + if(pDev->coreEvents) { + int min = pDev->valuator->axes[0].min_value; + int max = pDev->valuator->axes[0].max_value; + if(min < max) { + if((int)((float)(x-min)*scr->width/(max-min+1)) != cp->valuator->lastx) + x = (int)((float)(cp->valuator->lastx)*(max-min+1)/scr->width)+min; + } + else + x = cp->valuator->lastx; + } + } + + if (first_valuator <= 1 && num_valuators >= (2 - first_valuator)) { + y = valuators[1 - first_valuator]; + } + else { + y = pDev->valuator->lasty; + if(pDev->coreEvents) { + int min = pDev->valuator->axes[1].min_value; + int max = pDev->valuator->axes[1].max_value; + if(min < max) { + if((int)((float)(y-min)*scr->height/(max-min+1)) != cp->valuator->lasty) + y = (int)((float)(cp->valuator->lasty)*(max-min+1)/scr->height)+min; + } + else + y = cp->valuator->lasty; + } + } + + /* Clip both x and y to the defined limits (usually co-ord space limit). */ + clipAxis(pDev, 0, &x); + clipAxis(pDev, 1, &y); + } + else { + if (flags & POINTER_ACCELERATE) + acceleratePointer(pDev, first_valuator, num_valuators, + valuators); + + if (pDev->coreEvents) { + /* Get and convert the core void * coordinate space into + * device coordinates. Use the device coords if it translates + * into the same position as the core to preserve relative sub- + * pixel movements from the device. */ + int min = pDev->valuator->axes[0].min_value; + int max = pDev->valuator->axes[0].max_value; + if(min < max) { + x = pDev->valuator->lastx; + if((int)((float)(x-min)*scr->width/(max-min+1)) != cp->valuator->lastx) + x = (int)((float)(cp->valuator->lastx)*(max-min+1)/scr->width)+min; + } + else + x = cp->valuator->lastx; + + min = pDev->valuator->axes[1].min_value; + max = pDev->valuator->axes[1].max_value; + if(min < max) { + y = pDev->valuator->lasty; + if((int)((float)(y-min)*scr->height/(max-min+1)) != cp->valuator->lasty) + y = (int)((float)(cp->valuator->lasty)*(max-min+1)/scr->height)+min; + } + else + y = cp->valuator->lasty; + + /* Add relative movement */ + if (first_valuator == 0 && num_valuators >= 1) + x += valuators[0]; + if (first_valuator <= 1 && num_valuators >= (2 - first_valuator)) + y += valuators[1 - first_valuator]; + } + else { + x = pDev->valuator->lastx; + y = pDev->valuator->lasty; + if (first_valuator == 0 && num_valuators >= 1) + x += valuators[0]; + if (first_valuator <= 1 && num_valuators >= (2 - first_valuator)) + y += valuators[1 - first_valuator]; + + if(!coreOnly) { + /* Since we're not sending core-events we must clip both x and y + * to the defined limits so we don't run outside the box. */ + clipAxis(pDev, 0, &x); + clipAxis(pDev, 1, &y); + } + } + } + + pDev->valuator->lastx = x; + pDev->valuator->lasty = y; + /* Convert the dev coord back to screen coord if we're + * sending core events */ + if (pDev->coreEvents) { + int min = pDev->valuator->axes[0].min_value; + int max = pDev->valuator->axes[0].max_value; + if(min < max) + x = (int)((float)(x-min)*scr->width/(max-min+1)); + cp->valuator->lastx = x; + min = pDev->valuator->axes[1].min_value; + max = pDev->valuator->axes[1].max_value; + if(min < max) + y = (int)((float)(y-min)*scr->height/(max-min+1)); + cp->valuator->lasty = y; + } + + /* This takes care of crossing screens for us, as well as clipping + * to the current screen. Right now, we only have one history buffer, + * so we don't set this for both the device and core.*/ + miPointerSetPosition(pDev, &x, &y, ms); + + if (pDev->coreEvents) { + /* miPointerSetPosition may have changed screen */ + scr = miPointerGetScreen(pDev); + if(x != cp->valuator->lastx) { + int min = pDev->valuator->axes[0].min_value; + int max = pDev->valuator->axes[0].max_value; + cp->valuator->lastx = pDev->valuator->lastx = x; + if(min < max) + pDev->valuator->lastx = (int)((float)(x)*(max-min+1)/scr->width)+min; + } + if(y != cp->valuator->lasty) { + int min = pDev->valuator->axes[1].min_value; + int max = pDev->valuator->axes[1].max_value; + cp->valuator->lasty = pDev->valuator->lasty = y; + if(min < max) + pDev->valuator->lasty = (int)((float)(y)*(max-min+1)/scr->height)+min; + } + } + else if (coreOnly) { + cp->valuator->lastx = x; + cp->valuator->lasty = y; + } + + /* Drop x and y back into the valuators list, if they were originally + * present. */ + if (first_valuator == 0 && num_valuators >= 1) + valuators[0] = pDev->valuator->lastx; + if (first_valuator <= 1 && num_valuators >= (2 - first_valuator)) + valuators[1 - first_valuator] = pDev->valuator->lasty; + + updateMotionHistory(pDev, ms, first_valuator, num_valuators, valuators); + + /* for some reason inputInfo.void * does not have coreEvents set */ + if (coreOnly || pDev->coreEvents) { + events->u.u.type = type; + events->u.keyButtonPointer.time = ms; + events->u.keyButtonPointer.rootX = x; + events->u.keyButtonPointer.rootY = y; + + if (type == ButtonPress || type == ButtonRelease) { + /* We hijack SetPointerMapping to work on all core-sending + * devices, so we use the device-specific map here instead of + * the core one. */ + events->u.u.detail = pDev->button->map[buttons]; + } + else { + events->u.u.detail = 0; + } + + events++; + } + + if (!coreOnly) { + kbp = (deviceKeyButtonPointer *) events; + kbp->time = ms; + kbp->deviceid = pDev->id; + + if (type == MotionNotify) { + kbp->type = DeviceMotionNotify; + } + else { + if (type == ButtonPress) + kbp->type = DeviceButtonPress; + else if (type == ButtonRelease) + kbp->type = DeviceButtonRelease; + kbp->detail = pDev->button->map[buttons]; + } + + kbp->root_x = pDev->valuator->lastx; + kbp->root_y = pDev->valuator->lasty; + + events++; + if (num_valuators) { + kbp->deviceid |= MORE_EVENTS; + clipValuators(pDev, first_valuator, num_valuators, valuators); + events = getValuatorEvents(events, pDev, first_valuator, + num_valuators, valuators); + } + } + + return num_events; +} + + +/** + * Post ProximityIn/ProximityOut events, accompanied by valuators. + * + * events is not NULL-terminated; the return value is the number of events. + * The DDX is responsible for allocating the event structure in the first + * place via GetMaximumEventsNum(), and for freeing it. + */ +int +GetProximityEvents(xEvent *events, DeviceIntPtr pDev, int type, + int first_valuator, int num_valuators, int *valuators) +{ + int num_events = 1; + deviceKeyButtonPointer *kbp = (deviceKeyButtonPointer *) events; + + /* Sanity checks. */ + if (type != ProximityIn && type != ProximityOut) + return 0; + + if (!pDev->valuator) + return 0; + + /* Do we need to send a DeviceValuator event? */ + if ((pDev->valuator->mode & 1) == Relative) + num_valuators = 0; + + if (num_valuators) { + if ((((num_valuators - 1) / 6) + 1) > MAX_VALUATOR_EVENTS) + num_valuators = MAX_VALUATOR_EVENTS * 6; + num_events += ((num_valuators - 1) / 6) + 1; + } + + /* You fail. */ + if (first_valuator < 0 || + (num_valuators + first_valuator) > pDev->valuator->numAxes) + return 0; + + kbp->type = type; + kbp->deviceid = pDev->id; + kbp->detail = 0; + kbp->time = GetTimeInMillis(); + + if (num_valuators) { + kbp->deviceid |= MORE_EVENTS; + events++; + clipValuators(pDev, first_valuator, num_valuators, valuators); + events = getValuatorEvents(events, pDev, first_valuator, + num_valuators, valuators); + } + + return num_events; +} + + +/** + * Note that pDev was the last device to send a core event. This function + * copies the complete keymap from the originating device to the core + * device, and makes sure the appropriate notifications are generated. + * + * Call this just before processInputProc. + */ +void +SwitchCoreKeyboard(DeviceIntPtr pDev) +{ + KeyClassPtr ckeyc = inputInfo.keyboard->key; + int i = 0; + + if (inputInfo.keyboard->devPrivates[CoreDevicePrivatesIndex].ptr != pDev) { + memcpy(ckeyc->modifierMap, pDev->key->modifierMap, MAP_LENGTH); + if (ckeyc->modifierKeyMap) + free(ckeyc->modifierKeyMap); + ckeyc->modifierKeyMap = malloc(8 * pDev->key->maxKeysPerModifier); + memcpy(ckeyc->modifierKeyMap, pDev->key->modifierKeyMap, + (8 * pDev->key->maxKeysPerModifier)); + + ckeyc->maxKeysPerModifier = pDev->key->maxKeysPerModifier; + ckeyc->curKeySyms.minKeyCode = pDev->key->curKeySyms.minKeyCode; + ckeyc->curKeySyms.maxKeyCode = pDev->key->curKeySyms.maxKeyCode; + SetKeySymsMap(&ckeyc->curKeySyms, &pDev->key->curKeySyms); + + /* + * Copy state from the extended keyboard to core. If you omit this, + * holding Ctrl on keyboard one, and pressing Q on keyboard two, will + * cause your app to quit. This feels wrong to me, hence the below + * code. + * + * XXX: If you synthesise core modifier events, the state will get + * clobbered here. You'll have to work out something sensible + * to fix that. Good luck. + */ + +#define KEYBOARD_MASK (ShiftMask | LockMask | ControlMask | Mod1Mask | \ + Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask) + ckeyc->state &= ~(KEYBOARD_MASK); + ckeyc->state |= (pDev->key->state & KEYBOARD_MASK); +#undef KEYBOARD_MASK + for (i = 0; i < 8; i++) + ckeyc->modifierKeyCount[i] = pDev->key->modifierKeyCount[i]; + +#ifdef XKB + if (!noXkbExtension && pDev->key->xkbInfo && pDev->key->xkbInfo->desc) { + if (!XkbCopyKeymap(pDev->key->xkbInfo->desc, ckeyc->xkbInfo->desc, + True)) + FatalError("Couldn't pivot keymap from device to core!\n"); + } +#endif + + SendMappingNotify(MappingKeyboard, ckeyc->curKeySyms.minKeyCode, + (ckeyc->curKeySyms.maxKeyCode - + ckeyc->curKeySyms.minKeyCode), + serverClient); + inputInfo.keyboard->devPrivates[CoreDevicePrivatesIndex].ptr = pDev; + } +} + + +/** + * Note that pDev was the last function to send a core void * event. + * Currently a no-op. + * + * Call this just before processInputProc. + */ +void +SwitchCorePointer(DeviceIntPtr pDev) +{ + if (inputInfo.pointer->devPrivates[CoreDevicePrivatesIndex].ptr != pDev) + inputInfo.pointer->devPrivates[CoreDevicePrivatesIndex].ptr = pDev; +} + + +/** + * Synthesize a single motion event for the core pointer. + * + * Used in cursor functions, e.g. when cursor confinement changes, and we need + * to shift the void * to get it inside the new bounds. + */ +void +PostSyntheticMotion(int x, int y, int screen, unsigned long time) +{ + xEvent xE; + +#ifdef PANORAMIX + /* Translate back to the sprite screen since processInputProc + will translate from sprite screen to screen 0 upon reentry + to the DIX layer. */ + if (!noPanoramiXExtension) { + x += panoramiXdataPtr[0].x - panoramiXdataPtr[screen].x; + y += panoramiXdataPtr[0].y - panoramiXdataPtr[screen].y; + } +#endif + + memset(&xE, 0, sizeof(xEvent)); + xE.u.u.type = MotionNotify; + xE.u.keyButtonPointer.rootX = x; + xE.u.keyButtonPointer.rootY = y; + xE.u.keyButtonPointer.time = time; + + (*inputInfo.pointer->public.processInputProc)(&xE, inputInfo.pointer, 1); +} diff --git a/nx-X11/programs/Xserver/dix/globals.c b/nx-X11/programs/Xserver/dix/globals.c index f192cb09c6..2e38f3e918 100644 --- a/nx-X11/programs/Xserver/dix/globals.c +++ b/nx-X11/programs/Xserver/dix/globals.c @@ -27,13 +27,13 @@ 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, +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 +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. +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 diff --git a/nx-X11/programs/Xserver/dix/glyphcurs.c b/nx-X11/programs/Xserver/dix/glyphcurs.c index 5e36f158c6..85b267660a 100644 --- a/nx-X11/programs/Xserver/dix/glyphcurs.c +++ b/nx-X11/programs/Xserver/dix/glyphcurs.c @@ -27,13 +27,13 @@ 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, +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 +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. +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 @@ -75,10 +75,10 @@ cursor metrics. #ifndef NXAGENT_SERVER int -ServerBitsFromGlyph(FontPtr pfont, unsigned ch, register CursorMetricPtr cm, unsigned char **ppbits) +ServerBitsFromGlyph(FontPtr pfont, unsigned ch, CursorMetricPtr cm, unsigned char **ppbits) { - register ScreenPtr pScreen; - register GCPtr pGC; + ScreenPtr pScreen; + GCPtr pGC; xRectangle rect; PixmapPtr ppix; long nby; @@ -142,7 +142,7 @@ ServerBitsFromGlyph(FontPtr pfont, unsigned ch, register CursorMetricPtr cm, uns #endif /* NXAGENT_SERVER */ Bool -CursorMetricsFromGlyph(register FontPtr pfont, unsigned ch, register CursorMetricPtr cm) +CursorMetricsFromGlyph(FontPtr pfont, unsigned ch, CursorMetricPtr cm) { CharInfoPtr pci; unsigned long nglyphs; diff --git a/nx-X11/programs/Xserver/dix/grabs.c b/nx-X11/programs/Xserver/dix/grabs.c index 0068676c2e..86d47509a8 100644 --- a/nx-X11/programs/Xserver/dix/grabs.c +++ b/nx-X11/programs/Xserver/dix/grabs.c @@ -29,13 +29,13 @@ 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, +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 +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. +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 @@ -127,7 +127,7 @@ FreeGrab(GrabPtr pGrab) int DeletePassiveGrab(void * value, XID id) { - register GrabPtr g, prev; + GrabPtr g, prev; GrabPtr pGrab = (GrabPtr)value; /* it is OK if the grab isn't found */ @@ -152,8 +152,8 @@ DeletePassiveGrab(void * value, XID id) static Mask * DeleteDetailFromMask(Mask *pDetailMask, unsigned short detail) { - register Mask *mask; - register int i; + Mask *mask; + int i; mask = (Mask *)malloc(sizeof(Mask) * MasksPerDetailMask); if (mask) @@ -166,7 +166,7 @@ DeleteDetailFromMask(Mask *pDetailMask, unsigned short detail) mask[i]= ~0L; BITCLEAR(mask, detail); } - return mask; + return mask; } static Bool @@ -187,11 +187,11 @@ IsInGrabMask( if (GETBIT(firstDetail.pMask, secondDetail.exact)) return TRUE; } - + return FALSE; } -static Bool +static Bool IdenticalExactDetails( unsigned short firstExact, unsigned short secondExact, @@ -199,14 +199,14 @@ IdenticalExactDetails( { if ((firstExact == exception) || (secondExact == exception)) return FALSE; - + if (firstExact == secondExact) return TRUE; return FALSE; } -static Bool +static Bool DetailSupersedesSecond( DetailRec firstDetail, DetailRec secondDetail, @@ -218,7 +218,7 @@ DetailSupersedesSecond( if (IdenticalExactDetails(firstDetail.exact, secondDetail.exact, exception)) return TRUE; - + return FALSE; } @@ -226,14 +226,14 @@ static Bool GrabSupersedesSecond(GrabPtr pFirstGrab, GrabPtr pSecondGrab) { if (!DetailSupersedesSecond(pFirstGrab->modifiersDetail, - pSecondGrab->modifiersDetail, + pSecondGrab->modifiersDetail, (unsigned short)AnyModifier)) return FALSE; if (DetailSupersedesSecond(pFirstGrab->detail, pSecondGrab->detail, (unsigned short)AnyKey)) return TRUE; - + return FALSE; } @@ -248,10 +248,10 @@ GrabMatchesSecond(GrabPtr pFirstGrab, GrabPtr pSecondGrab) if (GrabSupersedesSecond(pFirstGrab, pSecondGrab) || GrabSupersedesSecond(pSecondGrab, pFirstGrab)) return TRUE; - + if (DetailSupersedesSecond(pSecondGrab->detail, pFirstGrab->detail, - (unsigned short)AnyKey) - && + (unsigned short)AnyKey) + && DetailSupersedesSecond(pFirstGrab->modifiersDetail, pSecondGrab->modifiersDetail, (unsigned short)AnyModifier)) @@ -259,7 +259,7 @@ GrabMatchesSecond(GrabPtr pFirstGrab, GrabPtr pSecondGrab) if (DetailSupersedesSecond(pFirstGrab->detail, pSecondGrab->detail, (unsigned short)AnyKey) - && + && DetailSupersedesSecond(pSecondGrab->modifiersDetail, pFirstGrab->modifiersDetail, (unsigned short)AnyModifier)) @@ -268,6 +268,42 @@ GrabMatchesSecond(GrabPtr pFirstGrab, GrabPtr pSecondGrab) return FALSE; } +static Bool +GrabsAreIdentical(GrabPtr pFirstGrab, GrabPtr pSecondGrab) +{ + if (pFirstGrab->device != pSecondGrab->device || + (pFirstGrab->modifierDevice != pSecondGrab->modifierDevice) || + (pFirstGrab->type != pSecondGrab->type)) + return FALSE; + + if (!(DetailSupersedesSecond(pFirstGrab->detail, + pSecondGrab->detail, + (unsigned short)AnyKey) && + DetailSupersedesSecond(pSecondGrab->detail, + pFirstGrab->detail, + (unsigned short)AnyKey))) + return FALSE; + + if (!(DetailSupersedesSecond(pFirstGrab->modifiersDetail, + pSecondGrab->modifiersDetail, + (unsigned short)AnyModifier) && + DetailSupersedesSecond(pSecondGrab->modifiersDetail, + pFirstGrab->modifiersDetail, + (unsigned short)AnyModifier))) + return FALSE; + + return TRUE; +} + + +/** + * Prepend the new grab to the list of passive grabs on the window. + * Any previously existing grab that matches the new grab will be removed. + * Adding a new grab that would override another client's grab will result in + * a BadAccess. + * + * @return Success or X error code on failure. + */ int AddPassiveGrabToList(GrabPtr pGrab) { @@ -285,11 +321,22 @@ AddPassiveGrabToList(GrabPtr pGrab) } } + /* Remove all grabs that match the new one exactly */ + for (grab = wPassiveGrabs(pGrab->window); grab; grab = grab->next) + { + if (GrabsAreIdentical(pGrab, grab)) + { + DeletePassiveGrabFromList(grab); + break; + } + } + if (!pGrab->window->optional && !MakeWindowOptional (pGrab->window)) { FreeGrab(pGrab); return BadAlloc; } + pGrab->next = pGrab->window->optional->passiveGrabs; pGrab->window->optional->passiveGrabs = pGrab; if (AddResource(pGrab->resource, RT_PASSIVEGRAB, (void *)pGrab)) @@ -304,7 +351,7 @@ AddPassiveGrabToList(GrabPtr pGrab) Bool DeletePassiveGrabFromList(GrabPtr pMinuendGrab) { - register GrabPtr grab; + GrabPtr grab; GrabPtr *deletes, *adds; Mask ***updates, **details; int i, ndels, nadds, nups; @@ -351,7 +398,7 @@ DeletePassiveGrabFromList(GrabPtr pMinuendGrab) { UPDATE(grab->detail.pMask, pMinuendGrab->detail.exact); } - else if ((grab->modifiersDetail.exact == AnyModifier) + else if ((grab->modifiersDetail.exact == AnyModifier) && (grab->detail.exact != AnyKey)) { UPDATE(grab->modifiersDetail.pMask, @@ -390,7 +437,7 @@ DeletePassiveGrabFromList(GrabPtr pMinuendGrab) ok = FALSE; else adds[nadds++] = pNewGrab; - } + } else if (pMinuendGrab->detail.exact == AnyKey) { UPDATE(grab->modifiersDetail.pMask, diff --git a/nx-X11/programs/Xserver/dix/initatoms.c b/nx-X11/programs/Xserver/dix/initatoms.c index 5f6244a76e..7f07a4305f 100644 --- a/nx-X11/programs/Xserver/dix/initatoms.c +++ b/nx-X11/programs/Xserver/dix/initatoms.c @@ -11,7 +11,7 @@ #include #include "misc.h" #include "dix.h" -void MakePredeclaredAtoms() +void MakePredeclaredAtoms(void) { if (MakeAtom("PRIMARY", 7, 1) != XA_PRIMARY) AtomError(); if (MakeAtom("SECONDARY", 9, 1) != XA_SECONDARY) AtomError(); diff --git a/nx-X11/programs/Xserver/dix/main.c b/nx-X11/programs/Xserver/dix/main.c index 1ae51fc817..6ecb2538e8 100644 --- a/nx-X11/programs/Xserver/dix/main.c +++ b/nx-X11/programs/Xserver/dix/main.c @@ -27,13 +27,13 @@ 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, +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 +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. +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 @@ -74,8 +74,6 @@ Equipment Corporation. ******************************************************************/ -/* $TOG: main.c /main/86 1998/02/09 14:20:03 kaleb $ */ - #ifdef HAVE_DIX_CONFIG_H #include #endif @@ -103,6 +101,7 @@ Equipment Corporation. #endif /* HAS_XFONT2 */ #include "opaque.h" #include "servermd.h" +#include "hotplug.h" #include "site.h" #include "dixfont.h" #include "extnsionst.h" @@ -167,13 +166,14 @@ ReplyNotSwappd( int main(int argc, char *argv[], char *envp[]) { - int i; + int i; char *xauthfile; HWEventQueueType alwaysCheckForInput[2]; display = "0"; InitGlobals(); + InitRegions(); /* Quartz support on Mac OS X requires that the Cocoa event loop be in * the main thread. This allows the X server main to be called again @@ -228,7 +228,8 @@ main(int argc, char *argv[], char *envp[]) #endif InitBlockAndWakeupHandlers(); /* Perform any operating system dependent initializations you'd like */ - OsInit(); + OsInit(); + config_init(); if(serverGeneration == 1) { CreateWellKnownSockets(); @@ -236,7 +237,7 @@ main(int argc, char *argv[], char *envp[]) clients = (ClientPtr *)malloc(MAXCLIENTS * sizeof(ClientPtr)); if (!clients) FatalError("couldn't create client array"); - for (i=1; iroot = NullWindow; CloseDownDevices(); - CloseDownEvents(); - for (i = screenInfo.numScreens - 1; i >= 0; i--) { FreeScratchPixmapsForScreen(i); @@ -380,6 +387,7 @@ main(int argc, char *argv[], char *envp[]) FreeScreen(screenInfo.screens[i]); screenInfo.numScreens = i; } + CloseDownEvents(); FreeFonts(); FreeAuditTimer(); @@ -428,7 +436,7 @@ static int padlength[4] = {0, 3, 2, 1}; static #endif Bool -CreateConnectionBlock() +CreateConnectionBlock(void) { xConnSetup setup; xWindowRoot root; @@ -441,11 +449,10 @@ CreateConnectionBlock() sizesofar = 0; char *pBuf; - - memset(&setup, 0, sizeof(xConnSetup)); - /* Leave off the ridBase and ridMask, these must be sent with - connection */ + /* Leave off the ridBase and ridMask, these must be sent with + connection */ + memset(&setup, 0, sizeof(xConnSetup)); setup.release = VendorRelease; /* * per-server image and bitmap parameters are defined in Xmd.h @@ -458,12 +465,12 @@ CreateConnectionBlock() setup.bitmapBitOrder = screenInfo.bitmapBitOrder; setup.motionBufferSize = NumMotionEvents(); setup.numRoots = screenInfo.numScreens; - setup.nbytesVendor = strlen(VendorString); + setup.nbytesVendor = strlen(VendorString); setup.numFormats = screenInfo.numPixmapFormats; setup.maxRequestSize = MAX_REQUEST_SIZE; QueryMinMaxKeyCodes(&setup.minKeyCode, &setup.maxKeyCode); - - lenofblock = sizeof(xConnSetup) + + + lenofblock = sizeof(xConnSetup) + ((setup.nbytesVendor + 3) & ~3) + (setup.numFormats * sizeof(xPixmapFormat)) + (setup.numRoots * sizeof(xWindowRoot)); @@ -482,7 +489,7 @@ CreateConnectionBlock() sizesofar += i; while (--i >= 0) *pBuf++ = 0; - + memset(&format, 0, sizeof(xPixmapFormat)); for (i=0; immWidth; root.mmHeight = pScreen->mmHeight; root.minInstalledMaps = pScreen->minInstalledCmaps; - root.maxInstalledMaps = pScreen->maxInstalledCmaps; + root.maxInstalledMaps = pScreen->maxInstalledCmaps; root.rootVisualID = pScreen->rootVisual; root.backingStore = pScreen->backingStoreSupport; root.saveUnders = pScreen->saveUnderSupport != NotUseful; @@ -527,7 +534,7 @@ CreateConnectionBlock() pDepth = pScreen->allowedDepths; for(j = 0; j < pScreen->numDepths; j++, pDepth++) { - lenofblock += sizeof(xDepth) + + lenofblock += sizeof(xDepth) + (pDepth->numVids * sizeof(xVisualType)); pBuf = (char *)realloc(ConnectionInfo, lenofblock); if (!pBuf) @@ -536,7 +543,7 @@ CreateConnectionBlock() return FALSE; } ConnectionInfo = pBuf; - pBuf += sizesofar; + pBuf += sizesofar; depth.depth = pDepth->depth; depth.nVisuals = pDepth->numVids; memmove(pBuf, (char *)&depth, sizeof(xDepth)); diff --git a/nx-X11/programs/Xserver/dix/pixmap.c b/nx-X11/programs/Xserver/dix/pixmap.c index 247fa34ab3..3c97f2d762 100644 --- a/nx-X11/programs/Xserver/dix/pixmap.c +++ b/nx-X11/programs/Xserver/dix/pixmap.c @@ -50,7 +50,7 @@ from The Open Group. /* callable by ddx */ PixmapPtr -GetScratchPixmapHeader(ScreenPtr pScreen, int width, int height, int depth, +GetScratchPixmapHeader(ScreenPtr pScreen, int width, int height, int depth, int bitsPerPixel, int devKind, void * pPixData) { PixmapPtr pPixmap = pScreen->pScratchPixmap; @@ -118,7 +118,7 @@ AllocatePixmap(ScreenPtr pScreen, int pixDataSize) if (pScreen->totalPixmapSize > ((size_t)-1) - pixDataSize) return NullPixmap; - + /* * FIXME: Allocate 4 bytes at the end of each pixmap. This * is a quick workaround intended to fix a problem reported diff --git a/nx-X11/programs/Xserver/dix/privates.c b/nx-X11/programs/Xserver/dix/privates.c index 6c793ef975..9abad0b437 100644 --- a/nx-X11/programs/Xserver/dix/privates.c +++ b/nx-X11/programs/Xserver/dix/privates.c @@ -60,7 +60,7 @@ unsigned *extensionPrivateSizes; unsigned totalExtensionSize; void -ResetExtensionPrivates() +ResetExtensionPrivates(void) { extensionPrivateCount = 0; extensionPrivateLen = 0; @@ -71,7 +71,7 @@ ResetExtensionPrivates() } int -AllocateExtensionPrivateIndex() +AllocateExtensionPrivateIndex(void) { return extensionPrivateCount++; } @@ -117,7 +117,7 @@ unsigned *clientPrivateSizes; unsigned totalClientSize; void -ResetClientPrivates() +ResetClientPrivates(void) { clientPrivateCount = 0; clientPrivateLen = 0; @@ -128,7 +128,7 @@ ResetClientPrivates() } int -AllocateClientPrivateIndex() +AllocateClientPrivateIndex(void) { return clientPrivateCount++; } @@ -171,7 +171,7 @@ AllocateClientPrivate(int index2, unsigned amount) int screenPrivateCount; void -ResetScreenPrivates() +ResetScreenPrivates(void) { screenPrivateCount = 0; } @@ -180,7 +180,7 @@ ResetScreenPrivates() * so we have to worry about resizing existing devPrivates */ int -AllocateScreenPrivateIndex() +AllocateScreenPrivateIndex(void) { int idx; int i; @@ -213,19 +213,19 @@ AllocateScreenPrivateIndex() static int windowPrivateCount; void -ResetWindowPrivates() +ResetWindowPrivates(void) { windowPrivateCount = 0; } int -AllocateWindowPrivateIndex() +AllocateWindowPrivateIndex(void) { return windowPrivateCount++; } Bool -AllocateWindowPrivate(register ScreenPtr pScreen, int index2, unsigned amount) +AllocateWindowPrivate(ScreenPtr pScreen, int index2, unsigned amount) { unsigned oldamount; @@ -257,25 +257,25 @@ AllocateWindowPrivate(register ScreenPtr pScreen, int index2, unsigned amount) /* - * gc private machinery + * gc private machinery */ static int gcPrivateCount; void -ResetGCPrivates() +ResetGCPrivates(void) { gcPrivateCount = 0; } int -AllocateGCPrivateIndex() +AllocateGCPrivateIndex(void) { return gcPrivateCount++; } Bool -AllocateGCPrivate(register ScreenPtr pScreen, int index2, unsigned amount) +AllocateGCPrivate(ScreenPtr pScreen, int index2, unsigned amount) { unsigned oldamount; @@ -313,19 +313,19 @@ AllocateGCPrivate(register ScreenPtr pScreen, int index2, unsigned amount) static int pixmapPrivateCount; void -ResetPixmapPrivates() +ResetPixmapPrivates(void) { pixmapPrivateCount = 0; } int -AllocatePixmapPrivateIndex() +AllocatePixmapPrivateIndex(void) { return pixmapPrivateCount++; } Bool -AllocatePixmapPrivate(register ScreenPtr pScreen, int index2, unsigned amount) +AllocatePixmapPrivate(ScreenPtr pScreen, int index2, unsigned amount) { unsigned oldamount; @@ -357,7 +357,6 @@ AllocatePixmapPrivate(register ScreenPtr pScreen, int index2, unsigned amount) } #endif - /* * colormap private machinery */ @@ -365,7 +364,7 @@ AllocatePixmapPrivate(register ScreenPtr pScreen, int index2, unsigned amount) int colormapPrivateCount; void -ResetColormapPrivates() +ResetColormapPrivates(void) { colormapPrivateCount = 0; } @@ -426,7 +425,7 @@ AllocateColormapPrivateIndex (InitCmapPrivFunc initPrivFunc) static int devicePrivateIndex = 0; int -AllocateDevicePrivateIndex() +AllocateDevicePrivateIndex(void) { return devicePrivateIndex++; } diff --git a/nx-X11/programs/Xserver/dix/property.c b/nx-X11/programs/Xserver/dix/property.c index f46b53f7ca..4ba18f41e0 100644 --- a/nx-X11/programs/Xserver/dix/property.c +++ b/nx-X11/programs/Xserver/dix/property.c @@ -27,13 +27,13 @@ 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, +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 +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. +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 @@ -77,7 +77,7 @@ static void PrintPropertys(WindowPtr pWin) { PropertyPtr pProp; - register int j; + int j; pProp = pWin->userProps; while (pProp) @@ -92,14 +92,27 @@ PrintPropertys(WindowPtr pWin) } #endif +static void +deliverPropertyNotifyEvent(WindowPtr pWin, int state, Atom atom) +{ + xEvent event = {0}; + + event.u.u.type = PropertyNotify; + event.u.property.window = pWin->drawable.id; + event.u.property.state = state; + event.u.property.atom = atom; + event.u.property.time = currentTime.milliseconds; + DeliverEvents(pWin, &event, 1, (WindowPtr)NULL); +} + int ProcRotateProperties(ClientPtr client) { int i, j, delta; REQUEST(xRotatePropertiesReq); WindowPtr pWin; - register Atom * atoms; - PropertyPtr * props; /* array of pointer */ + Atom * atoms; + PropertyPtr * props; /* array of void * */ PropertyPtr pProp; REQUEST_FIXED_SIZE(xRotatePropertiesReq, stuff->nAtoms << 2); @@ -152,7 +165,7 @@ ProcRotateProperties(ClientPtr client) } free(props); return BadMatch; -found: +found: props[i] = pProp; } delta = stuff->nPositions; @@ -160,24 +173,15 @@ ProcRotateProperties(ClientPtr client) /* If the rotation is a complete 360 degrees, then moving the properties around and generating PropertyNotify events should be skipped. */ - if ( (stuff->nAtoms != 0) && (abs(delta) % stuff->nAtoms) != 0 ) + if ( (stuff->nAtoms != 0) && (abs(delta) % stuff->nAtoms) != 0 ) { while (delta < 0) /* faster if abs value is small */ delta += stuff->nAtoms; for (i = 0; i < stuff->nAtoms; i++) - { - /* Generate a PropertyNotify event for each property whose value - is changed in the order in which they appear in the request. */ - xEvent event; - - memset(&event, 0, sizeof(xEvent)); - event.u.u.type = PropertyNotify; - event.u.property.window = pWin->drawable.id; - event.u.property.state = PropertyNewValue; - event.u.property.atom = props[i]->propertyName; - event.u.property.time = currentTime.milliseconds; - DeliverEvents(pWin, &event, 1, (WindowPtr)NULL); - + { + deliverPropertyNotifyEvent(pWin, PropertyNewValue, + props[i]->propertyName); + props[i]->propertyName = atoms[(i + delta) % stuff->nAtoms]; } } @@ -186,15 +190,13 @@ ProcRotateProperties(ClientPtr client) } #ifndef NXAGENT_SERVER -int +int ProcChangeProperty(ClientPtr client) -{ +{ WindowPtr pWin; char format, mode; unsigned long len; - int sizeInBytes; - int totalSize; - int err; + int sizeInBytes, totalSize, err; REQUEST(xChangePropertyReq); REQUEST_AT_LEAST_SIZE(xChangePropertyReq); @@ -343,7 +345,7 @@ ChangeWindowProperty(WindowPtr pWin, Atom property, Atom type, int format, if (!data) return(BadAlloc); pProp->data = data; - memmove(&((char *)data)[pProp->size * sizeInBytes], + memmove(&((char *)data)[pProp->size * sizeInBytes], (char *)value, totalSize); pProp->size += len; @@ -353,7 +355,7 @@ ChangeWindowProperty(WindowPtr pWin, Atom property, Atom type, int format, data = (void *)malloc(sizeInBytes * (len + pProp->size)); if (!data) return(BadAlloc); - memmove(&((char *)data)[totalSize], (char *)pProp->data, + memmove(&((char *)data)[totalSize], (char *)pProp->data, (int)(pProp->size * sizeInBytes)); memmove((char *)data, (char *)value, totalSize); free(pProp->data); @@ -361,17 +363,10 @@ ChangeWindowProperty(WindowPtr pWin, Atom property, Atom type, int format, pProp->size += len; } } + if (sendevent) - { - xEvent event; - memset(&event, 0, sizeof(xEvent)); - event.u.u.type = PropertyNotify; - event.u.property.window = pWin->drawable.id; - event.u.property.state = PropertyNewValue; - event.u.property.atom = pProp->propertyName; - event.u.property.time = currentTime.milliseconds; - DeliverEvents(pWin, &event, 1, (WindowPtr)NULL); - } + deliverPropertyNotifyEvent(pWin, PropertyNewValue, pProp->propertyName); + return(Success); } @@ -390,9 +385,8 @@ DeleteProperty(WindowPtr pWin, Atom propName) prevProp = pProp; pProp = pProp->next; } - if (pProp) - { - xEvent event; + if (pProp) + { if (prevProp == (PropertyPtr)NULL) /* takes care of head */ { if (!(pWin->optional->userProps = pProp->next)) @@ -402,13 +396,7 @@ DeleteProperty(WindowPtr pWin, Atom propName) { prevProp->next = pProp->next; } - memset(&event, 0, sizeof(xEvent)); - event.u.u.type = PropertyNotify; - event.u.property.window = pWin->drawable.id; - event.u.property.state = PropertyDelete; - event.u.property.atom = pProp->propertyName; - event.u.property.time = currentTime.milliseconds; - DeliverEvents(pWin, &event, 1, (WindowPtr)NULL); + deliverPropertyNotifyEvent(pWin, PropertyDelete, pProp->propertyName); free(pProp->data); free(pProp); } @@ -419,18 +407,11 @@ void DeleteAllWindowProperties(WindowPtr pWin) { PropertyPtr pProp, pNextProp; - xEvent event; - memset(&event, 0, sizeof(xEvent)); pProp = wUserProps (pWin); while (pProp) { - event.u.u.type = PropertyNotify; - event.u.property.window = pWin->drawable.id; - event.u.property.state = PropertyDelete; - event.u.property.atom = pProp->propertyName; - event.u.property.time = currentTime.milliseconds; - DeliverEvents(pWin, &event, 1, (WindowPtr)NULL); + deliverPropertyNotifyEvent(pWin, PropertyDelete, pProp->propertyName); pNextProp = pProp->next; free(pProp->data); free(pProp); @@ -503,7 +484,7 @@ ProcGetProperty(ClientPtr client) prevProp = (PropertyPtr)NULL; while (pProp) { - if (pProp->propertyName == stuff->property) + if (pProp->propertyName == stuff->property) break; prevProp = pProp; pProp = pProp->next; @@ -512,7 +493,7 @@ ProcGetProperty(ClientPtr client) memset(&reply, 0, sizeof(xGetPropertyReply)); reply.type = X_Reply; reply.sequenceNumber = client->sequence; - if (!pProp) + if (!pProp) return NullPropertyReply(client, None, 0, &reply); #ifdef XCSECURITY @@ -553,7 +534,7 @@ ProcGetProperty(ClientPtr client) * Return type, format, value to client */ n = (pProp->format/8) * pProp->size; /* size (bytes) of prop */ - ind = stuff->longOffset << 2; + ind = stuff->longOffset << 2; /* If longOffset is invalid such that it causes "len" to be negative, it's a value error. */ @@ -573,17 +554,7 @@ ProcGetProperty(ClientPtr client) reply.propertyType = pProp->type; if (stuff->delete && (reply.bytesAfter == 0)) - { /* send the event */ - xEvent event; - - memset(&event, 0, sizeof(xEvent)); - event.u.u.type = PropertyNotify; - event.u.property.window = pWin->drawable.id; - event.u.property.state = PropertyDelete; - event.u.property.atom = pProp->propertyName; - event.u.property.time = currentTime.milliseconds; - DeliverEvents(pWin, &event, 1, (WindowPtr)NULL); - } + deliverPropertyNotifyEvent(pWin, PropertyDelete, pProp->propertyName); WriteReplyToClient(client, sizeof(xGenericReply), &reply); if (len) @@ -631,7 +602,7 @@ ProcListProperties(ClientPtr client) pProp = wUserProps (pWin); while (pProp) - { + { pProp = pProp->next; numProps++; } @@ -662,13 +633,13 @@ ProcListProperties(ClientPtr client) } #ifndef NXAGENT_SERVER -int -ProcDeleteProperty(register ClientPtr client) +int +ProcDeleteProperty(ClientPtr client) { WindowPtr pWin; REQUEST(xDeletePropertyReq); int result; - + REQUEST_SIZE_MATCH(xDeletePropertyReq); UpdateCurrentTime(); pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, diff --git a/nx-X11/programs/Xserver/dix/region.c b/nx-X11/programs/Xserver/dix/region.c index 46e8845bf5..f17cbcf0eb 100644 --- a/nx-X11/programs/Xserver/dix/region.c +++ b/nx-X11/programs/Xserver/dix/region.c @@ -21,20 +21,20 @@ 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, 1988, 1989 by -Digital Equipment Corporation, Maynard, Massachusetts. + +Copyright 1987, 1988, 1989 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, +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 +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. +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 @@ -119,9 +119,9 @@ Equipment Corporation. * there is no separate list of band start pointers. * * The y-x band representation does not minimize rectangles. In particular, - * if a rectangle vertically crosses a band (the rectangle has scanlines in + * if a rectangle vertically crosses a band (the rectangle has scanlines in * the y1 to y2 area spanned by the band), then the rectangle may be broken - * down into two or more smaller rectangles stacked one atop the other. + * down into two or more smaller rectangles stacked one atop the other. * * ----------- ----------- * | | | | band 0 @@ -223,13 +223,20 @@ RegDataRec RegionEmptyData = {0, 0}; RegDataRec RegionBrokenData = {0, 0}; RegionRec RegionBrokenRegion = { { 0, 0, 0, 0 }, &RegionBrokenData }; +void +InitRegions(void) +{ + pixman_region_set_static_pointers(&RegionEmptyBox, &RegionEmptyData, + &RegionBrokenData); +} + #ifdef DEBUG int RegionPrint(rgn) RegionPtr rgn; { int num, size; - register int i; + int i; BoxPtr rects; num = RegionNumRects(rgn); @@ -251,7 +258,7 @@ Bool RegionIsValid(reg) RegionPtr reg; { - register int i, numRects; + int i, numRects; if ((reg->extents.x1 > reg->extents.x2) || (reg->extents.y1 > reg->extents.y2)) @@ -265,7 +272,7 @@ RegionIsValid(reg) return (!reg->data); else { - register BoxPtr pboxP, pboxN; + BoxPtr pboxP, pboxN; BoxRec box; pboxP = RegionRects(reg); @@ -307,7 +314,7 @@ RegionCreate(rect, size) BoxPtr rect; int size; { - register RegionPtr pReg; + RegionPtr pReg; size_t newSize; pReg = (RegionPtr)malloc(sizeof(RegionRec)); if (!pReg) @@ -355,12 +362,12 @@ RegionBreak (pReg) Bool RegionRectAlloc( - register RegionPtr pRgn, + RegionPtr pRgn, int n) { RegDataPtr data; size_t rgnSize; - + if (!pRgn->data) { n++; @@ -424,14 +431,14 @@ RegionRectAlloc( */ INLINE static int RegionCoalesce ( - register RegionPtr pReg, /* Region to coalesce */ + RegionPtr pReg, /* Region to coalesce */ int prevStart, /* Index of start of previous band */ int curStart) /* Index of start of current band */ { - register BoxPtr pPrevBox; /* Current box in previous band */ - register BoxPtr pCurBox; /* Current box in current band */ - register int numRects; /* Number rectangles in both bands */ - register int y2; /* Bottom of current band */ + BoxPtr pPrevBox; /* Current box in previous band */ + BoxPtr pCurBox; /* Current box in current band */ + int numRects; /* Number rectangles in both bands */ + int y2; /* Bottom of current band */ /* * Figure out how many rectangles are in the band. */ @@ -508,14 +515,14 @@ RegionCoalesce ( INLINE static Bool RegionAppendNonO ( - register RegionPtr pReg, - register BoxPtr r, + RegionPtr pReg, + BoxPtr r, BoxPtr rEnd, - register int y1, - register int y2) + int y1, + int y2) { - register BoxPtr pNextRect; - register int newRects; + BoxPtr pNextRect; + int newRects; newRects = rEnd - r; @@ -607,8 +614,8 @@ RegionOp( /* in region 2 ? */ Bool *pOverlap) { - register BoxPtr r1; /* Pointer into first region */ - register BoxPtr r2; /* Pointer into 2d region */ + BoxPtr r1; /* Pointer into first region */ + BoxPtr r2; /* Pointer into 2d region */ BoxPtr r1End; /* End of 1st region */ BoxPtr r2End; /* End of 2d region */ short ybot; /* Bottom of intersection */ @@ -618,12 +625,12 @@ RegionOp( * previous band in newReg */ int curBand; /* Index of start of current * band in newReg */ - register BoxPtr r1BandEnd; /* End of current band in r1 */ - register BoxPtr r2BandEnd; /* End of current band in r2 */ + BoxPtr r1BandEnd; /* End of current band in r1 */ + BoxPtr r2BandEnd; /* End of current band in r2 */ short top; /* Top of non-overlapping band */ short bot; /* Bottom of non-overlapping band*/ - register int r1y1; /* Temps for r1->y1 and r2->y1 */ - register int r2y1; + int r1y1; /* Temps for r1->y1 and r2->y1 */ + int r2y1; int newSize; int numRects; @@ -632,7 +639,7 @@ RegionOp( */ if (RegionNar (reg1) || RegionNar(reg2)) return RegionBreak (newReg); - + /* * Initialization: * set r1, r2, r1End and r2End appropriately, save the rectangles @@ -684,7 +691,7 @@ RegionOp( */ ybot = min(r1->y1, r2->y1); - + /* * prevBand serves to mark the start of the previous band so rectangles * can be coalesced into larger rectangles. qv. RegionCoalesce, above. @@ -695,7 +702,7 @@ RegionOp( * array of rectangles. */ prevBand = 0; - + do { /* * This algorithm proceeds one source-band (as opposed to a @@ -706,7 +713,7 @@ RegionOp( */ assert(r1 != r1End); assert(r2 != r2End); - + FindBand(r1, r1BandEnd, r1End, r1y1); FindBand(r2, r2BandEnd, r2End, r2y1); @@ -831,9 +838,9 @@ RegionOp( */ void RegionSetExtents (pReg) - register RegionPtr pReg; + RegionPtr pReg; { - register BoxPtr pBox, pBoxEnd; + BoxPtr pBox, pBoxEnd; if (!pReg->data) return; @@ -907,18 +914,18 @@ RegionSetExtents (pReg) */ static Bool RegionUnionO ( - register RegionPtr pReg, - register BoxPtr r1, + RegionPtr pReg, + BoxPtr r1, BoxPtr r1End, - register BoxPtr r2, + BoxPtr r2, BoxPtr r2End, short y1, short y2, Bool *pOverlap) { - register BoxPtr pNextRect; - register int x1; /* left and right side of current union */ - register int x2; + BoxPtr pNextRect; + int x1; /* left and right side of current union */ + int x2; assert (y1 < y2); assert(r1 != r1End && r2 != r2End); @@ -958,7 +965,7 @@ RegionUnionO ( MERGERECT(r2); } while (r2 != r2End); } - + /* Add current rectangle */ NEWRECT(pReg, pNextRect, x1, y1, x2, y2); @@ -972,7 +979,7 @@ RegionUnionO ( /*- *----------------------------------------------------------------------- * RegionAppend -- - * + * * "Append" the rgn rectangles onto the end of dstrgn, maintaining * knowledge of YX-banding when it's easy. Otherwise, dstrgn just * becomes a non-y-x-banded random collection of rectangles, and not @@ -988,8 +995,8 @@ RegionUnionO ( */ Bool RegionAppend(dstrgn, rgn) - register RegionPtr dstrgn; - register RegionPtr rgn; + RegionPtr dstrgn; + RegionPtr rgn; { int numRects, dnumRects, size; BoxPtr new, old; @@ -997,7 +1004,7 @@ RegionAppend(dstrgn, rgn) if (RegionNar(rgn)) return RegionBreak (dstrgn); - + if (!rgn->data && (dstrgn->data == &RegionEmptyData)) { dstrgn->extents = rgn->extents; @@ -1019,7 +1026,7 @@ RegionAppend(dstrgn, rgn) dstrgn->extents = rgn->extents; else if (dstrgn->extents.x2 > dstrgn->extents.x1) { - register BoxPtr first, last; + BoxPtr first, last; first = old; last = RegionBoxptr(dstrgn) + (dnumRects - 1); @@ -1058,7 +1065,7 @@ RegionAppend(dstrgn, rgn) if (dnumRects == 1) *new = *RegionBoxptr(dstrgn); else - memmove((char *)new,(char *)RegionBoxptr(dstrgn), + memmove((char *)new,(char *)RegionBoxptr(dstrgn), dnumRects * sizeof(BoxRec)); new = RegionBoxptr(dstrgn); } @@ -1072,7 +1079,7 @@ RegionAppend(dstrgn, rgn) return TRUE; } - + #define ExchangeRects(a, b) \ { \ BoxRec t; \ @@ -1083,13 +1090,13 @@ RegionAppend(dstrgn, rgn) static void QuickSortRects( - register BoxRec rects[], - register int numRects) + BoxRec rects[], + int numRects) { - register int y1; - register int x1; - register int i, j; - register BoxPtr r; + int y1; + int x1; + int i, j; + BoxPtr r; /* Always called with numRects > 1 */ @@ -1143,7 +1150,7 @@ QuickSortRects( /*- *----------------------------------------------------------------------- * RegionValidate -- - * + * * Take a ``region'' which is a non-y-x-banded random collection of * rectangles, and compute a nice region which is the union of all the * rectangles. @@ -1189,12 +1196,12 @@ RegionValidate(badreg, pOverlap) int numRI; /* Number of entries used in ri */ int sizeRI; /* Number of entries available in ri */ int i; /* Index into rects */ - register int j; /* Index into ri */ - register RegionInfo *rit; /* &ri[j] */ - register RegionPtr reg; /* ri[j].reg */ - register BoxPtr box; /* Current box in rects */ - register BoxPtr riBox; /* Last box in ri[j].reg */ - register RegionPtr hreg; /* ri[j_half].reg */ + int j; /* Index into ri */ + RegionInfo *rit; /* &ri[j] */ + RegionPtr reg; /* ri[j].reg */ + BoxPtr box; /* Current box in rects */ + BoxPtr riBox; /* Last box in ri[j].reg */ + RegionPtr hreg; /* ri[j_half].reg */ Bool ret = TRUE; *pOverlap = FALSE; @@ -1366,13 +1373,13 @@ NextRect: ; RegionPtr RegionFromRects(nrects, prect, ctype) int nrects; - register xRectangle *prect; + xRectangle *prect; int ctype; { - register RegionPtr pRgn; - register RegDataPtr pData; - register BoxPtr pBox; - register int i; + RegionPtr pRgn; + RegDataPtr pData; + BoxPtr pBox; + int i; int x1, y1, x2, y2; size_t newSize; @@ -1448,12 +1455,12 @@ RegionFromRects(nrects, prect, ctype) Bool miRegionDataCopy( - register RegionPtr dst, - register RegionPtr src) + RegionPtr dst, + RegionPtr src) { good(dst); good(src); - if (dst->data) + if (dst->data) return TRUE; if (dst == src) return TRUE; @@ -1479,7 +1486,7 @@ miRegionDataCopy( #define ExchangeSpans(a, b) \ { \ DDXPointRec tpt; \ - register int tw; \ + int tw; \ \ tpt = spans[a]; spans[a] = spans[b]; spans[b] = tpt; \ tw = widths[a]; widths[a] = widths[b]; widths[b] = tw; \ @@ -1491,13 +1498,13 @@ miRegionDataCopy( */ static void QuickSortSpans( - register DDXPointRec spans[], - register int widths[], - register int numSpans) + DDXPointRec spans[], + int widths[], + int numSpans) { - register int y; - register int i, j, m; - register DDXPointPtr r; + int y; + int i, j, m; + DDXPointPtr r; /* Always called with numSpans > 1 */ /* Sorts only by y, doesn't bother to sort by x */ @@ -1507,7 +1514,7 @@ static void QuickSortSpans( if (numSpans < 9) { /* Do insertion sort */ - register int yprev; + int yprev; yprev = spans[0].y; i = 1; @@ -1597,17 +1604,17 @@ static void QuickSortSpans( int RegionClipSpans( RegionPtr prgnDst, - register DDXPointPtr ppt, - register int *pwidth, + DDXPointPtr ppt, + int *pwidth, int nspans, - register DDXPointPtr pptNew, + DDXPointPtr pptNew, int *pwidthNew, int fSorted) { - register DDXPointPtr pptLast; + DDXPointPtr pptLast; int *pwidthNewStart; /* the vengeance of Xerox! */ - register int y, x1, x2; - register int numRects; + int y, x1, x2; + int numRects; good(prgnDst); pptLast = ppt + nspans; @@ -1615,17 +1622,17 @@ RegionClipSpans( if (!prgnDst->data) { - /* Do special fast code with clip boundaries in registers(?) */ - /* It doesn't pay much to make use of fSorted in this case, + /* Do special fast code with clip boundaries in s(?) */ + /* It doesn't pay much to make use of fSorted in this case, so we lump everything together. */ - register int clipx1, clipx2, clipy1, clipy2; + int clipx1, clipx2, clipy1, clipy2; clipx1 = prgnDst->extents.x1; clipy1 = prgnDst->extents.y1; clipx2 = prgnDst->extents.x2; clipy2 = prgnDst->extents.y2; - + for (; ppt != pptLast; ppt++, pwidth++) { y = ppt->y; @@ -1652,9 +1659,9 @@ RegionClipSpans( { /* Have to clip against many boxes */ BoxPtr pboxBandStart, pboxBandEnd; - register BoxPtr pbox; - register BoxPtr pboxLast; - register int clipy1, clipy2; + BoxPtr pbox; + BoxPtr pboxLast; + int clipy1, clipy2; /* In this case, taking advantage of sorted spans gains more than the sorting costs. */ @@ -1663,7 +1670,7 @@ RegionClipSpans( pboxBandStart = RegionBoxptr(prgnDst); pboxLast = pboxBandStart + numRects; - + NextBand(); for (; ppt != pptLast; ) @@ -1677,7 +1684,7 @@ RegionClipSpans( x2 = x1 + *pwidth; do { /* For each box in band */ - register int newx1, newx2; + int newx1, newx2; newx1 = x1; newx2 = x2; @@ -1715,10 +1722,10 @@ int miFindMaxBand(prgn) RegionPtr prgn; { - register int nbox; - register BoxPtr pbox; - register int nThisBand; - register int nMaxBand = 0; + int nbox; + BoxPtr pbox; + int nThisBand; + int nMaxBand = 0; short yThisBand; good(prgn); diff --git a/nx-X11/programs/Xserver/dix/resource.c b/nx-X11/programs/Xserver/dix/resource.c index 8d2b612d75..5d7543f320 100644 --- a/nx-X11/programs/Xserver/dix/resource.c +++ b/nx-X11/programs/Xserver/dix/resource.c @@ -27,13 +27,13 @@ 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, +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 +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. +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 @@ -72,8 +72,34 @@ dealings in this Software without prior written authorization from Digital Equipment Corporation. ******************************************************************/ - -/* $TOG: resource.c /main/41 1998/02/09 14:20:31 kaleb $ */ +/* XSERVER_DTRACE additions: + * Copyright 2005-2006 Sun Microsystems, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons + * to whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * 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 + * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR 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. + * + * Except as contained in this notice, the name of a copyright holder + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * of the copyright holder. + */ /* Routines to manage various kinds of resources: * @@ -82,7 +108,7 @@ Equipment Corporation. * FreeAllResources, LookupIDByType, LookupIDByClass, GetXIDRange */ -/* +/* * A resource ID is a 32 bit quantity, the upper 2 bits of which are * off-limits for client-visible resources. The next 8 bits are * used as client ID, and the low 22 bits come from the client. @@ -106,7 +132,7 @@ Equipment Corporation. #include "misc.h" #include "os.h" #include "resource.h" -#include "dixstruct.h" +#include "dixstruct.h" #include "opaque.h" #include "windowstr.h" #include "dixfont.h" @@ -121,6 +147,14 @@ Equipment Corporation. #endif #include +#ifdef XSERVER_DTRACE +#include +typedef const char *string; +#include "Xserver-dtrace.h" + +#define TypeNameString(t) NameForAtom(ResourceNames[t & TypeMask]) +#endif + static void RebuildTable( int /*client*/ ); @@ -197,7 +231,7 @@ CreateNewResourceType(DeleteType deleteFunc) } RESTYPE -CreateNewResourceClass() +CreateNewResourceClass(void) { RESTYPE next = lastResourceClass >> 1; @@ -208,7 +242,7 @@ CreateNewResourceClass() return next; } -ClientResourceRec clientTable[MAXCLIENTS]; +static ClientResourceRec clientTable[MAXCLIENTS]; /***************** * InitClientResources @@ -219,8 +253,8 @@ ClientResourceRec clientTable[MAXCLIENTS]; Bool InitClientResources(ClientPtr client) { - register int i, j; - + int i, j; + if (client == serverClient) { lastResourceType = RT_LASTPREDEF; @@ -267,7 +301,7 @@ InitClientResources(ClientPtr client) (client->index ? SERVER_BIT : SERVER_MINID); clientTable[i].endFakeID = (clientTable[i].fakeID | RESOURCE_ID_MASK) + 1; clientTable[i].expectID = client->clientAsMask; - for (j=0; j= id) && (goodid <= maxid)) return goodid; @@ -322,10 +356,10 @@ AvailableID( void GetXIDRange(int client, Bool server, XID *minp, XID *maxp) { - register XID id, maxid; - register ResourcePtr *resp; - register ResourcePtr res; - register int i; + XID id, maxid; + ResourcePtr *resp; + ResourcePtr res; + int i; XID goodid; id = (Mask)client << CLIENTOFFSET; @@ -356,7 +390,7 @@ GetXIDRange(int client, Bool server, XID *minp, XID *maxp) /** * GetXIDList is called by the XC-MISC extension's MiscGetXIDList function. - * This function tries to find count unused XIDs for the given client. It + * This function tries to find count unused XIDs for the given client. It * puts the IDs in the array pids and returns the number found, which should * almost always be the number requested. * @@ -398,7 +432,7 @@ GetXIDList(ClientPtr pClient, unsigned count, XID *pids) */ XID -FakeClientID(register int client) +FakeClientID(int client) { XID id, maxid; @@ -423,9 +457,12 @@ Bool AddResource(XID id, RESTYPE type, void * value) { int client; - register ClientResourceRec *rrec; - register ResourcePtr res, *head; + ClientResourceRec *rrec; + ResourcePtr res, *head; +#ifdef XSERVER_DTRACE + XSERVER_RESOURCE_ALLOC(id, type, value, TypeNameString(type)); +#endif client = CLIENT_ID(id); rrec = &clientTable[client]; if (!rrec->buckets) @@ -459,10 +496,10 @@ AddResource(XID id, RESTYPE type, void * value) static void RebuildTable(int client) { - register int j; - register ResourcePtr res, next; + int j; + ResourcePtr res, next; ResourcePtr **tails, *resources; - register ResourcePtr **tptr, *rptr; + ResourcePtr **tptr, *rptr; /* * For now, preserve insertion order, since some ddx layers depend @@ -510,9 +547,9 @@ void FreeResource(XID id, RESTYPE skipDeleteFuncType) { int cid; - register ResourcePtr res; - register ResourcePtr *prev, *head; - register int *eltptr; + ResourcePtr res; + ResourcePtr *prev, *head; + int *eltptr; int elements; Bool gotOne = FALSE; @@ -527,6 +564,11 @@ FreeResource(XID id, RESTYPE skipDeleteFuncType) if (res->id == id) { RESTYPE rtype = res->type; + +#ifdef XSERVER_DTRACE + XSERVER_RESOURCE_FREE(res->id, res->type, + res->value, TypeNameString(res->type)); +#endif *prev = res->next; elements = --*eltptr; if (rtype != skipDeleteFuncType) @@ -550,8 +592,8 @@ void FreeResourceByType(XID id, RESTYPE type, Bool skipFree) { int cid; - register ResourcePtr res; - register ResourcePtr *prev, *head; + ResourcePtr res; + ResourcePtr *prev, *head; if (((cid = CLIENT_ID(id)) < MAXCLIENTS) && clientTable[cid].buckets) { head = &clientTable[cid].resources[Hash(cid, id)]; @@ -561,6 +603,10 @@ FreeResourceByType(XID id, RESTYPE type, Bool skipFree) { if (res->id == id && res->type == type) { +#ifdef XSERVER_DTRACE + XSERVER_RESOURCE_FREE(res->id, res->type, + res->value, TypeNameString(res->type)); +#endif *prev = res->next; if (!skipFree) (*DeleteFuncs[type & TypeMask])(res->value, res->id); @@ -584,7 +630,7 @@ Bool ChangeResourceValue (XID id, RESTYPE rtype, void * value) { int cid; - register ResourcePtr res; + ResourcePtr res; if (((cid = CLIENT_ID(id)) < MAXCLIENTS) && clientTable[cid].buckets) { @@ -614,17 +660,17 @@ FindClientResourcesByType( FindResType func, void * cdata ){ - register ResourcePtr *resources; - register ResourcePtr this, next; + ResourcePtr *resources; + ResourcePtr this, next; int i, elements; - register int *eltptr; + int *eltptr; if (!client) client = serverClient; resources = clientTable[client->index].resources; eltptr = &clientTable[client->index].elements; - for (i = 0; i < clientTable[client->index].buckets; i++) + for (i = 0; i < clientTable[client->index].buckets; i++) { for (this = resources[i]; this; this = next) { @@ -645,10 +691,10 @@ FindAllClientResources( FindAllRes func, void * cdata ){ - register ResourcePtr *resources; - register ResourcePtr this, next; + ResourcePtr *resources; + ResourcePtr this, next; int i, elements; - register int *eltptr; + int *eltptr; if (!client) client = serverClient; @@ -709,7 +755,7 @@ FreeClientNeverRetainResources(ClientPtr client) return; resources = clientTable[client->index].resources; - for (j=0; j < clientTable[client->index].buckets; j++) + for (j=0; j < clientTable[client->index].buckets; j++) { prev = &resources[j]; while ( (this = *prev) ) @@ -717,9 +763,13 @@ FreeClientNeverRetainResources(ClientPtr client) RESTYPE rtype = this->type; if (rtype & RC_NEVERRETAIN) { +#ifdef XSERVER_DTRACE + XSERVER_RESOURCE_FREE(this->id, this->type, + this->value, TypeNameString(this->type)); +#endif *prev = this->next; (*DeleteFuncs[rtype & TypeMask])(this->value, this->id); - free(this); + free(this); } else prev = &this->next; @@ -730,8 +780,8 @@ FreeClientNeverRetainResources(ClientPtr client) void FreeClientResources(ClientPtr client) { - register ResourcePtr *resources; - register ResourcePtr this; + ResourcePtr *resources; + ResourcePtr this; int j; /* This routine shouldn't be called with a null client, but just in @@ -743,11 +793,11 @@ FreeClientResources(ClientPtr client) HandleSaveSet(client); resources = clientTable[client->index].resources; - for (j=0; j < clientTable[client->index].buckets; j++) + for (j=0; j < clientTable[client->index].buckets; j++) { /* It may seem silly to update the head of this resource list as - we delete the members, since the entire list will be deleted any way, - but there are some resource deletion functions "FreeClientPixels" for + we delete the members, since the entire list will be deleted any way, + but there are some resource deletion functions "FreeClientPixels" for one which do a LookupID on another resource id (a Colormap id in this case), so the resource list must be kept valid up to the point that it is deleted, so every time we delete a resource, we must update the @@ -761,9 +811,13 @@ FreeClientResources(ClientPtr client) for (this = *head; this; this = *head) { RESTYPE rtype = this->type; +#ifdef XSERVER_DTRACE + XSERVER_RESOURCE_FREE(this->id, this->type, + this->value, TypeNameString(this->type)); +#endif *head = this->next; (*DeleteFuncs[rtype & TypeMask])(this->value, this->id); - free(this); + free(this); } } free(clientTable[client->index].resources); @@ -772,26 +826,26 @@ FreeClientResources(ClientPtr client) } void -FreeAllResources() +FreeAllResources(void) { int i; - for (i = currentMaxClients; --i >= 0; ) + for (i = currentMaxClients; --i >= 0; ) { - if (clientTable[i].buckets) + if (clientTable[i].buckets) FreeClientResources(clients[i]); } } Bool -LegalNewID(XID id, register ClientPtr client) +LegalNewID(XID id, ClientPtr client) { #ifdef PANORAMIX XID minid, maxid; - if (!noPanoramiXExtension) { - minid = client->clientAsMask | (client->index ? + if (!noPanoramiXExtension) { + minid = client->clientAsMask | (client->index ? SERVER_BIT : SERVER_MINID); maxid = (clientTable[client->index].fakeID | RESOURCE_ID_MASK) + 1; if ((id >= minid) && (id <= maxid)) @@ -817,13 +871,9 @@ void * SecurityLookupIDByType(ClientPtr client, XID id, RESTYPE rtype, Mask mode) { int cid; - register ResourcePtr res; + ResourcePtr res; void * retval = NULL; - assert(client == NullClient || - (client->index <= currentMaxClients && clients[client->index] == client)); - assert( (rtype & TypeMask) <= lastResourceType); - if (((cid = CLIENT_ID(id)) < MAXCLIENTS) && clientTable[cid].buckets) { @@ -846,13 +896,9 @@ void * SecurityLookupIDByClass(ClientPtr client, XID id, RESTYPE classes, Mask mode) { int cid; - register ResourcePtr res = NULL; + ResourcePtr res = NULL; void * retval = NULL; - assert(client == NullClient || - (client->index <= currentMaxClients && clients[client->index] == client)); - assert (classes >= lastResourceClass); - if (((cid = CLIENT_ID(id)) < MAXCLIENTS) && clientTable[cid].buckets) { @@ -892,12 +938,12 @@ LookupIDByClass(XID id, RESTYPE classes) /* * LookupIDByType returns the object with the given id and type, else NULL. - */ + */ void * LookupIDByType(XID id, RESTYPE rtype) { int cid; - register ResourcePtr res; + ResourcePtr res; if (((cid = CLIENT_ID(id)) < MAXCLIENTS) && clientTable[cid].buckets) @@ -914,12 +960,12 @@ LookupIDByType(XID id, RESTYPE rtype) /* * LookupIDByClass returns the object with the given id and any one of the * given classes, else NULL. - */ + */ void * LookupIDByClass(XID id, RESTYPE classes) { int cid; - register ResourcePtr res; + ResourcePtr res; if (((cid = CLIENT_ID(id)) < MAXCLIENTS) && clientTable[cid].buckets) diff --git a/nx-X11/programs/Xserver/dix/swaprep.c b/nx-X11/programs/Xserver/dix/swaprep.c index 315e050168..c976dceceb 100644 --- a/nx-X11/programs/Xserver/dix/swaprep.c +++ b/nx-X11/programs/Xserver/dix/swaprep.c @@ -27,13 +27,13 @@ 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, +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 +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. +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 @@ -71,15 +71,15 @@ static void SwapFont(xQueryFontReply *pr, Bool hasGlyphs); * \param size size in bytes */ void -Swap32Write(ClientPtr pClient, int size, register CARD32 *pbuf) +Swap32Write(ClientPtr pClient, int size, CARD32 *pbuf) { - register int i; + int i; size >>= 2; for(i = 0; i < size; i++) /* brackets are mandatory here, because "swapl" macro expands to several statements */ - { + { swapl(&pbuf[i]); } WriteToClient(pClient, size << 2, pbuf); @@ -94,9 +94,9 @@ CopySwap32Write(ClientPtr pClient, int size, CARD32 *pbuf) { int bufsize = size; CARD32 *pbufT; - register CARD32 *from, *to, *fromLast, *toLast; + CARD32 *from, *to, *fromLast, *toLast; CARD32 tmpbuf[1]; - + /* Allocate as big a buffer as we can... */ while (!(pbufT = (CARD32 *) malloc(bufsize))) { @@ -107,7 +107,7 @@ CopySwap32Write(ClientPtr pClient, int size, CARD32 *pbuf) break; } } - + /* convert lengths from # of bytes to # of longs */ size >>= 2; bufsize >>= 2; @@ -142,9 +142,9 @@ CopySwap16Write(ClientPtr pClient, int size, short *pbuf) { int bufsize = size; short *pbufT; - register short *from, *to, *fromLast, *toLast; + short *from, *to, *fromLast, *toLast; short tmpbuf[2]; - + /* Allocate as big a buffer as we can... */ while (!(pbufT = (short *) malloc(bufsize))) { @@ -155,7 +155,7 @@ CopySwap16Write(ClientPtr pClient, int size, short *pbuf) break; } } - + /* convert lengths from # of bytes to # of shorts */ size >>= 1; bufsize >>= 1; @@ -294,7 +294,7 @@ SQueryPointerReply(ClientPtr pClient, int size, xQueryPointerReply *pRep) WriteToClient(pClient, size, pRep); } -void +static void SwapTimecoord(xTimecoord* pCoord) { swapl(&pCoord->time); @@ -528,7 +528,7 @@ SAllocColorPlanesReply(ClientPtr pClient, int size, xAllocColorPlanesReply *pRep WriteToClient(pClient, size, pRep); } -void +static void SwapRGB(xrgb *prgb) { swaps(&prgb->red); @@ -708,7 +708,7 @@ SKeyButtonPtrEvent(xEvent *from, xEvent *to) to->u.keyButtonPointer.eventY); cpswaps(from->u.keyButtonPointer.state, to->u.keyButtonPointer.state); - to->u.keyButtonPointer.sameScreen = + to->u.keyButtonPointer.sameScreen = from->u.keyButtonPointer.sameScreen; } @@ -761,19 +761,19 @@ SGraphicsExposureEvent(xEvent *from, xEvent *to) cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); cpswapl(from->u.graphicsExposure.drawable, to->u.graphicsExposure.drawable); - cpswaps(from->u.graphicsExposure.x, + cpswaps(from->u.graphicsExposure.x, to->u.graphicsExposure.x); - cpswaps(from->u.graphicsExposure.y, + cpswaps(from->u.graphicsExposure.y, to->u.graphicsExposure.y); - cpswaps(from->u.graphicsExposure.width, + cpswaps(from->u.graphicsExposure.width, to->u.graphicsExposure.width); - cpswaps(from->u.graphicsExposure.height, + cpswaps(from->u.graphicsExposure.height, to->u.graphicsExposure.height); cpswaps(from->u.graphicsExposure.minorEvent, to->u.graphicsExposure.minorEvent); cpswaps(from->u.graphicsExposure.count, to->u.graphicsExposure.count); - to->u.graphicsExposure.majorEvent = + to->u.graphicsExposure.majorEvent = from->u.graphicsExposure.majorEvent; } @@ -1026,11 +1026,11 @@ SClientMessageEvent(xEvent *from, xEvent *to) to->u.u.detail = from->u.u.detail; /* actually format */ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); cpswapl(from->u.clientMessage.window, to->u.clientMessage.window); - cpswapl(from->u.clientMessage.u.l.type, + cpswapl(from->u.clientMessage.u.l.type, to->u.clientMessage.u.l.type); switch (from->u.u.detail) { case 8: - memmove(to->u.clientMessage.u.b.bytes, + memmove(to->u.clientMessage.u.b.bytes, from->u.clientMessage.u.b.bytes,20); break; case 16: @@ -1078,6 +1078,58 @@ SKeymapNotifyEvent(xEvent *from, xEvent *to) *to = *from; } +static void +SwapConnSetup(xConnSetup *pConnSetup, xConnSetup *pConnSetupT) +{ + cpswapl(pConnSetup->release, pConnSetupT->release); + cpswapl(pConnSetup->ridBase, pConnSetupT->ridBase); + cpswapl(pConnSetup->ridMask, pConnSetupT->ridMask); + cpswapl(pConnSetup->motionBufferSize, pConnSetupT->motionBufferSize); + cpswaps(pConnSetup->nbytesVendor, pConnSetupT->nbytesVendor); + cpswaps(pConnSetup->maxRequestSize, pConnSetupT->maxRequestSize); + pConnSetupT->minKeyCode = pConnSetup->minKeyCode; + pConnSetupT->maxKeyCode = pConnSetup->maxKeyCode; + pConnSetupT->numRoots = pConnSetup->numRoots; + pConnSetupT->numFormats = pConnSetup->numFormats; + pConnSetupT->imageByteOrder = pConnSetup->imageByteOrder; + pConnSetupT->bitmapBitOrder = pConnSetup->bitmapBitOrder; + pConnSetupT->bitmapScanlineUnit = pConnSetup->bitmapScanlineUnit; + pConnSetupT->bitmapScanlinePad = pConnSetup->bitmapScanlinePad; +} + +static void +SwapWinRoot(xWindowRoot *pRoot, xWindowRoot *pRootT) +{ + cpswapl(pRoot->windowId, pRootT->windowId); + cpswapl(pRoot->defaultColormap, pRootT->defaultColormap); + cpswapl(pRoot->whitePixel, pRootT->whitePixel); + cpswapl(pRoot->blackPixel, pRootT->blackPixel); + cpswapl(pRoot->currentInputMask, pRootT->currentInputMask); + cpswaps(pRoot->pixWidth, pRootT->pixWidth); + cpswaps(pRoot->pixHeight, pRootT->pixHeight); + cpswaps(pRoot->mmWidth, pRootT->mmWidth); + cpswaps(pRoot->mmHeight, pRootT->mmHeight); + cpswaps(pRoot->minInstalledMaps, pRootT->minInstalledMaps); + cpswaps(pRoot->maxInstalledMaps, pRootT->maxInstalledMaps); + cpswapl(pRoot->rootVisualID, pRootT->rootVisualID); + pRootT->backingStore = pRoot->backingStore; + pRootT->saveUnders = pRoot->saveUnders; + pRootT->rootDepth = pRoot->rootDepth; + pRootT->nDepths = pRoot->nDepths; +} + +static void +SwapVisual(xVisualType *pVis, xVisualType *pVisT) +{ + cpswapl(pVis->visualID, pVisT->visualID); + pVisT->class = pVis->class; + pVisT->bitsPerRGB = pVis->bitsPerRGB; + cpswaps(pVis->colormapEntries, pVisT->colormapEntries); + cpswapl(pVis->redMask, pVisT->redMask); + cpswapl(pVis->greenMask, pVisT->greenMask); + cpswapl(pVis->blueMask, pVisT->blueMask); +} + void SwapConnSetupInfo( char *pInfo, @@ -1129,7 +1181,6 @@ SwapConnSetupInfo( } } - void WriteSConnectionInfo(ClientPtr pClient, unsigned long size, char *pInfo) { @@ -1146,58 +1197,6 @@ WriteSConnectionInfo(ClientPtr pClient, unsigned long size, char *pInfo) free(pInfoTBase); } -void -SwapConnSetup(xConnSetup *pConnSetup, xConnSetup *pConnSetupT) -{ - cpswapl(pConnSetup->release, pConnSetupT->release); - cpswapl(pConnSetup->ridBase, pConnSetupT->ridBase); - cpswapl(pConnSetup->ridMask, pConnSetupT->ridMask); - cpswapl(pConnSetup->motionBufferSize, pConnSetupT->motionBufferSize); - cpswaps(pConnSetup->nbytesVendor, pConnSetupT->nbytesVendor); - cpswaps(pConnSetup->maxRequestSize, pConnSetupT->maxRequestSize); - pConnSetupT->minKeyCode = pConnSetup->minKeyCode; - pConnSetupT->maxKeyCode = pConnSetup->maxKeyCode; - pConnSetupT->numRoots = pConnSetup->numRoots; - pConnSetupT->numFormats = pConnSetup->numFormats; - pConnSetupT->imageByteOrder = pConnSetup->imageByteOrder; - pConnSetupT->bitmapBitOrder = pConnSetup->bitmapBitOrder; - pConnSetupT->bitmapScanlineUnit = pConnSetup->bitmapScanlineUnit; - pConnSetupT->bitmapScanlinePad = pConnSetup->bitmapScanlinePad; -} - -void -SwapWinRoot(xWindowRoot *pRoot, xWindowRoot *pRootT) -{ - cpswapl(pRoot->windowId, pRootT->windowId); - cpswapl(pRoot->defaultColormap, pRootT->defaultColormap); - cpswapl(pRoot->whitePixel, pRootT->whitePixel); - cpswapl(pRoot->blackPixel, pRootT->blackPixel); - cpswapl(pRoot->currentInputMask, pRootT->currentInputMask); - cpswaps(pRoot->pixWidth, pRootT->pixWidth); - cpswaps(pRoot->pixHeight, pRootT->pixHeight); - cpswaps(pRoot->mmWidth, pRootT->mmWidth); - cpswaps(pRoot->mmHeight, pRootT->mmHeight); - cpswaps(pRoot->minInstalledMaps, pRootT->minInstalledMaps); - cpswaps(pRoot->maxInstalledMaps, pRootT->maxInstalledMaps); - cpswapl(pRoot->rootVisualID, pRootT->rootVisualID); - pRootT->backingStore = pRoot->backingStore; - pRootT->saveUnders = pRoot->saveUnders; - pRootT->rootDepth = pRoot->rootDepth; - pRootT->nDepths = pRoot->nDepths; -} - -void -SwapVisual(xVisualType *pVis, xVisualType *pVisT) -{ - cpswapl(pVis->visualID, pVisT->visualID); - pVisT->class = pVis->class; - pVisT->bitsPerRGB = pVis->bitsPerRGB; - cpswaps(pVis->colormapEntries, pVisT->colormapEntries); - cpswapl(pVis->redMask, pVisT->redMask); - cpswapl(pVis->greenMask, pVisT->greenMask); - cpswapl(pVis->blueMask, pVisT->blueMask); -} - void SwapConnSetupPrefix(xConnSetupPrefix *pcspFrom, xConnSetupPrefix *pcspTo) { diff --git a/nx-X11/programs/Xserver/dix/swapreq.c b/nx-X11/programs/Xserver/dix/swapreq.c index c88a48b14f..c8044f4990 100644 --- a/nx-X11/programs/Xserver/dix/swapreq.c +++ b/nx-X11/programs/Xserver/dix/swapreq.c @@ -27,13 +27,13 @@ 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, +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 +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. +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 @@ -62,7 +62,7 @@ SOFTWARE. /* Byte swap a list of longs */ void -SwapLongs (register CARD32 *list, register unsigned long count) +SwapLongs (CARD32 *list, unsigned long count) { while (count >= 8) { swapl(list+0); @@ -86,7 +86,7 @@ SwapLongs (register CARD32 *list, register unsigned long count) /* Byte swap a list of shorts */ void -SwapShorts (register short *list, register unsigned long count) +SwapShorts (short *list, unsigned long count) { while (count >= 16) { swaps(list+0); @@ -119,7 +119,7 @@ SwapShorts (register short *list, register unsigned long count) /* The following is used for all requests that have no fields to be swapped (except "length") */ int -SProcSimpleReq(register ClientPtr client) +SProcSimpleReq(ClientPtr client) { REQUEST(xReq); swaps(&stuff->length); @@ -130,7 +130,7 @@ SProcSimpleReq(register ClientPtr client) only a single 32-bit field to be swapped, coming right after the "length" field */ int -SProcResourceReq(register ClientPtr client) +SProcResourceReq(ClientPtr client) { REQUEST(xResourceReq); swaps(&stuff->length); @@ -140,7 +140,7 @@ SProcResourceReq(register ClientPtr client) } int -SProcCreateWindow(register ClientPtr client) +SProcCreateWindow(ClientPtr client) { REQUEST(xCreateWindowReq); swaps(&stuff->length); @@ -160,7 +160,7 @@ SProcCreateWindow(register ClientPtr client) } int -SProcChangeWindowAttributes(register ClientPtr client) +SProcChangeWindowAttributes(ClientPtr client) { REQUEST(xChangeWindowAttributesReq); swaps(&stuff->length); @@ -172,7 +172,7 @@ SProcChangeWindowAttributes(register ClientPtr client) } int -SProcReparentWindow(register ClientPtr client) +SProcReparentWindow(ClientPtr client) { REQUEST(xReparentWindowReq); swaps(&stuff->length); @@ -185,7 +185,7 @@ SProcReparentWindow(register ClientPtr client) } int -SProcConfigureWindow(register ClientPtr client) +SProcConfigureWindow(ClientPtr client) { REQUEST(xConfigureWindowReq); swaps(&stuff->length); @@ -199,7 +199,7 @@ SProcConfigureWindow(register ClientPtr client) int -SProcInternAtom(register ClientPtr client) +SProcInternAtom(ClientPtr client) { REQUEST(xInternAtomReq); swaps(&stuff->length); @@ -209,7 +209,7 @@ SProcInternAtom(register ClientPtr client) } int -SProcChangeProperty(register ClientPtr client) +SProcChangeProperty(ClientPtr client) { REQUEST(xChangePropertyReq); swaps(&stuff->length); @@ -231,8 +231,8 @@ SProcChangeProperty(register ClientPtr client) return((* ProcVector[X_ChangeProperty])(client)); } -int -SProcDeleteProperty(register ClientPtr client) +int +SProcDeleteProperty(ClientPtr client) { REQUEST(xDeletePropertyReq); swaps(&stuff->length); @@ -240,11 +240,11 @@ SProcDeleteProperty(register ClientPtr client) swapl(&stuff->window); swapl(&stuff->property); return((* ProcVector[X_DeleteProperty])(client)); - + } -int -SProcGetProperty(register ClientPtr client) +int +SProcGetProperty(ClientPtr client) { REQUEST(xGetPropertyReq); swaps(&stuff->length); @@ -258,7 +258,7 @@ SProcGetProperty(register ClientPtr client) } int -SProcSetSelectionOwner(register ClientPtr client) +SProcSetSelectionOwner(ClientPtr client) { REQUEST(xSetSelectionOwnerReq); swaps(&stuff->length); @@ -270,7 +270,7 @@ SProcSetSelectionOwner(register ClientPtr client) } int -SProcConvertSelection(register ClientPtr client) +SProcConvertSelection(ClientPtr client) { REQUEST(xConvertSelectionReq); swaps(&stuff->length); @@ -284,7 +284,7 @@ SProcConvertSelection(register ClientPtr client) } int -SProcSendEvent(register ClientPtr client) +SProcSendEvent(ClientPtr client) { xEvent eventT; EventSwapPtr proc; @@ -305,7 +305,7 @@ SProcSendEvent(register ClientPtr client) } int -SProcGrabPointer(register ClientPtr client) +SProcGrabPointer(ClientPtr client) { REQUEST(xGrabPointerReq); swaps(&stuff->length); @@ -319,7 +319,7 @@ SProcGrabPointer(register ClientPtr client) } int -SProcGrabButton(register ClientPtr client) +SProcGrabButton(ClientPtr client) { REQUEST(xGrabButtonReq); swaps(&stuff->length); @@ -333,7 +333,7 @@ SProcGrabButton(register ClientPtr client) } int -SProcUngrabButton(register ClientPtr client) +SProcUngrabButton(ClientPtr client) { REQUEST(xUngrabButtonReq); swaps(&stuff->length); @@ -344,7 +344,7 @@ SProcUngrabButton(register ClientPtr client) } int -SProcChangeActivePointerGrab(register ClientPtr client) +SProcChangeActivePointerGrab(ClientPtr client) { REQUEST(xChangeActivePointerGrabReq); swaps(&stuff->length); @@ -356,7 +356,7 @@ SProcChangeActivePointerGrab(register ClientPtr client) } int -SProcGrabKeyboard(register ClientPtr client) +SProcGrabKeyboard(ClientPtr client) { REQUEST(xGrabKeyboardReq); swaps(&stuff->length); @@ -367,7 +367,7 @@ SProcGrabKeyboard(register ClientPtr client) } int -SProcGrabKey(register ClientPtr client) +SProcGrabKey(ClientPtr client) { REQUEST(xGrabKeyReq); swaps(&stuff->length); @@ -378,7 +378,7 @@ SProcGrabKey(register ClientPtr client) } int -SProcUngrabKey(register ClientPtr client) +SProcUngrabKey(ClientPtr client) { REQUEST(xUngrabKeyReq); swaps(&stuff->length); @@ -389,7 +389,7 @@ SProcUngrabKey(register ClientPtr client) } int -SProcGetMotionEvents(register ClientPtr client) +SProcGetMotionEvents(ClientPtr client) { REQUEST(xGetMotionEventsReq); swaps(&stuff->length); @@ -401,7 +401,7 @@ SProcGetMotionEvents(register ClientPtr client) } int -SProcTranslateCoords(register ClientPtr client) +SProcTranslateCoords(ClientPtr client) { REQUEST(xTranslateCoordsReq); swaps(&stuff->length); @@ -414,7 +414,7 @@ SProcTranslateCoords(register ClientPtr client) } int -SProcWarpPointer(register ClientPtr client) +SProcWarpPointer(ClientPtr client) { REQUEST(xWarpPointerReq); swaps(&stuff->length); @@ -431,7 +431,7 @@ SProcWarpPointer(register ClientPtr client) } int -SProcSetInputFocus(register ClientPtr client) +SProcSetInputFocus(ClientPtr client) { REQUEST(xSetInputFocusReq); swaps(&stuff->length); @@ -442,7 +442,7 @@ SProcSetInputFocus(register ClientPtr client) } int -SProcOpenFont(register ClientPtr client) +SProcOpenFont(ClientPtr client) { REQUEST(xOpenFontReq); swaps(&stuff->length); @@ -453,7 +453,7 @@ SProcOpenFont(register ClientPtr client) } int -SProcListFonts(register ClientPtr client) +SProcListFonts(ClientPtr client) { REQUEST(xListFontsReq); swaps(&stuff->length); @@ -464,7 +464,7 @@ SProcListFonts(register ClientPtr client) } int -SProcListFontsWithInfo(register ClientPtr client) +SProcListFontsWithInfo(ClientPtr client) { REQUEST(xListFontsWithInfoReq); swaps(&stuff->length); @@ -475,7 +475,7 @@ SProcListFontsWithInfo(register ClientPtr client) } int -SProcSetFontPath(register ClientPtr client) +SProcSetFontPath(ClientPtr client) { REQUEST(xSetFontPathReq); swaps(&stuff->length); @@ -485,7 +485,7 @@ SProcSetFontPath(register ClientPtr client) } int -SProcCreatePixmap(register ClientPtr client) +SProcCreatePixmap(ClientPtr client) { REQUEST(xCreatePixmapReq); @@ -499,7 +499,7 @@ SProcCreatePixmap(register ClientPtr client) } int -SProcCreateGC(register ClientPtr client) +SProcCreateGC(ClientPtr client) { REQUEST(xCreateGCReq); swaps(&stuff->length); @@ -512,7 +512,7 @@ SProcCreateGC(register ClientPtr client) } int -SProcChangeGC(register ClientPtr client) +SProcChangeGC(ClientPtr client) { REQUEST(xChangeGCReq); swaps(&stuff->length); @@ -524,7 +524,7 @@ SProcChangeGC(register ClientPtr client) } int -SProcCopyGC(register ClientPtr client) +SProcCopyGC(ClientPtr client) { REQUEST(xCopyGCReq); swaps(&stuff->length); @@ -536,7 +536,7 @@ SProcCopyGC(register ClientPtr client) } int -SProcSetDashes(register ClientPtr client) +SProcSetDashes(ClientPtr client) { REQUEST(xSetDashesReq); swaps(&stuff->length); @@ -549,7 +549,7 @@ SProcSetDashes(register ClientPtr client) } int -SProcSetClipRectangles(register ClientPtr client) +SProcSetClipRectangles(ClientPtr client) { REQUEST(xSetClipRectanglesReq); swaps(&stuff->length); @@ -562,7 +562,7 @@ SProcSetClipRectangles(register ClientPtr client) } int -SProcClearToBackground(register ClientPtr client) +SProcClearToBackground(ClientPtr client) { REQUEST(xClearAreaReq); swaps(&stuff->length); @@ -576,7 +576,7 @@ SProcClearToBackground(register ClientPtr client) } int -SProcCopyArea(register ClientPtr client) +SProcCopyArea(ClientPtr client) { REQUEST(xCopyAreaReq); swaps(&stuff->length); @@ -594,7 +594,7 @@ SProcCopyArea(register ClientPtr client) } int -SProcCopyPlane(register ClientPtr client) +SProcCopyPlane(ClientPtr client) { REQUEST(xCopyPlaneReq); swaps(&stuff->length); @@ -615,7 +615,7 @@ SProcCopyPlane(register ClientPtr client) /* The following routine is used for all Poly drawing requests (except FillPoly, which uses a different request format) */ int -SProcPoly(register ClientPtr client) +SProcPoly(ClientPtr client) { REQUEST(xPolyPointReq); swaps(&stuff->length); @@ -630,7 +630,7 @@ SProcPoly(register ClientPtr client) is longer than xPolyPointReq, and we don't want to swap the difference as shorts! */ int -SProcFillPoly(register ClientPtr client) +SProcFillPoly(ClientPtr client) { REQUEST(xFillPolyReq); swaps(&stuff->length); @@ -642,7 +642,7 @@ SProcFillPoly(register ClientPtr client) } int -SProcPutImage(register ClientPtr client) +SProcPutImage(ClientPtr client) { REQUEST(xPutImageReq); swaps(&stuff->length); @@ -659,7 +659,7 @@ SProcPutImage(register ClientPtr client) } int -SProcGetImage(register ClientPtr client) +SProcGetImage(ClientPtr client) { REQUEST(xGetImageReq); swaps(&stuff->length); @@ -676,7 +676,7 @@ SProcGetImage(register ClientPtr client) /* ProcPolyText used for both PolyText8 and PolyText16 */ int -SProcPolyText(register ClientPtr client) +SProcPolyText(ClientPtr client) { REQUEST(xPolyTextReq); swaps(&stuff->length); @@ -691,7 +691,7 @@ SProcPolyText(register ClientPtr client) /* ProcImageText used for both ImageText8 and ImageText16 */ int -SProcImageText(register ClientPtr client) +SProcImageText(ClientPtr client) { REQUEST(xImageTextReq); swaps(&stuff->length); @@ -704,7 +704,7 @@ SProcImageText(register ClientPtr client) } int -SProcCreateColormap(register ClientPtr client) +SProcCreateColormap(ClientPtr client) { REQUEST(xCreateColormapReq); swaps(&stuff->length); @@ -717,7 +717,7 @@ SProcCreateColormap(register ClientPtr client) int -SProcCopyColormapAndFree(register ClientPtr client) +SProcCopyColormapAndFree(ClientPtr client) { REQUEST(xCopyColormapAndFreeReq); swaps(&stuff->length); @@ -729,7 +729,7 @@ SProcCopyColormapAndFree(register ClientPtr client) } int -SProcAllocColor(register ClientPtr client) +SProcAllocColor(ClientPtr client) { REQUEST(xAllocColorReq); swaps(&stuff->length); @@ -742,7 +742,7 @@ SProcAllocColor(register ClientPtr client) } int -SProcAllocNamedColor(register ClientPtr client) +SProcAllocNamedColor(ClientPtr client) { REQUEST(xAllocNamedColorReq); swaps(&stuff->length); @@ -753,7 +753,7 @@ SProcAllocNamedColor(register ClientPtr client) } int -SProcAllocColorCells(register ClientPtr client) +SProcAllocColorCells(ClientPtr client) { REQUEST(xAllocColorCellsReq); swaps(&stuff->length); @@ -765,7 +765,7 @@ SProcAllocColorCells(register ClientPtr client) } int -SProcAllocColorPlanes(register ClientPtr client) +SProcAllocColorPlanes(ClientPtr client) { REQUEST(xAllocColorPlanesReq); swaps(&stuff->length); @@ -779,7 +779,7 @@ SProcAllocColorPlanes(register ClientPtr client) } int -SProcFreeColors(register ClientPtr client) +SProcFreeColors(ClientPtr client) { REQUEST(xFreeColorsReq); swaps(&stuff->length); @@ -801,7 +801,7 @@ SwapColorItem(xColorItem *pItem) } int -SProcStoreColors(register ClientPtr client) +SProcStoreColors(ClientPtr client) { long count; xColorItem *pItem; @@ -817,7 +817,7 @@ SProcStoreColors(register ClientPtr client) } int -SProcStoreNamedColor (register ClientPtr client) +SProcStoreNamedColor (ClientPtr client) { REQUEST(xStoreNamedColorReq); swaps(&stuff->length); @@ -829,7 +829,7 @@ SProcStoreNamedColor (register ClientPtr client) } int -SProcQueryColors (register ClientPtr client) +SProcQueryColors (ClientPtr client) { REQUEST(xQueryColorsReq); swaps(&stuff->length); @@ -837,10 +837,10 @@ SProcQueryColors (register ClientPtr client) swapl(&stuff->cmap); SwapRestL(stuff); return((* ProcVector[X_QueryColors])(client)); -} +} int -SProcLookupColor (register ClientPtr client) +SProcLookupColor (ClientPtr client) { REQUEST(xLookupColorReq); swaps(&stuff->length); @@ -851,7 +851,7 @@ SProcLookupColor (register ClientPtr client) } int -SProcCreateCursor (register ClientPtr client) +SProcCreateCursor (ClientPtr client) { REQUEST(xCreateCursorReq); swaps(&stuff->length); @@ -871,7 +871,7 @@ SProcCreateCursor (register ClientPtr client) } int -SProcCreateGlyphCursor (register ClientPtr client) +SProcCreateGlyphCursor (ClientPtr client) { REQUEST(xCreateGlyphCursorReq); swaps(&stuff->length); @@ -892,7 +892,7 @@ SProcCreateGlyphCursor (register ClientPtr client) int -SProcRecolorCursor (register ClientPtr client) +SProcRecolorCursor (ClientPtr client) { REQUEST(xRecolorCursorReq); swaps(&stuff->length); @@ -908,7 +908,7 @@ SProcRecolorCursor (register ClientPtr client) } int -SProcQueryBestSize (register ClientPtr client) +SProcQueryBestSize (ClientPtr client) { REQUEST(xQueryBestSizeReq); swaps(&stuff->length); @@ -921,7 +921,7 @@ SProcQueryBestSize (register ClientPtr client) } int -SProcQueryExtension (register ClientPtr client) +SProcQueryExtension (ClientPtr client) { REQUEST(xQueryExtensionReq); swaps(&stuff->length); @@ -931,7 +931,7 @@ SProcQueryExtension (register ClientPtr client) } int -SProcChangeKeyboardMapping (register ClientPtr client) +SProcChangeKeyboardMapping (ClientPtr client) { REQUEST(xChangeKeyboardMappingReq); swaps(&stuff->length); @@ -942,7 +942,7 @@ SProcChangeKeyboardMapping (register ClientPtr client) int -SProcChangeKeyboardControl (register ClientPtr client) +SProcChangeKeyboardControl (ClientPtr client) { REQUEST(xChangeKeyboardControlReq); swaps(&stuff->length); @@ -953,7 +953,7 @@ SProcChangeKeyboardControl (register ClientPtr client) } int -SProcChangePointerControl (register ClientPtr client) +SProcChangePointerControl (ClientPtr client) { REQUEST(xChangePointerControlReq); swaps(&stuff->length); @@ -966,7 +966,7 @@ SProcChangePointerControl (register ClientPtr client) int -SProcSetScreenSaver (register ClientPtr client) +SProcSetScreenSaver (ClientPtr client) { REQUEST(xSetScreenSaverReq); swaps(&stuff->length); @@ -977,7 +977,7 @@ SProcSetScreenSaver (register ClientPtr client) } int -SProcChangeHosts (register ClientPtr client) +SProcChangeHosts (ClientPtr client) { REQUEST(xChangeHostsReq); swaps(&stuff->length); @@ -987,7 +987,7 @@ SProcChangeHosts (register ClientPtr client) } -int SProcRotateProperties (register ClientPtr client) +int SProcRotateProperties (ClientPtr client) { REQUEST(xRotatePropertiesReq); swaps(&stuff->length); @@ -1000,7 +1000,7 @@ int SProcRotateProperties (register ClientPtr client) } int -SProcNoOperation(register ClientPtr client) +SProcNoOperation(ClientPtr client) { REQUEST(xReq); swaps(&stuff->length); diff --git a/nx-X11/programs/Xserver/dix/tables.c b/nx-X11/programs/Xserver/dix/tables.c index 624522daf9..f737aa64d6 100644 --- a/nx-X11/programs/Xserver/dix/tables.c +++ b/nx-X11/programs/Xserver/dix/tables.c @@ -27,13 +27,13 @@ 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, +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 +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. +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 @@ -199,7 +199,7 @@ int (* ProcVector[256]) ( 0, 0, /* 125 */ 0, - ProcNoOperation + ProcNoOperation }; int (* SwappedProcVector[256]) ( diff --git a/nx-X11/programs/Xserver/dix/window.c b/nx-X11/programs/Xserver/dix/window.c index d294e139d6..d743edde83 100644 --- a/nx-X11/programs/Xserver/dix/window.c +++ b/nx-X11/programs/Xserver/dix/window.c @@ -13,8 +13,8 @@ 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 -RED HAT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +RED HAT 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. @@ -51,13 +51,13 @@ 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, +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 +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. +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 @@ -129,7 +129,7 @@ Equipment Corporation. #endif /****** - * Window stuff for server + * Window stuff for server * * CreateRootWindow, CreateWindow, ChangeWindowAttributes, * GetWindowAttributes, DeleteWindow, DestroySubWindows, @@ -185,7 +185,7 @@ int deltaSaveUndersViewable = 0; * For debugging only ******/ -int +static void PrintChildren(WindowPtr p1, int indent) { WindowPtr p2; @@ -195,14 +195,15 @@ PrintChildren(WindowPtr p1, int indent) { p2 = p1->firstChild; for (i=0; idrawable.id); + ErrorF( "%lx\n", p1->drawable.id); RegionPrint(&p1->clipList); PrintChildren(p2, indent+4); p1 = p1->nextSib; } } -PrintWindowTree() +static void +PrintWindowTree(void) { int i; WindowPtr pWin, p1; @@ -219,10 +220,10 @@ PrintWindowTree() #endif int -TraverseTree(register WindowPtr pWin, VisitWindowProcPtr func, void * data) +TraverseTree(WindowPtr pWin, VisitWindowProcPtr func, void * data) { - register int result; - register WindowPtr pChild; + int result; + WindowPtr pChild; if (!(pChild = pWin)) return(WT_NOMATCH); @@ -268,7 +269,7 @@ Bool enableBackingStore = FALSE; Bool disableSaveUnders = FALSE; static void -SetWindowToDefaults(register WindowPtr pWin) +SetWindowToDefaults(WindowPtr pWin) { pWin->prevSib = NullWindow; pWin->firstChild = NullWindow; @@ -301,7 +302,7 @@ SetWindowToDefaults(register WindowPtr pWin) pWin->dstBuffer = DBE_FRONT_BUFFER; #endif #ifdef COMPOSITE - pWin->redirectDraw = 0; + pWin->redirectDraw = RedirectDrawNone; #endif } @@ -312,8 +313,8 @@ MakeRootTile(WindowPtr pWin) GCPtr pGC; unsigned char back[128]; int len = BitmapBytePad(sizeof(long)); - register unsigned char *from, *to; - register int i, j; + unsigned char *from, *to; + int i, j; pWin->background.pixmap = (*pScreen->CreatePixmap)(pScreen, 4, 4, pScreen->rootDepth, 0); @@ -352,11 +353,11 @@ WindowPtr AllocateWindow(ScreenPtr pScreen) { WindowPtr pWin; - register char *ptr; - register DevUnion *ppriv; - register unsigned *sizes; - register unsigned size; - register int i; + char *ptr; + DevUnion *ppriv; + unsigned *sizes; + unsigned size; + int i; pWin = (WindowPtr)malloc(pScreen->totalWindowSize); if (pWin) @@ -540,10 +541,10 @@ InitRootWindow(WindowPtr pWin) * window from which the region came. */ -void -ClippedRegionFromBox(register WindowPtr pWin, RegionPtr Rgn, - register int x, register int y, - register int w, register int h) +static void +ClippedRegionFromBox(WindowPtr pWin, RegionPtr Rgn, + int x, int y, + int w, int h) { BoxRec box; @@ -576,7 +577,7 @@ RegisterRealChildHeadProc (RealChildHeadProc proc) } WindowPtr -RealChildHead(register WindowPtr pWin) +RealChildHead(WindowPtr pWin) { if (realChildHeadProc) { return realChildHeadProc (pWin); @@ -592,23 +593,23 @@ RealChildHead(register WindowPtr pWin) /***** * CreateWindow - * Makes a window in response to client request + * Makes a window in response to client request *****/ WindowPtr -CreateWindow(Window wid, register WindowPtr pParent, int x, int y, unsigned w, - unsigned h, unsigned bw, unsigned class, register Mask vmask, XID *vlist, +CreateWindow(Window wid, WindowPtr pParent, int x, int y, unsigned w, + unsigned h, unsigned bw, unsigned class, Mask vmask, XID *vlist, int depth, ClientPtr client, VisualID visual, int *error) { - register WindowPtr pWin; + WindowPtr pWin; WindowPtr pHead; - register ScreenPtr pScreen; + ScreenPtr pScreen; xEvent event; int idepth, ivisual; Bool fOK; DepthPtr pDepth; PixmapFormatRec *format; - register WindowOptPtr ancwopt; + WindowOptPtr ancwopt; if (class == CopyFromParent) class = pParent->drawable.class; @@ -826,9 +827,29 @@ CreateWindow(Window wid, register WindowPtr pParent, int x, int y, unsigned w, } static void -FreeWindowResources(register WindowPtr pWin) +DisposeWindowOptional (WindowPtr pWin) { - register ScreenPtr pScreen = pWin->drawable.pScreen; + if (!pWin->optional) + return; + /* + * everything is peachy. Delete the optional record + * and clean up + */ + if (pWin->optional->cursor) + { + FreeCursor (pWin->optional->cursor, (Cursor)0); + pWin->cursorIsNone = FALSE; + } + else + pWin->cursorIsNone = TRUE; + free (pWin->optional); + pWin->optional = NULL; +} + +static void +FreeWindowResources(WindowPtr pWin) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; DeleteWindowFromAnySaveSet(pWin); DeleteWindowFromAnySelections(pWin); @@ -859,7 +880,7 @@ FreeWindowResources(register WindowPtr pWin) static void CrushTree(WindowPtr pWin) { - register WindowPtr pChild, pSib, pParent; + WindowPtr pChild, pSib, pParent; UnrealizeWindowProcPtr UnrealizeWindow; xEvent event; @@ -908,7 +929,6 @@ CrushTree(WindowPtr pWin) } } - /***** * DeleteWindow * Deletes child of window then window itself @@ -918,8 +938,8 @@ CrushTree(WindowPtr pWin) int DeleteWindow(void * value, XID wid) { - register WindowPtr pParent; - register WindowPtr pWin = (WindowPtr)value; + WindowPtr pParent; + WindowPtr pWin = (WindowPtr)value; xEvent event; UnmapWindow(pWin, FALSE); @@ -952,7 +972,7 @@ DeleteWindow(void * value, XID wid) } void -DestroySubwindows(register WindowPtr pWin, ClientPtr client) +DestroySubwindows(WindowPtr pWin, ClientPtr client) { /* XXX * The protocol is quite clear that each window should be @@ -972,17 +992,17 @@ DestroySubwindows(register WindowPtr pWin, ClientPtr client) /***** * ChangeWindowAttributes - * + * * The value-mask specifies which attributes are to be changed; the * value-list contains one value for each one bit in the mask, from least - * to most significant bit in the mask. + * to most significant bit in the mask. *****/ - + int -ChangeWindowAttributes(register WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client) +ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client) { - register Mask index2; - register XID *pVlist; + Mask index2; + XID *pVlist; PixmapPtr pPixmap; Pixmap pixID; CursorPtr pCursor, pOldCursor; @@ -992,9 +1012,9 @@ ChangeWindowAttributes(register WindowPtr pWin, Mask vmask, XID *vlist, ClientPt ColormapPtr pCmap; xEvent xE; int result; - register ScreenPtr pScreen; + ScreenPtr pScreen; Mask vmaskCopy = 0; - register Mask tmask; + Mask tmask; unsigned int val; int error; Bool checkOptional = FALSE; @@ -1036,7 +1056,7 @@ ChangeWindowAttributes(register WindowPtr pWin, Mask vmask, XID *vlist, ClientPt } else { /* didn't change the background to None, so don't tell ddx */ - index2 = 0; + index2 = 0; } #endif } @@ -1250,11 +1270,11 @@ ChangeWindowAttributes(register WindowPtr pWin, Mask vmask, XID *vlist, ClientPt if ((*pScreen->ChangeSaveUnder)(pWin, pWin->nextSib)) (*pScreen->PostChangeSaveUnder)(pWin, pWin->nextSib); - } + } } else { - /* If we're changing the saveUnder attribute of the root + /* If we're changing the saveUnder attribute of the root * window, all we do is set pWin->saveUnder so that * GetWindowAttributes returns the right value. We don't * do the "normal" save-under processing (as above). @@ -1497,8 +1517,8 @@ ChangeWindowAttributes(register WindowPtr pWin, Mask vmask, XID *vlist, ClientPt /* We SHOULD check for an error value here XXX */ (*pScreen->ChangeWindowAttributes)(pWin, vmaskCopy); - /* - If the border contents have changed, redraw the border. + /* + If the border contents have changed, redraw the border. Note that this has to be done AFTER pScreen->ChangeWindowAttributes for the tile to be rotated, and the correct function selected. */ @@ -1522,7 +1542,7 @@ ChangeWindowAttributes(register WindowPtr pWin, Mask vmask, XID *vlist, ClientPt *****/ void -GetWindowAttributes(register WindowPtr pWin, ClientPtr client, xGetWindowAttributesReply *wa) +GetWindowAttributes(WindowPtr pWin, ClientPtr client, xGetWindowAttributesReply *wa) { wa->type = X_Reply; wa->bitGravity = pWin->bitGravity; @@ -1558,9 +1578,9 @@ GetWindowAttributes(register WindowPtr pWin, ClientPtr client, xGetWindowAttribu WindowPtr -MoveWindowInStack(register WindowPtr pWin, register WindowPtr pNextSib) +MoveWindowInStack(WindowPtr pWin, WindowPtr pNextSib) { - register WindowPtr pParent = pWin->parent; + WindowPtr pParent = pWin->parent; WindowPtr pFirstChange = pWin; /* highest window where list changes */ if (pWin->nextSib != pNextSib) @@ -1642,7 +1662,7 @@ MoveWindowInStack(register WindowPtr pWin, register WindowPtr pNextSib) } RegionPtr -CreateUnclippedWinSize (register WindowPtr pWin) +CreateUnclippedWinSize (WindowPtr pWin) { RegionPtr pRgn; BoxRec box; @@ -1667,13 +1687,17 @@ CreateUnclippedWinSize (register WindowPtr pWin) } void -SetWinSize (register WindowPtr pWin) +SetWinSize (WindowPtr pWin) { #ifdef COMPOSITE - if (pWin->redirectDraw) + if (pWin->redirectDraw != RedirectDrawNone) { BoxRec box; + /* + * Redirected clients get clip list equal to their + * own geometry, not clipped to their parent + */ box.x1 = pWin->drawable.x; box.y1 = pWin->drawable.y; box.x2 = pWin->drawable.x + pWin->drawable.width; @@ -1703,17 +1727,21 @@ SetWinSize (register WindowPtr pWin) } void -SetBorderSize (register WindowPtr pWin) +SetBorderSize (WindowPtr pWin) { int bw; if (HasBorder (pWin)) { bw = wBorderWidth (pWin); #ifdef COMPOSITE - if (pWin->redirectDraw) + if (pWin->redirectDraw != RedirectDrawNone) { BoxRec box; + /* + * Redirected clients get clip list equal to their + * own geometry, not clipped to their parent + */ box.x1 = pWin->drawable.x - bw; box.y1 = pWin->drawable.y - bw; box.x2 = pWin->drawable.x + pWin->drawable.width + bw; @@ -1752,9 +1780,9 @@ SetBorderSize (register WindowPtr pWin) */ void -GravityTranslate (register int x, register int y, int oldx, int oldy, +GravityTranslate (int x, int y, int oldx, int oldy, int dw, int dh, unsigned gravity, - register int *destx, register int *desty) + int *destx, int *desty) { switch (gravity) { case NorthGravity: @@ -1803,10 +1831,10 @@ 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) +ResizeChildrenWinSize(WindowPtr pWin, int dx, int dy, int dw, int dh) { - register ScreenPtr pScreen; - register WindowPtr pSib, pChild; + ScreenPtr pScreen; + WindowPtr pSib, pChild; Bool resized = (dw || dh); pScreen = pWin->drawable.pScreen; @@ -1894,15 +1922,15 @@ ResizeChildrenWinSize(register WindowPtr pWin, int dx, int dy, int dw, int dh) /* * IsSiblingAboveMe - * returns Above if pSib above pMe in stack or Below otherwise + * returns Above if pSib above pMe in stack or Below otherwise */ static int IsSiblingAboveMe( - register WindowPtr pMe, - register WindowPtr pSib) + WindowPtr pMe, + WindowPtr pSib) { - register WindowPtr pWin; + WindowPtr pWin; pWin = pMe->parent->firstChild; while (pWin) @@ -1918,8 +1946,8 @@ IsSiblingAboveMe( static BoxPtr WindowExtents( - register WindowPtr pWin, - register BoxPtr pBox) + WindowPtr pWin, + BoxPtr pBox) { pBox->x1 = pWin->drawable.x - wBorderWidth (pWin); pBox->y1 = pWin->drawable.y - wBorderWidth (pWin); @@ -1935,7 +1963,7 @@ WindowExtents( static RegionPtr MakeBoundingRegion ( - register WindowPtr pWin, + WindowPtr pWin, BoxPtr pBox) { RegionPtr pRgn; @@ -1977,11 +2005,11 @@ static Bool AnyWindowOverlapsMe( WindowPtr pWin, WindowPtr pHead, - register BoxPtr box) + BoxPtr box) { - register WindowPtr pSib; + WindowPtr pSib; BoxRec sboxrec; - register BoxPtr sbox; + BoxPtr sbox; for (pSib = pWin->prevSib; pSib != pHead; pSib = pSib->prevSib) { @@ -2002,11 +2030,11 @@ AnyWindowOverlapsMe( static Bool IOverlapAnyWindow( WindowPtr pWin, - register BoxPtr box) + BoxPtr box) { - register WindowPtr pSib; + WindowPtr pSib; BoxRec sboxrec; - register BoxPtr sbox; + BoxPtr sbox; for (pSib = pWin->nextSib; pSib; pSib = pSib->nextSib) { @@ -2025,7 +2053,7 @@ IOverlapAnyWindow( } /* - * WhereDoIGoInTheStack() + * WhereDoIGoInTheStack() * Given pWin and pSib and the relationshipe smode, return * the window that pWin should go ABOVE. * If a pSib is specified: @@ -2033,7 +2061,7 @@ IOverlapAnyWindow( * Below: pWin is placed just below pSib * TopIf: if pSib occludes pWin, then pWin is placed * at the top of the stack - * BottomIf: if pWin occludes pSib, then pWin is + * BottomIf: if pWin occludes pSib, then pWin is * placed at the bottom of the stack * Opposite: if pSib occludes pWin, then pWin is placed at the * top of the stack, else if pWin occludes pSib, then @@ -2054,8 +2082,8 @@ IOverlapAnyWindow( static WindowPtr WhereDoIGoInTheStack( - register WindowPtr pWin, - register WindowPtr pSib, + WindowPtr pWin, + WindowPtr pSib, short x, short y, unsigned short w, @@ -2158,8 +2186,8 @@ WhereDoIGoInTheStack( static void ReflectStackChange( - register WindowPtr pWin, - register WindowPtr pSib, + WindowPtr pWin, + WindowPtr pSib, VTKind kind) { /* Note that pSib might be NULL */ @@ -2212,17 +2240,17 @@ ReflectStackChange( #ifndef NXAGENT_SERVER int -ConfigureWindow(register WindowPtr pWin, register Mask mask, XID *vlist, ClientPtr client) +ConfigureWindow(WindowPtr pWin, 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; + WindowPtr pSib = NullWindow; + WindowPtr pParent = pWin->parent; Window sibwid = 0; Mask index2, tmask; - register XID *pVlist; + XID *pVlist; short x, y, beforeX, beforeY; unsigned short w = pWin->drawable.width, h = pWin->drawable.height, @@ -2324,7 +2352,7 @@ ConfigureWindow(register WindowPtr pWin, register Mask mask, XID *vlist, ClientP else pSib = pWin->nextSib; - if ((!pWin->overrideRedirect) && + if ((!pWin->overrideRedirect) && (RedirectSend(pParent) )) { @@ -2473,14 +2501,14 @@ ConfigureWindow(register WindowPtr pWin, register Mask mask, XID *vlist, ClientP * For RaiseLowest, raises the lowest mapped child (if any) that is * obscured by another child to the top of the stack. For LowerHighest, * lowers the highest mapped child (if any) that is obscuring another - * child to the bottom of the stack. Exposure processing is performed + * child to the bottom of the stack. Exposure processing is performed * ******/ int CirculateWindow(WindowPtr pParent, int direction, ClientPtr client) { - register WindowPtr pWin, pHead, pFirst; + WindowPtr pWin, pHead, pFirst; xEvent event; BoxRec box; @@ -2562,14 +2590,14 @@ CompareWIDs( #ifndef NXAGENT_SERVER int -ReparentWindow(register WindowPtr pWin, register WindowPtr pParent, +ReparentWindow(WindowPtr pWin, WindowPtr pParent, int x, int y, ClientPtr client) { WindowPtr pPrev, pPriorParent; Bool WasMapped = (Bool)(pWin->mapped); xEvent event; int bw = wBorderWidth (pWin); - register ScreenPtr pScreen; + ScreenPtr pScreen; pScreen = pWin->drawable.pScreen; if (TraverseTree(pWin, CompareWIDs, (void *)&pParent->drawable.id) == WT_STOPWALKING) @@ -2658,7 +2686,7 @@ ReparentWindow(register WindowPtr pWin, register WindowPtr pParent, static void RealizeTree(WindowPtr pWin) { - register WindowPtr pChild; + WindowPtr pChild; RealizeWindowProcPtr Realize; Realize = pWin->drawable.pScreen->RealizeWindow; @@ -2688,6 +2716,30 @@ RealizeTree(WindowPtr pWin) } } +static WindowPtr windowDisableMapUnmapEvents; + +void +DisableMapUnmapEvents(WindowPtr pWin) +{ + assert (windowDisableMapUnmapEvents == NULL); + + windowDisableMapUnmapEvents = pWin; +} + +void +EnableMapUnmapEvents(WindowPtr pWin) +{ + assert (windowDisableMapUnmapEvents != NULL); + + windowDisableMapUnmapEvents = NULL; +} + +static Bool +MapUnmapEventsEnabled(WindowPtr pWin) +{ + return pWin != windowDisableMapUnmapEvents; +} + /***** * MapWindow * If some other client has selected SubStructureReDirect on the parent @@ -2698,11 +2750,11 @@ RealizeTree(WindowPtr pWin) #ifndef NXAGENT_SERVER int -MapWindow(register WindowPtr pWin, ClientPtr client) +MapWindow(WindowPtr pWin, ClientPtr client) { - register ScreenPtr pScreen; + ScreenPtr pScreen; - register WindowPtr pParent; + WindowPtr pParent; #ifdef DO_SAVE_UNDERS Bool dosave = FALSE; #endif @@ -2727,7 +2779,7 @@ MapWindow(register WindowPtr pWin, ClientPtr client) xEvent event; Bool anyMarked; - if ((!pWin->overrideRedirect) && + if ((!pWin->overrideRedirect) && (RedirectSend(pParent) )) { @@ -2808,18 +2860,18 @@ MapWindow(register WindowPtr pWin, ClientPtr client) *****/ void -MapSubwindows(register WindowPtr pParent, ClientPtr client) +MapSubwindows(WindowPtr pParent, ClientPtr client) { - register WindowPtr pWin; - WindowPtr pFirstMapped = NullWindow; + WindowPtr pWin; + WindowPtr pFirstMapped = NullWindow; #ifdef DO_SAVE_UNDERS - WindowPtr pFirstSaveUndered = NullWindow; + WindowPtr pFirstSaveUndered = NullWindow; #endif - register ScreenPtr pScreen; - register Mask parentRedirect; - register Mask parentNotify; - xEvent event; - Bool anyMarked; + ScreenPtr pScreen; + Mask parentRedirect; + Mask parentNotify; + xEvent event; + Bool anyMarked; #ifdef DO_SAVE_UNDERS Bool dosave = FALSE; #endif @@ -2839,12 +2891,12 @@ MapSubwindows(register WindowPtr pParent, ClientPtr client) 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) continue; } - + pWin->mapped = TRUE; if (parentNotify || StrSend(pWin)) { @@ -2854,7 +2906,7 @@ MapSubwindows(register WindowPtr pParent, ClientPtr client) event.u.mapNotify.override = pWin->overrideRedirect; DeliverEvents(pWin, &event, 1, NullWindow); } - + if (!pFirstMapped) pFirstMapped = pWin; if (pParent->realized) @@ -2930,7 +2982,7 @@ UnrealizeTree( WindowPtr pWin, Bool fromConfigure) { - register WindowPtr pChild; + WindowPtr pChild; UnrealizeWindowProcPtr Unrealize; MarkUnrealizedWindowProcPtr MarkUnrealizedWindow; @@ -2950,10 +3002,11 @@ UnrealizeTree( XRT_WINDOW); if(win) win->u.win.visibility = VisibilityNotViewable; - } + } #endif (* Unrealize)(pChild); - DeleteWindowFromAnyEvents(pChild, FALSE); + if (MapUnmapEventsEnabled(pWin)) + DeleteWindowFromAnyEvents(pChild, FALSE); if (pChild->viewable) { #ifdef DO_SAVE_UNDERS @@ -2989,9 +3042,9 @@ UnrealizeTree( *****/ int -UnmapWindow(register WindowPtr pWin, Bool fromConfigure) +UnmapWindow(WindowPtr pWin, Bool fromConfigure) { - register WindowPtr pParent; + WindowPtr pParent; xEvent event; Bool wasRealized = (Bool)pWin->realized; Bool wasViewable = (Bool)pWin->viewable; @@ -3049,9 +3102,9 @@ UnmapWindow(register WindowPtr pWin, Bool fromConfigure) *****/ void -UnmapSubwindows(register WindowPtr pWin) +UnmapSubwindows(WindowPtr pWin) { - register WindowPtr pChild, pHead; + WindowPtr pChild, pHead; xEvent event; Bool wasRealized = (Bool)pWin->realized; Bool wasViewable = (Bool)pWin->viewable; @@ -3113,7 +3166,7 @@ UnmapSubwindows(register WindowPtr pWin) /* Windows between pWin and pLayerWin may not have been marked */ ptmp = pWin; - + while (ptmp != pLayerWin->parent) { (*pScreen->MarkWindow)(ptmp); @@ -3140,10 +3193,10 @@ UnmapSubwindows(register WindowPtr pWin) void -HandleSaveSet(register ClientPtr client) +HandleSaveSet(ClientPtr client) { - register WindowPtr pParent, pWin; - register int j; + WindowPtr pParent, pWin; + int j; for (j=0; jnumSaved; j++) { @@ -3180,27 +3233,12 @@ HandleSaveSet(register ClientPtr client) client->saveSet = (SaveSetElt *)NULL; } -/** - * - * \param x,y in root - * \param box "return" value - */ -Bool -VisibleBoundingBoxFromPoint(register WindowPtr pWin, int x, int y, BoxPtr box) -{ - if (!pWin->realized) - return (FALSE); - if (RegionContainsPoint(&pWin->clipList, x, y, box)) - return(TRUE); - return(FALSE); -} - /** * * \param x,y in root */ Bool -PointInWindowIsVisible(register WindowPtr pWin, int x, int y) +PointInWindowIsVisible(WindowPtr pWin, int x, int y) { BoxRec box; @@ -3211,7 +3249,7 @@ PointInWindowIsVisible(register WindowPtr pWin, int x, int y) && (!wInputShape(pWin) || RegionContainsPoint( wInputShape(pWin), - x - pWin->drawable.x, + x - pWin->drawable.x, y - pWin->drawable.y, &box))) return(TRUE); return(FALSE); @@ -3219,7 +3257,7 @@ PointInWindowIsVisible(register WindowPtr pWin, int x, int y) RegionPtr -NotClippedByChildren(register WindowPtr pWin) +NotClippedByChildren(WindowPtr pWin) { RegionPtr pReg; @@ -3302,30 +3340,6 @@ SendVisibilityNotify(WindowPtr pWin) DeliverEvents(pWin, &event, 1, NullWindow); } -static WindowPtr windowDisableMapUnmapEvents; - -void -DisableMapUnmapEvents(WindowPtr pWin) -{ - assert (windowDisableMapUnmapEvents == NULL); - - windowDisableMapUnmapEvents = pWin; -} - -void -EnableMapUnmapEvents(WindowPtr pWin) -{ - assert (windowDisableMapUnmapEvents != NULL); - - windowDisableMapUnmapEvents = NULL; -} - -Bool -MapUnmapEventsEnabled(WindowPtr pWin) -{ - return pWin != windowDisableMapUnmapEvents; -} - #define RANDOM_WIDTH 32 #ifndef NOLOGOHACK @@ -3566,7 +3580,7 @@ TileScreenSaver(int i, int kind) */ WindowPtr -FindWindowWithOptional (register WindowPtr w) +FindWindowWithOptional (WindowPtr w) { do w = w->parent; @@ -3583,10 +3597,10 @@ FindWindowWithOptional (register WindowPtr w) */ void -CheckWindowOptionalNeed (register WindowPtr w) +CheckWindowOptionalNeed (WindowPtr w) { - register WindowOptPtr optional; - register WindowOptPtr parentOptional; + WindowOptPtr optional; + WindowOptPtr parentOptional; if (!w->parent) return; @@ -3637,10 +3651,10 @@ CheckWindowOptionalNeed (register WindowPtr w) */ Bool -MakeWindowOptional (register WindowPtr pWin) +MakeWindowOptional (WindowPtr pWin) { - register WindowOptPtr optional; - register WindowOptPtr parentOptional; + WindowOptPtr optional; + WindowOptPtr parentOptional; if (pWin->optional) return TRUE; @@ -3678,41 +3692,6 @@ MakeWindowOptional (register WindowPtr pWin) return TRUE; } -void -DisposeWindowOptional (register WindowPtr pWin) -{ - if (!pWin->optional) - return; - /* - * everything is peachy. Delete the optional record - * and clean up - */ - /* - * TOG changed this code to: - * - * if (pWin->cursorIsNone == FALSE) - * FreeCursor (pWin->optional->cursor, (Cursor)0); - * pWin->cursorIsNone = TRUE; - * - * This is blatently wrong; windows without optionals can have - * two different cursor values, either None or sharing their - * parents cursor. This difference is controlled by the - * cursorIsNone value; when TRUE, the window has no cursor, - * when false, it shares its cursor with its parent; TOG - * made it impossible for a window to have a cursor without - * an optional record. - */ - if (pWin->optional->cursor) - { - FreeCursor (pWin->optional->cursor, (Cursor)0); - pWin->cursorIsNone = FALSE; - } - else - pWin->cursorIsNone = TRUE; - free (pWin->optional); - pWin->optional = NULL; -} - #ifndef NOLOGOHACK static void DrawLogo(WindowPtr pWin) diff --git a/nx-X11/programs/Xserver/fb/Imakefile b/nx-X11/programs/Xserver/fb/Imakefile index 5daa10c6f0..c298e355ad 100644 --- a/nx-X11/programs/Xserver/fb/Imakefile +++ b/nx-X11/programs/Xserver/fb/Imakefile @@ -10,10 +10,20 @@ FB_DEFINES=-DFBNOPIXADDR -DFBNO24BIT SHM_DEFINES = ShmDefines #endif -#if BuildRender -RENDERSRC = fbcompose.c -RENDEROBJ = fbcompose.o +/* + FIXME: How to check properly? THIS way does not work... + +#ifdef XFree86Server +FB_CMAPSRC = fbcmap_mi.c +FB_CMAPOBJ = fbcmap_mi.o +#else +FB_CMAPSRC = fbcmap.c +FB_CMAPOBJ = fbcmap.o #endif +*/ + +FB_CMAPSRC = fbcmap_mi.c +FB_CMAPOBJ = fbcmap_mi.o #if defined(NXAgentServer) && NXAgentServer NX_DEFINES = -DNXAGENT_SERVER @@ -25,16 +35,15 @@ NX_DEFINES = -DNXAGENT_SERVER DEFINES = $(FB_DEFINES) #endif -SRCS = $(XFMODSRC) \ +SRCS = fb24_32.c \ fballpriv.c \ + fbarc.c \ fbbits.c \ fbblt.c \ fbbltone.c \ fbbstore.c \ - fbcmap.c \ - $(RENDERSRC) \ + $(FB_CMAPSRC) \ fbcopy.c \ - fbedge.c \ fbfill.c \ fbfillrect.c \ fbfillsp.c \ @@ -44,6 +53,7 @@ SRCS = $(XFMODSRC) \ fbimage.c \ fbline.c \ fboverlay.c \ + fbpict.c \ fbpixmap.c \ fbpoint.c \ fbpush.c \ @@ -56,21 +66,16 @@ SRCS = $(XFMODSRC) \ fbtrap.c \ fbutil.c \ fbwindow.c \ - fb24_32.c \ - fbpict.c \ $(NULL) -OBJS = $(XFMODOBJ) \ - fbarc.o \ +OBJS = fbarc.o \ fballpriv.o \ fbbits.o \ fbblt.o \ fbbltone.o \ fbbstore.o \ - fbcmap.o \ - $(RENDEROBJ) \ + $(FB_CMAPOBJ) \ fbcopy.o \ - fbedge.o \ fbfill.o \ fbfillrect.o \ fbfillsp.o \ @@ -130,9 +135,6 @@ LinkSourceFile(fbblt.c,LinkDirectory) LinkSourceFile(fbbltone.c,LinkDirectory) LinkSourceFile(fbbstore.c,LinkDirectory) LinkSourceFile(fbcmap.c,LinkDirectory) -#if BuildRender -LinkSourceFile(fbcompose.c,LinkDirectory) -#endif LinkSourceFile(fbcopy.c,LinkDirectory) LinkSourceFile(fbfill.c,LinkDirectory) LinkSourceFile(fbfillrect.c,LinkDirectory) diff --git a/nx-X11/programs/Xserver/fb/fb.h b/nx-X11/programs/Xserver/fb/fb.h index 61bf18caf4..65f32d444e 100644 --- a/nx-X11/programs/Xserver/fb/fb.h +++ b/nx-X11/programs/Xserver/fb/fb.h @@ -1,4 +1,5 @@ /* + * * Copyright © 1998 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its @@ -25,6 +26,8 @@ #define _FB_H_ #include +#include + #include "scrnintstr.h" #include "pixmap.h" #include "pixmapstr.h" @@ -43,6 +46,39 @@ #include "picture.h" #endif +#ifdef FB_ACCESS_WRAPPER + +#include "wfbrename.h" +#define FBPREFIX(x) wfb##x +#define WRITE(ptr, val) ((*wfbWriteMemory)((ptr), (val), sizeof(*(ptr)))) +#define READ(ptr) ((*wfbReadMemory)((ptr), sizeof(*(ptr)))) + +#define MEMCPY_WRAPPED(dst, src, size) do { \ + size_t _i; \ + CARD8 *_dst = (CARD8*)(dst), *_src = (CARD8*)(src); \ + for(_i = 0; _i < size; _i++) { \ + WRITE(_dst +_i, READ(_src + _i)); \ + } \ +} while(0) + +#define MEMSET_WRAPPED(dst, val, size) do { \ + size_t _i; \ + CARD8 *_dst = (CARD8*)(dst); \ + for(_i = 0; _i < size; _i++) { \ + WRITE(_dst +_i, (val)); \ + } \ +} while(0) + +#else + +#define FBPREFIX(x) fb##x +#define WRITE(ptr, val) (*(ptr) = (val)) +#define READ(ptr) (*(ptr)) +#define MEMCPY_WRAPPED(dst, src, size) memcpy((dst), (src), (size)) +#define MEMSET_WRAPPED(dst, val, size) memset((dst), (val), (size)) + +#endif + /* * This single define controls the basic size of data manipulated * by this software; it must be log2(sizeof (FbBits) * 8) @@ -64,6 +100,9 @@ #if GLYPHPADBYTES != 4 #error "GLYPHPADBYTES must be 4" #endif +#if GETLEFTBITS_ALIGNMENT != 1 +#error "GETLEFTBITS_ALIGNMENT must be 1" +#endif /* whether to bother to include 24bpp support */ #ifndef FBNO24BIT #define FB_24BIT @@ -94,20 +133,17 @@ #define FbFullMask(n) ((n) == FB_UNIT ? FB_ALLONES : ((((FbBits) 1) << n) - 1)) #if FB_SHIFT == 6 -# ifdef WIN32 -typedef unsigned __int64 FbBits; -# else # if defined(__alpha__) || defined(__alpha) || \ defined(ia64) || defined(__ia64__) || \ defined(__sparc64__) || defined(_LP64) || \ defined(__s390x__) || \ defined(amd64) || defined (__amd64__) || \ - defined (__powerpc64__) + defined (__powerpc64__) || \ + (defined(sgi) && (_MIPS_SZLONG == 64)) typedef unsigned long FbBits; # else typedef unsigned long long FbBits; # endif -# endif #endif #if FB_SHIFT == 5 @@ -217,8 +253,8 @@ extern void fbSetBits (FbStip *bits, int stride, FbStip data); #define FbPtrOffset(p,o,t) ((t *) ((CARD8 *) (p) + (o))) #define FbSelectPatternPart(xor,o,t) ((xor) >> (FbPatternOffset (o,t) << 3)) -#define FbStorePart(dst,off,t,xor) (*FbPtrOffset(dst,off,t) = \ - FbSelectPart(xor,off,t)) +#define FbStorePart(dst,off,t,xor) (WRITE(FbPtrOffset(dst,off,t), \ + FbSelectPart(xor,off,t))) #ifndef FbSelectPart #define FbSelectPart(x,o,t) FbSelectPatternPart(x,o,t) #endif @@ -398,7 +434,7 @@ extern void fbSetBits (FbStip *bits, int stride, FbStip data); FbStorePart(dst,sizeof (FbBits) - 1,CARD8,xor); \ break; \ default: \ - *dst = FbDoMaskRRop(*dst, and, xor, l); \ + WRITE(dst, FbDoMaskRRop(READ(dst), and, xor, l)); \ break; \ } \ } @@ -418,7 +454,7 @@ extern void fbSetBits (FbStip *bits, int stride, FbStip data); break; \ FbDoRightMaskByteRRop6Cases(dst,xor) \ default: \ - *dst = FbDoMaskRRop (*dst, and, xor, r); \ + WRITE(dst, FbDoMaskRRop (READ(dst), and, xor, r)); \ } \ } #endif @@ -450,20 +486,20 @@ extern void fbSetBits (FbStip *bits, int stride, FbStip data); * The term "lane" comes from the hardware term "byte-lane" which */ -#define FbLaneCase1(n,a,o) ((n) == 0x01 ? \ - (*(CARD8 *) ((a)+FbPatternOffset(o,CARD8)) = \ - fgxor) : 0) -#define FbLaneCase2(n,a,o) ((n) == 0x03 ? \ - (*(CARD16 *) ((a)+FbPatternOffset(o,CARD16)) = \ +#define FbLaneCase1(n,a,o) ((n) == 0x01 ? (void) \ + WRITE((CARD8 *) ((a)+FbPatternOffset(o,CARD8)), \ + fgxor) : (void) 0) +#define FbLaneCase2(n,a,o) ((n) == 0x03 ? (void) \ + WRITE((CARD16 *) ((a)+FbPatternOffset(o,CARD16)), \ fgxor) : \ ((void)FbLaneCase1((n)&1,a,o), \ FbLaneCase1((n)>>1,a,(o)+1))) -#define FbLaneCase4(n,a,o) ((n) == 0x0f ? \ - (*(CARD32 *) ((a)+FbPatternOffset(o,CARD32)) = \ +#define FbLaneCase4(n,a,o) ((n) == 0x0f ? (void) \ + WRITE((CARD32 *) ((a)+FbPatternOffset(o,CARD32)), \ fgxor) : \ ((void)FbLaneCase2((n)&3,a,o), \ FbLaneCase2((n)>>2,a,(o)+2))) -#define FbLaneCase8(n,a,o) ((n) == 0x0ff ? (*(FbBits *) ((a)+(o)) = fgxor) : \ +#define FbLaneCase8(n,a,o) ((n) == 0x0ff ? (void) (*(FbBits *) ((a)+(o)) = fgxor) : \ ((void)FbLaneCase4((n)&15,a,o), \ FbLaneCase4((n)>>4,a,(o)+4))) @@ -569,19 +605,36 @@ extern int fbGetWinPrivateIndex(void); extern const GCOps fbGCOps; extern const GCFuncs fbGCFuncs; -#ifdef TEKX11 -#define FB_OLD_GC -#define FB_OLD_SCREEN +#ifdef FB_24_32BIT +#define FB_SCREEN_PRIVATE #endif -#ifdef FB_OLD_SCREEN -# define FB_OLD_MISCREENINIT /* miScreenInit requires 14 args, not 13 */ -#endif +/* Framebuffer access wrapper */ +typedef FbBits (*ReadMemoryProcPtr)(const void *src, int size); +typedef void (*WriteMemoryProcPtr)(void *dst, FbBits value, int size); +typedef void (*SetupWrapProcPtr)(ReadMemoryProcPtr *pRead, + WriteMemoryProcPtr *pWrite, + DrawablePtr pDraw); +typedef void (*FinishWrapProcPtr)(DrawablePtr pDraw); + +#ifdef FB_ACCESS_WRAPPER + +#define fbPrepareAccess(pDraw) \ + fbGetScreenPrivate((pDraw)->pScreen)->setupWrap( \ + &wfbReadMemory, \ + &wfbWriteMemory, \ + (pDraw)) +#define fbFinishAccess(pDraw) \ + fbGetScreenPrivate((pDraw)->pScreen)->finishWrap(pDraw) + +#else + +#define fbPrepareAccess(pPix) +#define fbFinishAccess(pDraw) -#ifdef FB_24_32BIT -#define FB_SCREEN_PRIVATE #endif + #ifdef FB_SCREEN_PRIVATE extern int fbScreenPrivateIndex; extern int fbGetScreenPrivateIndex(void); @@ -590,6 +643,10 @@ extern int fbGetScreenPrivateIndex(void); typedef struct { unsigned char win32bpp; /* window bpp for 32-bpp images */ unsigned char pix32bpp; /* pixmap bpp for 32-bpp images */ +#ifdef FB_ACCESS_WRAPPER + SetupWrapProcPtr setupWrap; /* driver hook to set pixmap access wrapping */ + FinishWrapProcPtr finishWrap; /* driver hook to clean up pixmap access wrapping */ +#endif } FbScreenPrivRec, *FbScreenPrivPtr; #define fbGetScreenPrivate(pScreen) ((FbScreenPrivPtr) \ @@ -598,15 +655,6 @@ typedef struct { /* private field of GC */ typedef struct { -#ifdef FB_OLD_GC - unsigned char pad1; - unsigned char pad2; - unsigned char pad3; - unsigned fExpose:1; - unsigned freeCompClip:1; - PixmapPtr pRotatedPixmap; - RegionPtr pCompositeClip; -#endif FbBits and, xor; /* reduced rop values */ FbBits bgand, bgxor; /* for stipples */ FbBits fg, bg, pm; /* expanded and filled */ @@ -619,17 +667,10 @@ typedef struct { #define fbGetGCPrivate(pGC) ((FbGCPrivPtr)\ (pGC)->devPrivates[fbGetGCPrivateIndex()].ptr) -#ifdef FB_OLD_GC -#define fbGetCompositeClip(pGC) (fbGetGCPrivate(pGC)->pCompositeClip) -#define fbGetExpose(pGC) (fbGetGCPrivate(pGC)->fExpose) -#define fbGetFreeCompClip(pGC) (fbGetGCPrivate(pGC)->freeCompClip) -#define fbGetRotatedPixmap(pGC) (fbGetGCPrivate(pGC)->pRotatedPixmap) -#else #define fbGetCompositeClip(pGC) ((pGC)->pCompositeClip) #define fbGetExpose(pGC) ((pGC)->fExpose) #define fbGetFreeCompClip(pGC) ((pGC)->freeCompClip) #define fbGetRotatedPixmap(pGC) ((pGC)->pRotatedPixmap) -#endif #define fbGetScreenPixmap(s) ((PixmapPtr) (s)->devPrivate) #ifdef FB_NO_WINDOW_PIXMAPS @@ -668,6 +709,7 @@ typedef struct { (xoff) = __fbPixOffXPix(_pPix); \ (yoff) = __fbPixOffYPix(_pPix); \ } \ + fbPrepareAccess(pDrawable); \ (pointer) = (FbBits *) _pPix->devPrivate.ptr; \ (stride) = ((int) _pPix->devKind) / sizeof (FbBits); (void)(stride); \ (bpp) = _pPix->drawable.bitsPerPixel; (void)(bpp); \ @@ -684,6 +726,7 @@ typedef struct { (xoff) = __fbPixOffXPix(_pPix); \ (yoff) = __fbPixOffYPix(_pPix); \ } \ + fbPrepareAccess(pDrawable); \ (pointer) = (FbStip *) _pPix->devPrivate.ptr; \ (stride) = ((int) _pPix->devKind) / sizeof (FbStip); (void)(stride); \ (bpp) = _pPix->drawable.bitsPerPixel; (void)(bpp); \ @@ -702,12 +745,6 @@ typedef struct { ((pDrawable)->type == DRAWABLE_PIXMAP ? \ TRUE : fbWindowEnabled((WindowPtr) pDrawable)) -#ifdef FB_OLD_SCREEN -#define BitsPerPixel(d) (\ - ((1 << PixmapWidthPaddingInfo[d].padBytesLog2) * 8 / \ - (PixmapWidthPaddingInfo[d].padRoundUp+1))) -#endif - #define FbPowerOfTwo(w) (((w) & ((w) - 1)) == 0) /* * Accelerated tiles are power of 2 width <= FB_UNIT @@ -1270,6 +1307,9 @@ fbCreateDefColormap(ScreenPtr pScreen); void fbClearVisualTypes(void); +Bool +fbHasVisualTypes (int depth); + Bool fbSetVisualTypes (int depth, int visuals, int bitsPerRGB); @@ -1715,13 +1755,11 @@ fbQueryBestSize (int class, unsigned short *width, unsigned short *height, ScreenPtr pScreen); -#ifndef FB_OLD_SCREEN PixmapPtr _fbGetWindowPixmap (WindowPtr pWindow); void _fbSetWindowPixmap (WindowPtr pWindow, PixmapPtr pPixmap); -#endif Bool fbSetupScreen(ScreenPtr pScreen, @@ -1733,6 +1771,30 @@ fbSetupScreen(ScreenPtr pScreen, int width, /* pixel width of frame buffer */ int bpp); /* bits per pixel of frame buffer */ +Bool +wfbFinishScreenInit(ScreenPtr pScreen, + void * pbits, + int xsize, + int ysize, + int dpix, + int dpiy, + int width, + int bpp, + SetupWrapProcPtr setupWrap, + FinishWrapProcPtr finishWrap); + +Bool +wfbScreenInit(ScreenPtr pScreen, + void * pbits, + int xsize, + int ysize, + int dpix, + int dpiy, + int width, + int bpp, + SetupWrapProcPtr setupWrap, + FinishWrapProcPtr finishWrap); + Bool fbFinishScreenInit(ScreenPtr pScreen, void *pbits, @@ -1933,6 +1995,7 @@ fbEvenTile (FbBits *dst, int height, FbBits *tile, + FbStride tileStride, int tileHeight, int alu, @@ -1989,6 +2052,11 @@ fbReplicatePixel (Pixel p, int bpp); void fbReduceRasterOp (int rop, FbBits fg, FbBits pm, FbBits *andp, FbBits *xorp); +#ifdef FB_ACCESS_WRAPPER +extern ReadMemoryProcPtr wfbReadMemory; +extern WriteMemoryProcPtr wfbWriteMemory; +#endif + /* * fbwindow.c */ @@ -2044,4 +2112,9 @@ void fbPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what); +pixman_image_t *image_from_pict (PicturePtr pict, + Bool has_clip); +void free_pixman_pict (PicturePtr, pixman_image_t *); + #endif /* _FB_H_ */ + diff --git a/nx-X11/programs/Xserver/fb/fb24_32.c b/nx-X11/programs/Xserver/fb/fb24_32.c index 7255b5021a..a26f07979c 100644 --- a/nx-X11/programs/Xserver/fb/fb24_32.c +++ b/nx-X11/programs/Xserver/fb/fb24_32.c @@ -1,4 +1,5 @@ /* + * * Copyright © 2000 SuSE, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its @@ -36,18 +37,18 @@ * by reading/writing aligned CARD32s where it's easy */ -#define Get8(a) ((CARD32) *(a)) +#define Get8(a) ((CARD32) READ(a)) #if BITMAP_BIT_ORDER == MSBFirst #define Get24(a) ((Get8(a) << 16) | (Get8((a)+1) << 8) | Get8((a)+2)) -#define Put24(a,p) (((a)[0] = (CARD8) ((p) >> 16)), \ - ((a)[1] = (CARD8) ((p) >> 8)), \ - ((a)[2] = (CARD8) (p))) +#define Put24(a,p) ((WRITE((a+0), (CARD8) ((p) >> 16))), \ + (WRITE((a+1), (CARD8) ((p) >> 8))), \ + (WRITE((a+2), (CARD8) (p)))) #else #define Get24(a) (Get8(a) | (Get8((a)+1) << 8) | (Get8((a)+2)<<16)) -#define Put24(a,p) (((a)[0] = (CARD8) (p)), \ - ((a)[1] = (CARD8) ((p) >> 8)), \ - ((a)[2] = (CARD8) ((p) >> 16))) +#define Put24(a,p) ((WRITE((a+0), (CARD8) (p))), \ + (WRITE((a+1), (CARD8) ((p) >> 8))), \ + (WRITE((a+2), (CARD8) ((p) >> 16)))) #endif typedef void (*fb24_32BltFunc) (CARD8 *srcLine, @@ -104,7 +105,7 @@ fb24_32BltDown (CARD8 *srcLine, while (((long) dst & 3) && w) { w--; - pixel = *src++; + pixel = READ(src++); pixel = FbDoDestInvarientMergeRop(pixel); Put24 (dst, pixel); dst += 3; @@ -113,35 +114,35 @@ fb24_32BltDown (CARD8 *srcLine, while (w >= 4) { CARD32 s0, s1; - s0 = *src++; + s0 = READ(src++); s0 = FbDoDestInvarientMergeRop(s0); - s1 = *src++; + s1 = READ(src++); s1 = FbDoDestInvarientMergeRop(s1); #if BITMAP_BIT_ORDER == LSBFirst - *(CARD32 *)(dst) = (s0 & 0xffffff) | (s1 << 24); + WRITE((CARD32 *)dst, (s0 & 0xffffff) | (s1 << 24)); #else - *(CARD32 *)(dst) = (s0 << 8) | ((s1 & 0xffffff) >> 16); + WRITE((CARD32 *)dst, (s0 << 8) | ((s1 & 0xffffff) >> 16)); #endif - s0 = *src++; + s0 = READ(src++); s0 = FbDoDestInvarientMergeRop(s0); #if BITMAP_BIT_ORDER == LSBFirst - *(CARD32 *)(dst+4) = ((s1 & 0xffffff) >> 8) | (s0 << 16); + WRITE((CARD32 *)(dst+4), ((s1 & 0xffffff) >> 8) | (s0 << 16)); #else - *(CARD32 *)(dst+4) = (s1 << 16) | ((s0 & 0xffffff) >> 8); + WRITE((CARD32 *)(dst+4), (s1 << 16) | ((s0 & 0xffffff) >> 8)); #endif - s1 = *src++; + s1 = READ(src++); s1 = FbDoDestInvarientMergeRop(s1); #if BITMAP_BIT_ORDER == LSBFirst - *(CARD32 *)(dst+8) = ((s0 & 0xffffff) >> 16) | (s1 << 8); + WRITE((CARD32 *)(dst+8), ((s0 & 0xffffff) >> 16) | (s1 << 8)); #else - *(CARD32 *)(dst+8) = (s0 << 24) | (s1 & 0xffffff); + WRITE((CARD32 *)(dst+8), (s0 << 24) | (s1 & 0xffffff)); #endif dst += 12; w -= 4; } while (w--) { - pixel = *src++; + pixel = READ(src++); pixel = FbDoDestInvarientMergeRop(pixel); Put24 (dst, pixel); dst += 3; @@ -203,40 +204,40 @@ fb24_32BltUp (CARD8 *srcLine, w--; pixel = Get24(src); src += 3; - *dst++ = FbDoDestInvarientMergeRop(pixel); + WRITE(dst++, FbDoDestInvarientMergeRop(pixel)); } /* Do four aligned pixels at a time */ while (w >= 4) { CARD32 s0, s1; - s0 = *(CARD32 *)(src); + s0 = READ((CARD32 *)src); #if BITMAP_BIT_ORDER == LSBFirst pixel = s0 & 0xffffff; #else pixel = s0 >> 8; #endif - *dst++ = FbDoDestInvarientMergeRop(pixel); - s1 = *(CARD32 *)(src+4); + WRITE(dst++, FbDoDestInvarientMergeRop(pixel)); + s1 = READ((CARD32 *)(src+4)); #if BITMAP_BIT_ORDER == LSBFirst pixel = (s0 >> 24) | ((s1 << 8) & 0xffffff); #else pixel = ((s0 << 16) & 0xffffff) | (s1 >> 16); #endif - *dst++ = FbDoDestInvarientMergeRop(pixel); - s0 = *(CARD32 *)(src+8); + WRITE(dst++, FbDoDestInvarientMergeRop(pixel)); + s0 = READ((CARD32 *)(src+8)); #if BITMAP_BIT_ORDER == LSBFirst pixel = (s1 >> 16) | ((s0 << 16) & 0xffffff); #else pixel = ((s1 << 8) & 0xffffff) | (s0 >> 24); #endif - *dst++ = FbDoDestInvarientMergeRop(pixel); + WRITE(dst++, FbDoDestInvarientMergeRop(pixel)); #if BITMAP_BIT_ORDER == LSBFirst pixel = s0 >> 8; #else pixel = s0 & 0xffffff; #endif - *dst++ = FbDoDestInvarientMergeRop(pixel); + WRITE(dst++, FbDoDestInvarientMergeRop(pixel)); src += 12; w -= 4; } @@ -245,7 +246,7 @@ fb24_32BltUp (CARD8 *srcLine, w--; pixel = Get24(src); src += 3; - *dst++ = FbDoDestInvarientMergeRop(pixel); + WRITE(dst++, FbDoDestInvarientMergeRop(pixel)); } } else @@ -254,7 +255,7 @@ fb24_32BltUp (CARD8 *srcLine, { pixel = Get24(src); src += 3; - *dst = FbDoMergeRop(pixel, *dst); + WRITE(dst, FbDoMergeRop(pixel, READ(dst))); dst++; } } @@ -303,6 +304,8 @@ fb24_32GetSpans(DrawablePtr pDrawable, ppt++; pwidth++; } + + fbFinishAccess (pDrawable); } void @@ -364,6 +367,8 @@ fb24_32SetSpans (DrawablePtr pDrawable, ppt++; pwidth++; } + + fbFinishAccess (pDrawable); } /* @@ -427,6 +432,8 @@ fb24_32PutZImage (DrawablePtr pDrawable, alu, pm); } + + fbFinishAccess (pDrawable); } void @@ -461,6 +468,8 @@ fb24_32GetImage (DrawablePtr pDrawable, fb24_32BltUp (src + (y + srcYoff) * srcStride, srcStride, x + srcXoff, (CARD8 *) d, dstStride, 0, w, h, GXcopy, pm); + + fbFinishAccess (pDrawable); } void @@ -517,6 +526,9 @@ fb24_32CopyMtoN (DrawablePtr pSrcDrawable, pPriv->pm); pbox++; } + + fbFinishAccess (pSrcDrawable); + fbFinishAccess (pDstDrawable); } PixmapPtr @@ -561,6 +573,9 @@ fb24_32ReformatTile(PixmapPtr pOldTile, int bitsPerPixel) GXcopy, FB_ALLONES); + fbFinishAccess (&pOldTile->drawable); + fbFinishAccess (&pNewTile->drawable); + return pNewTile; } diff --git a/nx-X11/programs/Xserver/fb/fb24_32.h b/nx-X11/programs/Xserver/fb/fb24_32.h new file mode 100644 index 0000000000..bfef9f5f69 --- /dev/null +++ b/nx-X11/programs/Xserver/fb/fb24_32.h @@ -0,0 +1,51 @@ +/* + * Copyright © 2000 SuSE, Inc. + * + * 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 SuSE not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. SuSE makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE + * 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. + * + * Author: Keith Packard, SuSE, Inc. + */ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#ifndef _FB24_32_H_ +#define _FB24_32_H_ + +Bool +fb24_32FinishScreenInit(ScreenPtr pScreen, + void * pbits, + int xsize, + int ysize, + int dpix, + int dpiy, + int width, + int bpp); + +Bool +fb24_32ScreenInit(ScreenPtr pScreen, + void * pbits, + int xsize, + int ysize, + int dpix, + int dpiy, + int width, + int bpp); + +#endif diff --git a/nx-X11/programs/Xserver/fb/fballpriv.c b/nx-X11/programs/Xserver/fb/fballpriv.c index d2d8866e22..aedb456c64 100644 --- a/nx-X11/programs/Xserver/fb/fballpriv.c +++ b/nx-X11/programs/Xserver/fb/fballpriv.c @@ -1,6 +1,4 @@ /* - * Id: fballpriv.c,v 1.1 1999/11/02 03:54:45 keithp Exp $ - * * Copyright © 1998 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its @@ -49,10 +47,6 @@ int fbGetWinPrivateIndex(void) #endif int fbGeneration; -#ifdef FB_OLD_SCREEN -#define miAllocateGCPrivateIndex() AllocateGCPrivateIndex() -#endif - Bool fbAllocatePrivates(ScreenPtr pScreen, int *pGCIndex) { @@ -90,3 +84,8 @@ fbAllocatePrivates(ScreenPtr pScreen, int *pGCIndex) #endif return TRUE; } + +#ifdef FB_ACCESS_WRAPPER +ReadMemoryProcPtr wfbReadMemory; +WriteMemoryProcPtr wfbWriteMemory; +#endif diff --git a/nx-X11/programs/Xserver/fb/fbarc.c b/nx-X11/programs/Xserver/fb/fbarc.c index ae89e44d83..562b37c7c6 100644 --- a/nx-X11/programs/Xserver/fb/fbarc.c +++ b/nx-X11/programs/Xserver/fb/fbarc.c @@ -1,6 +1,4 @@ /* - * Id: fbarc.c,v 1.1 1999/11/02 03:54:45 keithp Exp $ - * * Copyright © 1998 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its @@ -109,6 +107,7 @@ fbPolyArc (DrawablePtr pDrawable, miPolyArc(pDrawable, pGC, 1, parcs); parcs++; } + fbFinishAccess (pDrawable); } else #endif diff --git a/nx-X11/programs/Xserver/fb/fbbits.c b/nx-X11/programs/Xserver/fb/fbbits.c index 56b58df4ef..9e6abce23b 100644 --- a/nx-X11/programs/Xserver/fb/fbbits.c +++ b/nx-X11/programs/Xserver/fb/fbbits.c @@ -1,6 +1,4 @@ /* - * Id: fbbits.c,v 1.1 1999/11/02 03:54:45 keithp Exp $ - * * Copyright © 1998 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its @@ -103,13 +101,13 @@ #define BITSUNIT BYTE #define BITSMUL 3 -#define FbDoTypeStore(b,t,x,s) (*((t *) (b)) = (x) >> (s)) -#define FbDoTypeRRop(b,t,a,x,s) (*((t *) (b)) = FbDoRRop(*((t *) (b)),\ - (a) >> (s), \ - (x) >> (s))) -#define FbDoTypeMaskRRop(b,t,a,x,m,s) (*((t *) (b)) = FbDoMaskRRop(*((t *) (b)),\ - (a) >> (s), \ - (x) >> (s), \ +#define FbDoTypeStore(b,t,x,s) WRITE(((t *) (b)), (x) >> (s)) +#define FbDoTypeRRop(b,t,a,x,s) WRITE((t *) (b), FbDoRRop(READ((t *) (b)),\ + (a) >> (s), \ + (x) >> (s))) +#define FbDoTypeMaskRRop(b,t,a,x,m,s) WRITE((t *) (b), FbDoMaskRRop(READ((t *) (b)),\ + (a) >> (s), \ + (x) >> (s), \ (m) >> (s)) #if BITMAP_BIT_ORDER == LSBFirst #define BITSSTORE(b,x) ((unsigned long) (b) & 1 ? \ diff --git a/nx-X11/programs/Xserver/fb/fbbits.h b/nx-X11/programs/Xserver/fb/fbbits.h index 30fa21f1e2..8bf1a0290d 100644 --- a/nx-X11/programs/Xserver/fb/fbbits.h +++ b/nx-X11/programs/Xserver/fb/fbbits.h @@ -40,13 +40,13 @@ #ifdef BITSSTORE #define STORE(b,x) BITSSTORE(b,x) #else -#define STORE(b,x) (*(b) = (x)) +#define STORE(b,x) WRITE((b), (x)) #endif #ifdef BITSRROP #define RROP(b,a,x) BITSRROP(b,a,x) #else -#define RROP(b,a,x) (*(b) = FbDoRRop (*(b), (a), (x))) +#define RROP(b,a,x) WRITE((b), FbDoRRop (READ(b), (a), (x))) #endif #ifdef BITSUNIT @@ -117,6 +117,8 @@ BRESSOLID (DrawablePtr pDrawable, e += e3; } } + + fbFinishAccess (pDrawable); } #endif @@ -261,6 +263,8 @@ BRESDASH (DrawablePtr pDrawable, dashlen = len; } } + + fbFinishAccess (pDrawable); } #endif @@ -539,18 +543,18 @@ ARC (FbBits *dst, # define WRITE_ADDR4(n) ((n)) #endif -#define WRITE1(d,n,fg) ((d)[WRITE_ADDR1(n)] = (BITS) (fg)) +#define WRITE1(d,n,fg) WRITE(d + WRITE_ADDR1(n), (BITS) (fg)) #ifdef BITS2 -# define WRITE2(d,n,fg) (*((BITS2 *) &((d)[WRITE_ADDR2(n)])) = (BITS2) (fg)) +# define WRITE2(d,n,fg) WRITE((BITS2 *) &((d)[WRITE_ADDR2(n)]), (BITS2) (fg)) #else -# define WRITE2(d,n,fg) WRITE1(d,(n)+1,WRITE1(d,n,fg)) +# define WRITE2(d,n,fg) (WRITE1(d,n,fg), WRITE1(d,(n)+1,fg)) #endif #ifdef BITS4 -# define WRITE4(d,n,fg) (*((BITS4 *) &((d)[WRITE_ADDR4(n)])) = (BITS4) (fg)) +# define WRITE4(d,n,fg) WRITE((BITS4 *) &((d)[WRITE_ADDR4(n)]), (BITS4) (fg)) #else -# define WRITE4(d,n,fg) WRITE2(d,(n)+2,WRITE2(d,n,fg)) +# define WRITE4(d,n,fg) (WRITE2(d,n,fg), WRITE2(d,(n)+2,fg)) #endif void @@ -708,8 +712,10 @@ POLYLINE (DrawablePtr pDrawable, intToX(pt2) + xoff, intToY(pt2) + yoff, npt == 0 && pGC->capStyle != CapNotLast, &dashoffset); - if (!npt) + if (!npt) { + fbFinishAccess (pDrawable); return; + } pt1 = pt2; pt2 = *pts++; npt--; @@ -774,6 +780,7 @@ POLYLINE (DrawablePtr pDrawable, { RROP(bits,and,xor); } + fbFinishAccess (pDrawable); return; } pt1 = pt2; @@ -784,6 +791,8 @@ POLYLINE (DrawablePtr pDrawable, } } } + + fbFinishAccess (pDrawable); } #endif @@ -881,20 +890,20 @@ POLYSEGMENT (DrawablePtr pDrawable, FbMaskBits (dstX, width, startmask, nmiddle, endmask); if (startmask) { - *dstLine = FbDoMaskRRop (*dstLine, andBits, xorBits, startmask); + WRITE(dstLine, FbDoMaskRRop (READ(dstLine), andBits, xorBits, startmask)); dstLine++; } if (!andBits) while (nmiddle--) - *dstLine++ = xorBits; + WRITE(dstLine++, xorBits); else while (nmiddle--) { - *dstLine = FbDoRRop (*dstLine, andBits, xorBits); + WRITE(dstLine, FbDoRRop (READ(dstLine), andBits, xorBits)); dstLine++; } if (endmask) - *dstLine = FbDoMaskRRop (*dstLine, andBits, xorBits, endmask); + WRITE(dstLine, FbDoMaskRRop (READ(dstLine), andBits, xorBits, endmask)); } else { @@ -948,6 +957,8 @@ POLYSEGMENT (DrawablePtr pDrawable, } } } + + fbFinishAccess (pDrawable); } #endif diff --git a/nx-X11/programs/Xserver/fb/fbblt.c b/nx-X11/programs/Xserver/fb/fbblt.c index 6241af8eb1..78569b764b 100644 --- a/nx-X11/programs/Xserver/fb/fbblt.c +++ b/nx-X11/programs/Xserver/fb/fbblt.c @@ -1,6 +1,4 @@ /* - * Id: fbblt.c,v 1.1 1999/11/02 03:54:45 keithp Exp $ - * * Copyright © 1998 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its @@ -149,7 +147,7 @@ fbBlt (FbBits *srcLine, { if (endmask) { - bits = *--src; + bits = READ(--src); --dst; FbDoRightMaskByteMergeRop(dst, bits, endbyte, endmask); } @@ -157,20 +155,20 @@ fbBlt (FbBits *srcLine, if (destInvarient) { while (n--) - *--dst = FbDoDestInvarientMergeRop(*--src); + WRITE(--dst, FbDoDestInvarientMergeRop(READ(--src))); } else { while (n--) { - bits = *--src; + bits = READ(--src); --dst; - *dst = FbDoMergeRop (bits, *dst); + WRITE(dst, FbDoMergeRop (bits, READ(dst))); } } if (startmask) { - bits = *--src; + bits = READ(--src); --dst; FbDoLeftMaskByteMergeRop(dst, bits, startbyte, startmask); } @@ -179,7 +177,7 @@ fbBlt (FbBits *srcLine, { if (startmask) { - bits = *src++; + bits = READ(src++); FbDoLeftMaskByteMergeRop(dst, bits, startbyte, startmask); dst++; } @@ -210,20 +208,20 @@ fbBlt (FbBits *srcLine, } #endif while (n--) - *dst++ = FbDoDestInvarientMergeRop(*src++); + WRITE(dst++, FbDoDestInvarientMergeRop(READ(src++))); } else { while (n--) { - bits = *src++; - *dst = FbDoMergeRop (bits, *dst); + bits = READ(src++); + WRITE(dst, FbDoMergeRop (bits, READ(dst))); dst++; } } if (endmask) { - bits = *src; + bits = READ(src); FbDoRightMaskByteMergeRop(dst, bits, endbyte, endmask); } } @@ -252,13 +250,13 @@ fbBlt (FbBits *srcLine, if (reverse) { if (srcX < dstX) - bits1 = *--src; + bits1 = READ(--src); if (endmask) { bits = FbScrRight(bits1, rightShift); if (FbScrRight(endmask, leftShift)) { - bits1 = *--src; + bits1 = READ(--src); bits |= FbScrLeft(bits1, leftShift); } --dst; @@ -270,10 +268,10 @@ fbBlt (FbBits *srcLine, while (n--) { bits = FbScrRight(bits1, rightShift); - bits1 = *--src; + bits1 = READ(--src); bits |= FbScrLeft(bits1, leftShift); --dst; - *dst = FbDoDestInvarientMergeRop(bits); + WRITE(dst, FbDoDestInvarientMergeRop(bits)); } } else @@ -281,10 +279,10 @@ fbBlt (FbBits *srcLine, while (n--) { bits = FbScrRight(bits1, rightShift); - bits1 = *--src; + bits1 = READ(--src); bits |= FbScrLeft(bits1, leftShift); --dst; - *dst = FbDoMergeRop(bits, *dst); + WRITE(dst, FbDoMergeRop(bits, READ(dst))); } } if (startmask) @@ -292,7 +290,7 @@ fbBlt (FbBits *srcLine, bits = FbScrRight(bits1, rightShift); if (FbScrRight(startmask, leftShift)) { - bits1 = *--src; + bits1 = READ(--src); bits |= FbScrLeft(bits1, leftShift); } --dst; @@ -302,13 +300,13 @@ fbBlt (FbBits *srcLine, else { if (srcX > dstX) - bits1 = *src++; + bits1 = READ(src++); if (startmask) { bits = FbScrLeft(bits1, leftShift); if (FbScrLeft(startmask, rightShift)) { - bits1 = *src++; + bits1 = READ(src++); bits |= FbScrRight(bits1, rightShift); } FbDoLeftMaskByteMergeRop (dst, bits, startbyte, startmask); @@ -320,9 +318,9 @@ fbBlt (FbBits *srcLine, while (n--) { bits = FbScrLeft(bits1, leftShift); - bits1 = *src++; + bits1 = READ(src++); bits |= FbScrRight(bits1, rightShift); - *dst = FbDoDestInvarientMergeRop(bits); + WRITE(dst, FbDoDestInvarientMergeRop(bits)); dst++; } } @@ -331,9 +329,9 @@ fbBlt (FbBits *srcLine, while (n--) { bits = FbScrLeft(bits1, leftShift); - bits1 = *src++; + bits1 = READ(src++); bits |= FbScrRight(bits1, rightShift); - *dst = FbDoMergeRop(bits, *dst); + WRITE(dst, FbDoMergeRop(bits, READ(dst))); dst++; } } @@ -342,7 +340,7 @@ fbBlt (FbBits *srcLine, bits = FbScrLeft(bits1, leftShift); if (FbScrLeft(endmask, rightShift)) { - bits1 = *src; + bits1 = READ(src); bits |= FbScrRight(bits1, rightShift); } FbDoRightMaskByteMergeRop (dst, bits, endbyte, endmask); @@ -437,45 +435,45 @@ fbBlt24Line (FbBits *src, { if (endmask) { - bits = *--src; + bits = READ(--src); --dst; - *dst = FbDoMaskMergeRop (bits, *dst, mask & endmask); + WRITE(dst, FbDoMaskMergeRop (bits, READ(dst), mask & endmask)); mask = FbPrev24Pix (mask); } while (n--) { - bits = *--src; + bits = READ(--src); --dst; - *dst = FbDoMaskMergeRop (bits, *dst, mask); + WRITE(dst, FbDoMaskMergeRop (bits, READ(dst), mask)); mask = FbPrev24Pix (mask); } if (startmask) { - bits = *--src; + bits = READ(--src); --dst; - *dst = FbDoMaskMergeRop(bits, *dst, mask & startmask); + WRITE(dst, FbDoMaskMergeRop(bits, READ(dst), mask & startmask)); } } else { if (startmask) { - bits = *src++; - *dst = FbDoMaskMergeRop (bits, *dst, mask & startmask); + bits = READ(src++); + WRITE(dst, FbDoMaskMergeRop (bits, READ(dst), mask & startmask)); dst++; mask = FbNext24Pix(mask); } while (n--) { - bits = *src++; - *dst = FbDoMaskMergeRop (bits, *dst, mask); + bits = READ(src++); + WRITE(dst, FbDoMaskMergeRop (bits, READ(dst), mask)); dst++; mask = FbNext24Pix(mask); } if (endmask) { - bits = *src; - *dst = FbDoMaskMergeRop(bits, *dst, mask & endmask); + bits = READ(src); + WRITE(dst, FbDoMaskMergeRop(bits, READ(dst), mask & endmask)); } } } @@ -496,26 +494,26 @@ fbBlt24Line (FbBits *src, if (reverse) { if (srcX < dstX) - bits1 = *--src; + bits1 = READ(--src); if (endmask) { bits = FbScrRight(bits1, rightShift); if (FbScrRight(endmask, leftShift)) { - bits1 = *--src; + bits1 = READ(--src); bits |= FbScrLeft(bits1, leftShift); } --dst; - *dst = FbDoMaskMergeRop (bits, *dst, mask & endmask); + WRITE(dst, FbDoMaskMergeRop (bits, READ(dst), mask & endmask)); mask = FbPrev24Pix(mask); } while (n--) { bits = FbScrRight(bits1, rightShift); - bits1 = *--src; + bits1 = READ(--src); bits |= FbScrLeft(bits1, leftShift); --dst; - *dst = FbDoMaskMergeRop(bits, *dst, mask); + WRITE(dst, FbDoMaskMergeRop(bits, READ(dst), mask)); mask = FbPrev24Pix(mask); } if (startmask) @@ -523,32 +521,32 @@ fbBlt24Line (FbBits *src, bits = FbScrRight(bits1, rightShift); if (FbScrRight(startmask, leftShift)) { - bits1 = *--src; + bits1 = READ(--src); bits |= FbScrLeft(bits1, leftShift); } --dst; - *dst = FbDoMaskMergeRop (bits, *dst, mask & startmask); + WRITE(dst, FbDoMaskMergeRop (bits, READ(dst), mask & startmask)); } } else { if (srcX > dstX) - bits1 = *src++; + bits1 = READ(src++); if (startmask) { bits = FbScrLeft(bits1, leftShift); - bits1 = *src++; + bits1 = READ(src++); bits |= FbScrRight(bits1, rightShift); - *dst = FbDoMaskMergeRop (bits, *dst, mask & startmask); + WRITE(dst, FbDoMaskMergeRop (bits, READ(dst), mask & startmask)); dst++; mask = FbNext24Pix(mask); } while (n--) { bits = FbScrLeft(bits1, leftShift); - bits1 = *src++; + bits1 = READ(src++); bits |= FbScrRight(bits1, rightShift); - *dst = FbDoMaskMergeRop(bits, *dst, mask); + WRITE(dst, FbDoMaskMergeRop(bits, READ(dst), mask)); dst++; mask = FbNext24Pix(mask); } @@ -557,10 +555,10 @@ fbBlt24Line (FbBits *src, bits = FbScrLeft(bits1, leftShift); if (FbScrLeft(endmask, rightShift)) { - bits1 = *src; + bits1 = READ(src); bits |= FbScrRight(bits1, rightShift); } - *dst = FbDoMaskMergeRop (bits, *dst, mask & endmask); + WRITE(dst, FbDoMaskMergeRop (bits, READ(dst), mask & endmask)); } } } @@ -719,8 +717,8 @@ fbBltOdd (FbBits *srcLine, { if (startmask) { - bits = *src++; - *dst = FbDoMaskMergeRop (bits, *dst, startmask); + bits = READ(src++); + WRITE(dst, FbDoMaskMergeRop (bits, READ(dst), startmask)); dst++; } n = nmiddle; @@ -728,8 +726,8 @@ fbBltOdd (FbBits *srcLine, { while (n--) { - bits = *src++; - *dst = FbDoDestInvarientMergeRop(bits); + bits = READ(src++); + WRITE(dst, FbDoDestInvarientMergeRop(bits)); dst++; } } @@ -737,28 +735,28 @@ fbBltOdd (FbBits *srcLine, { while (n--) { - bits = *src++; - *dst = FbDoMergeRop (bits, *dst); + bits = READ(src++); + WRITE(dst, FbDoMergeRop (bits, READ(dst))); dst++; } } if (endmask) { - bits = *src; - *dst = FbDoMaskMergeRop(bits, *dst, endmask); + bits = READ(src); + WRITE(dst, FbDoMaskMergeRop(bits, READ(dst), endmask)); } } else { bits = 0; if (srcX > dstX) - bits = *src++; + bits = READ(src++); if (startmask) { bits1 = FbScrLeft(bits, leftShift); - bits = *src++; + bits = READ(src++); bits1 |= FbScrRight(bits, rightShift); - *dst = FbDoMaskMergeRop (bits1, *dst, startmask); + WRITE(dst, FbDoMaskMergeRop (bits1, READ(dst), startmask)); dst++; } n = nmiddle; @@ -767,9 +765,9 @@ fbBltOdd (FbBits *srcLine, while (n--) { bits1 = FbScrLeft(bits, leftShift); - bits = *src++; + bits = READ(src++); bits1 |= FbScrRight(bits, rightShift); - *dst = FbDoDestInvarientMergeRop(bits1); + WRITE(dst, FbDoDestInvarientMergeRop(bits1)); dst++; } } @@ -778,9 +776,9 @@ fbBltOdd (FbBits *srcLine, while (n--) { bits1 = FbScrLeft(bits, leftShift); - bits = *src++; + bits = READ(src++); bits1 |= FbScrRight(bits, rightShift); - *dst = FbDoMergeRop(bits1, *dst); + WRITE(dst, FbDoMergeRop(bits1, READ(dst))); dst++; } } @@ -789,10 +787,10 @@ fbBltOdd (FbBits *srcLine, bits1 = FbScrLeft(bits, leftShift); if (FbScrLeft(endmask, rightShift)) { - bits = *src; + bits = READ(src); bits1 |= FbScrRight(bits, rightShift); } - *dst = FbDoMaskMergeRop (bits1, *dst, endmask); + WRITE(dst, FbDoMaskMergeRop (bits1, READ(dst), endmask)); } } } diff --git a/nx-X11/programs/Xserver/fb/fbbltone.c b/nx-X11/programs/Xserver/fb/fbbltone.c index f06357a372..ffe69775a6 100644 --- a/nx-X11/programs/Xserver/fb/fbbltone.c +++ b/nx-X11/programs/Xserver/fb/fbbltone.c @@ -1,6 +1,4 @@ /* - * Id: fbbltone.c,v 1.1 1999/11/02 03:54:45 keithp Exp $ - * * Copyright © 1998 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its @@ -51,12 +49,12 @@ #define LoadBits {\ if (leftShift) { \ - bitsRight = (src < srcEnd ? *src++ : 0); \ + bitsRight = (src < srcEnd ? READ(src++) : 0); \ bits = (FbStipLeft (bitsLeft, leftShift) | \ FbStipRight(bitsRight, rightShift)); \ bitsLeft = bitsRight; \ } else \ - bits = (src < srcEnd ? *src++ : 0); \ + bits = (src < srcEnd ? READ(src++) : 0); \ } #ifndef FBNOPIXADDR @@ -285,7 +283,7 @@ fbBltOne (FbStip *src, bitsLeft = 0; if (srcX > dstS) - bitsLeft = *src++; + bitsLeft = READ(src++); if (n) { /* @@ -338,7 +336,7 @@ fbBltOne (FbStip *src, else #endif mask = fbBits[FbLeftStipBits(bits,pixelsPerDst)]; - *dst = FbOpaqueStipple (mask, fgxor, bgxor); + WRITE(dst, FbOpaqueStipple (mask, fgxor, bgxor)); dst++; bits = FbStipLeft(bits, pixelsPerDst); } @@ -368,8 +366,8 @@ fbBltOne (FbStip *src, if (left || !transparent) { mask = fbBits[left]; - *dst = FbStippleRRop (*dst, mask, - fgand, fgxor, bgand, bgxor); + WRITE(dst, FbStippleRRop (READ(dst), mask, + fgand, fgxor, bgand, bgxor)); } dst++; bits = FbStipLeft(bits, pixelsPerDst); @@ -537,7 +535,7 @@ const FbBits fbStipple24Bits[3][1 << FbStip24Len] = { stip = FbLeftStipBits(bits, len); \ } else { \ stip = FbLeftStipBits(bits, remain); \ - bits = (src < srcEnd ? *src++ : 0); \ + bits = (src < srcEnd ? READ(src++) : 0); \ __len = (len) - remain; \ stip = FbMergePartStip24Bits(stip, FbLeftStipBits(bits, __len), \ remain, __len); \ @@ -548,7 +546,7 @@ const FbBits fbStipple24Bits[3][1 << FbStip24Len] = { } #define fbInitStipBits(offset,len,stip) {\ - bits = FbStipLeft (*src++,offset); \ + bits = FbStipLeft (READ(src++),offset); \ remain = FB_STIP_UNIT - offset; \ fbFirstStipBits(len,stip); \ stip = FbMergeStip24Bits (0, stip, len); \ @@ -631,10 +629,11 @@ fbBltOne24 (FbStip *srcLine, if (leftMask) { mask = fbStipple24Bits[rot >> 3][stip]; - *dst = (*dst & ~leftMask) | (FbOpaqueStipple (mask, - FbRot24(fgxor, rot), - FbRot24(bgxor, rot)) - & leftMask); + WRITE(dst, (READ(dst) & ~leftMask) | + (FbOpaqueStipple (mask, + FbRot24(fgxor, rot), + FbRot24(bgxor, rot)) + & leftMask)); dst++; fbNextStipBits(rot,stip); } @@ -642,19 +641,20 @@ fbBltOne24 (FbStip *srcLine, while (nl--) { mask = fbStipple24Bits[rot>>3][stip]; - *dst = FbOpaqueStipple (mask, - FbRot24(fgxor, rot), - FbRot24(bgxor, rot)); + WRITE(dst, FbOpaqueStipple (mask, + FbRot24(fgxor, rot), + FbRot24(bgxor, rot))); dst++; fbNextStipBits(rot,stip); } if (rightMask) { mask = fbStipple24Bits[rot >> 3][stip]; - *dst = (*dst & ~rightMask) | (FbOpaqueStipple (mask, - FbRot24(fgxor, rot), - FbRot24(bgxor, rot)) - & rightMask); + WRITE(dst, (READ(dst) & ~rightMask) | + (FbOpaqueStipple (mask, + FbRot24(fgxor, rot), + FbRot24(bgxor, rot)) + & rightMask)); } dst += dstStride; src += srcStride; @@ -674,7 +674,7 @@ fbBltOne24 (FbStip *srcLine, if (stip) { mask = fbStipple24Bits[rot >> 3][stip] & leftMask; - *dst = (*dst & ~mask) | (FbRot24(fgxor, rot) & mask); + WRITE(dst, (READ(dst) & ~mask) | (FbRot24(fgxor, rot) & mask)); } dst++; fbNextStipBits (rot, stip); @@ -685,7 +685,7 @@ fbBltOne24 (FbStip *srcLine, if (stip) { mask = fbStipple24Bits[rot>>3][stip]; - *dst = (*dst & ~mask) | (FbRot24(fgxor,rot) & mask); + WRITE(dst, (READ(dst) & ~mask) | (FbRot24(fgxor,rot) & mask)); } dst++; fbNextStipBits (rot, stip); @@ -695,7 +695,7 @@ fbBltOne24 (FbStip *srcLine, if (stip) { mask = fbStipple24Bits[rot >> 3][stip] & rightMask; - *dst = (*dst & ~mask) | (FbRot24(fgxor, rot) & mask); + WRITE(dst, (READ(dst) & ~mask) | (FbRot24(fgxor, rot) & mask)); } } dst += dstStride; @@ -712,12 +712,12 @@ fbBltOne24 (FbStip *srcLine, if (leftMask) { mask = fbStipple24Bits[rot >> 3][stip]; - *dst = FbStippleRRopMask (*dst, mask, - FbRot24(fgand, rot), - FbRot24(fgxor, rot), - FbRot24(bgand, rot), - FbRot24(bgxor, rot), - leftMask); + WRITE(dst, FbStippleRRopMask (READ(dst), mask, + FbRot24(fgand, rot), + FbRot24(fgxor, rot), + FbRot24(bgand, rot), + FbRot24(bgxor, rot), + leftMask)); dst++; fbNextStipBits(rot,stip); } @@ -725,23 +725,23 @@ fbBltOne24 (FbStip *srcLine, while (nl--) { mask = fbStipple24Bits[rot >> 3][stip]; - *dst = FbStippleRRop (*dst, mask, - FbRot24(fgand, rot), - FbRot24(fgxor, rot), - FbRot24(bgand, rot), - FbRot24(bgxor, rot)); + WRITE(dst, FbStippleRRop (READ(dst), mask, + FbRot24(fgand, rot), + FbRot24(fgxor, rot), + FbRot24(bgand, rot), + FbRot24(bgxor, rot))); dst++; fbNextStipBits(rot,stip); } if (rightMask) { mask = fbStipple24Bits[rot >> 3][stip]; - *dst = FbStippleRRopMask (*dst, mask, - FbRot24(fgand, rot), - FbRot24(fgxor, rot), - FbRot24(bgand, rot), - FbRot24(bgxor, rot), - rightMask); + WRITE(dst, FbStippleRRopMask (READ(dst), mask, + FbRot24(fgand, rot), + FbRot24(fgxor, rot), + FbRot24(bgand, rot), + FbRot24(bgxor, rot), + rightMask)); } dst += dstStride; } @@ -832,7 +832,7 @@ fbBltPlane (FbBits *src, if (srcBpp == 24) srcMask0 = FbRot24(pm,rot0) & FbBitsMask(0, srcBpp); #endif - srcBits = *s++; + srcBits = READ(s++); dstMask = dstMaskFirst; dstUnion = 0; @@ -844,7 +844,7 @@ fbBltPlane (FbBits *src, { if (!srcMask) { - srcBits = *s++; + srcBits = READ(s++); #ifdef FB_24BIT if (srcBpp == 24) srcMask0 = FbNext24Pix(srcMask0) & FbBitsMask(0,24); @@ -853,9 +853,9 @@ fbBltPlane (FbBits *src, } if (!dstMask) { - *d = FbStippleRRopMask(*d, dstBits, - fgand, fgxor, bgand, bgxor, - dstUnion); + WRITE(d, FbStippleRRopMask(READ(d), dstBits, + fgand, fgxor, bgand, bgxor, + dstUnion)); d++; dstMask = FbStipMask(0,1); dstUnion = 0; @@ -871,9 +871,9 @@ fbBltPlane (FbBits *src, dstMask = FbStipRight(dstMask,1); } if (dstUnion) - *d = FbStippleRRopMask(*d,dstBits, - fgand, fgxor, bgand, bgxor, - dstUnion); + WRITE(d, FbStippleRRopMask(READ(d),dstBits, + fgand, fgxor, bgand, bgxor, + dstUnion)); } } diff --git a/nx-X11/programs/Xserver/fb/fbbstore.c b/nx-X11/programs/Xserver/fb/fbbstore.c index 75f6084c07..f527f8d811 100644 --- a/nx-X11/programs/Xserver/fb/fbbstore.c +++ b/nx-X11/programs/Xserver/fb/fbbstore.c @@ -1,6 +1,4 @@ /* - * Id: fbbstore.c,v 1.1 1999/11/02 03:54:45 keithp Exp $ - * * Copyright © 1998 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its diff --git a/nx-X11/programs/Xserver/fb/fbcmap.c b/nx-X11/programs/Xserver/fb/fbcmap.c index ec8ddff4f1..7730de92f4 100644 --- a/nx-X11/programs/Xserver/fb/fbcmap.c +++ b/nx-X11/programs/Xserver/fb/fbcmap.c @@ -1,4 +1,3 @@ -/* $XConsortium: fbcmap.c,v 4.19 94/04/17 20:28:46 dpw Exp $ */ /************************************************************ Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA. @@ -40,7 +39,12 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "resource.h" #include "fb.h" -#ifndef XFree86Server +#ifdef XFree86Server +#error "You should be compiling fbcmap_mi.c instead of fbcmap.c!" +#endif + + + ColormapPtr FbInstalledMaps[MAXSCREENS]; int @@ -585,87 +589,3 @@ fbInitVisuals (VisualPtr *visualp, *defaultVisp = depth[i].vids[j]; return TRUE; } -#else - -#include "micmap.h" - -int -fbListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps) -{ - return miListInstalledColormaps(pScreen, pmaps); -} - -void -fbInstallColormap(ColormapPtr pmap) -{ - miInstallColormap(pmap); -} - -void -fbUninstallColormap(ColormapPtr pmap) -{ - miUninstallColormap(pmap); -} - -void -fbResolveColor(unsigned short *pred, - unsigned short *pgreen, - unsigned short *pblue, - VisualPtr pVisual) -{ - miResolveColor(pred, pgreen, pblue, pVisual); -} - -Bool -fbInitializeColormap(ColormapPtr pmap) -{ - return miInitializeColormap(pmap); -} - -int -fbExpandDirectColors (ColormapPtr pmap, - int ndef, - xColorItem *indefs, - xColorItem *outdefs) -{ - return miExpandDirectColors(pmap, ndef, indefs, outdefs); -} - -Bool -fbCreateDefColormap(ScreenPtr pScreen) -{ - return miCreateDefColormap(pScreen); -} - -void -fbClearVisualTypes(void) -{ - miClearVisualTypes(); -} - -Bool -fbSetVisualTypes (int depth, int visuals, int bitsPerRGB) -{ - return miSetVisualTypes(depth, visuals, bitsPerRGB, -1); -} - -/* - * Given a list of formats for a screen, create a list - * of visuals and depths for the screen which coorespond to - * the set which can be used with this version of fb. - */ - -Bool -fbInitVisuals (VisualPtr *visualp, - DepthPtr *depthp, - int *nvisualp, - int *ndepthp, - int *rootDepthp, - VisualID *defaultVisp, - unsigned long sizes, - int bitsPerRGB) -{ - return miInitVisuals(visualp, depthp, nvisualp, ndepthp, rootDepthp, - defaultVisp, sizes, bitsPerRGB, -1); -} -#endif diff --git a/nx-X11/programs/Xserver/fb/fbcmap_mi.c b/nx-X11/programs/Xserver/fb/fbcmap_mi.c new file mode 100644 index 0000000000..19fa782727 --- /dev/null +++ b/nx-X11/programs/Xserver/fb/fbcmap_mi.c @@ -0,0 +1,123 @@ +/************************************************************ +Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA. + + 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 no- +tice appear in all copies and that both that copyright no- +tice and this permission notice appear in supporting docu- +mentation, and that the names of Sun or X Consortium +not be used in advertising or publicity pertaining to +distribution of the software without specific prior +written permission. Sun and X Consortium make no +representations about the suitability of this software for +any purpose. It is provided "as is" without any express or +implied warranty. + +SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT- +NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI- +ABLE 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. + +********************************************************/ + + +/** + * This version of fbcmap.c is implemented in terms of mi functions. + * These functions used to be in fbcmap.c and depended upon the symbol + * XFree86Server being defined. + */ + + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include +#include "fb.h" +#include "micmap.h" + +int +fbListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps) +{ + return miListInstalledColormaps(pScreen, pmaps); +} + +void +fbInstallColormap(ColormapPtr pmap) +{ + miInstallColormap(pmap); +} + +void +fbUninstallColormap(ColormapPtr pmap) +{ + miUninstallColormap(pmap); +} + +void +fbResolveColor(unsigned short *pred, + unsigned short *pgreen, + unsigned short *pblue, + VisualPtr pVisual) +{ + miResolveColor(pred, pgreen, pblue, pVisual); +} + +Bool +fbInitializeColormap(ColormapPtr pmap) +{ + return miInitializeColormap(pmap); +} + +int +fbExpandDirectColors (ColormapPtr pmap, + int ndef, + xColorItem *indefs, + xColorItem *outdefs) +{ + return miExpandDirectColors(pmap, ndef, indefs, outdefs); +} + +Bool +fbCreateDefColormap(ScreenPtr pScreen) +{ + return miCreateDefColormap(pScreen); +} + +void +fbClearVisualTypes(void) +{ + miClearVisualTypes(); +} + +Bool +fbSetVisualTypes (int depth, int visuals, int bitsPerRGB) +{ + return miSetVisualTypes(depth, visuals, bitsPerRGB, -1); +} + +/* + * Given a list of formats for a screen, create a list + * of visuals and depths for the screen which coorespond to + * the set which can be used with this version of fb. + */ +Bool +fbInitVisuals (VisualPtr *visualp, + DepthPtr *depthp, + int *nvisualp, + int *ndepthp, + int *rootDepthp, + VisualID *defaultVisp, + unsigned long sizes, + int bitsPerRGB) +{ + return miInitVisuals(visualp, depthp, nvisualp, ndepthp, rootDepthp, + defaultVisp, sizes, bitsPerRGB, -1); +} diff --git a/nx-X11/programs/Xserver/fb/fbcompose.c b/nx-X11/programs/Xserver/fb/fbcompose.c deleted file mode 100644 index 7699ae755c..0000000000 --- a/nx-X11/programs/Xserver/fb/fbcompose.c +++ /dev/null @@ -1,3652 +0,0 @@ -/* - * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc. - * 2005 Lars Knoll & Zack Rusin, Trolltech - * - * 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. - * - * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS - * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS 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. - */ - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#include "fb.h" - -#ifdef RENDER - -#include -#include -#include -#include - -#include "picturestr.h" -#include "mipict.h" -#include "fbpict.h" - -#define mod(a,b) ((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (b) - (-a) % (b)) - -#define SCANLINE_BUFFER_LENGTH 2048 - -typedef FASTCALL void (*fetchProc)(const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed); - -/* - * All of the fetch functions - */ - -static FASTCALL void -fbFetch_a8r8g8b8 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed) -{ - memcpy(buffer, (const CARD32 *)bits + x, width*sizeof(CARD32)); -} - -static FASTCALL void -fbFetch_x8r8g8b8 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed) -{ - const CARD32 *pixel = (const CARD32 *)bits + x; - const CARD32 *end = pixel + width; - while (pixel < end) { - *buffer++ = *pixel++ | 0xff000000; - } -} - -static FASTCALL void -fbFetch_a8b8g8r8 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed) -{ - const CARD32 *pixel = (CARD32 *)bits + x; - const CARD32 *end = pixel + width; - while (pixel < end) { - *buffer++ = ((*pixel & 0xff00ff00) | - ((*pixel >> 16) & 0xff) | - ((*pixel & 0xff) << 16)); - ++pixel; - } -} - -static FASTCALL void -fbFetch_x8b8g8r8 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed) -{ - const CARD32 *pixel = (CARD32 *)bits + x; - const CARD32 *end = pixel + width; - while (pixel < end) { - *buffer++ = 0xff000000 | - ((*pixel & 0x0000ff00) | - ((*pixel >> 16) & 0xff) | - ((*pixel & 0xff) << 16)); - ++pixel; - } -} - -static FASTCALL void -fbFetch_r8g8b8 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed) -{ - const CARD8 *pixel = (const CARD8 *)bits + 3*x; - const CARD8 *end = pixel + 3*width; - while (pixel < end) { - CARD32 b = Fetch24(pixel) | 0xff000000; - pixel += 3; - *buffer++ = b; - } -} - -static FASTCALL void -fbFetch_b8g8r8 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed) -{ - const CARD8 *pixel = (const CARD8 *)bits + 3*x; - const CARD8 *end = pixel + 3*width; - while (pixel < end) { - CARD32 b = 0xff000000; -#if IMAGE_BYTE_ORDER == MSBFirst - b |= (*pixel++); - b |= (*pixel++ << 8); - b |= (*pixel++ << 16); -#else - b |= (*pixel++ << 16); - b |= (*pixel++ << 8); - b |= (*pixel++); -#endif - } -} - -static FASTCALL void -fbFetch_r5g6b5 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed) -{ - const CARD16 *pixel = (const CARD16 *)bits + x; - const CARD16 *end = pixel + width; - while (pixel < end) { - CARD32 p = *pixel++; - CARD32 r = (((p) << 3) & 0xf8) | - (((p) << 5) & 0xfc00) | - (((p) << 8) & 0xf80000); - r |= (r >> 5) & 0x70007; - r |= (r >> 6) & 0x300; - *buffer++ = 0xff000000 | r; - } -} - -static FASTCALL void -fbFetch_b5g6r5 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed) -{ - const CARD16 *pixel = (const CARD16 *)bits + x; - const CARD16 *end = pixel + width; - while (pixel < end) { - CARD32 p = *pixel++; - CARD32 r,g,b; - - b = ((p & 0xf800) | ((p & 0xe000) >> 5)) >> 8; - g = ((p & 0x07e0) | ((p & 0x0600) >> 6)) << 5; - r = ((p & 0x001c) | ((p & 0x001f) << 5)) << 14; - *buffer++ = (0xff000000 | r | g | b); - } -} - -static FASTCALL void -fbFetch_a1r5g5b5 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed) -{ - const CARD16 *pixel = (const CARD16 *)bits + x; - const CARD16 *end = pixel + width; - while (pixel < end) { - CARD32 p = *pixel++; - CARD32 r,g,b, a; - - a = (CARD32) ((CARD8) (0 - ((p & 0x8000) >> 15))) << 24; - r = ((p & 0x7c00) | ((p & 0x7000) >> 5)) << 9; - g = ((p & 0x03e0) | ((p & 0x0380) >> 5)) << 6; - b = ((p & 0x001c) | ((p & 0x001f) << 5)) >> 2; - *buffer++ = (a | r | g | b); - } -} - -static FASTCALL void -fbFetch_x1r5g5b5 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed) -{ - const CARD16 *pixel = (const CARD16 *)bits + x; - const CARD16 *end = pixel + width; - while (pixel < end) { - CARD32 p = *pixel++; - CARD32 r,g,b; - - r = ((p & 0x7c00) | ((p & 0x7000) >> 5)) << 9; - g = ((p & 0x03e0) | ((p & 0x0380) >> 5)) << 6; - b = ((p & 0x001c) | ((p & 0x001f) << 5)) >> 2; - *buffer++ = (0xff000000 | r | g | b); - } -} - -static FASTCALL void -fbFetch_a1b5g5r5 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed) -{ - const CARD16 *pixel = (const CARD16 *)bits + x; - const CARD16 *end = pixel + width; - while (pixel < end) { - CARD32 p = *pixel++; - CARD32 r,g,b, a; - - a = (CARD32) ((CARD8) (0 - ((p & 0x8000) >> 15))) << 24; - b = ((p & 0x7c00) | ((p & 0x7000) >> 5)) >> 7; - g = ((p & 0x03e0) | ((p & 0x0380) >> 5)) << 6; - r = ((p & 0x001c) | ((p & 0x001f) << 5)) << 14; - *buffer++ = (a | r | g | b); - } -} - -static FASTCALL void -fbFetch_x1b5g5r5 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed) -{ - const CARD16 *pixel = (const CARD16 *)bits + x; - const CARD16 *end = pixel + width; - while (pixel < end) { - CARD32 p = *pixel++; - CARD32 r,g,b; - - b = ((p & 0x7c00) | ((p & 0x7000) >> 5)) >> 7; - g = ((p & 0x03e0) | ((p & 0x0380) >> 5)) << 6; - r = ((p & 0x001c) | ((p & 0x001f) << 5)) << 14; - *buffer++ = (0xff000000 | r | g | b); - } -} - -static FASTCALL void -fbFetch_a4r4g4b4 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed) -{ - const CARD16 *pixel = (const CARD16 *)bits + x; - const CARD16 *end = pixel + width; - while (pixel < end) { - CARD32 p = *pixel++; - CARD32 r,g,b, a; - - a = ((p & 0xf000) | ((p & 0xf000) >> 4)) << 16; - r = ((p & 0x0f00) | ((p & 0x0f00) >> 4)) << 12; - g = ((p & 0x00f0) | ((p & 0x00f0) >> 4)) << 8; - b = ((p & 0x000f) | ((p & 0x000f) << 4)); - *buffer++ = (a | r | g | b); - } -} - -static FASTCALL void -fbFetch_x4r4g4b4 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed) -{ - const CARD16 *pixel = (const CARD16 *)bits + x; - const CARD16 *end = pixel + width; - while (pixel < end) { - CARD32 p = *pixel++; - CARD32 r,g,b; - - r = ((p & 0x0f00) | ((p & 0x0f00) >> 4)) << 12; - g = ((p & 0x00f0) | ((p & 0x00f0) >> 4)) << 8; - b = ((p & 0x000f) | ((p & 0x000f) << 4)); - *buffer++ = (0xff000000 | r | g | b); - } -} - -static FASTCALL void -fbFetch_a4b4g4r4 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed) -{ - const CARD16 *pixel = (const CARD16 *)bits + x; - const CARD16 *end = pixel + width; - while (pixel < end) { - CARD32 p = *pixel++; - CARD32 r,g,b, a; - - a = ((p & 0xf000) | ((p & 0xf000) >> 4)) << 16; - b = ((p & 0x0f00) | ((p & 0x0f00) >> 4)) << 12; - g = ((p & 0x00f0) | ((p & 0x00f0) >> 4)) << 8; - r = ((p & 0x000f) | ((p & 0x000f) << 4)); - *buffer++ = (a | r | g | b); - } -} - -static FASTCALL void -fbFetch_x4b4g4r4 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed) -{ - const CARD16 *pixel = (const CARD16 *)bits + x; - const CARD16 *end = pixel + width; - while (pixel < end) { - CARD32 p = *pixel++; - CARD32 r,g,b; - - b = ((p & 0x0f00) | ((p & 0x0f00) >> 4)) << 12; - g = ((p & 0x00f0) | ((p & 0x00f0) >> 4)) << 8; - r = ((p & 0x000f) | ((p & 0x000f) << 4)); - *buffer++ = (0xff000000 | r | g | b); - } -} - -static FASTCALL void -fbFetch_a8 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed) -{ - const CARD8 *pixel = (const CARD8 *)bits + x; - const CARD8 *end = pixel + width; - while (pixel < end) { - *buffer++ = (*pixel++) << 24; - } -} - -static FASTCALL void -fbFetch_r3g3b2 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed) -{ - const CARD8 *pixel = (const CARD8 *)bits + x; - const CARD8 *end = pixel + width; - while (pixel < end) { - CARD32 p = *pixel++; - CARD32 r,g,b; - - r = ((p & 0xe0) | ((p & 0xe0) >> 3) | ((p & 0xc0) >> 6)) << 16; - g = ((p & 0x1c) | ((p & 0x18) >> 3) | ((p & 0x1c) << 3)) << 8; - b = (((p & 0x03) ) | - ((p & 0x03) << 2) | - ((p & 0x03) << 4) | - ((p & 0x03) << 6)); - *buffer++ = (0xff000000 | r | g | b); - } -} - -static FASTCALL void -fbFetch_b2g3r3 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed) -{ - const CARD8 *pixel = (const CARD8 *)bits + x; - const CARD8 *end = pixel + width; - while (pixel < end) { - CARD32 p = *pixel++; - CARD32 r,g,b; - - b = (((p & 0xc0) ) | - ((p & 0xc0) >> 2) | - ((p & 0xc0) >> 4) | - ((p & 0xc0) >> 6)); - g = ((p & 0x38) | ((p & 0x38) >> 3) | ((p & 0x30) << 2)) << 8; - r = (((p & 0x07) ) | - ((p & 0x07) << 3) | - ((p & 0x06) << 6)) << 16; - *buffer++ = (0xff000000 | r | g | b); - } -} - -static FASTCALL void -fbFetch_a2r2g2b2 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed) -{ - const CARD8 *pixel = (const CARD8 *)bits + x; - const CARD8 *end = pixel + width; - while (pixel < end) { - CARD32 p = *pixel++; - CARD32 a,r,g,b; - - a = ((p & 0xc0) * 0x55) << 18; - r = ((p & 0x30) * 0x55) << 12; - g = ((p & 0x0c) * 0x55) << 6; - b = ((p & 0x03) * 0x55); - *buffer++ = a|r|g|b; - } -} - -static FASTCALL void -fbFetch_a2b2g2r2 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed) -{ - const CARD8 *pixel = (const CARD8 *)bits + x; - const CARD8 *end = pixel + width; - while (pixel < end) { - CARD32 p = *pixel++; - CARD32 a,r,g,b; - - a = ((p & 0xc0) * 0x55) << 18; - b = ((p & 0x30) * 0x55) >> 6; - g = ((p & 0x0c) * 0x55) << 6; - r = ((p & 0x03) * 0x55) << 16; - *buffer++ = a|r|g|b; - } -} - -static FASTCALL void -fbFetch_c8 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed) -{ - const CARD8 *pixel = (const CARD8 *)bits + x; - const CARD8 *end = pixel + width; - while (pixel < end) { - CARD32 p = *pixel++; - *buffer++ = indexed->rgba[p]; - } -} - -static FASTCALL void -fbFetch_x4a4 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed) -{ - const CARD8 *pixel = (const CARD8 *)bits + x; - const CARD8 *end = pixel + width; - while (pixel < end) { - CARD8 p = (*pixel++) & 0xf; - *buffer++ = (p | (p << 4)) << 24; - } -} - -#define Fetch8(l,o) (((CARD8 *) (l))[(o) >> 2]) -#if IMAGE_BYTE_ORDER == MSBFirst -#define Fetch4(l,o) ((o) & 2 ? Fetch8(l,o) & 0xf : Fetch8(l,o) >> 4) -#else -#define Fetch4(l,o) ((o) & 2 ? Fetch8(l,o) >> 4 : Fetch8(l,o) & 0xf) -#endif - -static FASTCALL void -fbFetch_a4 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed) -{ - int i; - for (i = 0; i < width; ++i) { - CARD32 p = Fetch4(bits, i + x); - - p |= p << 4; - *buffer++ = p << 24; - } -} - -static FASTCALL void -fbFetch_r1g2b1 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed) -{ - int i; - for (i = 0; i < width; ++i) { - CARD32 p = Fetch4(bits, i + x); - CARD32 r,g,b; - - r = ((p & 0x8) * 0xff) << 13; - g = ((p & 0x6) * 0x55) << 7; - b = ((p & 0x1) * 0xff); - *buffer++ = 0xff000000|r|g|b; - } -} - -static FASTCALL void -fbFetch_b1g2r1 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed) -{ - int i; - for (i = 0; i < width; ++i) { - CARD32 p = Fetch4(bits, i + x); - CARD32 r,g,b; - - b = ((p & 0x8) * 0xff) >> 3; - g = ((p & 0x6) * 0x55) << 7; - r = ((p & 0x1) * 0xff) << 16; - *buffer++ = 0xff000000|r|g|b; - } -} - -static FASTCALL void -fbFetch_a1r1g1b1 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed) -{ - int i; - for (i = 0; i < width; ++i) { - CARD32 p = Fetch4(bits, i + x); - CARD32 a,r,g,b; - - a = ((p & 0x8) * 0xff) << 21; - r = ((p & 0x4) * 0xff) << 14; - g = ((p & 0x2) * 0xff) << 7; - b = ((p & 0x1) * 0xff); - *buffer++ = a|r|g|b; - } -} - -static FASTCALL void -fbFetch_a1b1g1r1 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed) -{ - int i; - for (i = 0; i < width; ++i) { - CARD32 p = Fetch4(bits, i + x); - CARD32 a,r,g,b; - - a = ((p & 0x8) * 0xff) << 21; - r = ((p & 0x4) * 0xff) >> 3; - g = ((p & 0x2) * 0xff) << 7; - b = ((p & 0x1) * 0xff) << 16; - *buffer++ = a|r|g|b; - } -} - -static FASTCALL void -fbFetch_c4 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed) -{ - int i; - for (i = 0; i < width; ++i) { - CARD32 p = Fetch4(bits, i + x); - - *buffer++ = indexed->rgba[p]; - } -} - - -static FASTCALL void -fbFetch_a1 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed) -{ - int i; - for (i = 0; i < width; ++i) { - CARD32 p = ((CARD32 *)bits)[(i + x) >> 5]; - CARD32 a; -#if BITMAP_BIT_ORDER == MSBFirst - a = p >> (0x1f - ((i+x) & 0x1f)); -#else - a = p >> ((i+x) & 0x1f); -#endif - a = a & 1; - a |= a << 1; - a |= a << 2; - a |= a << 4; - *buffer++ = a << 24; - } -} - -static FASTCALL void -fbFetch_g1 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed) -{ - int i; - for (i = 0; i < width; ++i) { - CARD32 p = ((CARD32 *)bits)[(i+x) >> 5]; - CARD32 a; -#if BITMAP_BIT_ORDER == MSBFirst - a = p >> (0x1f - ((i+x) & 0x1f)); -#else - a = p >> ((i+x) & 0x1f); -#endif - a = a & 1; - *buffer++ = indexed->rgba[a]; - } -} - -static fetchProc fetchProcForPicture (PicturePtr pict) -{ - switch(pict->format) { - case PICT_a8r8g8b8: return fbFetch_a8r8g8b8; - case PICT_x8r8g8b8: return fbFetch_x8r8g8b8; - case PICT_a8b8g8r8: return fbFetch_a8b8g8r8; - case PICT_x8b8g8r8: return fbFetch_x8b8g8r8; - - /* 24bpp formats */ - case PICT_r8g8b8: return fbFetch_r8g8b8; - case PICT_b8g8r8: return fbFetch_b8g8r8; - - /* 16bpp formats */ - case PICT_r5g6b5: return fbFetch_r5g6b5; - case PICT_b5g6r5: return fbFetch_b5g6r5; - - case PICT_a1r5g5b5: return fbFetch_a1r5g5b5; - case PICT_x1r5g5b5: return fbFetch_x1r5g5b5; - case PICT_a1b5g5r5: return fbFetch_a1b5g5r5; - case PICT_x1b5g5r5: return fbFetch_x1b5g5r5; - case PICT_a4r4g4b4: return fbFetch_a4r4g4b4; - case PICT_x4r4g4b4: return fbFetch_x4r4g4b4; - case PICT_a4b4g4r4: return fbFetch_a4b4g4r4; - case PICT_x4b4g4r4: return fbFetch_x4b4g4r4; - - /* 8bpp formats */ - case PICT_a8: return fbFetch_a8; - case PICT_r3g3b2: return fbFetch_r3g3b2; - case PICT_b2g3r3: return fbFetch_b2g3r3; - case PICT_a2r2g2b2: return fbFetch_a2r2g2b2; - case PICT_a2b2g2r2: return fbFetch_a2b2g2r2; - case PICT_c8: return fbFetch_c8; - case PICT_g8: return fbFetch_c8; - case PICT_x4a4: return fbFetch_x4a4; - - /* 4bpp formats */ - case PICT_a4: return fbFetch_a4; - case PICT_r1g2b1: return fbFetch_r1g2b1; - case PICT_b1g2r1: return fbFetch_b1g2r1; - case PICT_a1r1g1b1: return fbFetch_a1r1g1b1; - case PICT_a1b1g1r1: return fbFetch_a1b1g1r1; - case PICT_c4: return fbFetch_c4; - case PICT_g4: return fbFetch_c4; - - /* 1bpp formats */ - case PICT_a1: return fbFetch_a1; - case PICT_g1: return fbFetch_g1; - default: - return NULL; - } -} - -/* - * Pixel wise fetching - */ - -typedef FASTCALL CARD32 (*fetchPixelProc)(const FbBits *bits, int offset, miIndexedPtr indexed); - -static FASTCALL CARD32 -fbFetchPixel_a8r8g8b8 (const FbBits *bits, int offset, miIndexedPtr indexed) -{ - return ((CARD32 *)bits)[offset]; -} - -static FASTCALL CARD32 -fbFetchPixel_x8r8g8b8 (const FbBits *bits, int offset, miIndexedPtr indexed) -{ - return ((CARD32 *)bits)[offset] | 0xff000000; -} - -static FASTCALL CARD32 -fbFetchPixel_a8b8g8r8 (const FbBits *bits, int offset, miIndexedPtr indexed) -{ - CARD32 pixel = ((CARD32 *)bits)[offset]; - - return ((pixel & 0xff000000) | - ((pixel >> 16) & 0xff) | - (pixel & 0x0000ff00) | - ((pixel & 0xff) << 16)); -} - -static FASTCALL CARD32 -fbFetchPixel_x8b8g8r8 (const FbBits *bits, int offset, miIndexedPtr indexed) -{ - CARD32 pixel = ((CARD32 *)bits)[offset]; - - return ((0xff000000) | - ((pixel >> 16) & 0xff) | - (pixel & 0x0000ff00) | - ((pixel & 0xff) << 16)); -} - -static FASTCALL CARD32 -fbFetchPixel_r8g8b8 (const FbBits *bits, int offset, miIndexedPtr indexed) -{ - CARD8 *pixel = ((CARD8 *) bits) + (offset*3); -#if IMAGE_BYTE_ORDER == MSBFirst - return (0xff000000 | - (pixel[0] << 16) | - (pixel[1] << 8) | - (pixel[2])); -#else - return (0xff000000 | - (pixel[2] << 16) | - (pixel[1] << 8) | - (pixel[0])); -#endif -} - -static FASTCALL CARD32 -fbFetchPixel_b8g8r8 (const FbBits *bits, int offset, miIndexedPtr indexed) -{ - CARD8 *pixel = ((CARD8 *) bits) + (offset*3); -#if IMAGE_BYTE_ORDER == MSBFirst - return (0xff000000 | - (pixel[2] << 16) | - (pixel[1] << 8) | - (pixel[0])); -#else - return (0xff000000 | - (pixel[0] << 16) | - (pixel[1] << 8) | - (pixel[2])); -#endif -} - -static FASTCALL CARD32 -fbFetchPixel_r5g6b5 (const FbBits *bits, int offset, miIndexedPtr indexed) -{ - CARD32 pixel = ((CARD16 *) bits)[offset]; - CARD32 r,g,b; - - r = ((pixel & 0xf800) | ((pixel & 0xe000) >> 5)) << 8; - g = ((pixel & 0x07e0) | ((pixel & 0x0600) >> 6)) << 5; - b = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) >> 2; - return (0xff000000 | r | g | b); -} - -static FASTCALL CARD32 -fbFetchPixel_b5g6r5 (const FbBits *bits, int offset, miIndexedPtr indexed) -{ - CARD32 pixel = ((CARD16 *) bits)[offset]; - CARD32 r,g,b; - - b = ((pixel & 0xf800) | ((pixel & 0xe000) >> 5)) >> 8; - g = ((pixel & 0x07e0) | ((pixel & 0x0600) >> 6)) << 5; - r = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) << 14; - return (0xff000000 | r | g | b); -} - -static FASTCALL CARD32 -fbFetchPixel_a1r5g5b5 (const FbBits *bits, int offset, miIndexedPtr indexed) -{ - CARD32 pixel = ((CARD16 *) bits)[offset]; - CARD32 a,r,g,b; - - a = (CARD32) ((CARD8) (0 - ((pixel & 0x8000) >> 15))) << 24; - r = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) << 9; - g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6; - b = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) >> 2; - return (a | r | g | b); -} - -static FASTCALL CARD32 -fbFetchPixel_x1r5g5b5 (const FbBits *bits, int offset, miIndexedPtr indexed) -{ - CARD32 pixel = ((CARD16 *) bits)[offset]; - CARD32 r,g,b; - - r = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) << 9; - g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6; - b = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) >> 2; - return (0xff000000 | r | g | b); -} - -static FASTCALL CARD32 -fbFetchPixel_a1b5g5r5 (const FbBits *bits, int offset, miIndexedPtr indexed) -{ - CARD32 pixel = ((CARD16 *) bits)[offset]; - CARD32 a,r,g,b; - - a = (CARD32) ((CARD8) (0 - ((pixel & 0x8000) >> 15))) << 24; - b = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) >> 7; - g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6; - r = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) << 14; - return (a | r | g | b); -} - -static FASTCALL CARD32 -fbFetchPixel_x1b5g5r5 (const FbBits *bits, int offset, miIndexedPtr indexed) -{ - CARD32 pixel = ((CARD16 *) bits)[offset]; - CARD32 r,g,b; - - b = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) >> 7; - g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6; - r = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) << 14; - return (0xff000000 | r | g | b); -} - -static FASTCALL CARD32 -fbFetchPixel_a4r4g4b4 (const FbBits *bits, int offset, miIndexedPtr indexed) -{ - CARD32 pixel = ((CARD16 *) bits)[offset]; - CARD32 a,r,g,b; - - a = ((pixel & 0xf000) | ((pixel & 0xf000) >> 4)) << 16; - r = ((pixel & 0x0f00) | ((pixel & 0x0f00) >> 4)) << 12; - g = ((pixel & 0x00f0) | ((pixel & 0x00f0) >> 4)) << 8; - b = ((pixel & 0x000f) | ((pixel & 0x000f) << 4)); - return (a | r | g | b); -} - -static FASTCALL CARD32 -fbFetchPixel_x4r4g4b4 (const FbBits *bits, int offset, miIndexedPtr indexed) -{ - CARD32 pixel = ((CARD16 *) bits)[offset]; - CARD32 r,g,b; - - r = ((pixel & 0x0f00) | ((pixel & 0x0f00) >> 4)) << 12; - g = ((pixel & 0x00f0) | ((pixel & 0x00f0) >> 4)) << 8; - b = ((pixel & 0x000f) | ((pixel & 0x000f) << 4)); - return (0xff000000 | r | g | b); -} - -static FASTCALL CARD32 -fbFetchPixel_a4b4g4r4 (const FbBits *bits, int offset, miIndexedPtr indexed) -{ - CARD32 pixel = ((CARD16 *) bits)[offset]; - CARD32 a,r,g,b; - - a = ((pixel & 0xf000) | ((pixel & 0xf000) >> 4)) << 16; - b = ((pixel & 0x0f00) | ((pixel & 0x0f00) >> 4)) << 12; - g = ((pixel & 0x00f0) | ((pixel & 0x00f0) >> 4)) << 8; - r = ((pixel & 0x000f) | ((pixel & 0x000f) << 4)); - return (a | r | g | b); -} - -static FASTCALL CARD32 -fbFetchPixel_x4b4g4r4 (const FbBits *bits, int offset, miIndexedPtr indexed) -{ - CARD32 pixel = ((CARD16 *) bits)[offset]; - CARD32 r,g,b; - - b = ((pixel & 0x0f00) | ((pixel & 0x0f00) >> 4)) << 12; - g = ((pixel & 0x00f0) | ((pixel & 0x00f0) >> 4)) << 8; - r = ((pixel & 0x000f) | ((pixel & 0x000f) << 4)); - return (0xff000000 | r | g | b); -} - -static FASTCALL CARD32 -fbFetchPixel_a8 (const FbBits *bits, int offset, miIndexedPtr indexed) -{ - CARD32 pixel = ((CARD8 *) bits)[offset]; - - return pixel << 24; -} - -static FASTCALL CARD32 -fbFetchPixel_r3g3b2 (const FbBits *bits, int offset, miIndexedPtr indexed) -{ - CARD32 pixel = ((CARD8 *) bits)[offset]; - CARD32 r,g,b; - - r = ((pixel & 0xe0) | ((pixel & 0xe0) >> 3) | ((pixel & 0xc0) >> 6)) << 16; - g = ((pixel & 0x1c) | ((pixel & 0x18) >> 3) | ((pixel & 0x1c) << 3)) << 8; - b = (((pixel & 0x03) ) | - ((pixel & 0x03) << 2) | - ((pixel & 0x03) << 4) | - ((pixel & 0x03) << 6)); - return (0xff000000 | r | g | b); -} - -static FASTCALL CARD32 -fbFetchPixel_b2g3r3 (const FbBits *bits, int offset, miIndexedPtr indexed) -{ - CARD32 pixel = ((CARD8 *) bits)[offset]; - CARD32 r,g,b; - - b = (((pixel & 0xc0) ) | - ((pixel & 0xc0) >> 2) | - ((pixel & 0xc0) >> 4) | - ((pixel & 0xc0) >> 6)); - g = ((pixel & 0x38) | ((pixel & 0x38) >> 3) | ((pixel & 0x30) << 2)) << 8; - r = (((pixel & 0x07) ) | - ((pixel & 0x07) << 3) | - ((pixel & 0x06) << 6)) << 16; - return (0xff000000 | r | g | b); -} - -static FASTCALL CARD32 -fbFetchPixel_a2r2g2b2 (const FbBits *bits, int offset, miIndexedPtr indexed) -{ - CARD32 pixel = ((CARD8 *) bits)[offset]; - CARD32 a,r,g,b; - - a = ((pixel & 0xc0) * 0x55) << 18; - r = ((pixel & 0x30) * 0x55) << 12; - g = ((pixel & 0x0c) * 0x55) << 6; - b = ((pixel & 0x03) * 0x55); - return a|r|g|b; -} - -static FASTCALL CARD32 -fbFetchPixel_a2b2g2r2 (const FbBits *bits, int offset, miIndexedPtr indexed) -{ - CARD32 pixel = ((CARD8 *) bits)[offset]; - CARD32 a,r,g,b; - - a = ((pixel & 0xc0) * 0x55) << 18; - b = ((pixel & 0x30) * 0x55) >> 6; - g = ((pixel & 0x0c) * 0x55) << 6; - r = ((pixel & 0x03) * 0x55) << 16; - return a|r|g|b; -} - -static FASTCALL CARD32 -fbFetchPixel_c8 (const FbBits *bits, int offset, miIndexedPtr indexed) -{ - CARD32 pixel = ((CARD8 *) bits)[offset]; - return indexed->rgba[pixel]; -} - -#define Fetch8(l,o) (((CARD8 *) (l))[(o) >> 2]) -#if IMAGE_BYTE_ORDER == MSBFirst -#define Fetch4(l,o) ((o) & 2 ? Fetch8(l,o) & 0xf : Fetch8(l,o) >> 4) -#else -#define Fetch4(l,o) ((o) & 2 ? Fetch8(l,o) >> 4 : Fetch8(l,o) & 0xf) -#endif - -static FASTCALL CARD32 -fbFetchPixel_a4 (const FbBits *bits, int offset, miIndexedPtr indexed) -{ - CARD32 pixel = Fetch4(bits, offset); - - pixel |= pixel << 4; - return pixel << 24; -} - -static FASTCALL CARD32 -fbFetchPixel_r1g2b1 (const FbBits *bits, int offset, miIndexedPtr indexed) -{ - CARD32 pixel = Fetch4(bits, offset); - CARD32 r,g,b; - - r = ((pixel & 0x8) * 0xff) << 13; - g = ((pixel & 0x6) * 0x55) << 7; - b = ((pixel & 0x1) * 0xff); - return 0xff000000|r|g|b; -} - -static FASTCALL CARD32 -fbFetchPixel_b1g2r1 (const FbBits *bits, int offset, miIndexedPtr indexed) -{ - CARD32 pixel = Fetch4(bits, offset); - CARD32 r,g,b; - - b = ((pixel & 0x8) * 0xff) >> 3; - g = ((pixel & 0x6) * 0x55) << 7; - r = ((pixel & 0x1) * 0xff) << 16; - return 0xff000000|r|g|b; -} - -static FASTCALL CARD32 -fbFetchPixel_a1r1g1b1 (const FbBits *bits, int offset, miIndexedPtr indexed) -{ - CARD32 pixel = Fetch4(bits, offset); - CARD32 a,r,g,b; - - a = ((pixel & 0x8) * 0xff) << 21; - r = ((pixel & 0x4) * 0xff) << 14; - g = ((pixel & 0x2) * 0xff) << 7; - b = ((pixel & 0x1) * 0xff); - return a|r|g|b; -} - -static FASTCALL CARD32 -fbFetchPixel_a1b1g1r1 (const FbBits *bits, int offset, miIndexedPtr indexed) -{ - CARD32 pixel = Fetch4(bits, offset); - CARD32 a,r,g,b; - - a = ((pixel & 0x8) * 0xff) << 21; - r = ((pixel & 0x4) * 0xff) >> 3; - g = ((pixel & 0x2) * 0xff) << 7; - b = ((pixel & 0x1) * 0xff) << 16; - return a|r|g|b; -} - -static FASTCALL CARD32 -fbFetchPixel_c4 (const FbBits *bits, int offset, miIndexedPtr indexed) -{ - CARD32 pixel = Fetch4(bits, offset); - - return indexed->rgba[pixel]; -} - - -static FASTCALL CARD32 -fbFetchPixel_a1 (const FbBits *bits, int offset, miIndexedPtr indexed) -{ - CARD32 pixel = ((CARD32 *)bits)[offset >> 5]; - CARD32 a; -#if BITMAP_BIT_ORDER == MSBFirst - a = pixel >> (0x1f - (offset & 0x1f)); -#else - a = pixel >> (offset & 0x1f); -#endif - a = a & 1; - a |= a << 1; - a |= a << 2; - a |= a << 4; - return a << 24; -} - -static FASTCALL CARD32 -fbFetchPixel_g1 (const FbBits *bits, int offset, miIndexedPtr indexed) -{ - CARD32 pixel = ((CARD32 *)bits)[offset >> 5]; - CARD32 a; -#if BITMAP_BIT_ORDER == MSBFirst - a = pixel >> (0x1f - (offset & 0x1f)); -#else - a = pixel >> (offset & 0x1f); -#endif - a = a & 1; - return indexed->rgba[a]; -} - -static fetchPixelProc fetchPixelProcForPicture (PicturePtr pict) -{ - switch(pict->format) { - case PICT_a8r8g8b8: return fbFetchPixel_a8r8g8b8; - case PICT_x8r8g8b8: return fbFetchPixel_x8r8g8b8; - case PICT_a8b8g8r8: return fbFetchPixel_a8b8g8r8; - case PICT_x8b8g8r8: return fbFetchPixel_x8b8g8r8; - - /* 24bpp formats */ - case PICT_r8g8b8: return fbFetchPixel_r8g8b8; - case PICT_b8g8r8: return fbFetchPixel_b8g8r8; - - /* 16bpp formats */ - case PICT_r5g6b5: return fbFetchPixel_r5g6b5; - case PICT_b5g6r5: return fbFetchPixel_b5g6r5; - - case PICT_a1r5g5b5: return fbFetchPixel_a1r5g5b5; - case PICT_x1r5g5b5: return fbFetchPixel_x1r5g5b5; - case PICT_a1b5g5r5: return fbFetchPixel_a1b5g5r5; - case PICT_x1b5g5r5: return fbFetchPixel_x1b5g5r5; - case PICT_a4r4g4b4: return fbFetchPixel_a4r4g4b4; - case PICT_x4r4g4b4: return fbFetchPixel_x4r4g4b4; - case PICT_a4b4g4r4: return fbFetchPixel_a4b4g4r4; - case PICT_x4b4g4r4: return fbFetchPixel_x4b4g4r4; - - /* 8bpp formats */ - case PICT_a8: return fbFetchPixel_a8; - case PICT_r3g3b2: return fbFetchPixel_r3g3b2; - case PICT_b2g3r3: return fbFetchPixel_b2g3r3; - case PICT_a2r2g2b2: return fbFetchPixel_a2r2g2b2; - case PICT_a2b2g2r2: return fbFetchPixel_a2b2g2r2; - case PICT_c8: return fbFetchPixel_c8; - case PICT_g8: return fbFetchPixel_c8; - - /* 4bpp formats */ - case PICT_a4: return fbFetchPixel_a4; - case PICT_r1g2b1: return fbFetchPixel_r1g2b1; - case PICT_b1g2r1: return fbFetchPixel_b1g2r1; - case PICT_a1r1g1b1: return fbFetchPixel_a1r1g1b1; - case PICT_a1b1g1r1: return fbFetchPixel_a1b1g1r1; - case PICT_c4: return fbFetchPixel_c4; - case PICT_g4: return fbFetchPixel_c4; - - /* 1bpp formats */ - case PICT_a1: return fbFetchPixel_a1; - case PICT_g1: return fbFetchPixel_g1; - default: - return NULL; - } -} - - - -/* - * All the store functions - */ - -typedef FASTCALL void (*storeProc) (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed); - -#define Splita(v) CARD32 a = ((v) >> 24), r = ((v) >> 16) & 0xff, g = ((v) >> 8) & 0xff, b = (v) & 0xff -#define Split(v) CARD32 r = ((v) >> 16) & 0xff, g = ((v) >> 8) & 0xff, b = (v) & 0xff - -static FASTCALL void -fbStore_a8r8g8b8 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed) -{ - memcpy(((CARD32 *)bits) + x, values, width*sizeof(CARD32)); -} - -static FASTCALL void -fbStore_x8r8g8b8 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed) -{ - int i; - CARD32 *pixel = (CARD32 *)bits + x; - for (i = 0; i < width; ++i) - *pixel++ = values[i] & 0xffffff; -} - -static FASTCALL void -fbStore_a8b8g8r8 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed) -{ - int i; - CARD32 *pixel = (CARD32 *)bits + x; - for (i = 0; i < width; ++i) - *pixel++ = (values[i] & 0xff00ff00) | ((values[i] >> 16) & 0xff) | ((values[i] & 0xff) << 16); -} - -static FASTCALL void -fbStore_x8b8g8r8 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed) -{ - int i; - CARD32 *pixel = (CARD32 *)bits + x; - for (i = 0; i < width; ++i) - *pixel++ = (values[i] & 0x0000ff00) | ((values[i] >> 16) & 0xff) | ((values[i] & 0xff) << 16); -} - -static FASTCALL void -fbStore_r8g8b8 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed) -{ - int i; - CARD8 *pixel = ((CARD8 *) bits) + 3*x; - for (i = 0; i < width; ++i) { - Store24(pixel, values[i]); - pixel += 3; - } -} - -static FASTCALL void -fbStore_b8g8r8 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed) -{ - int i; - CARD8 *pixel = ((CARD8 *) bits) + 3*x; - for (i = 0; i < width; ++i) { -#if IMAGE_BYTE_ORDER == MSBFirst - *pixel++ = Blue(values[i]); - *pixel++ = Green(values[i]); - *pixel++ = Red(values[i]); -#else - *pixel++ = Red(values[i]); - *pixel++ = Green(values[i]); - *pixel++ = Blue(values[i]); -#endif - } -} - -static FASTCALL void -fbStore_r5g6b5 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed) -{ - int i; - CARD16 *pixel = ((CARD16 *) bits) + x; - for (i = 0; i < width; ++i) { - CARD32 s = values[i]; - *pixel++ = ((s >> 3) & 0x001f) | - ((s >> 5) & 0x07e0) | - ((s >> 8) & 0xf800); - } -} - -static FASTCALL void -fbStore_b5g6r5 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed) -{ - int i; - CARD16 *pixel = ((CARD16 *) bits) + x; - for (i = 0; i < width; ++i) { - Split(values[i]); - *pixel++ = (((b << 8) & 0xf800) | - ((g << 3) & 0x07e0) | - ((r >> 3) )); - } -} - -static FASTCALL void -fbStore_a1r5g5b5 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed) -{ - int i; - CARD16 *pixel = ((CARD16 *) bits) + x; - for (i = 0; i < width; ++i) { - Splita(values[i]); - *pixel++ = (((a << 8) & 0x8000) | - ((r << 7) & 0x7c00) | - ((g << 2) & 0x03e0) | - ((b >> 3) )); - } -} - -static FASTCALL void -fbStore_x1r5g5b5 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed) -{ - int i; - CARD16 *pixel = ((CARD16 *) bits) + x; - for (i = 0; i < width; ++i) { - Split(values[i]); - *pixel++ = (((r << 7) & 0x7c00) | - ((g << 2) & 0x03e0) | - ((b >> 3) )); - } -} - -static FASTCALL void -fbStore_a1b5g5r5 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed) -{ - int i; - CARD16 *pixel = ((CARD16 *) bits) + x; - for (i = 0; i < width; ++i) { - Splita(values[i]); - *pixel++ = (((a << 8) & 0x8000) | - ((b << 7) & 0x7c00) | - ((g << 2) & 0x03e0) | - ((r >> 3) )); - } -} - -static FASTCALL void -fbStore_x1b5g5r5 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed) -{ - int i; - CARD16 *pixel = ((CARD16 *) bits) + x; - for (i = 0; i < width; ++i) { - Split(values[i]); - *pixel++ = (((b << 7) & 0x7c00) | - ((g << 2) & 0x03e0) | - ((r >> 3) )); - } -} - -static FASTCALL void -fbStore_a4r4g4b4 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed) -{ - int i; - CARD16 *pixel = ((CARD16 *) bits) + x; - for (i = 0; i < width; ++i) { - Splita(values[i]); - *pixel++ = (((a << 8) & 0xf000) | - ((r << 4) & 0x0f00) | - ((g ) & 0x00f0) | - ((b >> 4) )); - } -} - -static FASTCALL void -fbStore_x4r4g4b4 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed) -{ - int i; - CARD16 *pixel = ((CARD16 *) bits) + x; - for (i = 0; i < width; ++i) { - Split(values[i]); - *pixel++ = (((r << 4) & 0x0f00) | - ((g ) & 0x00f0) | - ((b >> 4) )); - } -} - -static FASTCALL void -fbStore_a4b4g4r4 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed) -{ - int i; - CARD16 *pixel = ((CARD16 *) bits) + x; - for (i = 0; i < width; ++i) { - Splita(values[i]); - *pixel++ = (((a << 8) & 0xf000) | - ((b << 4) & 0x0f00) | - ((g ) & 0x00f0) | - ((r >> 4) )); - } -} - -static FASTCALL void -fbStore_x4b4g4r4 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed) -{ - int i; - CARD16 *pixel = ((CARD16 *) bits) + x; - for (i = 0; i < width; ++i) { - Split(values[i]); - *pixel++ = (((b << 4) & 0x0f00) | - ((g ) & 0x00f0) | - ((r >> 4) )); - } -} - -static FASTCALL void -fbStore_a8 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed) -{ - int i; - CARD8 *pixel = ((CARD8 *) bits) + x; - for (i = 0; i < width; ++i) { - *pixel++ = values[i] >> 24; - } -} - -static FASTCALL void -fbStore_r3g3b2 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed) -{ - int i; - CARD8 *pixel = ((CARD8 *) bits) + x; - for (i = 0; i < width; ++i) { - Split(values[i]); - *pixel++ = (((r ) & 0xe0) | - ((g >> 3) & 0x1c) | - ((b >> 6) )); - } -} - -static FASTCALL void -fbStore_b2g3r3 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed) -{ - int i; - CARD8 *pixel = ((CARD8 *) bits) + x; - for (i = 0; i < width; ++i) { - Split(values[i]); - *pixel++ = (((b ) & 0xe0) | - ((g >> 3) & 0x1c) | - ((r >> 6) )); - } -} - -static FASTCALL void -fbStore_a2r2g2b2 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed) -{ - int i; - CARD8 *pixel = ((CARD8 *) bits) + x; - for (i = 0; i < width; ++i) { - Splita(values[i]); - *pixel++ = (((a ) & 0xc0) | - ((r >> 2) & 0x30) | - ((g >> 4) & 0x0c) | - ((b >> 6) )); - } -} - -static FASTCALL void -fbStore_c8 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed) -{ - int i; - CARD8 *pixel = ((CARD8 *) bits) + x; - for (i = 0; i < width; ++i) { - *pixel++ = miIndexToEnt24(indexed,values[i]); - } -} - -static FASTCALL void -fbStore_x4a4 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed) -{ - int i; - CARD8 *pixel = ((CARD8 *) bits) + x; - for (i = 0; i < width; ++i) { - *pixel++ = values[i] >> 28; - } -} - -#define Store8(l,o,v) (((CARD8 *) l)[(o) >> 3] = (v)) -#if IMAGE_BYTE_ORDER == MSBFirst -#define Store4(l,o,v) Store8(l,o,((o) & 4 ? \ - (Fetch8(l,o) & 0xf0) | (v) : \ - (Fetch8(l,o) & 0x0f) | ((v) << 4))) -#else -#define Store4(l,o,v) Store8(l,o,((o) & 4 ? \ - (Fetch8(l,o) & 0x0f) | ((v) << 4) : \ - (Fetch8(l,o) & 0xf0) | (v))) -#endif - -static FASTCALL void -fbStore_a4 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed) -{ - int i; - for (i = 0; i < width; ++i) { - Store4(bits, i + x, values[i]>>28); - } -} - -static FASTCALL void -fbStore_r1g2b1 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed) -{ - int i; - for (i = 0; i < width; ++i) { - CARD32 pixel; - - Split(values[i]); - pixel = (((r >> 4) & 0x8) | - ((g >> 5) & 0x6) | - ((b >> 7) )); - Store4(bits, i + x, pixel); - } -} - -static FASTCALL void -fbStore_b1g2r1 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed) -{ - int i; - for (i = 0; i < width; ++i) { - CARD32 pixel; - - Split(values[i]); - pixel = (((b >> 4) & 0x8) | - ((g >> 5) & 0x6) | - ((r >> 7) )); - Store4(bits, i + x, pixel); - } -} - -static FASTCALL void -fbStore_a1r1g1b1 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed) -{ - int i; - for (i = 0; i < width; ++i) { - CARD32 pixel; - Splita(values[i]); - pixel = (((a >> 4) & 0x8) | - ((r >> 5) & 0x4) | - ((g >> 6) & 0x2) | - ((b >> 7) )); - Store4(bits, i + x, pixel); - } -} - -static FASTCALL void -fbStore_a1b1g1r1 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed) -{ - int i; - for (i = 0; i < width; ++i) { - CARD32 pixel; - Splita(values[i]); - pixel = (((a >> 4) & 0x8) | - ((b >> 5) & 0x4) | - ((g >> 6) & 0x2) | - ((r >> 7) )); - Store4(bits, i + x, pixel); - } -} - -static FASTCALL void -fbStore_c4 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed) -{ - int i; - for (i = 0; i < width; ++i) { - CARD32 pixel; - - pixel = miIndexToEnt24(indexed, values[i]); - Store4(bits, i + x, pixel); - } -} - -static FASTCALL void -fbStore_a1 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed) -{ - int i; - for (i = 0; i < width; ++i) { - CARD32 *pixel = ((CARD32 *) bits) + ((i+x) >> 5); - CARD32 mask = FbStipMask((i+x) & 0x1f, 1); - - CARD32 v = values[i] & 0x80000000 ? mask : 0; - *pixel = (*pixel & ~mask) | v; - } -} - -static FASTCALL void -fbStore_g1 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed) -{ - int i; - for (i = 0; i < width; ++i) { - CARD32 *pixel = ((CARD32 *) bits) + ((i+x) >> 5); - CARD32 mask = FbStipMask((i+x) & 0x1f, 1); - - CARD32 v = miIndexToEntY24(indexed,values[i]) ? mask : 0; - *pixel = (*pixel & ~mask) | v; - } -} - - -static storeProc storeProcForPicture (PicturePtr pict) -{ - switch(pict->format) { - case PICT_a8r8g8b8: return fbStore_a8r8g8b8; - case PICT_x8r8g8b8: return fbStore_x8r8g8b8; - case PICT_a8b8g8r8: return fbStore_a8b8g8r8; - case PICT_x8b8g8r8: return fbStore_x8b8g8r8; - - /* 24bpp formats */ - case PICT_r8g8b8: return fbStore_r8g8b8; - case PICT_b8g8r8: return fbStore_b8g8r8; - - /* 16bpp formats */ - case PICT_r5g6b5: return fbStore_r5g6b5; - case PICT_b5g6r5: return fbStore_b5g6r5; - - case PICT_a1r5g5b5: return fbStore_a1r5g5b5; - case PICT_x1r5g5b5: return fbStore_x1r5g5b5; - case PICT_a1b5g5r5: return fbStore_a1b5g5r5; - case PICT_x1b5g5r5: return fbStore_x1b5g5r5; - case PICT_a4r4g4b4: return fbStore_a4r4g4b4; - case PICT_x4r4g4b4: return fbStore_x4r4g4b4; - case PICT_a4b4g4r4: return fbStore_a4b4g4r4; - case PICT_x4b4g4r4: return fbStore_x4b4g4r4; - - /* 8bpp formats */ - case PICT_a8: return fbStore_a8; - case PICT_r3g3b2: return fbStore_r3g3b2; - case PICT_b2g3r3: return fbStore_b2g3r3; - case PICT_a2r2g2b2: return fbStore_a2r2g2b2; - case PICT_c8: return fbStore_c8; - case PICT_g8: return fbStore_c8; - case PICT_x4a4: return fbStore_x4a4; - - /* 4bpp formats */ - case PICT_a4: return fbStore_a4; - case PICT_r1g2b1: return fbStore_r1g2b1; - case PICT_b1g2r1: return fbStore_b1g2r1; - case PICT_a1r1g1b1: return fbStore_a1r1g1b1; - case PICT_a1b1g1r1: return fbStore_a1b1g1r1; - case PICT_c4: return fbStore_c4; - case PICT_g4: return fbStore_c4; - - /* 1bpp formats */ - case PICT_a1: return fbStore_a1; - case PICT_g1: return fbStore_g1; - default: - return NULL; - } -} - - -/* - * Combine src and mask - */ -static FASTCALL void -fbCombineMaskU (CARD32 *src, const CARD32 *mask, int width) -{ - int i; - for (i = 0; i < width; ++i) { - CARD32 a = mask[i] >> 24; - CARD32 s = src[i]; - FbByteMul(s, a); - src[i] = s; - } -} - -/* - * All of the composing functions - */ - -static FASTCALL void -fbCombineClear (CARD32 *dest, const CARD32 *src, int width) -{ - memset(dest, 0, width*sizeof(CARD32)); -} - -static FASTCALL void -fbCombineSrcU (CARD32 *dest, const CARD32 *src, int width) -{ - memcpy(dest, src, width*sizeof(CARD32)); -} - - -static FASTCALL void -fbCombineOverU (CARD32 *dest, const CARD32 *src, int width) -{ - int i; - for (i = 0; i < width; ++i) { - CARD32 s = src[i]; - CARD32 d = dest[i]; - CARD32 ia = Alpha(~s); - - FbByteMulAdd(d, ia, s); - dest[i] = d; - } -} - -static FASTCALL void -fbCombineOverReverseU (CARD32 *dest, const CARD32 *src, int width) -{ - int i; - for (i = 0; i < width; ++i) { - CARD32 s = src[i]; - CARD32 d = dest[i]; - CARD32 ia = Alpha(~dest[i]); - FbByteMulAdd(s, ia, d); - dest[i] = s; - } -} - -static FASTCALL void -fbCombineInU (CARD32 *dest, const CARD32 *src, int width) -{ - int i; - for (i = 0; i < width; ++i) { - CARD32 s = src[i]; - CARD32 a = Alpha(dest[i]); - FbByteMul(s, a); - dest[i] = s; - } -} - -static FASTCALL void -fbCombineInReverseU (CARD32 *dest, const CARD32 *src, int width) -{ - int i; - for (i = 0; i < width; ++i) { - CARD32 d = dest[i]; - CARD32 a = Alpha(src[i]); - FbByteMul(d, a); - dest[i] = d; - } -} - -static FASTCALL void -fbCombineOutU (CARD32 *dest, const CARD32 *src, int width) -{ - int i; - for (i = 0; i < width; ++i) { - CARD32 s = src[i]; - CARD32 a = Alpha(~dest[i]); - FbByteMul(s, a); - dest[i] = s; - } -} - -static FASTCALL void -fbCombineOutReverseU (CARD32 *dest, const CARD32 *src, int width) -{ - int i; - for (i = 0; i < width; ++i) { - CARD32 d = dest[i]; - CARD32 a = Alpha(~src[i]); - FbByteMul(d, a); - dest[i] = d; - } -} - -static FASTCALL void -fbCombineAtopU (CARD32 *dest, const CARD32 *src, int width) -{ - int i; - for (i = 0; i < width; ++i) { - CARD32 s = src[i]; - CARD32 d = dest[i]; - CARD32 dest_a = Alpha(d); - CARD32 src_ia = Alpha(~s); - - FbByteAddMul(s, dest_a, d, src_ia); - dest[i] = s; - } -} - -static FASTCALL void -fbCombineAtopReverseU (CARD32 *dest, const CARD32 *src, int width) -{ - int i; - for (i = 0; i < width; ++i) { - CARD32 s = src[i]; - CARD32 d = dest[i]; - CARD32 src_a = Alpha(s); - CARD32 dest_ia = Alpha(~d); - - FbByteAddMul(s, dest_ia, d, src_a); - dest[i] = s; - } -} - -static FASTCALL void -fbCombineXorU (CARD32 *dest, const CARD32 *src, int width) -{ - int i; - for (i = 0; i < width; ++i) { - CARD32 s = src[i]; - CARD32 d = dest[i]; - CARD32 src_ia = Alpha(~s); - CARD32 dest_ia = Alpha(~d); - - FbByteAddMul(s, dest_ia, d, src_ia); - dest[i] = s; - } -} - -static FASTCALL void -fbCombineAddU (CARD32 *dest, const CARD32 *src, int width) -{ - int i; - for (i = 0; i < width; ++i) { - CARD32 s = src[i]; - CARD32 d = dest[i]; - FbByteAdd(d, s); - dest[i] = d; - } -} - -static FASTCALL void -fbCombineSaturateU (CARD32 *dest, const CARD32 *src, int width) -{ - int i; - for (i = 0; i < width; ++i) { - CARD32 s = src[i]; - CARD32 d = dest[i]; - CARD16 sa, da; - - sa = s >> 24; - da = ~d >> 24; - if (sa > da) - { - sa = FbIntDiv(da, sa); - FbByteMul(s, sa); - } - FbByteAdd(d, s); - dest[i] = d; - } -} - -/* - * All of the disjoint composing functions - - The four entries in the first column indicate what source contributions - come from each of the four areas of the picture -- areas covered by neither - A nor B, areas covered only by A, areas covered only by B and finally - areas covered by both A and B. - - Disjoint Conjoint - Fa Fb Fa Fb -(0,0,0,0) 0 0 0 0 -(0,A,0,A) 1 0 1 0 -(0,0,B,B) 0 1 0 1 -(0,A,B,A) 1 min((1-a)/b,1) 1 max(1-a/b,0) -(0,A,B,B) min((1-b)/a,1) 1 max(1-b/a,0) 1 -(0,0,0,A) max(1-(1-b)/a,0) 0 min(1,b/a) 0 -(0,0,0,B) 0 max(1-(1-a)/b,0) 0 min(a/b,1) -(0,A,0,0) min(1,(1-b)/a) 0 max(1-b/a,0) 0 -(0,0,B,0) 0 min(1,(1-a)/b) 0 max(1-a/b,0) -(0,0,B,A) max(1-(1-b)/a,0) min(1,(1-a)/b) min(1,b/a) max(1-a/b,0) -(0,A,0,B) min(1,(1-b)/a) max(1-(1-a)/b,0) max(1-b/a,0) min(1,a/b) -(0,A,B,0) min(1,(1-b)/a) min(1,(1-a)/b) max(1-b/a,0) max(1-a/b,0) - - */ - -#define CombineAOut 1 -#define CombineAIn 2 -#define CombineBOut 4 -#define CombineBIn 8 - -#define CombineClear 0 -#define CombineA (CombineAOut|CombineAIn) -#define CombineB (CombineBOut|CombineBIn) -#define CombineAOver (CombineAOut|CombineBOut|CombineAIn) -#define CombineBOver (CombineAOut|CombineBOut|CombineBIn) -#define CombineAAtop (CombineBOut|CombineAIn) -#define CombineBAtop (CombineAOut|CombineBIn) -#define CombineXor (CombineAOut|CombineBOut) - -/* portion covered by a but not b */ -static INLINE CARD8 -fbCombineDisjointOutPart (CARD8 a, CARD8 b) -{ - /* min (1, (1-b) / a) */ - - b = ~b; /* 1 - b */ - if (b >= a) /* 1 - b >= a -> (1-b)/a >= 1 */ - return 0xff; /* 1 */ - return FbIntDiv(b,a); /* (1-b) / a */ -} - -/* portion covered by both a and b */ -static INLINE CARD8 -fbCombineDisjointInPart (CARD8 a, CARD8 b) -{ - /* max (1-(1-b)/a,0) */ - /* = - min ((1-b)/a - 1, 0) */ - /* = 1 - min (1, (1-b)/a) */ - - b = ~b; /* 1 - b */ - if (b >= a) /* 1 - b >= a -> (1-b)/a >= 1 */ - return 0; /* 1 - 1 */ - return ~FbIntDiv(b,a); /* 1 - (1-b) / a */ -} - -static FASTCALL void -fbCombineDisjointGeneralU (CARD32 *dest, const CARD32 *src, int width, CARD8 combine) -{ - int i; - for (i = 0; i < width; ++i) { - CARD32 s = src[i]; - CARD32 d = dest[i]; - CARD32 m,n,o,p; - CARD16 Fa, Fb, t, u, v; - CARD8 sa = s >> 24; - CARD8 da = d >> 24; - - switch (combine & CombineA) { - default: - Fa = 0; - break; - case CombineAOut: - Fa = fbCombineDisjointOutPart (sa, da); - break; - case CombineAIn: - Fa = fbCombineDisjointInPart (sa, da); - break; - case CombineA: - Fa = 0xff; - break; - } - - switch (combine & CombineB) { - default: - Fb = 0; - break; - case CombineBOut: - Fb = fbCombineDisjointOutPart (da, sa); - break; - case CombineBIn: - Fb = fbCombineDisjointInPart (da, sa); - break; - case CombineB: - Fb = 0xff; - break; - } - m = FbGen (s,d,0,Fa,Fb,t, u, v); - n = FbGen (s,d,8,Fa,Fb,t, u, v); - o = FbGen (s,d,16,Fa,Fb,t, u, v); - p = FbGen (s,d,24,Fa,Fb,t, u, v); - s = m|n|o|p; - dest[i] = s; - } -} - -static FASTCALL void -fbCombineDisjointOverU (CARD32 *dest, const CARD32 *src, int width) -{ - int i; - for (i = 0; i < width; ++i) { - CARD32 s = src[i]; - CARD16 a = s >> 24; - - if (a != 0x00) - { - if (a != 0xff) - { - CARD32 d = dest[i]; - a = fbCombineDisjointOutPart (d >> 24, a); - FbByteMulAdd(d, a, s); - s = d; - } - dest[i] = s; - } - } -} - -static FASTCALL void -fbCombineDisjointInU (CARD32 *dest, const CARD32 *src, int width) -{ - fbCombineDisjointGeneralU (dest, src, width, CombineAIn); -} - -static FASTCALL void -fbCombineDisjointInReverseU (CARD32 *dest, const CARD32 *src, int width) -{ - fbCombineDisjointGeneralU (dest, src, width, CombineBIn); -} - -static FASTCALL void -fbCombineDisjointOutU (CARD32 *dest, const CARD32 *src, int width) -{ - fbCombineDisjointGeneralU (dest, src, width, CombineAOut); -} - -static FASTCALL void -fbCombineDisjointOutReverseU (CARD32 *dest, const CARD32 *src, int width) -{ - fbCombineDisjointGeneralU (dest, src, width, CombineBOut); -} - -static FASTCALL void -fbCombineDisjointAtopU (CARD32 *dest, const CARD32 *src, int width) -{ - fbCombineDisjointGeneralU (dest, src, width, CombineAAtop); -} - -static FASTCALL void -fbCombineDisjointAtopReverseU (CARD32 *dest, const CARD32 *src, int width) -{ - fbCombineDisjointGeneralU (dest, src, width, CombineBAtop); -} - -static FASTCALL void -fbCombineDisjointXorU (CARD32 *dest, const CARD32 *src, int width) -{ - fbCombineDisjointGeneralU (dest, src, width, CombineXor); -} - -/* portion covered by a but not b */ -static INLINE CARD8 -fbCombineConjointOutPart (CARD8 a, CARD8 b) -{ - /* max (1-b/a,0) */ - /* = 1-min(b/a,1) */ - - /* min (1, (1-b) / a) */ - - if (b >= a) /* b >= a -> b/a >= 1 */ - return 0x00; /* 0 */ - return ~FbIntDiv(b,a); /* 1 - b/a */ -} - -/* portion covered by both a and b */ -static INLINE CARD8 -fbCombineConjointInPart (CARD8 a, CARD8 b) -{ - /* min (1,b/a) */ - - if (b >= a) /* b >= a -> b/a >= 1 */ - return 0xff; /* 1 */ - return FbIntDiv(b,a); /* b/a */ -} - -static FASTCALL void -fbCombineConjointGeneralU (CARD32 *dest, const CARD32 *src, int width, CARD8 combine) -{ - int i; - for (i = 0; i < width; ++i) { - CARD32 s = src[i]; - CARD32 d = dest[i]; - CARD32 m,n,o,p; - CARD16 Fa, Fb, t, u, v; - CARD8 sa = s >> 24; - CARD8 da = d >> 24; - - switch (combine & CombineA) { - default: - Fa = 0; - break; - case CombineAOut: - Fa = fbCombineConjointOutPart (sa, da); - break; - case CombineAIn: - Fa = fbCombineConjointInPart (sa, da); - break; - case CombineA: - Fa = 0xff; - break; - } - - switch (combine & CombineB) { - default: - Fb = 0; - break; - case CombineBOut: - Fb = fbCombineConjointOutPart (da, sa); - break; - case CombineBIn: - Fb = fbCombineConjointInPart (da, sa); - break; - case CombineB: - Fb = 0xff; - break; - } - m = FbGen (s,d,0,Fa,Fb,t, u, v); - n = FbGen (s,d,8,Fa,Fb,t, u, v); - o = FbGen (s,d,16,Fa,Fb,t, u, v); - p = FbGen (s,d,24,Fa,Fb,t, u, v); - s = m|n|o|p; - dest[i] = s; - } -} - -static FASTCALL void -fbCombineConjointOverU (CARD32 *dest, const CARD32 *src, int width) -{ - fbCombineConjointGeneralU (dest, src, width, CombineAOver); -} - - -static FASTCALL void -fbCombineConjointOverReverseU (CARD32 *dest, const CARD32 *src, int width) -{ - fbCombineConjointGeneralU (dest, src, width, CombineBOver); -} - - -static FASTCALL void -fbCombineConjointInU (CARD32 *dest, const CARD32 *src, int width) -{ - fbCombineConjointGeneralU (dest, src, width, CombineAIn); -} - - -static FASTCALL void -fbCombineConjointInReverseU (CARD32 *dest, const CARD32 *src, int width) -{ - fbCombineConjointGeneralU (dest, src, width, CombineBIn); -} - -static FASTCALL void -fbCombineConjointOutU (CARD32 *dest, const CARD32 *src, int width) -{ - fbCombineConjointGeneralU (dest, src, width, CombineAOut); -} - -static FASTCALL void -fbCombineConjointOutReverseU (CARD32 *dest, const CARD32 *src, int width) -{ - fbCombineConjointGeneralU (dest, src, width, CombineBOut); -} - -static FASTCALL void -fbCombineConjointAtopU (CARD32 *dest, const CARD32 *src, int width) -{ - fbCombineConjointGeneralU (dest, src, width, CombineAAtop); -} - -static FASTCALL void -fbCombineConjointAtopReverseU (CARD32 *dest, const CARD32 *src, int width) -{ - fbCombineConjointGeneralU (dest, src, width, CombineBAtop); -} - -static FASTCALL void -fbCombineConjointXorU (CARD32 *dest, const CARD32 *src, int width) -{ - fbCombineConjointGeneralU (dest, src, width, CombineXor); -} - -static CombineFuncU fbCombineFuncU[] = { - fbCombineClear, - fbCombineSrcU, - NULL, /* CombineDst */ - fbCombineOverU, - fbCombineOverReverseU, - fbCombineInU, - fbCombineInReverseU, - fbCombineOutU, - fbCombineOutReverseU, - fbCombineAtopU, - fbCombineAtopReverseU, - fbCombineXorU, - fbCombineAddU, - fbCombineSaturateU, - NULL, - NULL, - fbCombineClear, - fbCombineSrcU, - NULL, /* CombineDst */ - fbCombineDisjointOverU, - fbCombineSaturateU, /* DisjointOverReverse */ - fbCombineDisjointInU, - fbCombineDisjointInReverseU, - fbCombineDisjointOutU, - fbCombineDisjointOutReverseU, - fbCombineDisjointAtopU, - fbCombineDisjointAtopReverseU, - fbCombineDisjointXorU, - NULL, - NULL, - NULL, - NULL, - fbCombineClear, - fbCombineSrcU, - NULL, /* CombineDst */ - fbCombineConjointOverU, - fbCombineConjointOverReverseU, - fbCombineConjointInU, - fbCombineConjointInReverseU, - fbCombineConjointOutU, - fbCombineConjointOutReverseU, - fbCombineConjointAtopU, - fbCombineConjointAtopReverseU, - fbCombineConjointXorU, -}; - -static FASTCALL void -fbCombineMaskC (CARD32 *src, CARD32 *mask, int width) -{ - int i; - for (i = 0; i < width; ++i) { - CARD32 a = mask[i]; - - CARD32 x; - CARD16 xa; - - if (!a) - { - src[i] = 0; - continue; - } - - x = src[i]; - if (a == 0xffffffff) - { - x = x >> 24; - x |= x << 8; - x |= x << 16; - mask[i] = x; - continue; - } - - xa = x >> 24; - FbByteMulC(x, a); - src[i] = x; - FbByteMul(a, xa); - mask[i] = a; - } -} - -static FASTCALL void -fbCombineMaskValueC (CARD32 *src, const CARD32 *mask, int width) -{ - int i; - for (i = 0; i < width; ++i) { - CARD32 a = mask[i]; - CARD32 x; - - if (!a) - { - src[i] = 0; - continue; - } - - if (a == 0xffffffff) - continue; - - x = src[i]; - FbByteMulC(x, a); - src[i] = x; - } -} - - -static FASTCALL void -fbCombineMaskAlphaC (const CARD32 *src, CARD32 *mask, int width) -{ - int i; - for (i = 0; i < width; ++i) { - CARD32 a = mask[i]; - CARD32 x; - - if (!a) - continue; - - x = src[i] >> 24; - if (x == 0xff) - continue; - if (a == 0xffffffff) - { - x = x >> 24; - x |= x << 8; - x |= x << 16; - mask[i] = x; - continue; - } - - FbByteMul(a, x); - mask[i] = a; - } -} - -static FASTCALL void -fbCombineClearC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width) -{ - memset(dest, 0, width*sizeof(CARD32)); -} - -static FASTCALL void -fbCombineSrcC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width) -{ - fbCombineMaskValueC(src, mask, width); - memcpy(dest, src, width*sizeof(CARD32)); -} - -static FASTCALL void -fbCombineOverC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width) -{ - int i; - fbCombineMaskC(src, mask, width); - for (i = 0; i < width; ++i) { - CARD32 s = src[i]; - CARD32 a = ~mask[i]; - - if (a != 0xffffffff) - { - if (a) - { - CARD32 d = dest[i]; - FbByteMulAddC(d, a, s); - s = d; - } - dest[i] = s; - } - } -} - -static FASTCALL void -fbCombineOverReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width) -{ - int i; - fbCombineMaskValueC(src, mask, width); - for (i = 0; i < width; ++i) { - CARD32 d = dest[i]; - CARD32 a = ~d >> 24; - - if (a) - { - CARD32 s = src[i]; - if (a != 0xff) - { - FbByteMulAdd(s, a, d); - } - dest[i] = s; - } - } -} - -static FASTCALL void -fbCombineInC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width) -{ - int i; - fbCombineMaskValueC(src, mask, width); - for (i = 0; i < width; ++i) { - CARD32 d = dest[i]; - CARD16 a = d >> 24; - CARD32 s = 0; - if (a) - { - s = src[i]; - if (a != 0xff) - { - FbByteMul(s, a); - } - } - dest[i] = s; - } -} - -static FASTCALL void -fbCombineInReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width) -{ - int i; - fbCombineMaskAlphaC(src, mask, width); - for (i = 0; i < width; ++i) { - CARD32 a = mask[i]; - - if (a != 0xffffffff) - { - CARD32 d = 0; - if (a) - { - d = dest[i]; - FbByteMulC(d, a); - } - dest[i] = d; - } - } -} - -static FASTCALL void -fbCombineOutC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width) -{ - int i; - fbCombineMaskValueC(src, mask, width); - for (i = 0; i < width; ++i) { - CARD32 d = dest[i]; - CARD16 a = ~d >> 24; - CARD32 s = 0; - if (a) - { - s = src[i]; - if (a != 0xff) - { - FbByteMul(s, a); - } - } - dest[i] = s; - } -} - -static FASTCALL void -fbCombineOutReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width) -{ - int i; - fbCombineMaskAlphaC(src, mask, width); - for (i = 0; i < width; ++i) { - CARD32 a = ~mask[i]; - - if (a != 0xffffffff) - { - CARD32 d = 0; - if (a) - { - d = dest[i]; - FbByteMulC(d, a); - } - dest[i] = d; - } - } -} - -static FASTCALL void -fbCombineAtopC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width) -{ - int i; - fbCombineMaskC(src, mask, width); - for (i = 0; i < width; ++i) { - CARD32 d = dest[i]; - CARD32 s = src[i]; - CARD32 ad = ~mask[i]; - CARD16 as = d >> 24; - FbByteAddMulC(d, ad, s, as); - dest[i] = d; - } -} - -static FASTCALL void -fbCombineAtopReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width) -{ - int i; - fbCombineMaskC(src, mask, width); - for (i = 0; i < width; ++i) { - - CARD32 d = dest[i]; - CARD32 s = src[i]; - CARD32 ad = mask[i]; - CARD16 as = ~d >> 24; - FbByteAddMulC(d, ad, s, as); - dest[i] = d; - } -} - -static FASTCALL void -fbCombineXorC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width) -{ - int i; - fbCombineMaskC(src, mask, width); - for (i = 0; i < width; ++i) { - CARD32 d = dest[i]; - CARD32 s = src[i]; - CARD32 ad = ~mask[i]; - CARD16 as = ~d >> 24; - FbByteAddMulC(d, ad, s, as); - dest[i] = d; - } -} - -static FASTCALL void -fbCombineAddC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width) -{ - int i; - fbCombineMaskValueC(src, mask, width); - for (i = 0; i < width; ++i) { - CARD32 s = src[i]; - CARD32 d = dest[i]; - FbByteAdd(d, s); - dest[i] = d; - } -} - -static FASTCALL void -fbCombineSaturateC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width) -{ - int i; - fbCombineMaskC(src, mask, width); - for (i = 0; i < width; ++i) { - CARD32 s, d; - CARD16 sa, sr, sg, sb, da; - CARD16 t, u, v; - CARD32 m,n,o,p; - - d = dest[i]; - s = src[i]; - sa = (mask[i] >> 24); - sr = (mask[i] >> 16) & 0xff; - sg = (mask[i] >> 8) & 0xff; - sb = (mask[i] ) & 0xff; - da = ~d >> 24; - - if (sb <= da) - m = FbAdd(s,d,0,t); - else - m = FbGen (s, d, 0, (da << 8) / sb, 0xff, t, u, v); - - if (sg <= da) - n = FbAdd(s,d,8,t); - else - n = FbGen (s, d, 8, (da << 8) / sg, 0xff, t, u, v); - - if (sr <= da) - o = FbAdd(s,d,16,t); - else - o = FbGen (s, d, 16, (da << 8) / sr, 0xff, t, u, v); - - if (sa <= da) - p = FbAdd(s,d,24,t); - else - p = FbGen (s, d, 24, (da << 8) / sa, 0xff, t, u, v); - - dest[i] = m|n|o|p; - } -} - -static FASTCALL void -fbCombineDisjointGeneralC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width, CARD8 combine) -{ - int i; - fbCombineMaskC(src, mask, width); - for (i = 0; i < width; ++i) { - CARD32 s, d; - CARD32 m,n,o,p; - CARD32 Fa, Fb; - CARD16 t, u, v; - CARD32 sa; - CARD8 da; - - s = src[i]; - sa = mask[i]; - d = dest[i]; - da = d >> 24; - - switch (combine & CombineA) { - default: - Fa = 0; - break; - case CombineAOut: - m = fbCombineDisjointOutPart ((CARD8) (sa >> 0), da); - n = fbCombineDisjointOutPart ((CARD8) (sa >> 8), da) << 8; - o = fbCombineDisjointOutPart ((CARD8) (sa >> 16), da) << 16; - p = fbCombineDisjointOutPart ((CARD8) (sa >> 24), da) << 24; - Fa = m|n|o|p; - break; - case CombineAIn: - m = fbCombineDisjointInPart ((CARD8) (sa >> 0), da); - n = fbCombineDisjointInPart ((CARD8) (sa >> 8), da) << 8; - o = fbCombineDisjointInPart ((CARD8) (sa >> 16), da) << 16; - p = fbCombineDisjointInPart ((CARD8) (sa >> 24), da) << 24; - Fa = m|n|o|p; - break; - case CombineA: - Fa = 0xffffffff; - break; - } - - switch (combine & CombineB) { - default: - Fb = 0; - break; - case CombineBOut: - m = fbCombineDisjointOutPart (da, (CARD8) (sa >> 0)); - n = fbCombineDisjointOutPart (da, (CARD8) (sa >> 8)) << 8; - o = fbCombineDisjointOutPart (da, (CARD8) (sa >> 16)) << 16; - p = fbCombineDisjointOutPart (da, (CARD8) (sa >> 24)) << 24; - Fb = m|n|o|p; - break; - case CombineBIn: - m = fbCombineDisjointInPart (da, (CARD8) (sa >> 0)); - n = fbCombineDisjointInPart (da, (CARD8) (sa >> 8)) << 8; - o = fbCombineDisjointInPart (da, (CARD8) (sa >> 16)) << 16; - p = fbCombineDisjointInPart (da, (CARD8) (sa >> 24)) << 24; - Fb = m|n|o|p; - break; - case CombineB: - Fb = 0xffffffff; - break; - } - m = FbGen (s,d,0,FbGet8(Fa,0),FbGet8(Fb,0),t, u, v); - n = FbGen (s,d,8,FbGet8(Fa,8),FbGet8(Fb,8),t, u, v); - o = FbGen (s,d,16,FbGet8(Fa,16),FbGet8(Fb,16),t, u, v); - p = FbGen (s,d,24,FbGet8(Fa,24),FbGet8(Fb,24),t, u, v); - s = m|n|o|p; - dest[i] = s; - } -} - -static FASTCALL void -fbCombineDisjointOverC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width) -{ - fbCombineDisjointGeneralC (dest, src, mask, width, CombineAOver); -} - -static FASTCALL void -fbCombineDisjointInC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width) -{ - fbCombineDisjointGeneralC (dest, src, mask, width, CombineAIn); -} - -static FASTCALL void -fbCombineDisjointInReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width) -{ - fbCombineDisjointGeneralC (dest, src, mask, width, CombineBIn); -} - -static FASTCALL void -fbCombineDisjointOutC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width) -{ - fbCombineDisjointGeneralC (dest, src, mask, width, CombineAOut); -} - -static FASTCALL void -fbCombineDisjointOutReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width) -{ - fbCombineDisjointGeneralC (dest, src, mask, width, CombineBOut); -} - -static FASTCALL void -fbCombineDisjointAtopC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width) -{ - fbCombineDisjointGeneralC (dest, src, mask, width, CombineAAtop); -} - -static FASTCALL void -fbCombineDisjointAtopReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width) -{ - fbCombineDisjointGeneralC (dest, src, mask, width, CombineBAtop); -} - -static FASTCALL void -fbCombineDisjointXorC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width) -{ - fbCombineDisjointGeneralC (dest, src, mask, width, CombineXor); -} - -static FASTCALL void -fbCombineConjointGeneralC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width, CARD8 combine) -{ - int i; - fbCombineMaskC(src, mask, width); - for (i = 0; i < width; ++i) { - CARD32 s, d; - CARD32 m,n,o,p; - CARD32 Fa, Fb; - CARD16 t, u, v; - CARD32 sa; - CARD8 da; - - s = src[i]; - sa = mask[i]; - d = dest[i]; - da = d >> 24; - - switch (combine & CombineA) { - default: - Fa = 0; - break; - case CombineAOut: - m = fbCombineConjointOutPart ((CARD8) (sa >> 0), da); - n = fbCombineConjointOutPart ((CARD8) (sa >> 8), da) << 8; - o = fbCombineConjointOutPart ((CARD8) (sa >> 16), da) << 16; - p = fbCombineConjointOutPart ((CARD8) (sa >> 24), da) << 24; - Fa = m|n|o|p; - break; - case CombineAIn: - m = fbCombineConjointInPart ((CARD8) (sa >> 0), da); - n = fbCombineConjointInPart ((CARD8) (sa >> 8), da) << 8; - o = fbCombineConjointInPart ((CARD8) (sa >> 16), da) << 16; - p = fbCombineConjointInPart ((CARD8) (sa >> 24), da) << 24; - Fa = m|n|o|p; - break; - case CombineA: - Fa = 0xffffffff; - break; - } - - switch (combine & CombineB) { - default: - Fb = 0; - break; - case CombineBOut: - m = fbCombineConjointOutPart (da, (CARD8) (sa >> 0)); - n = fbCombineConjointOutPart (da, (CARD8) (sa >> 8)) << 8; - o = fbCombineConjointOutPart (da, (CARD8) (sa >> 16)) << 16; - p = fbCombineConjointOutPart (da, (CARD8) (sa >> 24)) << 24; - Fb = m|n|o|p; - break; - case CombineBIn: - m = fbCombineConjointInPart (da, (CARD8) (sa >> 0)); - n = fbCombineConjointInPart (da, (CARD8) (sa >> 8)) << 8; - o = fbCombineConjointInPart (da, (CARD8) (sa >> 16)) << 16; - p = fbCombineConjointInPart (da, (CARD8) (sa >> 24)) << 24; - Fb = m|n|o|p; - break; - case CombineB: - Fb = 0xffffffff; - break; - } - m = FbGen (s,d,0,FbGet8(Fa,0),FbGet8(Fb,0),t, u, v); - n = FbGen (s,d,8,FbGet8(Fa,8),FbGet8(Fb,8),t, u, v); - o = FbGen (s,d,16,FbGet8(Fa,16),FbGet8(Fb,16),t, u, v); - p = FbGen (s,d,24,FbGet8(Fa,24),FbGet8(Fb,24),t, u, v); - s = m|n|o|p; - dest[i] = s; - } -} - -static FASTCALL void -fbCombineConjointOverC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width) -{ - fbCombineConjointGeneralC (dest, src, mask, width, CombineAOver); -} - -static FASTCALL void -fbCombineConjointOverReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width) -{ - fbCombineConjointGeneralC (dest, src, mask, width, CombineBOver); -} - -static FASTCALL void -fbCombineConjointInC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width) -{ - fbCombineConjointGeneralC (dest, src, mask, width, CombineAIn); -} - -static FASTCALL void -fbCombineConjointInReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width) -{ - fbCombineConjointGeneralC (dest, src, mask, width, CombineBIn); -} - -static FASTCALL void -fbCombineConjointOutC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width) -{ - fbCombineConjointGeneralC (dest, src, mask, width, CombineAOut); -} - -static FASTCALL void -fbCombineConjointOutReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width) -{ - fbCombineConjointGeneralC (dest, src, mask, width, CombineBOut); -} - -static FASTCALL void -fbCombineConjointAtopC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width) -{ - fbCombineConjointGeneralC (dest, src, mask, width, CombineAAtop); -} - -static FASTCALL void -fbCombineConjointAtopReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width) -{ - fbCombineConjointGeneralC (dest, src, mask, width, CombineBAtop); -} - -static FASTCALL void -fbCombineConjointXorC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width) -{ - fbCombineConjointGeneralC (dest, src, mask, width, CombineXor); -} - -static CombineFuncC fbCombineFuncC[] = { - fbCombineClearC, - fbCombineSrcC, - NULL, /* Dest */ - fbCombineOverC, - fbCombineOverReverseC, - fbCombineInC, - fbCombineInReverseC, - fbCombineOutC, - fbCombineOutReverseC, - fbCombineAtopC, - fbCombineAtopReverseC, - fbCombineXorC, - fbCombineAddC, - fbCombineSaturateC, - NULL, - NULL, - fbCombineClearC, /* 0x10 */ - fbCombineSrcC, - NULL, /* Dest */ - fbCombineDisjointOverC, - fbCombineSaturateC, /* DisjointOverReverse */ - fbCombineDisjointInC, - fbCombineDisjointInReverseC, - fbCombineDisjointOutC, - fbCombineDisjointOutReverseC, - fbCombineDisjointAtopC, - fbCombineDisjointAtopReverseC, - fbCombineDisjointXorC, /* 0x1b */ - NULL, - NULL, - NULL, - NULL, - fbCombineClearC, - fbCombineSrcC, - NULL, /* Dest */ - fbCombineConjointOverC, - fbCombineConjointOverReverseC, - fbCombineConjointInC, - fbCombineConjointInReverseC, - fbCombineConjointOutC, - fbCombineConjointOutReverseC, - fbCombineConjointAtopC, - fbCombineConjointAtopReverseC, - fbCombineConjointXorC, -}; - - -FbComposeFunctions composeFunctions = { - fbCombineFuncU, - fbCombineFuncC, - fbCombineMaskU -}; - - -static void fbFetchSolid(PicturePtr pict, int x, int y, int width, CARD32 *buffer) -{ - FbBits *bits; - FbStride stride; - int bpp; - int xoff, yoff; - CARD32 color; - CARD32 *end; - fetchPixelProc fetch = fetchPixelProcForPicture(pict); - miIndexedPtr indexed = (miIndexedPtr) pict->pFormat->index.devPrivate; - - fbGetDrawable (pict->pDrawable, bits, stride, bpp, xoff, yoff); - bits += yoff*stride + (xoff*bpp >> FB_SHIFT); - - color = fetch(bits, 0, indexed); - - end = buffer + width; - while (buffer < end) - *buffer++ = color; -} - -static void fbFetch(PicturePtr pict, int x, int y, int width, CARD32 *buffer) -{ - FbBits *bits; - FbStride stride; - int bpp; - int xoff, yoff; - fetchProc fetch = fetchProcForPicture(pict); - miIndexedPtr indexed = (miIndexedPtr) pict->pFormat->index.devPrivate; - - fbGetDrawable (pict->pDrawable, bits, stride, bpp, xoff, yoff); - x += xoff; - y += yoff; - - bits += y*stride; - - fetch(bits, x, width, buffer, indexed); -} - -#define MOD(a,b) ((a) < 0 ? ((b) - ((-(a) - 1) % (b))) - 1 : (a) % (b)) -#define DIV(a,b) ((((a) < 0) == ((b) < 0)) ? (a) / (b) :\ - ((a) - (b) + 1 - (((b) < 0) << 1)) / (b)) - - -static CARD32 gradientPixel(const SourcePictPtr pGradient, xFixed_48_16 pos, unsigned int spread) -{ - int ipos = (pos * PICT_GRADIENT_STOPTABLE_SIZE - 1) >> 16; - - /* calculate the actual offset. */ - if (ipos < 0 || ipos >= PICT_GRADIENT_STOPTABLE_SIZE) { - if (pGradient->type == SourcePictTypeConical || spread == RepeatNormal) { - ipos = ipos % PICT_GRADIENT_STOPTABLE_SIZE; - ipos = ipos < 0 ? PICT_GRADIENT_STOPTABLE_SIZE + ipos : ipos; - - } else if (spread == RepeatReflect) { - const int limit = PICT_GRADIENT_STOPTABLE_SIZE * 2 - 1; - ipos = ipos % limit; - ipos = ipos < 0 ? limit + ipos : ipos; - ipos = ipos >= PICT_GRADIENT_STOPTABLE_SIZE ? limit - ipos : ipos; - - } else if (spread == RepeatPad) { - if (ipos < 0) - ipos = 0; - else if (ipos >= PICT_GRADIENT_STOPTABLE_SIZE) - ipos = PICT_GRADIENT_STOPTABLE_SIZE-1; - } else { /* RepeatNone */ - return 0; - } - } - - assert(ipos >= 0); - assert(ipos < PICT_GRADIENT_STOPTABLE_SIZE); - - return pGradient->linear.colorTable[ipos]; -} - -static void fbFetchSourcePict(PicturePtr pict, int x, int y, int width, CARD32 *buffer) -{ - SourcePictPtr pGradient = pict->pSourcePict; - CARD32 *end = buffer + width; - - if (pGradient->type == SourcePictTypeSolidFill) { - register CARD32 color = pGradient->solidFill.color; - while (buffer < end) { - *buffer++ = color; - } - } else if (pGradient->type == SourcePictTypeLinear) { - PictVector v, unit; - xFixed_32_32 l; - xFixed_48_16 dx, dy, a, b, off; - - v.vector[0] = IntToxFixed(x); - v.vector[1] = IntToxFixed(y); - v.vector[2] = xFixed1; - if (pict->transform) { - if (!PictureTransformPoint3d (pict->transform, &v)) - return; - unit.vector[0] = pict->transform->matrix[0][0]; - unit.vector[1] = pict->transform->matrix[1][0]; - unit.vector[2] = pict->transform->matrix[2][0]; - } else { - unit.vector[0] = xFixed1; - unit.vector[1] = 0; - unit.vector[2] = 0; - } - - dx = pGradient->linear.p2.x - pGradient->linear.p1.x; - dy = pGradient->linear.p2.y - pGradient->linear.p1.y; - l = dx*dx + dy*dy; - if (l != 0) { - a = (dx << 32) / l; - b = (dy << 32) / l; - off = (-a*pGradient->linear.p1.x - b*pGradient->linear.p1.y)>>16; - } - if (l == 0 || (unit.vector[2] == 0 && v.vector[2] == xFixed1)) { - xFixed_48_16 inc, t; - /* affine transformation only */ - if (l == 0) { - t = 0; - inc = 0; - } else { - t = ((a*v.vector[0] + b*v.vector[1]) >> 16) + off; - inc = (a * unit.vector[0] + b * unit.vector[1]) >> 16; - } - while (buffer < end) { - *buffer++ = gradientPixel(pGradient, t, pict->repeatType); - t += inc; - } - } else { - /* projective transformation */ - while (buffer < end) { - xFixed_48_16 t; - if (v.vector[2] == 0) { - t = 0; - } else { - xFixed_48_16 x, y; - x = ((xFixed_48_16)v.vector[0] << 16) / v.vector[2]; - y = ((xFixed_48_16)v.vector[1] << 16) / v.vector[2]; - t = ((a*x + b*y) >> 16) + off; - } - *buffer++ = gradientPixel(pGradient, t, pict->repeatType); - v.vector[0] += unit.vector[0]; - v.vector[1] += unit.vector[1]; - v.vector[2] += unit.vector[2]; - } - } - } else { - /* radial or conical */ - Bool affine = TRUE; - double cx = 1.; - double cy = 0.; - double cz = 0.; - double rx = x; - double ry = y; - double rz = 1.; - - if (pict->transform) { - PictVector v; - v.vector[0] = IntToxFixed(x); - v.vector[1] = IntToxFixed(y); - v.vector[2] = xFixed1; - if (!PictureTransformPoint3d (pict->transform, &v)) - return; - - cx = pict->transform->matrix[0][0]/65536.; - cy = pict->transform->matrix[1][0]/65536.; - cz = pict->transform->matrix[2][0]/65536.; - rx = v.vector[0]/65536.; - ry = v.vector[1]/65536.; - rz = v.vector[2]/65536.; - affine = pict->transform->matrix[2][0] == 0 && v.vector[2] == xFixed1; - } - - if (pGradient->type == SourcePictTypeRadial) { - if (affine) { - rx -= pGradient->radial.fx; - ry -= pGradient->radial.fy; - - while (buffer < end) { - double b = 2*(rx*pGradient->radial.dx + ry*pGradient->radial.dy); - double c = -(rx*rx + ry*ry); - double det = (b * b) - (4 * pGradient->radial.a * c); - double s = (-b + sqrt(det))/(2. * pGradient->radial.a); - *buffer = gradientPixel(pGradient, - (xFixed_48_16)((s*pGradient->radial.m + pGradient->radial.b)*65536), - pict->repeatType); - ++buffer; - rx += cx; - ry += cy; - } - } else { - while (buffer < end) { - double x, y; - double b, c, det, s; - if (rz != 0) { - x = rx/rz; - y = ry/rz; - } else { - x = y = 0.; - } - x -= pGradient->radial.fx; - y -= pGradient->radial.fy; - b = 2*(x*pGradient->radial.dx + y*pGradient->radial.dy); - c = -(x*x + y*y); - det = (b * b) - (4 * pGradient->radial.a * c); - s = (-b + sqrt(det))/(2. * pGradient->radial.a); - *buffer = gradientPixel(pGradient, - (xFixed_48_16)((s*pGradient->radial.m + pGradient->radial.b)*65536), - pict->repeatType); - ++buffer; - rx += cx; - ry += cy; - rz += cz; - } - } - } else /* SourcePictTypeConical */ { - double a = pGradient->conical.angle/(180.*65536); - if (affine) { - rx -= pGradient->conical.center.x/65536.; - ry -= pGradient->conical.center.y/65536.; - - while (buffer < end) { - double angle = atan2(ry, rx) + a; - *buffer = gradientPixel(pGradient, (xFixed_48_16) (angle * (65536. / (2*M_PI))), - pict->repeatType); - ++buffer; - rx += cx; - ry += cy; - } - } else { - - while (buffer < end) { - double x, y, angle; - if (rz != 0) { - x = rx/rz; - y = ry/rz; - } else { - x = y = 0.; - } - x -= pGradient->conical.center.x/65536.; - y -= pGradient->conical.center.y/65536.; - angle = atan2(y, x) + a; - *buffer = gradientPixel(pGradient, (xFixed_48_16) (angle * (65536. / (2*M_PI))), - pict->repeatType); - ++buffer; - rx += cx; - ry += cy; - rz += cz; - } - } - } - } -} - - - -static void fbFetchTransformed(PicturePtr pict, int x, int y, int width, CARD32 *buffer) -{ - FbBits *bits; - FbStride stride; - int bpp; - int xoff, yoff, dx, dy; - fetchPixelProc fetch; - PictVector v; - PictVector unit; - int i; - BoxRec box; - miIndexedPtr indexed = (miIndexedPtr) pict->pFormat->index.devPrivate; - Bool affine = TRUE; - - fetch = fetchPixelProcForPicture(pict); - - fbGetDrawable(pict->pDrawable, bits, stride, bpp, xoff, yoff); - x += xoff; - y += yoff; - - dx = pict->pDrawable->x; - dy = pict->pDrawable->y; - - v.vector[0] = IntToxFixed(x - dx); - v.vector[1] = IntToxFixed(y - dy); - v.vector[2] = xFixed1; - - /* when using convolution filters one might get here without a transform */ - if (pict->transform) { - if (!PictureTransformPoint3d (pict->transform, &v)) - return; - unit.vector[0] = pict->transform->matrix[0][0]; - unit.vector[1] = pict->transform->matrix[1][0]; - unit.vector[2] = pict->transform->matrix[2][0]; - affine = v.vector[2] == xFixed1 && unit.vector[2] == 0; - } else { - unit.vector[0] = xFixed1; - unit.vector[1] = 0; - unit.vector[2] = 0; - } - - if (pict->filter == PictFilterNearest) - { - if (pict->repeatType == RepeatNormal) { - if (RegionNumRects(pict->pCompositeClip) == 1) { - for (i = 0; i < width; ++i) { - if (!v.vector[2]) { - buffer[i] = 0; - } else { - if (!affine) { - y = MOD(DIV(v.vector[1],v.vector[2]), pict->pDrawable->height); - x = MOD(DIV(v.vector[0],v.vector[2]), pict->pDrawable->width); - } else { - y = MOD(v.vector[1]>>16, pict->pDrawable->height); - x = MOD(v.vector[0]>>16, pict->pDrawable->width); - } - buffer[i] = fetch(bits + (y + dy)*stride, x + dx, indexed); - } - v.vector[0] += unit.vector[0]; - v.vector[1] += unit.vector[1]; - v.vector[2] += unit.vector[2]; - } - } else { - for (i = 0; i < width; ++i) { - if (!v.vector[2]) { - buffer[i] = 0; - } else { - if (!affine) { - y = MOD(DIV(v.vector[1],v.vector[2]), pict->pDrawable->height); - x = MOD(DIV(v.vector[0],v.vector[2]), pict->pDrawable->width); - } else { - y = MOD(v.vector[1]>>16, pict->pDrawable->height); - x = MOD(v.vector[0]>>16, pict->pDrawable->width); - } - if (RegionContainsPoint(pict->pCompositeClip, x + dx, y + dy, &box)) - buffer[i] = fetch(bits + (y + dy)*stride, x + dx, indexed); - else - buffer[i] = 0; - } - v.vector[0] += unit.vector[0]; - v.vector[1] += unit.vector[1]; - v.vector[2] += unit.vector[2]; - } - } - } else { - if (RegionNumRects(pict->pCompositeClip) == 1) { - box = pict->pCompositeClip->extents; - for (i = 0; i < width; ++i) { - if (!v.vector[2]) { - buffer[i] = 0; - } else { - if (!affine) { - y = DIV(v.vector[1],v.vector[2]); - x = DIV(v.vector[0],v.vector[2]); - } else { - y = v.vector[1]>>16; - x = v.vector[0]>>16; - } - buffer[i] = ((x < box.x1-dx) | (x >= box.x2-dx) | (y < box.y1-dy) | (y >= box.y2-dy)) ? - 0 : fetch(bits + (y + dy)*stride, x + dx, indexed); - } - v.vector[0] += unit.vector[0]; - v.vector[1] += unit.vector[1]; - v.vector[2] += unit.vector[2]; - } - } else { - for (i = 0; i < width; ++i) { - if (!v.vector[2]) { - buffer[i] = 0; - } else { - if (!affine) { - y = DIV(v.vector[1],v.vector[2]); - x = DIV(v.vector[0],v.vector[2]); - } else { - y = v.vector[1]>>16; - x = v.vector[0]>>16; - } - if (RegionContainsPoint(pict->pCompositeClip, x + dx, y + dy, &box)) - buffer[i] = fetch(bits + (y + dy)*stride, x + dx, indexed); - else - buffer[i] = 0; - } - v.vector[0] += unit.vector[0]; - v.vector[1] += unit.vector[1]; - v.vector[2] += unit.vector[2]; - } - } - } - } else if (pict->filter == PictFilterBilinear) { - if (pict->repeatType == RepeatNormal) { - if (RegionNumRects(pict->pCompositeClip) == 1) { - for (i = 0; i < width; ++i) { - if (!v.vector[2]) { - buffer[i] = 0; - } else { - int x1, x2, y1, y2, distx, idistx, disty, idisty; - FbBits *b; - CARD32 tl, tr, bl, br, r; - CARD32 ft, fb; - - if (!affine) { - xFixed_48_16 div; - div = ((xFixed_48_16)v.vector[0] << 16)/v.vector[2]; - x1 = div >> 16; - distx = ((xFixed)div >> 8) & 0xff; - div = ((xFixed_48_16)v.vector[1] << 16)/v.vector[2]; - y1 = div >> 16; - disty = ((xFixed)div >> 8) & 0xff; - } else { - x1 = v.vector[0] >> 16; - distx = (v.vector[0] >> 8) & 0xff; - y1 = v.vector[1] >> 16; - disty = (v.vector[1] >> 8) & 0xff; - } - x2 = x1 + 1; - y2 = y1 + 1; - - idistx = 256 - distx; - idisty = 256 - disty; - - x1 = MOD (x1, pict->pDrawable->width); - x2 = MOD (x2, pict->pDrawable->width); - y1 = MOD (y1, pict->pDrawable->height); - y2 = MOD (y2, pict->pDrawable->height); - - b = bits + (y1 + dy)*stride; - - tl = fetch(b, x1 + dx, indexed); - tr = fetch(b, x2 + dx, indexed); - b = bits + (y2 + dy)*stride; - bl = fetch(b, x1 + dx, indexed); - br = fetch(b, x2 + dx, indexed); - - ft = FbGet8(tl,0) * idistx + FbGet8(tr,0) * distx; - fb = FbGet8(bl,0) * idistx + FbGet8(br,0) * distx; - r = (((ft * idisty + fb * disty) >> 16) & 0xff); - ft = FbGet8(tl,8) * idistx + FbGet8(tr,8) * distx; - fb = FbGet8(bl,8) * idistx + FbGet8(br,8) * distx; - r |= (((ft * idisty + fb * disty) >> 8) & 0xff00); - ft = FbGet8(tl,16) * idistx + FbGet8(tr,16) * distx; - fb = FbGet8(bl,16) * idistx + FbGet8(br,16) * distx; - r |= (((ft * idisty + fb * disty)) & 0xff0000); - ft = FbGet8(tl,24) * idistx + FbGet8(tr,24) * distx; - fb = FbGet8(bl,24) * idistx + FbGet8(br,24) * distx; - r |= (((ft * idisty + fb * disty) << 8) & 0xff000000); - buffer[i] = r; - } - v.vector[0] += unit.vector[0]; - v.vector[1] += unit.vector[1]; - v.vector[2] += unit.vector[2]; - } - } else { - for (i = 0; i < width; ++i) { - if (!v.vector[2]) { - buffer[i] = 0; - } else { - int x1, x2, y1, y2, distx, idistx, disty, idisty; - FbBits *b; - CARD32 tl, tr, bl, br, r; - CARD32 ft, fb; - - if (!affine) { - xFixed_48_16 div; - div = ((xFixed_48_16)v.vector[0] << 16)/v.vector[2]; - x1 = div >> 16; - distx = ((xFixed)div >> 8) & 0xff; - div = ((xFixed_48_16)v.vector[1] << 16)/v.vector[2]; - y1 = div >> 16; - disty = ((xFixed)div >> 8) & 0xff; - } else { - x1 = v.vector[0] >> 16; - distx = (v.vector[0] >> 8) & 0xff; - y1 = v.vector[1] >> 16; - disty = (v.vector[1] >> 8) & 0xff; - } - x2 = x1 + 1; - y2 = y1 + 1; - - idistx = 256 - distx; - idisty = 256 - disty; - - x1 = MOD (x1, pict->pDrawable->width); - x2 = MOD (x2, pict->pDrawable->width); - y1 = MOD (y1, pict->pDrawable->height); - y2 = MOD (y2, pict->pDrawable->height); - - b = bits + (y1 + dy)*stride; - - tl = RegionContainsPoint(pict->pCompositeClip, x1 + dx, y1 + dy, &box) - ? fetch(b, x1 + dx, indexed) : 0; - tr = RegionContainsPoint(pict->pCompositeClip, x2 + dx, y1 + dy, &box) - ? fetch(b, x2 + dx, indexed) : 0; - b = bits + (y2 + dy)*stride; - bl = RegionContainsPoint(pict->pCompositeClip, x1 + dx, y2 + dy, &box) - ? fetch(b, x1 + dx, indexed) : 0; - br = RegionContainsPoint(pict->pCompositeClip, x2 + dx, y2 + dy, &box) - ? fetch(b, x2 + dx, indexed) : 0; - - ft = FbGet8(tl,0) * idistx + FbGet8(tr,0) * distx; - fb = FbGet8(bl,0) * idistx + FbGet8(br,0) * distx; - r = (((ft * idisty + fb * disty) >> 16) & 0xff); - ft = FbGet8(tl,8) * idistx + FbGet8(tr,8) * distx; - fb = FbGet8(bl,8) * idistx + FbGet8(br,8) * distx; - r |= (((ft * idisty + fb * disty) >> 8) & 0xff00); - ft = FbGet8(tl,16) * idistx + FbGet8(tr,16) * distx; - fb = FbGet8(bl,16) * idistx + FbGet8(br,16) * distx; - r |= (((ft * idisty + fb * disty)) & 0xff0000); - ft = FbGet8(tl,24) * idistx + FbGet8(tr,24) * distx; - fb = FbGet8(bl,24) * idistx + FbGet8(br,24) * distx; - r |= (((ft * idisty + fb * disty) << 8) & 0xff000000); - buffer[i] = r; - } - v.vector[0] += unit.vector[0]; - v.vector[1] += unit.vector[1]; - v.vector[2] += unit.vector[2]; - } - } - } else { - if (RegionNumRects(pict->pCompositeClip) == 1) { - box = pict->pCompositeClip->extents; - for (i = 0; i < width; ++i) { - if (!v.vector[2]) { - buffer[i] = 0; - } else { - int x1, x2, y1, y2, distx, idistx, disty, idisty, x_off; - FbBits *b; - CARD32 tl, tr, bl, br, r; - Bool x1_out, x2_out, y1_out, y2_out; - CARD32 ft, fb; - - if (!affine) { - xFixed_48_16 div; - div = ((xFixed_48_16)v.vector[0] << 16)/v.vector[2]; - x1 = div >> 16; - distx = ((xFixed)div >> 8) & 0xff; - div = ((xFixed_48_16)v.vector[1] << 16)/v.vector[2]; - y1 = div >> 16; - disty = ((xFixed)div >> 8) & 0xff; - } else { - x1 = v.vector[0] >> 16; - distx = (v.vector[0] >> 8) & 0xff; - y1 = v.vector[1] >> 16; - disty = (v.vector[1] >> 8) & 0xff; - } - x2 = x1 + 1; - y2 = y1 + 1; - - idistx = 256 - distx; - idisty = 256 - disty; - - b = bits + (y1 + dy)*stride; - x_off = x1 + dx; - - x1_out = (x1 < box.x1-dx) | (x1 >= box.x2-dx); - x2_out = (x2 < box.x1-dx) | (x2 >= box.x2-dx); - y1_out = (y1 < box.y1-dy) | (y1 >= box.y2-dy); - y2_out = (y2 < box.y1-dy) | (y2 >= box.y2-dy); - - tl = x1_out|y1_out ? 0 : fetch(b, x_off, indexed); - tr = x2_out|y1_out ? 0 : fetch(b, x_off + 1, indexed); - b += stride; - bl = x1_out|y2_out ? 0 : fetch(b, x_off, indexed); - br = x2_out|y2_out ? 0 : fetch(b, x_off + 1, indexed); - - ft = FbGet8(tl,0) * idistx + FbGet8(tr,0) * distx; - fb = FbGet8(bl,0) * idistx + FbGet8(br,0) * distx; - r = (((ft * idisty + fb * disty) >> 16) & 0xff); - ft = FbGet8(tl,8) * idistx + FbGet8(tr,8) * distx; - fb = FbGet8(bl,8) * idistx + FbGet8(br,8) * distx; - r |= (((ft * idisty + fb * disty) >> 8) & 0xff00); - ft = FbGet8(tl,16) * idistx + FbGet8(tr,16) * distx; - fb = FbGet8(bl,16) * idistx + FbGet8(br,16) * distx; - r |= (((ft * idisty + fb * disty)) & 0xff0000); - ft = FbGet8(tl,24) * idistx + FbGet8(tr,24) * distx; - fb = FbGet8(bl,24) * idistx + FbGet8(br,24) * distx; - r |= (((ft * idisty + fb * disty) << 8) & 0xff000000); - buffer[i] = r; - } - v.vector[0] += unit.vector[0]; - v.vector[1] += unit.vector[1]; - v.vector[2] += unit.vector[2]; - } - } else { - for (i = 0; i < width; ++i) { - if (!v.vector[2]) { - buffer[i] = 0; - } else { - int x1, x2, y1, y2, distx, idistx, disty, idisty, x_off; - FbBits *b; - CARD32 tl, tr, bl, br, r; - CARD32 ft, fb; - - if (!affine) { - xFixed_48_16 div; - div = ((xFixed_48_16)v.vector[0] << 16)/v.vector[2]; - x1 = div >> 16; - distx = ((xFixed)div >> 8) & 0xff; - div = ((xFixed_48_16)v.vector[1] << 16)/v.vector[2]; - y1 = div >> 16; - disty = ((xFixed)div >> 8) & 0xff; - } else { - x1 = v.vector[0] >> 16; - distx = (v.vector[0] >> 8) & 0xff; - y1 = v.vector[1] >> 16; - disty = (v.vector[1] >> 8) & 0xff; - } - x2 = x1 + 1; - y2 = y1 + 1; - - idistx = 256 - distx; - idisty = 256 - disty; - - b = bits + (y1 + dy)*stride; - x_off = x1 + dx; - - tl = RegionContainsPoint(pict->pCompositeClip, x1 + dx, y1 + dy, &box) - ? fetch(b, x_off, indexed) : 0; - tr = RegionContainsPoint(pict->pCompositeClip, x2 + dx, y1 + dy, &box) - ? fetch(b, x_off + 1, indexed) : 0; - b += stride; - bl = RegionContainsPoint(pict->pCompositeClip, x1 + dx, y2 + dy, &box) - ? fetch(b, x_off, indexed) : 0; - br = RegionContainsPoint(pict->pCompositeClip, x2 + dx, y2 + dy, &box) - ? fetch(b, x_off + 1, indexed) : 0; - - ft = FbGet8(tl,0) * idistx + FbGet8(tr,0) * distx; - fb = FbGet8(bl,0) * idistx + FbGet8(br,0) * distx; - r = (((ft * idisty + fb * disty) >> 16) & 0xff); - ft = FbGet8(tl,8) * idistx + FbGet8(tr,8) * distx; - fb = FbGet8(bl,8) * idistx + FbGet8(br,8) * distx; - r |= (((ft * idisty + fb * disty) >> 8) & 0xff00); - ft = FbGet8(tl,16) * idistx + FbGet8(tr,16) * distx; - fb = FbGet8(bl,16) * idistx + FbGet8(br,16) * distx; - r |= (((ft * idisty + fb * disty)) & 0xff0000); - ft = FbGet8(tl,24) * idistx + FbGet8(tr,24) * distx; - fb = FbGet8(bl,24) * idistx + FbGet8(br,24) * distx; - r |= (((ft * idisty + fb * disty) << 8) & 0xff000000); - buffer[i] = r; - } - v.vector[0] += unit.vector[0]; - v.vector[1] += unit.vector[1]; - v.vector[2] += unit.vector[2]; - } - } - } - } else if (pict->filter == PictFilterConvolution) { - xFixed *params = pict->filter_params; - INT32 cwidth = xFixedToInt(params[0]); - INT32 cheight = xFixedToInt(params[1]); - int xoff = params[0] >> 1; - int yoff = params[1] >> 1; - params += 2; - for (i = 0; i < width; ++i) { - if (!v.vector[2]) { - buffer[i] = 0; - } else { - int x1, x2, y1, y2, x, y; - INT32 srtot, sgtot, sbtot, satot; - xFixed *p = params; - - if (!affine) { - xFixed_48_16 tmp; - tmp = ((xFixed_48_16)v.vector[0] << 16)/v.vector[2] - xoff; - x1 = xFixedToInt(tmp); - tmp = ((xFixed_48_16)v.vector[1] << 16)/v.vector[2] - yoff; - y1 = xFixedToInt(tmp); - } else { - x1 = xFixedToInt(v.vector[0] - xoff); - y1 = xFixedToInt(v.vector[1] - yoff); - } - x2 = x1 + cwidth; - y2 = y1 + cheight; - - srtot = sgtot = sbtot = satot = 0; - - for (y = y1; y < y2; y++) { - int ty = (pict->repeatType == RepeatNormal) ? MOD (y, pict->pDrawable->height) : y; - for (x = x1; x < x2; x++) { - if (*p) { - int tx = (pict->repeatType == RepeatNormal) ? MOD (x, pict->pDrawable->width) : x; - if (RegionContainsPoint(pict->pCompositeClip, tx + dx, ty + dy, &box)) { - FbBits *b = bits + (ty + dy)*stride; - CARD32 c = fetch(b, tx + dx, indexed); - - srtot += Red(c) * *p; - sgtot += Green(c) * *p; - sbtot += Blue(c) * *p; - satot += Alpha(c) * *p; - } - } - p++; - } - } - - if (satot < 0) satot = 0; else if (satot > 0xff) satot = 0xff; - if (srtot < 0) srtot = 0; else if (srtot > 0xff) srtot = 0xff; - if (sgtot < 0) sgtot = 0; else if (sgtot > 0xff) sgtot = 0xff; - if (sbtot < 0) sbtot = 0; else if (sbtot > 0xff) sbtot = 0xff; - - buffer[i] = ((satot << 24) | - (srtot << 16) | - (sgtot << 8) | - (sbtot )); - } - v.vector[0] += unit.vector[0]; - v.vector[1] += unit.vector[1]; - v.vector[2] += unit.vector[2]; - } - } -} - - -static void fbFetchExternalAlpha(PicturePtr pict, int x, int y, int width, CARD32 *buffer) -{ - int i; - CARD32 _alpha_buffer[SCANLINE_BUFFER_LENGTH]; - CARD32 *alpha_buffer = _alpha_buffer; - - if (!pict->alphaMap) { - fbFetchTransformed(pict, x, y, width, buffer); - return; - } - if (width > SCANLINE_BUFFER_LENGTH) - alpha_buffer = (CARD32 *) malloc(width*sizeof(CARD32)); - - fbFetchTransformed(pict, x, y, width, buffer); - fbFetchTransformed(pict->alphaMap, x - pict->alphaOrigin.x, y - pict->alphaOrigin.y, width, alpha_buffer); - for (i = 0; i < width; ++i) { - int a = alpha_buffer[i]>>24; - buffer[i] = (a << 24) - | (div_255(Red(buffer[i]) * a) << 16) - | (div_255(Green(buffer[i]) * a) << 8) - | (div_255(Blue(buffer[i]) * a)); - } - - if (alpha_buffer != _alpha_buffer) - free(alpha_buffer); -} - -static void fbStore(PicturePtr pict, int x, int y, int width, CARD32 *buffer) -{ - FbBits *bits; - FbStride stride; - int bpp; - int xoff, yoff; - storeProc store = storeProcForPicture(pict); - miIndexedPtr indexed = (miIndexedPtr) pict->pFormat->index.devPrivate; - - fbGetDrawable (pict->pDrawable, bits, stride, bpp, xoff, yoff); - x += xoff; - y += yoff; - - bits += y*stride; - store(bits, buffer, x, width, indexed); -} - -static void fbStoreExternalAlpha(PicturePtr pict, int x, int y, int width, CARD32 *buffer) -{ - FbBits *bits, *alpha_bits; - FbStride stride, astride; - int bpp, abpp; - int xoff, yoff; - int ax, ay; - storeProc store; - storeProc astore; - miIndexedPtr indexed = (miIndexedPtr) pict->pFormat->index.devPrivate; - miIndexedPtr aindexed; - - if (!pict->alphaMap) { - fbStore(pict, x, y, width, buffer); - return; - } - - store = storeProcForPicture(pict); - astore = storeProcForPicture(pict->alphaMap); - aindexed = (miIndexedPtr) pict->alphaMap->pFormat->index.devPrivate; - - ax = x; - ay = y; - - fbGetDrawable (pict->pDrawable, bits, stride, bpp, xoff, yoff); - x += xoff; - y += yoff; - fbGetDrawable (pict->alphaMap->pDrawable, alpha_bits, astride, abpp, xoff, yoff); - ax += xoff; - ay += yoff; - - bits += y*stride; - alpha_bits += (ay - pict->alphaOrigin.y)*astride; - - - store(bits, buffer, x, width, indexed); - astore(alpha_bits, buffer, ax - pict->alphaOrigin.x, width, aindexed); -} - -typedef void (*scanStoreProc)(PicturePtr , int , int , int , CARD32 *); -typedef void (*scanFetchProc)(PicturePtr , int , int , int , CARD32 *); - -static void -fbCompositeRect (const FbComposeData *data, CARD32 *scanline_buffer) -{ - CARD32 *src_buffer = scanline_buffer; - CARD32 *dest_buffer = src_buffer + data->width; - int i; - scanStoreProc store; - scanFetchProc fetchSrc = NULL, fetchMask = NULL, fetchDest = NULL; - - if (data->op == PictOpClear) - fetchSrc = NULL; - else if (!data->src->pDrawable) { - if (data->src->pSourcePict) - fetchSrc = fbFetchSourcePict; - } else if (data->src->alphaMap) - fetchSrc = fbFetchExternalAlpha; - else if (data->src->repeatType == RepeatNormal && - data->src->pDrawable->width == 1 && data->src->pDrawable->height == 1) - fetchSrc = fbFetchSolid; - else if (!data->src->transform && data->src->filter != PictFilterConvolution) - fetchSrc = fbFetch; - else - fetchSrc = fbFetchTransformed; - - if (data->mask && data->op != PictOpClear) { - if (!data->mask->pDrawable) { - if (data->mask->pSourcePict) - fetchMask = fbFetchSourcePict; - } else if (data->mask->alphaMap) - fetchMask = fbFetchExternalAlpha; - else if (data->mask->repeatType == RepeatNormal - && data->mask->pDrawable->width == 1 && data->mask->pDrawable->height == 1) - fetchMask = fbFetchSolid; - else if (!data->mask->transform && data->mask->filter != PictFilterConvolution) - fetchMask = fbFetch; - else - fetchMask = fbFetchTransformed; - } else { - fetchMask = NULL; - } - - if (data->dest->alphaMap) { - fetchDest = fbFetchExternalAlpha; - store = fbStoreExternalAlpha; - } else { - fetchDest = fbFetch; - store = fbStore; - } - if (data->op == PictOpClear || data->op == PictOpSrc) - fetchDest = NULL; - - if (fetchSrc && fetchMask && data->mask && data->mask->componentAlpha && PICT_FORMAT_RGB(data->mask->format)) { - CARD32 *mask_buffer = dest_buffer + data->width; - CombineFuncC compose = composeFunctions.combineC[data->op]; - if (!compose) - return; - - for (i = 0; i < data->height; ++i) - { - /* fill first half of scanline with source */ - fetchSrc(data->src, data->xSrc, data->ySrc + i, data->width, src_buffer); - fetchMask(data->mask, data->xMask, data->yMask + i, data->width, mask_buffer); - - /* fill dest into second half of scanline */ - if (fetchDest) - fetchDest(data->dest, data->xDest, data->yDest + i, data->width, dest_buffer); - - /* blend */ - compose(dest_buffer, src_buffer, mask_buffer, data->width); - - /* write back */ - store(data->dest, data->xDest, data->yDest + i, data->width, dest_buffer); - } - } else { - - CombineFuncU compose = composeFunctions.combineU[data->op]; - if (!compose) - return; - - if (fetchSrc == fbFetchSolid && (!fetchMask || fetchMask == fbFetchSolid)) { - fetchSrc(data->src, data->xSrc, data->ySrc, data->width, src_buffer); - if (fetchMask) { - fetchMask(data->mask, data->xMask, data->yMask, data->width, dest_buffer); - composeFunctions.combineMaskU(src_buffer, dest_buffer, data->width); - } - fetchSrc = NULL; - fetchMask = NULL; - } - - for (i = 0; i < data->height; ++i) - { - /* fill first half of scanline with source */ - if (fetchSrc) { - fetchSrc(data->src, data->xSrc, data->ySrc + i, data->width, src_buffer); - - /* add in mask */ - if (fetchMask) { - fetchMask(data->mask, data->xMask, data->yMask + i, data->width, dest_buffer); - composeFunctions.combineMaskU(src_buffer, dest_buffer, data->width); - } - } - - /* fill dest into second half of scanline */ - if (fetchDest) - fetchDest(data->dest, data->xDest, data->yDest + i, data->width, dest_buffer); - - /* blend */ - compose(dest_buffer, src_buffer, data->width); - - /* write back */ - store(data->dest, data->xDest, data->yDest + i, data->width, dest_buffer); - } - } -} - -void -fbCompositeGeneral (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - RegionRec region; - int n; - BoxPtr pbox; - Bool srcRepeat = FALSE; - Bool maskRepeat = FALSE; - int w, h; - CARD32 _scanline_buffer[SCANLINE_BUFFER_LENGTH*3]; - CARD32 *scanline_buffer = _scanline_buffer; - FbComposeData compose_data; - - if (pSrc->pDrawable) - srcRepeat = pSrc->repeatType == RepeatNormal && !pSrc->transform - && (pSrc->pDrawable->width != 1 || pSrc->pDrawable->height != 1); - - if (pMask && pMask->pDrawable) - maskRepeat = pMask->repeatType == RepeatNormal && !pMask->transform - && (pMask->pDrawable->width != 1 || pMask->pDrawable->height != 1); - - if (op == PictOpOver && !pMask && !pSrc->transform && !PICT_FORMAT_A(pSrc->format) && !pSrc->alphaMap) - op = PictOpSrc; - - if (!miComputeCompositeRegion (®ion, - pSrc, - pMask, - pDst, - xSrc, - ySrc, - xMask, - yMask, - xDst, - yDst, - width, - height)) - return; - - compose_data.op = op; - compose_data.src = pSrc; - compose_data.mask = pMask; - compose_data.dest = pDst; - if (width > SCANLINE_BUFFER_LENGTH) - scanline_buffer = (CARD32 *) malloc(width * 3 * sizeof(CARD32)); - - n = RegionNumRects (®ion); - pbox = RegionRects (®ion); - while (n--) - { - h = pbox->y2 - pbox->y1; - compose_data.ySrc = pbox->y1 - yDst + ySrc; - compose_data.yMask = pbox->y1 - yDst + yMask; - compose_data.yDest = pbox->y1; - while (h) - { - compose_data.height = h; - w = pbox->x2 - pbox->x1; - compose_data.xSrc = pbox->x1 - xDst + xSrc; - compose_data.xMask = pbox->x1 - xDst + xMask; - compose_data.xDest = pbox->x1; - if (maskRepeat) - { - compose_data.yMask = mod (compose_data.yMask, pMask->pDrawable->height); - if (compose_data.height > pMask->pDrawable->height - compose_data.yMask) - compose_data.height = pMask->pDrawable->height - compose_data.yMask; - } - if (srcRepeat) - { - compose_data.ySrc = mod (compose_data.ySrc, pSrc->pDrawable->height); - if (compose_data.height > pSrc->pDrawable->height - compose_data.ySrc) - compose_data.height = pSrc->pDrawable->height - compose_data.ySrc; - } - while (w) - { - compose_data.width = w; - if (maskRepeat) - { - compose_data.xMask = mod (compose_data.xMask, pMask->pDrawable->width); - if (compose_data.width > pMask->pDrawable->width - compose_data.xMask) - compose_data.width = pMask->pDrawable->width - compose_data.xMask; - } - if (srcRepeat) - { - compose_data.xSrc = mod (compose_data.xSrc, pSrc->pDrawable->width); - if (compose_data.width > pSrc->pDrawable->width - compose_data.xSrc) - compose_data.width = pSrc->pDrawable->width - compose_data.xSrc; - } - fbCompositeRect(&compose_data, scanline_buffer); - w -= compose_data.width; - compose_data.xSrc += compose_data.width; - compose_data.xMask += compose_data.width; - compose_data.xDest += compose_data.width; - } - h -= compose_data.height; - compose_data.ySrc += compose_data.height; - compose_data.yMask += compose_data.height; - compose_data.yDest += compose_data.height; - } - pbox++; - } - RegionUninit(®ion); - - if (scanline_buffer != _scanline_buffer) - free(scanline_buffer); -} - -#endif diff --git a/nx-X11/programs/Xserver/fb/fbcopy.c b/nx-X11/programs/Xserver/fb/fbcopy.c index 7a1dbb5aaa..ab98400dfb 100644 --- a/nx-X11/programs/Xserver/fb/fbcopy.c +++ b/nx-X11/programs/Xserver/fb/fbcopy.c @@ -1,6 +1,4 @@ /* - * Id: fbcopy.c,v 1.1 1999/11/02 03:54:45 keithp Exp $ - * * Copyright © 1998 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its @@ -59,6 +57,23 @@ fbCopyNtoN (DrawablePtr pSrcDrawable, while (nbox--) { +#ifndef FB_ACCESS_WRAPPER /* pixman_blt() doesn't support accessors yet */ + if (pm == FB_ALLONES && alu == GXcopy && !reverse && + !upsidedown) + { + if (!pixman_blt ((uint32_t *)src, (uint32_t *)dst, srcStride, dstStride, srcBpp, dstBpp, + (pbox->x1 + dx + srcXoff), + (pbox->y1 + dy + srcYoff), + (pbox->x1 + dstXoff), + (pbox->y1 + dstYoff), + (pbox->x2 - pbox->x1), + (pbox->y2 - pbox->y1))) + goto fallback; + else + goto next; + } + fallback: +#endif fbBlt (src + (pbox->y1 + dy + srcYoff) * srcStride, srcStride, (pbox->x1 + dx + srcXoff) * srcBpp, @@ -76,8 +91,13 @@ fbCopyNtoN (DrawablePtr pSrcDrawable, reverse, upsidedown); +#ifndef FB_ACCESS_WRAPPER + next: +#endif pbox++; } + fbFinishAccess (pDstDrawable); + fbFinishAccess (pSrcDrawable); } void @@ -148,6 +168,9 @@ fbCopy1toN (DrawablePtr pSrcDrawable, } pbox++; } + + fbFinishAccess (pDstDrawable); + fbFinishAccess (pSrcDrawable); } void @@ -196,6 +219,8 @@ fbCopyNto1 (DrawablePtr pSrcDrawable, (FbStip) pPriv->and, (FbStip) pPriv->xor, (FbStip) pPriv->bgand, (FbStip) pPriv->bgxor, bitplane); + fbFinishAccess (pDstDrawable); + fbFinishAccess (pSrcDrawable); } else { @@ -256,6 +281,9 @@ fbCopyNto1 (DrawablePtr pSrcDrawable, pPriv->and, pPriv->xor, pPriv->bgand, pPriv->bgxor); free (tmp); + + fbFinishAccess (pDstDrawable); + fbFinishAccess (pSrcDrawable); } pbox++; } diff --git a/nx-X11/programs/Xserver/fb/fbedge.c b/nx-X11/programs/Xserver/fb/fbedge.c deleted file mode 100644 index 66dcdc35f4..0000000000 --- a/nx-X11/programs/Xserver/fb/fbedge.c +++ /dev/null @@ -1,314 +0,0 @@ -/* - * $Id: fbedge.c,v 1.5 2005/10/03 10:20:29 anholt Exp $ - * - * Copyright © 2004 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 - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#include "fb.h" - -#ifdef RENDER - -#include "picturestr.h" -#include "mipict.h" -#include "renderedge.h" -#include "fbpict.h" - -/* - * 4 bit alpha - */ - -#define N_BITS 4 -#define rasterizeEdges fbRasterizeEdges4 - -#if BITMAP_BIT_ORDER == LSBFirst -#define Shift4(o) ((o) << 2) -#else -#define Shift4(o) ((1-(o)) << 2) -#endif - -#define Get4(x,o) (((x) >> Shift4(o)) & 0xf) -#define Put4(x,o,v) (((x) & ~(0xf << Shift4(o))) | (((v) & 0xf) << Shift4(o))) - -#define DefineAlpha(line,x) \ - CARD8 *__ap = (CARD8 *) line + ((x) >> 1); \ - int __ao = (x) & 1 - -#define StepAlpha ((__ap += __ao), (__ao ^= 1)) - -#define AddAlpha(a) { \ - CARD8 __o = *__ap; \ - CARD8 __a = (a) + Get4(__o, __ao); \ - *__ap = Put4 (__o, __ao, __a | (0 - ((__a) >> 4))); \ -} - -#include "fbedgeimp.h" - -#undef AddAlpha -#undef StepAlpha -#undef DefineAlpha -#undef rasterizeEdges -#undef N_BITS - - -/* - * 1 bit alpha - */ - -#define N_BITS 1 -#define rasterizeEdges fbRasterizeEdges1 - -#include "fbedgeimp.h" - -#undef rasterizeEdges -#undef N_BITS - -/* - * 8 bit alpha - */ - -static INLINE CARD8 -clip255 (int x) -{ - if (x > 255) return 255; - return x; -} - -static INLINE void -add_saturate_8 (CARD8 *buf, int value, int length) -{ - while (length--) - { - *buf = clip255 (*buf + value); - buf++; - } -} - -/* - * We want to detect the case where we add the same value to a long - * span of pixels. The triangles on the end are filled in while we - * count how many sub-pixel scanlines contribute to the middle section. - * - * +--------------------------+ - * fill_height =| \ / - * +------------------+ - * |================| - * fill_start fill_end - */ -static void -fbRasterizeEdges8 (FbBits *buf, - int width, - int stride, - RenderEdge *l, - RenderEdge *r, - xFixed t, - xFixed b) -{ - xFixed y = t; - FbBits *line; - int fill_start = -1, fill_end = -1; - int fill_size = 0; - - line = buf + xFixedToInt (y) * stride; - - for (;;) - { - CARD8 *ap = (CARD8 *) line; - xFixed lx, rx; - int lxi, rxi; - - /* clip X */ - lx = l->x; - if (lx < 0) - lx = 0; - rx = r->x; - if (xFixedToInt (rx) >= width) - rx = IntToxFixed (width); - - /* Skip empty (or backwards) sections */ - if (rx > lx) - { - int lxs, rxs; - - /* Find pixel bounds for span. */ - lxi = xFixedToInt (lx); - rxi = xFixedToInt (rx); - - /* Sample coverage for edge pixels */ - lxs = RenderSamplesX (lx, 8); - rxs = RenderSamplesX (rx, 8); - - /* Add coverage across row */ - if (lxi == rxi) - { - ap[lxi] = clip255 (ap[lxi] + rxs - lxs); - } - else - { - ap[lxi] = clip255 (ap[lxi] + N_X_FRAC(8) - lxs); - - /* Move forward so that lxi/rxi is the pixel span */ - lxi++; - - /* Don't bother trying to optimize the fill unless - * the span is longer than 4 pixels. */ - if (rxi - lxi > 4) - { - if (fill_start < 0) - { - fill_start = lxi; - fill_end = rxi; - fill_size++; - } - else - { - if (lxi >= fill_end || rxi < fill_start) - { - /* We're beyond what we saved, just fill it */ - add_saturate_8 (ap + fill_start, - fill_size * N_X_FRAC(8), - fill_end - fill_start); - fill_start = lxi; - fill_end = rxi; - fill_size = 1; - } - else - { - /* Update fill_start */ - if (lxi > fill_start) - { - add_saturate_8 (ap + fill_start, - fill_size * N_X_FRAC(8), - lxi - fill_start); - fill_start = lxi; - } - else if (lxi < fill_start) - { - add_saturate_8 (ap + lxi, N_X_FRAC(8), - fill_start - lxi); - } - - /* Update fill_end */ - if (rxi < fill_end) - { - add_saturate_8 (ap + rxi, - fill_size * N_X_FRAC(8), - fill_end - rxi); - fill_end = rxi; - } - else if (fill_end < rxi) - { - add_saturate_8 (ap + fill_end, - N_X_FRAC(8), - rxi - fill_end); - } - fill_size++; - } - } - } - else - { - add_saturate_8 (ap + lxi, N_X_FRAC(8), rxi - lxi); - } - - /* Do not add in a 0 alpha here. This check is - * necessary to avoid a buffer overrun, (when rx - * is exactly on a pixel boundary). */ - if (rxs) - ap[rxi] = clip255 (ap[rxi] + rxs); - } - } - - if (y == b) { - /* We're done, make sure we clean up any remaining fill. */ - if (fill_start != fill_end) { - if (fill_size == N_Y_FRAC(8)) - { - memset (ap + fill_start, 0xff, fill_end - fill_start); - } - else - { - add_saturate_8 (ap + fill_start, fill_size * N_X_FRAC(8), - fill_end - fill_start); - } - } - break; - } - - if (xFixedFrac (y) != Y_FRAC_LAST(8)) - { - RenderEdgeStepSmall (l); - RenderEdgeStepSmall (r); - y += STEP_Y_SMALL(8); - } - else - { - RenderEdgeStepBig (l); - RenderEdgeStepBig (r); - y += STEP_Y_BIG(8); - if (fill_start != fill_end) - { - if (fill_size == N_Y_FRAC(8)) - { - memset (ap + fill_start, 0xff, fill_end - fill_start); - } - else - { - add_saturate_8 (ap + fill_start, fill_size * N_X_FRAC(8), - fill_end - fill_start); - } - fill_start = fill_end = -1; - fill_size = 0; - } - line += stride; - } - } -} - -void -fbRasterizeEdges (FbBits *buf, - int bpp, - int width, - int stride, - RenderEdge *l, - RenderEdge *r, - xFixed t, - xFixed b) -{ - switch (bpp) { - case 1: - fbRasterizeEdges1 (buf, width, stride, l, r, t, b); - break; - case 4: - fbRasterizeEdges4 (buf, width, stride, l, r, t, b); - break; - case 8: - fbRasterizeEdges8 (buf, width, stride, l, r, t, b); - break; - } -} - -#endif /* RENDER */ diff --git a/nx-X11/programs/Xserver/fb/fbedgeimp.h b/nx-X11/programs/Xserver/fb/fbedgeimp.h deleted file mode 100644 index 6b363d7cec..0000000000 --- a/nx-X11/programs/Xserver/fb/fbedgeimp.h +++ /dev/null @@ -1,143 +0,0 @@ -/* - * $Id: fbedgeimp.h,v 1.4 2005/08/30 03:05:21 anholt Exp $ - * - * Copyright © 2004 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. - */ - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#ifndef rasterizeSpan -#endif - -static void -rasterizeEdges (FbBits *buf, - int width, - int stride, - RenderEdge *l, - RenderEdge *r, - xFixed t, - xFixed b) -{ - xFixed y = t; - FbBits *line; - - line = buf + xFixedToInt (y) * stride; - - for (;;) - { - xFixed lx, rx; - int lxi, rxi; - - /* clip X */ - lx = l->x; - if (lx < 0) - lx = 0; - rx = r->x; - if (xFixedToInt (rx) >= width) - rx = IntToxFixed (width); - - /* Skip empty (or backwards) sections */ - if (rx > lx) - { - - /* Find pixel bounds for span */ - lxi = xFixedToInt (lx); - rxi = xFixedToInt (rx); - -#if N_BITS == 1 - { - FbBits *a = line; - FbBits startmask, endmask; - int nmiddle; - int width = rxi - lxi; - int x = lxi; - - a += x >> FB_SHIFT; - x &= FB_MASK; - - FbMaskBits (x, width, startmask, nmiddle, endmask); - if (startmask) - *a++ |= startmask; - while (nmiddle--) - *a++ = FB_ALLONES; - if (endmask) - *a |= endmask; - } -#else - { - DefineAlpha(line,lxi); - int lxs, rxs; - - /* Sample coverage for edge pixels */ - lxs = RenderSamplesX (lx, N_BITS); - rxs = RenderSamplesX (rx, N_BITS); - - /* Add coverage across row */ - if (lxi == rxi) - { - AddAlpha (rxs - lxs); - } - else - { - int xi; - - AddAlpha (N_X_FRAC(N_BITS) - lxs); - StepAlpha; - for (xi = lxi + 1; xi < rxi; xi++) - { - AddAlpha (N_X_FRAC(N_BITS)); - StepAlpha; - } - /* Do not add in a 0 alpha here. This check is necessary - * to avoid a buffer overrun when rx is exactly on a pixel - * boundary. - */ - if (rxs != 0) - AddAlpha (rxs); - } - } -#endif - } - - if (y == b) - break; - -#if N_BITS > 1 - if (xFixedFrac (y) != Y_FRAC_LAST(N_BITS)) - { - RenderEdgeStepSmall (l); - RenderEdgeStepSmall (r); - y += STEP_Y_SMALL(N_BITS); - } - else -#endif - { - RenderEdgeStepBig (l); - RenderEdgeStepBig (r); - y += STEP_Y_BIG(N_BITS); - line += stride; - } - } -} - -#undef rasterizeSpan diff --git a/nx-X11/programs/Xserver/fb/fbfill.c b/nx-X11/programs/Xserver/fb/fbfill.c index 2d1d163f6c..58165bd8b3 100644 --- a/nx-X11/programs/Xserver/fb/fbfill.c +++ b/nx-X11/programs/Xserver/fb/fbfill.c @@ -1,6 +1,4 @@ /* - * Id: fbfill.c,v 1.1 1999/11/02 03:54:45 keithp Exp $ - * * Copyright © 1998 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its @@ -46,12 +44,18 @@ fbFill (DrawablePtr pDrawable, switch (pGC->fillStyle) { case FillSolid: - fbSolid (dst + (y + dstYoff) * dstStride, - dstStride, - (x + dstXoff) * dstBpp, - dstBpp, - width * dstBpp, height, - pPriv->and, pPriv->xor); +#ifndef FB_ACCESS_WRAPPER + if (pPriv->and || !pixman_fill ((uint32_t *)dst, dstStride, dstBpp, + x + dstXoff, y + dstYoff, + width, height, + pPriv->xor)) +#endif + fbSolid (dst + (y + dstYoff) * dstStride, + dstStride, + (x + dstXoff) * dstBpp, + dstBpp, + width * dstBpp, height, + pPriv->and, pPriv->xor); break; case FillStippled: case FillOpaqueStippled: { @@ -86,6 +90,7 @@ fbFill (DrawablePtr pDrawable, (pGC->patOrg.x + pDrawable->x + dstXoff), pGC->patOrg.y + pDrawable->y - y); + fbFinishAccess (&pStip->drawable); } else { @@ -123,6 +128,7 @@ fbFill (DrawablePtr pDrawable, bgand, bgxor, pGC->patOrg.x + pDrawable->x + dstXoff, pGC->patOrg.y + pDrawable->y - y); + fbFinishAccess (&pStip->drawable); } break; } @@ -151,10 +157,12 @@ fbFill (DrawablePtr pDrawable, dstBpp, (pGC->patOrg.x + pDrawable->x + dstXoff) * dstBpp, pGC->patOrg.y + pDrawable->y - y); + fbFinishAccess (&pTile->drawable); break; } } fbValidateDrawable (pDrawable); + fbFinishAccess (pDrawable); } void @@ -202,14 +210,21 @@ fbSolidBoxClipped (DrawablePtr pDrawable, if (partY2 <= partY1) continue; - - fbSolid (dst + (partY1 + dstYoff) * dstStride, - dstStride, - (partX1 + dstXoff) * dstBpp, - dstBpp, - (partX2 - partX1) * dstBpp, - (partY2 - partY1), - and, xor); +#ifndef FB_ACCESS_WRAPPER + if (and || !pixman_fill ((uint32_t *)dst, dstStride, dstBpp, + partX1 + dstXoff, partY1 + dstYoff, + (partX2 - partX1), (partY2 - partY1), + xor)) +#endif + fbSolid (dst + (partY1 + dstYoff) * dstStride, + dstStride, + (partX1 + dstXoff) * dstBpp, + dstBpp, + + (partX2 - partX1) * dstBpp, + (partY2 - partY1), + and, xor); } + fbFinishAccess (pDrawable); } diff --git a/nx-X11/programs/Xserver/fb/fbfillrect.c b/nx-X11/programs/Xserver/fb/fbfillrect.c index 2a19fa7d2e..7fc03f9a5f 100644 --- a/nx-X11/programs/Xserver/fb/fbfillrect.c +++ b/nx-X11/programs/Xserver/fb/fbfillrect.c @@ -1,6 +1,4 @@ /* - * Id: fbfillrect.c,v 1.1 1999/11/02 03:54:45 keithp Exp $ - * * Copyright © 1998 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its diff --git a/nx-X11/programs/Xserver/fb/fbfillsp.c b/nx-X11/programs/Xserver/fb/fbfillsp.c index ca9fdbb0ae..194bfc88b5 100644 --- a/nx-X11/programs/Xserver/fb/fbfillsp.c +++ b/nx-X11/programs/Xserver/fb/fbfillsp.c @@ -1,6 +1,4 @@ /* - * Id: fbfillsp.c,v 1.1 1999/11/02 03:54:45 keithp Exp $ - * * Copyright © 1998 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its diff --git a/nx-X11/programs/Xserver/fb/fbgc.c b/nx-X11/programs/Xserver/fb/fbgc.c index 44eecfbe21..c81dfae87e 100644 --- a/nx-X11/programs/Xserver/fb/fbgc.c +++ b/nx-X11/programs/Xserver/fb/fbgc.c @@ -1,6 +1,4 @@ /* - * Id: fbgc.c,v 1.1 1999/11/02 03:54:45 keithp Exp $ - * * Copyright © 1998 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its @@ -61,9 +59,6 @@ const GCOps fbGCOps = { fbImageGlyphBlt, fbPolyGlyphBlt, fbPushPixels -#ifdef NEED_LINEHELPER - ,NULL -#endif }; Bool @@ -109,16 +104,18 @@ fbPadPixmap (PixmapPtr pPixmap) mask = FbBitsMask (0, width); while (height--) { - b = *bits & mask; + b = READ(bits) & mask; w = width; while (w < FB_UNIT) { b = b | FbScrRight(b, w); w <<= 1; } - *bits = b; + WRITE(bits, b); bits += stride; } + + fbFinishAccess (&pPixmap->drawable); } /* @@ -156,7 +153,7 @@ fbLineRepeat (FbBits *bits, int len, int width) width = (width + FB_UNIT-1) >> FB_SHIFT; bits++; while (--width) - if (*bits != first) + if (READ(bits) != first) return FALSE; return TRUE; } @@ -186,10 +183,13 @@ fbCanEvenStipple (PixmapPtr pStipple, int bpp) /* check to see that the stipple repeats horizontally */ while (h--) { - if (!fbLineRepeat (bits, len, pStipple->drawable.width)) + if (!fbLineRepeat (bits, len, pStipple->drawable.width)) { + fbFinishAccess (&pStipple->drawable); return FALSE; + } bits += stride; } + fbFinishAccess (&pStipple->drawable); return TRUE; } diff --git a/nx-X11/programs/Xserver/fb/fbgetsp.c b/nx-X11/programs/Xserver/fb/fbgetsp.c index f77ea8c52b..6402c6c38c 100644 --- a/nx-X11/programs/Xserver/fb/fbgetsp.c +++ b/nx-X11/programs/Xserver/fb/fbgetsp.c @@ -1,6 +1,4 @@ /* - * Id: fbgetsp.c,v 1.1 1999/11/02 03:54:45 keithp Exp $ - * * Copyright © 1998 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its @@ -84,4 +82,6 @@ fbGetSpans(DrawablePtr pDrawable, ppt++; pwidth++; } + + fbFinishAccess (pDrawable); } diff --git a/nx-X11/programs/Xserver/fb/fbglyph.c b/nx-X11/programs/Xserver/fb/fbglyph.c index 6ff90e54a2..785eaafd28 100644 --- a/nx-X11/programs/Xserver/fb/fbglyph.c +++ b/nx-X11/programs/Xserver/fb/fbglyph.c @@ -1,4 +1,5 @@ /* + * * Copyright © 1998 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its @@ -61,11 +62,11 @@ fbGlyphIn (RegionPtr pRegion, #ifdef FB_24BIT #ifndef FBNOPIXADDR -#define WRITE1(d,n,fg) ((d)[n] = (CARD8) fg) -#define WRITE2(d,n,fg) (*(CARD16 *) &(d[n]) = (CARD16) fg) -#define WRITE4(d,n,fg) (*(CARD32 *) &(d[n]) = (CARD32) fg) +#define WRITE1(d,n,fg) WRITE((d) + (n), (CARD8) fg) +#define WRITE2(d,n,fg) WRITE((CARD16 *) &(d[n]), (CARD16) fg) +#define WRITE4(d,n,fg) WRITE((CARD32 *) &(d[n]), (CARD32) fg) #if FB_UNIT == 6 && IMAGE_BYTE_ORDER == LSBFirst -#define WRITE8(d) (*(FbBits *) &(d[0]) = fg) +#define WRITE8(d) WRITE((FbBits *) &(d[0]), fg) #else #define WRITE8(d) WRITE4(d,0,_ABCA), WRITE4(d,4,_BCAB) #endif @@ -156,7 +157,7 @@ fbGlyph24 (FbBits *dstBits, lshift = 4 - shift; while (height--) { - bits = *stipple++; + bits = READ(stipple++); n = lshift; dst = dstLine; while (bits) @@ -283,7 +284,7 @@ fbPolyGlyphBlt (DrawablePtr pDrawable, glyph = 0; if (pGC->fillStyle == FillSolid && pPriv->and == 0) { - fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff); + dstBpp = pDrawable->bitsPerPixel; switch (dstBpp) { case 8: glyph = fbGlyph8; break; case 16: glyph = fbGlyph16; break; @@ -311,6 +312,7 @@ fbPolyGlyphBlt (DrawablePtr pDrawable, if (glyph && gWidth <= sizeof (FbStip) * 8 && fbGlyphIn (fbGetCompositeClip(pGC), gx, gy, gWidth, gHeight)) { + fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff); (*glyph) (dst + (gy + dstYoff) * dstStride, dstStride, dstBpp, @@ -318,6 +320,7 @@ fbPolyGlyphBlt (DrawablePtr pDrawable, pPriv->xor, gx + dstXoff, gHeight); + fbFinishAccess (pDrawable); } else #endif @@ -374,7 +377,7 @@ fbImageGlyphBlt (DrawablePtr pDrawable, glyph = 0; if (pPriv->and == 0) { - fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff); + dstBpp = pDrawable->bitsPerPixel; switch (dstBpp) { case 8: glyph = fbGlyph8; break; case 16: glyph = fbGlyph16; break; @@ -442,6 +445,7 @@ fbImageGlyphBlt (DrawablePtr pDrawable, if (glyph && gWidth <= sizeof (FbStip) * 8 && fbGlyphIn (fbGetCompositeClip(pGC), gx, gy, gWidth, gHeight)) { + fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff); (*glyph) (dst + (gy + dstYoff) * dstStride, dstStride, dstBpp, @@ -449,6 +453,7 @@ fbImageGlyphBlt (DrawablePtr pDrawable, pPriv->fg, gx + dstXoff, gHeight); + fbFinishAccess (pDrawable); } else #endif diff --git a/nx-X11/programs/Xserver/fb/fbimage.c b/nx-X11/programs/Xserver/fb/fbimage.c index 9894faf025..da1e8bcc4b 100644 --- a/nx-X11/programs/Xserver/fb/fbimage.c +++ b/nx-X11/programs/Xserver/fb/fbimage.c @@ -1,6 +1,4 @@ /* - * Id: fbimage.c,v 1.1 1999/11/02 03:54:45 keithp Exp $ - * * Copyright © 1998 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its @@ -68,7 +66,7 @@ fbPutImage (DrawablePtr pDrawable, break; case XYPixmap: srcStride = BitmapBytePad(w + leftPad) / sizeof (FbStip); - for (i = 1 << (pDrawable->depth - 1); i; i >>= 1) + for (i = (unsigned long)1 << (pDrawable->depth - 1); i; i >>= 1) { if (i & pGC->planemask) { @@ -170,6 +168,8 @@ fbPutZImage (DrawablePtr pDrawable, pm, dstBpp); } + + fbFinishAccess (pDrawable); } void @@ -277,6 +277,8 @@ fbPutXYImage (DrawablePtr pDrawable, fgand, fgxor, bgand, bgxor); } } + + fbFinishAccess (pDrawable); } void @@ -361,4 +363,6 @@ fbGetImage (DrawablePtr pDrawable, fbXorStip(GXcopy,0,FB_STIP_ALLONES), planeMask); } + + fbFinishAccess (pDrawable); } diff --git a/nx-X11/programs/Xserver/fb/fboverlay.c b/nx-X11/programs/Xserver/fb/fboverlay.c index 95101a731a..079ccf80a4 100644 --- a/nx-X11/programs/Xserver/fb/fboverlay.c +++ b/nx-X11/programs/Xserver/fb/fboverlay.c @@ -1,4 +1,5 @@ /* + * * Copyright © 2000 SuSE, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its @@ -21,6 +22,7 @@ * Author: Keith Packard, SuSE, Inc. */ + #ifdef HAVE_DIX_CONFIG_H #include #endif @@ -417,9 +419,6 @@ fbOverlayFinishScreenInit(ScreenPtr pScreen, if (! miScreenInit(pScreen, 0, xsize, ysize, dpix, dpiy, 0, depth1, ndepths, depths, defaultVisual, nvisuals, visuals -#ifdef FB_OLD_MISCREENINIT - , (miBSFuncPtr) 0 -#endif )) { free(pScrPriv); return FALSE; diff --git a/nx-X11/programs/Xserver/fb/fboverlay.h b/nx-X11/programs/Xserver/fb/fboverlay.h index 2bb8b176a0..1e01e0ddbd 100644 --- a/nx-X11/programs/Xserver/fb/fboverlay.h +++ b/nx-X11/programs/Xserver/fb/fboverlay.h @@ -1,4 +1,5 @@ /* + * * Copyright © 2000 SuSE, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its diff --git a/nx-X11/programs/Xserver/fb/fbpict.c b/nx-X11/programs/Xserver/fb/fbpict.c index 214ed5a4c7..5fec74a9fe 100644 --- a/nx-X11/programs/Xserver/fb/fbpict.c +++ b/nx-X11/programs/Xserver/fb/fbpict.c @@ -1,5 +1,7 @@ /* + * * Copyright © 2000 SuSE, Inc. + * Copyright © 2007 Red Hat, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -35,823 +37,35 @@ #include "mipict.h" #include "fbpict.h" -typedef void (*CompositeFunc) (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height); - -CARD32 -fbOver (CARD32 x, CARD32 y) -{ - CARD16 a = ~x >> 24; - CARD16 t; - CARD32 m,n,o,p; - - m = FbOverU(x,y,0,a,t); - n = FbOverU(x,y,8,a,t); - o = FbOverU(x,y,16,a,t); - p = FbOverU(x,y,24,a,t); - return m|n|o|p; -} - -CARD32 -fbOver24 (CARD32 x, CARD32 y) -{ - CARD16 a = ~x >> 24; - CARD16 t; - CARD32 m,n,o; - - m = FbOverU(x,y,0,a,t); - n = FbOverU(x,y,8,a,t); - o = FbOverU(x,y,16,a,t); - return m|n|o; -} - -CARD32 -fbIn (CARD32 x, CARD8 y) -{ - CARD16 a = y; - CARD16 t; - CARD32 m,n,o,p; - - m = FbInU(x,0,a,t); - n = FbInU(x,8,a,t); - o = FbInU(x,16,a,t); - p = FbInU(x,24,a,t); - return m|n|o|p; -} - -/* - * Naming convention: - * - * opSRCxMASKxDST - */ - -void -fbCompositeSolidMask_nx8x8888 (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - CARD32 src, srca; - CARD32 *dstLine, *dst, d, dstMask; - CARD8 *maskLine, *mask, m; - FbStride dstStride, maskStride; - CARD16 w; - - fbComposeGetSolid(pSrc, src, pDst->format); - - dstMask = FbFullMask (pDst->pDrawable->depth); - srca = src >> 24; - if (src == 0) - return; - - fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1); - fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1); - - while (height--) - { - dst = dstLine; - dstLine += dstStride; - mask = maskLine; - maskLine += maskStride; - w = width; - - while (w--) - { - m = *mask++; - if (m == 0xff) - { - if (srca == 0xff) - *dst = src & dstMask; - else - *dst = fbOver (src, *dst) & dstMask; - } - else if (m) - { - d = fbIn (src, m); - *dst = fbOver (d, *dst) & dstMask; - } - dst++; - } - } -} - -void -fbCompositeSolidMask_nx8888x8888C (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - CARD32 src, srca; - CARD32 *dstLine, *dst, d, dstMask; - CARD32 *maskLine, *mask, ma; - FbStride dstStride, maskStride; - CARD16 w; - CARD32 m, n, o, p; - - fbComposeGetSolid(pSrc, src, pDst->format); - - dstMask = FbFullMask (pDst->pDrawable->depth); - srca = src >> 24; - if (src == 0) - return; - - fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1); - fbComposeGetStart (pMask, xMask, yMask, CARD32, maskStride, maskLine, 1); - - while (height--) - { - dst = dstLine; - dstLine += dstStride; - mask = maskLine; - maskLine += maskStride; - w = width; - - while (w--) - { - ma = *mask++; - if (ma == 0xffffffff) - { - if (srca == 0xff) - *dst = src & dstMask; - else - *dst = fbOver (src, *dst) & dstMask; - } - else if (ma) - { - d = *dst; -#define FbInOverC(src,srca,msk,dst,i,result) { \ - CARD16 __a = FbGet8(msk,i); \ - CARD32 __t, __ta; \ - CARD32 __i; \ - __t = FbIntMult (FbGet8(src,i), __a,__i); \ - __ta = (CARD8) ~FbIntMult (srca, __a,__i); \ - __t = __t + FbIntMult(FbGet8(dst,i),__ta,__i); \ - __t = (CARD32) (CARD8) (__t | (-(__t >> 8))); \ - result = __t << (i); \ -} - FbInOverC (src, srca, ma, d, 0, m); - FbInOverC (src, srca, ma, d, 8, n); - FbInOverC (src, srca, ma, d, 16, o); - FbInOverC (src, srca, ma, d, 24, p); - *dst = m|n|o|p; - } - dst++; - } - } -} - -void -fbCompositeSolidMask_nx8x0888 (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - CARD32 src, srca; - CARD8 *dstLine, *dst; - CARD32 d; - CARD8 *maskLine, *mask, m; - FbStride dstStride, maskStride; - CARD16 w; - - fbComposeGetSolid(pSrc, src, pDst->format); - - srca = src >> 24; - if (src == 0) - return; - - fbComposeGetStart (pDst, xDst, yDst, CARD8, dstStride, dstLine, 3); - fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1); - - while (height--) - { - dst = dstLine; - dstLine += dstStride; - mask = maskLine; - maskLine += maskStride; - w = width; - - while (w--) - { - m = *mask++; - if (m == 0xff) - { - if (srca == 0xff) - d = src; - else - { - d = Fetch24(dst); - d = fbOver24 (src, d); - } - Store24(dst,d); - } - else if (m) - { - d = fbOver24 (fbIn(src,m), Fetch24(dst)); - Store24(dst,d); - } - dst += 3; - } - } -} - -void -fbCompositeSolidMask_nx8x0565 (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - CARD32 src, srca; - CARD16 *dstLine, *dst; - CARD32 d; - CARD8 *maskLine, *mask, m; - FbStride dstStride, maskStride; - CARD16 w; - - fbComposeGetSolid(pSrc, src, pDst->format); - - srca = src >> 24; - if (src == 0) - return; - - fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1); - fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1); - - while (height--) - { - dst = dstLine; - dstLine += dstStride; - mask = maskLine; - maskLine += maskStride; - w = width; - - while (w--) - { - m = *mask++; - if (m == 0xff) - { - if (srca == 0xff) - d = src; - else - { - d = *dst; - d = fbOver24 (src, cvt0565to8888(d)); - } - *dst = cvt8888to0565(d); - } - else if (m) - { - d = *dst; - d = fbOver24 (fbIn(src,m), cvt0565to8888(d)); - *dst = cvt8888to0565(d); - } - dst++; - } - } -} - -void -fbCompositeSolidMask_nx8888x0565C (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - CARD32 src, srca; - CARD16 src16; - CARD16 *dstLine, *dst; - CARD32 d; - CARD32 *maskLine, *mask, ma; - FbStride dstStride, maskStride; - CARD16 w; - CARD32 m, n, o; - - fbComposeGetSolid(pSrc, src, pDst->format); - - srca = src >> 24; - if (src == 0) - return; - - src16 = cvt8888to0565(src); - - fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1); - fbComposeGetStart (pMask, xMask, yMask, CARD32, maskStride, maskLine, 1); - - while (height--) - { - dst = dstLine; - dstLine += dstStride; - mask = maskLine; - maskLine += maskStride; - w = width; - - while (w--) - { - ma = *mask++; - if (ma == 0xffffffff) - { - if (srca == 0xff) - { - *dst = src16; - } - else - { - d = *dst; - d = fbOver24 (src, cvt0565to8888(d)); - *dst = cvt8888to0565(d); - } - } - else if (ma) - { - d = *dst; - d = cvt0565to8888(d); - FbInOverC (src, srca, ma, d, 0, m); - FbInOverC (src, srca, ma, d, 8, n); - FbInOverC (src, srca, ma, d, 16, o); - d = m|n|o; - *dst = cvt8888to0565(d); - } - dst++; - } - } -} - -void -fbCompositeSrc_8888x8888 (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - CARD32 *dstLine, *dst, dstMask; - CARD32 *srcLine, *src, s; - FbStride dstStride, srcStride; - CARD8 a; - CARD16 w; - - fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1); - fbComposeGetStart (pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1); - - dstMask = FbFullMask (pDst->pDrawable->depth); - - while (height--) - { - dst = dstLine; - dstLine += dstStride; - src = srcLine; - srcLine += srcStride; - w = width; - - while (w--) - { - s = *src++; - a = s >> 24; - if (a == 0xff) - *dst = s & dstMask; - else if (a) - *dst = fbOver (s, *dst) & dstMask; - dst++; - } - } -} - -void -fbCompositeSrc_8888x0888 (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - CARD8 *dstLine, *dst; - CARD32 d; - CARD32 *srcLine, *src, s; - CARD8 a; - FbStride dstStride, srcStride; - CARD16 w; - - fbComposeGetStart (pDst, xDst, yDst, CARD8, dstStride, dstLine, 3); - fbComposeGetStart (pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1); - - while (height--) - { - dst = dstLine; - dstLine += dstStride; - src = srcLine; - srcLine += srcStride; - w = width; - - while (w--) - { - s = *src++; - a = s >> 24; - if (a) - { - if (a == 0xff) - d = s; - else - d = fbOver24 (s, Fetch24(dst)); - Store24(dst,d); - } - dst += 3; - } - } -} - -void -fbCompositeSrc_8888x0565 (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - CARD16 *dstLine, *dst; - CARD32 d; - CARD32 *srcLine, *src, s; - CARD8 a; - FbStride dstStride, srcStride; - CARD16 w; - - fbComposeGetStart (pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1); - fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1); - - while (height--) - { - dst = dstLine; - dstLine += dstStride; - src = srcLine; - srcLine += srcStride; - w = width; - - while (w--) - { - s = *src++; - a = s >> 24; - if (a) - { - if (a == 0xff) - d = s; - else - { - d = *dst; - d = fbOver24 (s, cvt0565to8888(d)); - } - *dst = cvt8888to0565(d); - } - dst++; - } - } -} - -void -fbCompositeSrc_0565x0565 (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - CARD16 *dstLine, *dst; - CARD16 *srcLine, *src; - FbStride dstStride, srcStride; - CARD16 w; - - fbComposeGetStart (pSrc, xSrc, ySrc, CARD16, srcStride, srcLine, 1); - - fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1); - - while (height--) - { - dst = dstLine; - dstLine += dstStride; - src = srcLine; - srcLine += srcStride; - w = width; - - while (w--) - *dst++ = *src++; - } -} - -void -fbCompositeSrcAdd_8000x8000 (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - CARD8 *dstLine, *dst; - CARD8 *srcLine, *src; - FbStride dstStride, srcStride; - CARD16 w; - CARD8 s, d; - CARD16 t; - - fbComposeGetStart (pSrc, xSrc, ySrc, CARD8, srcStride, srcLine, 1); - fbComposeGetStart (pDst, xDst, yDst, CARD8, dstStride, dstLine, 1); - - while (height--) - { - dst = dstLine; - dstLine += dstStride; - src = srcLine; - srcLine += srcStride; - w = width; - - while (w--) - { - s = *src++; - if (s) - { - if (s != 0xff) - { - d = *dst; - t = d + s; - s = t | (0 - (t >> 8)); - } - *dst = s; - } - dst++; - } - } -} - -void -fbCompositeSrcAdd_8888x8888 (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - CARD32 *dstLine, *dst; - CARD32 *srcLine, *src; - FbStride dstStride, srcStride; - CARD16 w; - CARD32 s, d; - CARD16 t; - CARD32 m,n,o,p; - - fbComposeGetStart (pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1); - fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1); - - while (height--) - { - dst = dstLine; - dstLine += dstStride; - src = srcLine; - srcLine += srcStride; - w = width; - - while (w--) - { - s = *src++; - if (s) - { - if (s != 0xffffffff) - { - d = *dst; - if (d) - { - m = FbAdd(s,d,0,t); - n = FbAdd(s,d,8,t); - o = FbAdd(s,d,16,t); - p = FbAdd(s,d,24,t); - s = m|n|o|p; - } - } - *dst = s; - } - dst++; - } - } -} +#define mod(a,b) ((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (b) - (-a) % (b)) void -fbCompositeSrcAdd_1000x1000 (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - FbBits *dstBits, *srcBits; - FbStride dstStride, srcStride; - int dstBpp, srcBpp; - int dstXoff, dstYoff; - int srcXoff, srcYoff; - - fbGetDrawable(pSrc->pDrawable, srcBits, srcStride, srcBpp, srcXoff, srcYoff); - - fbGetDrawable(pDst->pDrawable, dstBits, dstStride, dstBpp, dstXoff, dstYoff); - - fbBlt (srcBits + srcStride * (ySrc + srcYoff), - srcStride, - xSrc + srcXoff, - - dstBits + dstStride * (yDst + dstYoff), - dstStride, - xDst + dstXoff, - - width, - height, - - GXor, - FB_ALLONES, - srcBpp, - - FALSE, - FALSE); -} - -void -fbCompositeSolidMask_nx1xn (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - FbBits *dstBits; - FbStip *maskBits; - FbStride dstStride, maskStride; - int dstBpp, maskBpp; - int dstXoff, dstYoff; - int maskXoff, maskYoff; - FbBits src; - - fbComposeGetSolid(pSrc, src, pDst->format); - - if ((src & 0xff000000) != 0xff000000) - { - fbCompositeGeneral (op, pSrc, pMask, pDst, - xSrc, ySrc, xMask, yMask, xDst, yDst, - width, height); - return; - } - fbGetStipDrawable (pMask->pDrawable, maskBits, maskStride, maskBpp, maskXoff, maskYoff); - fbGetDrawable (pDst->pDrawable, dstBits, dstStride, dstBpp, dstXoff, dstYoff); - - switch (dstBpp) { - case 32: - break; - case 24: - break; - case 16: - src = cvt8888to0565(src); - break; - } - - src = fbReplicatePixel (src, dstBpp); - - fbBltOne (maskBits + maskStride * (yMask + maskYoff), - maskStride, - xMask + maskXoff, - - dstBits + dstStride * (yDst + dstYoff), - dstStride, - (xDst + dstXoff) * dstBpp, - dstBpp, - - width * dstBpp, - height, - - 0x0, - src, - FB_ALLONES, - 0x0); -} - -# define mod(a,b) ((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (b) - (-a) % (b)) - -void -fbComposite (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) +fbWalkCompositeRegion (CARD8 op, + PicturePtr pSrc, + PicturePtr pMask, + PicturePtr pDst, + INT16 xSrc, + INT16 ySrc, + INT16 xMask, + INT16 yMask, + INT16 xDst, + INT16 yDst, + CARD16 width, + CARD16 height, + Bool srcRepeat, + Bool maskRepeat, + CompositeFunc compositeRect) { RegionRec region; int n; BoxPtr pbox; - CompositeFunc func = NULL; - Bool srcRepeat = pSrc->pDrawable && pSrc->repeat == RepeatNormal; - Bool maskRepeat = FALSE; - Bool srcAlphaMap = pSrc->alphaMap != 0; - Bool maskAlphaMap = FALSE; - Bool dstAlphaMap = pDst->alphaMap != 0; - int x_msk, y_msk, x_src, y_src, x_dst, y_dst; int w, h, w_this, h_this; - + int x_msk, y_msk, x_src, y_src, x_dst, y_dst; + xDst += pDst->pDrawable->x; yDst += pDst->pDrawable->y; - if (pSrc->pDrawable) { + if (pSrc->pDrawable) + { xSrc += pSrc->pDrawable->x; ySrc += pSrc->pDrawable->y; } @@ -859,282 +73,12 @@ fbComposite (CARD8 op, { xMask += pMask->pDrawable->x; yMask += pMask->pDrawable->y; - maskRepeat = pMask->repeat == RepeatNormal; - maskAlphaMap = pMask->alphaMap != 0; } - if (pSrc->pDrawable && (!pMask || pMask->pDrawable) - && !pSrc->transform && !(pMask && pMask->transform) - && !maskAlphaMap && !srcAlphaMap && !dstAlphaMap - && (pSrc->filter != PictFilterConvolution) - && (!pMask || pMask->filter != PictFilterConvolution)) - switch (op) { - case PictOpSrc: - break; - case PictOpOver: - if (pMask) - { - if (srcRepeat && - pSrc->pDrawable->width == 1 && - pSrc->pDrawable->height == 1) - { - srcRepeat = FALSE; - if (PICT_FORMAT_COLOR(pSrc->format)) { - switch (pMask->format) { - case PICT_a8: - switch (pDst->format) { - case PICT_r5g6b5: - case PICT_b5g6r5: - func = fbCompositeSolidMask_nx8x0565; - break; - case PICT_r8g8b8: - case PICT_b8g8r8: - func = fbCompositeSolidMask_nx8x0888; - break; - case PICT_a8r8g8b8: - case PICT_x8r8g8b8: - case PICT_a8b8g8r8: - case PICT_x8b8g8r8: - func = fbCompositeSolidMask_nx8x8888; - break; - } - break; - case PICT_a8r8g8b8: - if (pMask->componentAlpha) { - switch (pDst->format) { - case PICT_a8r8g8b8: - case PICT_x8r8g8b8: - func = fbCompositeSolidMask_nx8888x8888C; - break; - case PICT_r5g6b5: - func = fbCompositeSolidMask_nx8888x0565C; - break; - } - } - break; - case PICT_a8b8g8r8: - if (pMask->componentAlpha) { - switch (pDst->format) { - case PICT_a8b8g8r8: - case PICT_x8b8g8r8: - func = fbCompositeSolidMask_nx8888x8888C; - break; - case PICT_b5g6r5: - func = fbCompositeSolidMask_nx8888x0565C; - break; - } - } - break; - case PICT_a1: - switch (pDst->format) { - case PICT_r5g6b5: - case PICT_b5g6r5: - case PICT_r8g8b8: - case PICT_b8g8r8: - case PICT_a8r8g8b8: - case PICT_x8r8g8b8: - case PICT_a8b8g8r8: - case PICT_x8b8g8r8: - func = fbCompositeSolidMask_nx1xn; - break; - } - break; - } - } - } - else /* has mask and non-repeating source */ - { - if (pSrc->pDrawable == pMask->pDrawable && - xSrc == xMask && ySrc == yMask && - !pMask->componentAlpha) - { - /* source == mask: non-premultiplied data */ - switch (pSrc->format) { - case PICT_x8b8g8r8: - switch (pMask->format) { - case PICT_a8r8g8b8: - case PICT_a8b8g8r8: - switch (pDst->format) { - case PICT_a8r8g8b8: - case PICT_x8r8g8b8: - break; - case PICT_r5g6b5: - break; - } - break; - } - break; - case PICT_x8r8g8b8: - switch (pMask->format) { - case PICT_a8r8g8b8: - case PICT_a8b8g8r8: - switch (pDst->format) { - case PICT_a8b8g8r8: - case PICT_x8b8g8r8: - break; - case PICT_r5g6b5: - break; - } - break; - } - break; - } - break; - } - else - { - /* non-repeating source, repeating mask => translucent window */ - if (maskRepeat && - pMask->pDrawable->width == 1 && - pMask->pDrawable->height == 1) - { - if (pSrc->format == PICT_x8r8g8b8 && - pDst->format == PICT_x8r8g8b8 && - pMask->format == PICT_a8) - { - } - } - } - } - } - else /* no mask */ - { - if (srcRepeat && - pSrc->pDrawable->width == 1 && - pSrc->pDrawable->height == 1) - { - /* no mask and repeating source */ - switch (pSrc->format) { - case PICT_a8r8g8b8: - switch (pDst->format) { - case PICT_a8r8g8b8: - case PICT_x8r8g8b8: - break; - case PICT_r5g6b5: - break; - } - break; - } - } - else - { - switch (pSrc->format) { - case PICT_a8r8g8b8: - switch (pDst->format) { - case PICT_a8r8g8b8: - case PICT_x8r8g8b8: - func = fbCompositeSrc_8888x8888; - break; - case PICT_r8g8b8: - func = fbCompositeSrc_8888x0888; - break; - case PICT_r5g6b5: - func = fbCompositeSrc_8888x0565; - break; - } - break; - case PICT_x8r8g8b8: - switch (pDst->format) { - case PICT_a8r8g8b8: - case PICT_x8r8g8b8: - break; - } - case PICT_x8b8g8r8: - switch (pDst->format) { - case PICT_a8b8g8r8: - case PICT_x8b8g8r8: - break; - } - break; - case PICT_a8b8g8r8: - switch (pDst->format) { - case PICT_a8b8g8r8: - case PICT_x8b8g8r8: - func = fbCompositeSrc_8888x8888; - break; - case PICT_b8g8r8: - func = fbCompositeSrc_8888x0888; - break; - case PICT_b5g6r5: - func = fbCompositeSrc_8888x0565; - break; - } - break; - case PICT_r5g6b5: - switch (pDst->format) { - case PICT_r5g6b5: - func = fbCompositeSrc_0565x0565; - break; - } - break; - case PICT_b5g6r5: - switch (pDst->format) { - case PICT_b5g6r5: - func = fbCompositeSrc_0565x0565; - break; - } - break; - } - } - } - break; - case PictOpAdd: - if (pMask == 0) - { - switch (pSrc->format) { - case PICT_a8r8g8b8: - switch (pDst->format) { - case PICT_a8r8g8b8: - func = fbCompositeSrcAdd_8888x8888; - break; - } - break; - case PICT_a8b8g8r8: - switch (pDst->format) { - case PICT_a8b8g8r8: - func = fbCompositeSrcAdd_8888x8888; - break; - } - break; - case PICT_a8: - switch (pDst->format) { - case PICT_a8: - func = fbCompositeSrcAdd_8000x8000; - break; - } - break; - case PICT_a1: - switch (pDst->format) { - case PICT_a1: - func = fbCompositeSrcAdd_1000x1000; - break; - } - break; - } - } - break; - } - - if (!func) { - /* no fast path, use the general code */ - fbCompositeGeneral(op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask, xDst, yDst, width, height); - return; - } - - if (!miComputeCompositeRegion (®ion, - pSrc, - pMask, - pDst, - xSrc, - ySrc, - xMask, - yMask, - xDst, - yDst, - width, - height)) + if (!miComputeCompositeRegion (®ion, pSrc, pMask, pDst, xSrc, ySrc, + xMask, yMask, xDst, yDst, width, height)) return; - + n = RegionNumRects (®ion); pbox = RegionRects (®ion); while (n--) @@ -1181,9 +125,9 @@ fbComposite (CARD8 op, w_this = pSrc->pDrawable->width - x_src; x_src += pSrc->pDrawable->x; } - (*func) (op, pSrc, pMask, pDst, - x_src, y_src, x_msk, y_msk, x_dst, y_dst, - w_this, h_this); + (*compositeRect) (op, pSrc, pMask, pDst, + x_src, y_src, x_msk, y_msk, x_dst, y_dst, + w_this, h_this); w -= w_this; x_src += w_this; x_msk += w_this; @@ -1199,8 +143,310 @@ fbComposite (CARD8 op, RegionUninit(®ion); } +void +fbComposite (CARD8 op, + PicturePtr pSrc, + PicturePtr pMask, + PicturePtr pDst, + INT16 xSrc, + INT16 ySrc, + INT16 xMask, + INT16 yMask, + INT16 xDst, + INT16 yDst, + CARD16 width, + CARD16 height) +{ + pixman_image_t *src, *mask, *dest; + + xDst += pDst->pDrawable->x; + yDst += pDst->pDrawable->y; + if (pSrc->pDrawable) + { + xSrc += pSrc->pDrawable->x; + ySrc += pSrc->pDrawable->y; + } + if (pMask && pMask->pDrawable) + { + xMask += pMask->pDrawable->x; + yMask += pMask->pDrawable->y; + } + + miCompositeSourceValidate (pSrc, xSrc, ySrc, width, height); + if (pMask) + miCompositeSourceValidate (pMask, xMask, yMask, width, height); + + src = image_from_pict (pSrc, TRUE); + mask = image_from_pict (pMask, TRUE); + dest = image_from_pict (pDst, TRUE); + + if (src && dest && !(pMask && !mask)) + { + pixman_image_composite (op, src, mask, dest, + xSrc, ySrc, xMask, yMask, xDst, yDst, + width, height); + } + + free_pixman_pict (pSrc, src); + free_pixman_pict (pMask, mask); + free_pixman_pict (pDst, dest); +} + +void +fbCompositeGeneral (CARD8 op, + PicturePtr pSrc, + PicturePtr pMask, + PicturePtr pDst, + INT16 xSrc, + INT16 ySrc, + INT16 xMask, + INT16 yMask, + INT16 xDst, + INT16 yDst, + CARD16 width, + CARD16 height) +{ + fbComposite (op, pSrc, pMask, pDst, + xSrc, ySrc, xMask, yMask, xDst, yDst, + width, height); +} + #endif /* RENDER */ +static pixman_image_t * +create_solid_fill_image (PicturePtr pict) +{ + PictSolidFill *solid = &pict->pSourcePict->solidFill; + pixman_color_t color; + CARD32 a, r, g, b; + + a = (solid->color & 0xff000000) >> 24; + r = (solid->color & 0x00ff0000) >> 16; + g = (solid->color & 0x0000ff00) >> 8; + b = (solid->color & 0x000000ff) >> 0; + + color.alpha = (a << 8) | a; + color.red = (r << 8) | r; + color.green = (g << 8) | g; + color.blue = (b << 8) | b; + + return pixman_image_create_solid_fill (&color); +} + +static pixman_image_t * +create_linear_gradient_image (PictGradient *gradient) +{ + PictLinearGradient *linear = (PictLinearGradient *)gradient; + pixman_point_fixed_t p1; + pixman_point_fixed_t p2; + + p1.x = linear->p1.x; + p1.y = linear->p1.y; + p2.x = linear->p2.x; + p2.y = linear->p2.y; + + return pixman_image_create_linear_gradient ( + &p1, &p2, (pixman_gradient_stop_t *)gradient->stops, gradient->nstops); +} + +static pixman_image_t * +create_radial_gradient_image (PictGradient *gradient) +{ + PictRadialGradient *radial = (PictRadialGradient *)gradient; + pixman_point_fixed_t c1; + pixman_point_fixed_t c2; + + c1.x = radial->c1.x; + c1.y = radial->c1.y; + c2.x = radial->c2.x; + c2.y = radial->c2.y; + + return pixman_image_create_radial_gradient ( + &c1, &c2, radial->c1.radius, + radial->c2.radius, + (pixman_gradient_stop_t *)gradient->stops, gradient->nstops); +} + +static pixman_image_t * +create_conical_gradient_image (PictGradient *gradient) +{ + PictConicalGradient *conical = (PictConicalGradient *)gradient; + pixman_point_fixed_t center; + + center.x = conical->center.x; + center.y = conical->center.y; + + return pixman_image_create_conical_gradient ( + ¢er, conical->angle, (pixman_gradient_stop_t *)gradient->stops, + gradient->nstops); +} + +static pixman_image_t * +create_bits_picture (PicturePtr pict, + Bool has_clip) +{ + FbBits *bits; + FbStride stride; + int bpp, xoff, yoff; + pixman_image_t *image; + + fbGetDrawable (pict->pDrawable, bits, stride, bpp, xoff, yoff); + + bits = (CARD8*)bits + yoff * stride * sizeof(FbBits) + xoff * (bpp / 8); + + image = pixman_image_create_bits ( + pict->format, + pict->pDrawable->width, pict->pDrawable->height, + (uint32_t *)bits, stride * sizeof (FbStride)); + + +#ifdef FB_ACCESS_WRAPPER +#if FB_SHIFT==5 + + pixman_image_set_accessors (image, + (pixman_read_memory_func_t)wfbReadMemory, + (pixman_write_memory_func_t)wfbWriteMemory); + +#else + +#error The pixman library only works when FbBits is 32 bits wide + +#endif +#endif + + /* pCompositeClip is undefined for source pictures, so + * only set the clip region for pictures with drawables + */ + if (has_clip) + { + if (pict->clientClipType != CT_NONE) + pixman_image_set_has_client_clip (image, TRUE); + + pixman_image_set_clip_region (image, pict->pCompositeClip); + } + + /* Indexed table */ + if (pict->pFormat->index.devPrivate) + pixman_image_set_indexed (image, pict->pFormat->index.devPrivate); + + return image; +} + +static void +set_image_properties (pixman_image_t *image, PicturePtr pict) +{ + pixman_repeat_t repeat; + pixman_filter_t filter; + + if (pict->transform) + { + pixman_image_set_transform ( + image, (pixman_transform_t *)pict->transform); + } + + switch (pict->repeatType) + { + default: + case RepeatNone: + repeat = PIXMAN_REPEAT_NONE; + break; + + case RepeatPad: + repeat = PIXMAN_REPEAT_PAD; + break; + + case RepeatNormal: + repeat = PIXMAN_REPEAT_NORMAL; + break; + + case RepeatReflect: + repeat = PIXMAN_REPEAT_REFLECT; + break; + } + + pixman_image_set_repeat (image, repeat); + + if (pict->alphaMap) + { + pixman_image_t *alpha_map = image_from_pict (pict->alphaMap, TRUE); + + pixman_image_set_alpha_map ( + image, alpha_map, pict->alphaOrigin.x, pict->alphaOrigin.y); + + free_pixman_pict (pict->alphaMap, alpha_map); + } + + pixman_image_set_component_alpha (image, pict->componentAlpha); + + switch (pict->filter) + { + default: + case PictFilterNearest: + case PictFilterFast: + filter = PIXMAN_FILTER_NEAREST; + break; + + case PictFilterBilinear: + case PictFilterGood: + filter = PIXMAN_FILTER_BILINEAR; + break; + + case PictFilterConvolution: + filter = PIXMAN_FILTER_CONVOLUTION; + break; + } + + pixman_image_set_filter (image, filter, (pixman_fixed_t *)pict->filter_params, pict->filter_nparams); + pixman_image_set_source_clipping (image, TRUE); +} + +pixman_image_t * +image_from_pict (PicturePtr pict, + Bool has_clip) +{ + pixman_image_t *image = NULL; + + if (!pict) + return NULL; + + if (pict->pDrawable) + { + image = create_bits_picture (pict, has_clip); + } + else if (pict->pSourcePict) + { + SourcePict *sp = pict->pSourcePict; + + if (sp->type == SourcePictTypeSolidFill) + { + image = create_solid_fill_image (pict); + } + else + { + PictGradient *gradient = &pict->pSourcePict->gradient; + + if (sp->type == SourcePictTypeLinear) + image = create_linear_gradient_image (gradient); + else if (sp->type == SourcePictTypeRadial) + image = create_radial_gradient_image (gradient); + else if (sp->type == SourcePictTypeConical) + image = create_conical_gradient_image (gradient); + } + } + + if (image) + set_image_properties (image, pict); + + return image; +} + +void +free_pixman_pict (PicturePtr pict, pixman_image_t *image) +{ + if (image && pixman_image_unref (image) && pict->pDrawable) + fbFinishAccess (pict->pDrawable); +} + Bool fbPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats) { diff --git a/nx-X11/programs/Xserver/fb/fbpict.h b/nx-X11/programs/Xserver/fb/fbpict.h index 55c863db62..fcba0669fd 100644 --- a/nx-X11/programs/Xserver/fb/fbpict.h +++ b/nx-X11/programs/Xserver/fb/fbpict.h @@ -1,4 +1,5 @@ /* + * * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its @@ -29,6 +30,13 @@ #include "renderedge.h" + +#if defined(__GNUC__) +#define INLINE __inline__ +#else +#define INLINE +#endif + #define FbIntMult(a,b,t) ( (t) = (a) * (b) + 0x80, ( ( ( (t)>>8 ) + (t) )>>8 ) ) #define FbIntDiv(a,b) (((CARD16) (a) * 255) / (b)) @@ -66,6 +74,37 @@ #define Green(x) (((x) >> 8) & 0xff) #define Blue(x) ((x) & 0xff) +/** + * Returns TRUE if the fbComposeGetSolid can be used to get a single solid + * color representing every source sampling location of the picture. + */ +static INLINE Bool +fbCanGetSolid(PicturePtr pict) +{ + if (pict->pDrawable == NULL || + pict->pDrawable->width != 1 || + pict->pDrawable->height != 1) + { + return FALSE; + } + if (pict->repeat != RepeatNormal) + return FALSE; + + switch (pict->format) { + case PICT_a8r8g8b8: + case PICT_x8r8g8b8: + case PICT_a8b8g8r8: + case PICT_x8b8g8r8: + case PICT_r8g8b8: + case PICT_b8g8r8: + case PICT_r5g6b5: + case PICT_b5g6r5: + return TRUE; + default: + return FALSE; + } +} + #define fbComposeGetSolid(pict, bits, fmt) { \ FbBits *__bits__; \ FbStride __stride__; \ @@ -75,14 +114,22 @@ fbGetDrawable((pict)->pDrawable,__bits__,__stride__,__bpp__,__xoff__,__yoff__); \ switch (__bpp__) { \ case 32: \ - (bits) = *(CARD32 *) __bits__; \ + (bits) = READ((CARD32 *) __bits__); \ break; \ case 24: \ (bits) = Fetch24 ((CARD8 *) __bits__); \ break; \ case 16: \ - (bits) = *(CARD16 *) __bits__; \ - (bits) = cvt0565to8888(bits); \ + (bits) = READ((CARD16 *) __bits__); \ + (bits) = cvt0565to0888(bits); \ + break; \ + case 8: \ + (bits) = READ((CARD8 *) __bits__); \ + (bits) = (bits) << 24; \ + break; \ + case 1: \ + (bits) = READ((CARD32 *) __bits__); \ + (bits) = FbLeftStipBits((bits),1) ? 0xff000000 : 0x00000000;\ break; \ default: \ return; \ @@ -98,6 +145,7 @@ /* manage missing src alpha */ \ if ((pict)->pFormat->direct.alphaMask == 0) \ (bits) |= 0xff000000; \ + fbFinishAccess ((pict)->pDrawable); \ } #define fbComposeGetStart(pict,x,y,type,stride,line,mul) {\ @@ -113,28 +161,28 @@ #define cvt8888to0565(s) ((((s) >> 3) & 0x001f) | \ (((s) >> 5) & 0x07e0) | \ (((s) >> 8) & 0xf800)) -#define cvt0565to8888(s) (((((s) << 3) & 0xf8) | (((s) >> 2) & 0x7)) | \ +#define cvt0565to0888(s) (((((s) << 3) & 0xf8) | (((s) >> 2) & 0x7)) | \ ((((s) << 5) & 0xfc00) | (((s) >> 1) & 0x300)) | \ ((((s) << 8) & 0xf80000) | (((s) << 3) & 0x70000))) #if IMAGE_BYTE_ORDER == MSBFirst #define Fetch24(a) ((unsigned long) (a) & 1 ? \ - ((*(a) << 16) | *((CARD16 *) ((a)+1))) : \ - ((*((CARD16 *) (a)) << 8) | *((a)+2))) + ((READ(a) << 16) | READ((CARD16 *) ((a)+1))) : \ + ((READ((CARD16 *) (a)) << 8) | READ((a)+2))) #define Store24(a,v) ((unsigned long) (a) & 1 ? \ - ((*(a) = (CARD8) ((v) >> 16)), \ - (*((CARD16 *) ((a)+1)) = (CARD16) (v))) : \ - ((*((CARD16 *) (a)) = (CARD16) ((v) >> 8)), \ - (*((a)+2) = (CARD8) (v)))) + (WRITE(a, (CARD8) ((v) >> 16)), \ + WRITE((CARD16 *) ((a)+1), (CARD16) (v))) : \ + (WRITE((CARD16 *) (a), (CARD16) ((v) >> 8)), \ + WRITE((a)+2, (CARD8) (v)))) #else #define Fetch24(a) ((unsigned long) (a) & 1 ? \ - ((*(a)) | (*((CARD16 *) ((a)+1)) << 8)) : \ - ((*((CARD16 *) (a))) | (*((a)+2) << 16))) + (READ(a) | (READ((CARD16 *) ((a)+1)) << 8)) : \ + (READ((CARD16 *) (a)) | (READ((a)+2) << 16))) #define Store24(a,v) ((unsigned long) (a) & 1 ? \ - ((*(a) = (CARD8) (v)), \ - (*((CARD16 *) ((a)+1)) = (CARD16) ((v) >> 8))) : \ - ((*((CARD16 *) (a)) = (CARD16) (v)),\ - (*((a)+2) = (CARD8) ((v) >> 16)))) + (WRITE(a, (CARD8) (v)), \ + WRITE((CARD16 *) ((a)+1), (CARD16) ((v) >> 8))) : \ + (WRITE((CARD16 *) (a), (CARD16) (v)),\ + WRITE((a)+2, (CARD8) ((v) >> 16)))) #endif /* @@ -320,12 +368,6 @@ #define FASTCALL #endif -#if defined(__GNUC__) -#define INLINE __inline__ -#else -#define INLINE -#endif - typedef struct _FbComposeData { CARD8 op; PicturePtr src; @@ -341,6 +383,9 @@ typedef struct _FbComposeData { CARD16 height; } FbComposeData; +void +fbCompositeRect (const FbComposeData *data, CARD32 *scanline_buffer); + typedef FASTCALL void (*CombineMaskU) (CARD32 *src, const CARD32 *mask, int width); typedef FASTCALL void (*CombineFuncU) (CARD32 *dest, const CARD32 *src, int width); typedef FASTCALL void (*CombineFuncC) (CARD32 *dest, CARD32 *src, CARD32 *mask, int width); @@ -367,210 +412,7 @@ fbCompositeGeneral (CARD8 op, CARD16 width, CARD16 height); - -/* fbedge.c */ -void -fbRasterizeEdges (FbBits *buf, - int bpp, - int width, - int stride, - RenderEdge *l, - RenderEdge *r, - xFixed t, - xFixed b); - /* fbpict.c */ -CARD32 -fbOver (CARD32 x, CARD32 y); - -CARD32 -fbOver24 (CARD32 x, CARD32 y); - -CARD32 -fbIn (CARD32 x, CARD8 y); - -void -fbCompositeSolidMask_nx8x8888 (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height); - -void -fbCompositeSolidMask_nx8x0888 (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height); - -void -fbCompositeSolidMask_nx8888x8888C (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height); - -void -fbCompositeSolidMask_nx8x0565 (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height); - -void -fbCompositeSolidMask_nx8888x0565C (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height); - -void -fbCompositeSrc_8888x8888 (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height); - -void -fbCompositeSrc_8888x0888 (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height); - -void -fbCompositeSrc_8888x0565 (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height); - -void -fbCompositeSrc_0565x0565 (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height); - -void -fbCompositeSrcAdd_8000x8000 (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height); - -void -fbCompositeSrcAdd_8888x8888 (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height); - -void -fbCompositeSrcAdd_1000x1000 (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height); - -void -fbCompositeSolidMask_nx1xn (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height); - void fbComposite (CARD8 op, PicturePtr pSrc, @@ -585,6 +427,36 @@ fbComposite (CARD8 op, CARD16 width, CARD16 height); +typedef void (*CompositeFunc) (CARD8 op, + PicturePtr pSrc, + PicturePtr pMask, + PicturePtr pDst, + INT16 xSrc, + INT16 ySrc, + INT16 xMask, + INT16 yMask, + INT16 xDst, + INT16 yDst, + CARD16 width, + CARD16 height); + +void +fbWalkCompositeRegion (CARD8 op, + PicturePtr pSrc, + PicturePtr pMask, + PicturePtr pDst, + INT16 xSrc, + INT16 ySrc, + INT16 xMask, + INT16 yMask, + INT16 xDst, + INT16 yDst, + CARD16 width, + CARD16 height, + Bool srcRepeat, + Bool maskRepeat, + CompositeFunc compositeRect); + /* fbtrap.c */ void diff --git a/nx-X11/programs/Xserver/fb/fbpixmap.c b/nx-X11/programs/Xserver/fb/fbpixmap.c index 5f24433e3b..8f850cdff4 100644 --- a/nx-X11/programs/Xserver/fb/fbpixmap.c +++ b/nx-X11/programs/Xserver/fb/fbpixmap.c @@ -1,6 +1,4 @@ /* - * Id: fbpixmap.c,v 1.1 1999/11/02 03:54:45 keithp Exp $ - * * Copyright © 1998 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its @@ -163,6 +161,8 @@ fbPixmapToRegion(PixmapPtr pPix) FirstRect = RegionBoxptr(pReg); rects = FirstRect; + fbPrepareAccess(&pPix->drawable); + pwLine = (FbBits *) pPix->devPrivate.ptr; nWidth = pPix->devKind >> (FB_SHIFT-3); @@ -177,7 +177,7 @@ fbPixmapToRegion(PixmapPtr pPix) irectLineStart = rects - FirstRect; /* If the Screen left most bit of the word is set, we're starting in * a box */ - if(*pw & mask0) + if(READ(pw) & mask0) { fInBox = TRUE; rx1 = 0; @@ -188,7 +188,7 @@ fbPixmapToRegion(PixmapPtr pPix) pwLineEnd = pw + (width >> FB_SHIFT); for (base = 0; pw < pwLineEnd; base += FB_UNIT) { - w = *pw++; + w = READ(pw++); if (fInBox) { if (!~w) @@ -229,7 +229,7 @@ fbPixmapToRegion(PixmapPtr pPix) if(width & FB_MASK) { /* Process final partial word on line */ - w = *pw++; + w = READ(pw++); for(ib = 0; ib < (width & FB_MASK); ib++) { /* If the Screen left most bit of the word is set, we're @@ -314,6 +314,8 @@ fbPixmapToRegion(PixmapPtr pPix) pReg->data = (RegDataPtr)NULL; } } + + fbFinishAccess(&pPix->drawable); #ifdef DEBUG if (!RegionIsValid(pReg)) FatalError("Assertion failed file %s, line %d: expr\n", __FILE__, __LINE__); @@ -323,11 +325,7 @@ fbPixmapToRegion(PixmapPtr pPix) #ifdef FB_DEBUG -#ifndef WIN32 #include -#else -#include -#endif static Bool fbValidateBits (FbStip *bits, int stride, FbStip data) @@ -336,12 +334,7 @@ fbValidateBits (FbStip *bits, int stride, FbStip data) { if (*bits != data) { -#ifdef WIN32 - NCD_DEBUG ((DEBUG_FAILURE, "fdValidateBits failed at 0x%x (is 0x%x want 0x%x)", - bits, *bits, data)); -#else fprintf (stderr, "fbValidateBits failed\n"); -#endif return FALSE; } bits++; @@ -365,6 +358,7 @@ fbValidateDrawable (DrawablePtr pDrawable) if (!fbValidateBits (first, stride, FB_HEAD_BITS) || !fbValidateBits (last, stride, FB_TAIL_BITS)) fbInitializeDrawable(pDrawable); + fbFinishAccess (pDrawable); } void @@ -386,5 +380,6 @@ fbInitializeDrawable (DrawablePtr pDrawable) last = bits + stride * pDrawable->height; fbSetBits (first, stride, FB_HEAD_BITS); fbSetBits (last, stride, FB_TAIL_BITS); + fbFinishAccess (pDrawable); } #endif /* FB_DEBUG */ diff --git a/nx-X11/programs/Xserver/fb/fbpoint.c b/nx-X11/programs/Xserver/fb/fbpoint.c index 719dcfbb47..f260a69ca1 100644 --- a/nx-X11/programs/Xserver/fb/fbpoint.c +++ b/nx-X11/programs/Xserver/fb/fbpoint.c @@ -1,6 +1,4 @@ /* - * Id: fbpoint.c,v 1.1 1999/11/02 03:54:45 keithp Exp $ - * * Copyright © 1998 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its @@ -90,20 +88,20 @@ fbDots (FbBits *dstOrig, FbMaskStip (x, 24, leftMask, n, rightMask); if (leftMask) { - *d = FbDoMaskRRop (*d, andT, xorT, leftMask); + WRITE(d, FbDoMaskRRop (READ(d), andT, xorT, leftMask)); andT = FbNext24Stip(andT); xorT = FbNext24Stip(xorT); d++; } if (rightMask) - *d = FbDoMaskRRop(*d, andT, xorT, rightMask); + WRITE(d, FbDoMaskRRop(READ(d), andT, xorT, rightMask)); } else #endif { FbStip mask; mask = FbStipMask(x, dstBpp); - *d = FbDoMaskRRop (*d, and, xor, mask); + WRITE(d, FbDoMaskRRop (READ(d), and, xor, mask)); } } } @@ -160,4 +158,5 @@ fbPolyPoint (DrawablePtr pDrawable, nBox--; pBox++) (*dots) (dst, dstStride, dstBpp, pBox, pptInit, nptInit, pDrawable->x, pDrawable->y, dstXoff, dstYoff, and, xor); + fbFinishAccess (pDrawable); } diff --git a/nx-X11/programs/Xserver/fb/fbpseudocolor.c b/nx-X11/programs/Xserver/fb/fbpseudocolor.c new file mode 100644 index 0000000000..8f01e59f23 --- /dev/null +++ b/nx-X11/programs/Xserver/fb/fbpseudocolor.c @@ -0,0 +1,2338 @@ +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include + +#include +#include +#include "scrnintstr.h" +#include "colormapst.h" +#include "glyphstr.h" +#include "resource.h" +#include +#include "dixfontstr.h" +#include +#include "micmap.h" +#include "fb.h" +#include "fbpseudocolor.h" + +static Bool xxCreateGC(GCPtr pGC); +static void xxValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDraw); +static void xxDestroyGC(GCPtr pGC); +static void xxChangeGC (GCPtr pGC, unsigned long mask); +static void xxCopyGC (GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst); +static void xxChangeClip (GCPtr pGC, int type, void * pvalue, int nrects); + +static void xxCopyClip(GCPtr pgcDst, GCPtr pgcSrc); +static void xxDestroyClip(GCPtr pGC); +static void xxFillSpans(DrawablePtr pDraw, GC *pGC, int nInit, + DDXPointPtr pptInit, int *pwidthInit, int fSorted); +static void xxSetSpans(DrawablePtr pDraw, GCPtr pGC, char *pcharsrc, + DDXPointPtr pptInit, int *pwidthInit, int nspans, + int fSorted); +static void xxPutImage(DrawablePtr pDraw, GCPtr pGC, int depth, int x, int y, + int w, int h,int leftPad, int format, char *pImage); +static RegionPtr xxCopyPlane(DrawablePtr pSrc, + DrawablePtr pDst, GCPtr pGC,int srcx, int srcy, + int width, int height, int dstx, int dsty, + unsigned long bitPlane); +static void xxPolyPoint(DrawablePtr pDraw, GCPtr pGC, int mode, int npt, + xPoint *pptInit); +static void xxPolylines(DrawablePtr pDraw, GCPtr pGC, int mode, + int npt, DDXPointPtr pptInit); +static void xxPolySegment(DrawablePtr pDraw, GCPtr pGC, int nseg, + xSegment *pSeg); +static void xxPolyRectangle(DrawablePtr pDraw, GCPtr pGC, int nRects, + xRectangle *pRects); +static void xxPolyArc( DrawablePtr pDraw, GCPtr pGC, int narcs, xArc *parcs); +static void xxFillPolygon(DrawablePtr pDraw, GCPtr pGC, int shape, + int mode, int count, DDXPointPtr pptInit); +static void xxPolyFillRect(DrawablePtr pDraw, GCPtr pGC, int nRectsInit, + xRectangle *pRectsInit); +static RegionPtr xxCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GC *pGC, + int srcx, int srcy, int width, int height, + int dstx, int dsty); +static void xxPolyFillArc(DrawablePtr pDraw, GCPtr pGC, int narcs, + xArc *parcs); +static int xxPolyText8(DrawablePtr pDraw, GCPtr pGC, int x, int y, int count, + char *chars); +static int xxPolyText16(DrawablePtr pDraw, GCPtr pGC, int x, int y, + int count, unsigned short *chars); +static void xxImageText8(DrawablePtr pDraw, GCPtr pGC, int x, + int y, int count, char *chars); +static void xxImageText16(DrawablePtr pDraw, GCPtr pGC, int x, int y, + int count, unsigned short *chars); +static void xxImageGlyphBlt(DrawablePtr pDraw, GCPtr pGC, int x, int y, + unsigned int nglyph, CharInfoPtr *ppci, + void * pglyphBase); +static void xxPolyGlyphBlt(DrawablePtr pDraw, GCPtr pGC, int x, int y, + unsigned int nglyph, CharInfoPtr *ppci, + void * pglyphBase); +static void xxPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDraw, + int dx, int dy, int xOrg, int yOrg); +static void +xxComposite (CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, + INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask, + INT16 xDst, INT16 yDst, CARD16 width, CARD16 height); +static void +xxGlyphs (CARD8 op, PicturePtr pSrc, PicturePtr pDst, + PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, int nlist, + GlyphListPtr list, GlyphPtr *glyphs); + + +typedef struct _xxCmapPrivRec { + CARD32* cmap; + ColormapPtr pmap; + Bool dirty; + struct _xxCmapPrivRec *next; +} xxCmapPrivRec, *xxCmapPrivPtr; + + +typedef struct { + CloseScreenProcPtr CloseScreen; + CreateScreenResourcesProcPtr CreateScreenResources; + CreateWindowProcPtr CreateWindow; + CopyWindowProcPtr CopyWindow; + PaintWindowProcPtr PaintWindowBackground; + PaintWindowProcPtr PaintWindowBorder; + WindowExposuresProcPtr WindowExposures; + CreateGCProcPtr CreateGC; + CreateColormapProcPtr CreateColormap; + DestroyColormapProcPtr DestroyColormap; + InstallColormapProcPtr InstallColormap; + UninstallColormapProcPtr UninstallColormap; + ListInstalledColormapsProcPtr ListInstalledColormaps; + StoreColorsProcPtr StoreColors; +#ifdef RENDER + CompositeProcPtr Composite; + GlyphsProcPtr Glyphs; +#endif + PixmapPtr pPixmap; + char * addr; + void * pBits; + RegionRec region; + VisualPtr bVisual; + RegionRec bRegion; + int myDepth; + int depth; + ColormapPtr baseCmap; + ColormapPtr* InstalledCmaps; + xxCmapPrivPtr Cmaps; + int numInstalledColormaps; + int colormapDirty; + xxSyncFunc sync; +} xxScrPrivRec, *xxScrPrivPtr; + +#define xxGetScrPriv(s) ((xxScrPrivPtr) \ + (xxScrPrivateIndex != -1) \ + ? (s)->devPrivates[xxScrPrivateIndex].ptr\ + : NULL) +#define xxScrPriv(s) xxScrPrivPtr pScrPriv = xxGetScrPriv(s) + +#define xxGetCmapPriv(s) ((xxCmapPrivPtr) \ + (s)->devPrivates[xxColormapPrivateIndex].ptr) +#define xxCmapPriv(s) xxCmapPrivPtr pCmapPriv = xxGetCmapPriv(s); + +typedef struct _xxGCPriv { + GCOps *ops; + GCFuncs *funcs; +} xxGCPrivRec, *xxGCPrivPtr; + +#define xxGetGCPriv(pGC) ((xxGCPrivPtr) \ + (pGC)->devPrivates[xxGCPrivateIndex].ptr) +#define xxGCPriv(pGC) xxGCPrivPtr pGCPriv = xxGetGCPriv(pGC) + +int xxScrPrivateIndex = -1; +int xxGCPrivateIndex; +int xxColormapPrivateIndex = -1; +int xxGeneration; + + +#define wrap(priv,real,mem,func) {\ + priv->mem = real->mem; \ + real->mem = func; \ +} + +#define unwrap(priv,real,mem) {\ + real->mem = priv->mem; \ +} + +#define MARK_DIRTY (1 << 31) + +#define MAX_NUM_XX_INSTALLED_CMAPS 255 +/* #define DEBUG */ +#ifdef DEBUG +# define DBG ErrorF +# define DBG_ARGS(x) ErrorF x +# define PRINT_RECTS(rec) {\ + int i;\ + BoxPtr box;\ + ErrorF("RECTS: %i\n",RegionNumRects(&rec));\ + if (RegionNumRects(&rec) > 1) { \ + for (i = 0; i < RegionNumRects(&rec); i++ ) {\ + box = RegionBox(&rec,i);\ + ErrorF("x1: %hi x2: %hi y1: %hi y2: %hi\n", \ + box->x1,box->x2,box->y1,box->y2);\ + }\ + } else { \ + box = &(rec.extents); \ + ErrorF("x1: %hi x2: %hi y1: %hi y2: %hi\n", \ + box->x1,box->x2,box->y1,box->y2);\ + } \ +} +#else +# define DBG(x) +# define DBG_ARGS(x) +# define PRINT_RECTS(rec) +#endif + +#if 0 +static void xxCopyPseudocolorRegion(ScreenPtr pScreen, RegionPtr pReg, + xxCmapPrivPtr pCmapPriv); +static void xxUpdateFb(ScreenPtr pScreen); + + +static void +xxUpdateWindowImmediately(WindowPtr pWin) +{ + xxScrPriv(pWin->drawable.pScreen); + xxCmapPrivPtr pCmapPriv; + ColormapPtr pmap; + + pmap = (ColormapPtr)LookupIDByType(wColormap(pWin),RT_COLORMAP); + + if (pmap && (pCmapPriv = xxGetCmapPriv(pmap)) != (void *)-1) { + xxCopyPseudocolorRegion(pWin->drawable.pScreen, + &pScrPriv->region, pCmapPriv); + } +} +#else +# define xxUpdateWindowImmediately(x) +#endif + +static ColormapPtr +xxGetBaseColormap(ScreenPtr pScreen) +{ + xxScrPriv(pScreen); + DepthPtr pDepth = pScreen->allowedDepths; + int i,j,k; + ColormapPtr pDefMap + = (ColormapPtr) LookupIDByType(pScreen->defColormap,RT_COLORMAP); + ColormapPtr cmap = NULL; + VisualPtr pVisual = NULL; + + for (i = 0; i < pScreen->numDepths; i++, pDepth++) + if (pDepth->depth == pScrPriv->depth) { + for (j = 0; j < pDepth->numVids; j++) { + if (pDefMap->pVisual->vid == pDepth->vids[j] + && pDefMap->pVisual->class == TrueColor) { + cmap = pDefMap; + break; + } + if (!pVisual) { + for (k = 0; k < pScreen->numVisuals; k++) { + if (pScreen->visuals[k].class == TrueColor + && pScreen->visuals[k].vid + == pDepth->vids[j]) { + pVisual = &pScreen->visuals[k]; + break; + } + } + } + } + if (cmap) + break; + } + + if (!cmap) { + CreateColormap(FakeClientID(0),pScreen,pVisual,&cmap,AllocNone,0); + } + + return cmap; +} + +static Bool +xxCreateScreenResources(ScreenPtr pScreen) +{ + PixmapPtr pPix; + xxScrPriv(pScreen); + Bool ret; + PixmapPtr pPixmap; + BoxRec box; + int depth = pScrPriv->myDepth; + void * pBits; + + unwrap (pScrPriv,pScreen, CreateScreenResources); + ret = pScreen->CreateScreenResources(pScreen); + wrap(pScrPriv,pScreen,CreateScreenResources,xxCreateScreenResources); + + if (!ret) return FALSE; + + pScrPriv->pBits = NULL; + if (pScrPriv->addr) + pBits = pScrPriv->addr; + else + pBits = malloc(pScreen->width * pScreen->height + * (BitsPerPixel(depth) >> 3)); + if (!pBits) return FALSE; + + pPixmap = (*pScreen->CreatePixmap)(pScreen, 0, 0, depth); + if (!pPixmap) { + free(pBits); + return FALSE; + } + if (!(*pScreen->ModifyPixmapHeader)(pPixmap, pScreen->width, + pScreen->height, depth, + BitsPerPixel(depth), + PixmapBytePad(pScreen->width, depth), + pBits)) { + free(pBits); + return FALSE; + } + if (pScreen->rootDepth == pScrPriv->myDepth) { + pPix = (PixmapPtr)pScreen->devPrivate; + if (!(*pScreen->ModifyPixmapHeader)(pPix, 0,0, pScrPriv->depth, + BitsPerPixel(pScrPriv->depth), + PixmapBytePad(pScreen->width, + pScrPriv->depth), + 0)) { + free(pBits); + return FALSE; + } + } + + pScrPriv->baseCmap = xxGetBaseColormap(pScreen); + + pScrPriv->pBits = pBits; + pScrPriv->pPixmap = pPixmap; + box.x1 = 0; + box.y1 = 0; + box.x2 = pScreen->width; + box.y2 = pScreen->height; + RegionNull(&pScrPriv->region); + RegionInit(&pScrPriv->bRegion, &box, 0); + + return TRUE; +} + +static Bool +xxCloseScreen (int iScreen, ScreenPtr pScreen) +{ + xxScrPriv(pScreen); + Bool ret; + + (*pScreen->DestroyPixmap)(pScrPriv->pPixmap); + /* We don't need to free the baseColormap as FreeClientResourcess + will have taken care of it. */ + RegionUninit(&pScrPriv->region); + + unwrap (pScrPriv,pScreen, CloseScreen); + ret = pScreen->CloseScreen(iScreen,pScreen); + + free(pScrPriv->pBits); + free(pScrPriv->InstalledCmaps); + free(pScrPriv); + + return TRUE; +} + +static Bool +xxMyVisual(ScreenPtr pScreen, VisualID vid) +{ + xxScrPriv(pScreen); + DepthPtr pDepth = pScreen->allowedDepths; + int i,j; + + for (i = 0; i < pScreen->numDepths; i++, pDepth++) + if (pDepth->depth == pScrPriv->myDepth) { + for (j = 0; j < pDepth->numVids; j++) { + if (vid == pDepth->vids[j]) { + return TRUE; + } + } + } + return FALSE; +} + +static Bool +xxInitColormapDummy(ColormapPtr pmap, int index) +{ + return TRUE; +} + +static Bool +xxInitColormapPrivate(ColormapPtr pmap) +{ + xxScrPriv(pmap->pScreen); + xxCmapPrivPtr pCmapPriv; + void * cmap; + + pmap->devPrivates[xxColormapPrivateIndex].ptr = (void *) -1; + + if (xxMyVisual(pmap->pScreen,pmap->pVisual->vid)) { + DBG("CreateColormap\n"); + pCmapPriv = (xxCmapPrivPtr) malloc (sizeof (xxCmapPrivRec)); + if (!pCmapPriv) + return FALSE; + pmap->devPrivates[xxColormapPrivateIndex].ptr = (void *) pCmapPriv; + cmap = malloc(sizeof (CARD32) * (1 << pScrPriv->myDepth)); + if (!cmap) + return FALSE; + + memset(cmap,0,sizeof (CARD32) * (1 << pScrPriv->myDepth)); + + pCmapPriv->cmap = cmap; + pCmapPriv->dirty = FALSE; + pCmapPriv->pmap = pmap; + pCmapPriv->next = pScrPriv->Cmaps; + pScrPriv->Cmaps = pCmapPriv; + } + return TRUE; +} + + +static Bool +xxCreateColormap(ColormapPtr pmap) +{ + xxScrPriv(pmap->pScreen); + Bool ret; + + if (!xxInitColormapPrivate(pmap)) return FALSE; + + unwrap(pScrPriv,pmap->pScreen, CreateColormap); + ret = pmap->pScreen->CreateColormap(pmap); + wrap(pScrPriv,pmap->pScreen,CreateColormap,xxCreateColormap); + + return ret; +} + +static int +xxCmapInstalled(ColormapPtr pmap) +{ + xxScrPriv(pmap->pScreen); + int i; + + for (i = 0; i < pScrPriv->numInstalledColormaps; i++) + if (pScrPriv->InstalledCmaps[i] == pmap) + break; + if (i == pScrPriv->numInstalledColormaps) /* not installed */ + return -1; + return i; +} + +static void +xxInstalledCmapDelete(ScreenPtr pScreen, int num) +{ + xxScrPriv(pScreen); + int i; + + pScrPriv->numInstalledColormaps--; + + for (i = num; i < pScrPriv->numInstalledColormaps; i++) + pScrPriv->InstalledCmaps[i] = pScrPriv->InstalledCmaps[i+1]; +} + +static void +xxDestroyColormap(ColormapPtr pmap) +{ + xxScrPriv(pmap->pScreen); + xxCmapPriv(pmap); + + if (pCmapPriv != (void *) -1) { + xxCmapPrivPtr tmpCmapPriv = pScrPriv->Cmaps; + xxCmapPrivPtr *prevCmapPriv = &pScrPriv->Cmaps; + int n; + + DBG("DestroyColormap\n"); + + if ((n = xxCmapInstalled(pmap)) != -1) + xxInstalledCmapDelete(pmap->pScreen,n); + + while (tmpCmapPriv) { + if (tmpCmapPriv->pmap == pmap) { + *prevCmapPriv = tmpCmapPriv->next; + break; + } + prevCmapPriv = &tmpCmapPriv->next; + tmpCmapPriv = tmpCmapPriv->next; + } + + free(pCmapPriv->cmap); + free(pCmapPriv); + } + + unwrap(pScrPriv,pmap->pScreen, DestroyColormap); + pmap->pScreen->DestroyColormap(pmap); + wrap(pScrPriv,pmap->pScreen,DestroyColormap,xxDestroyColormap); +} + +#define Shift(v,d) ((d) < 0 ? ((v) >> (-d)) : ((v) << (d))) + +static int +xxComputeCmapShift (unsigned long mask) +{ + int shift; + unsigned long bit; + + shift = 16; + bit = 0x80000000; + while (!(mask & bit)) + { + shift--; + bit >>= 1; + } + return shift; +} + +static void +xxStoreColors(ColormapPtr pmap, int nColors, xColorItem *pColors) +{ + xxScrPriv(pmap->pScreen); + xxCmapPriv(pmap); + + if (pCmapPriv != (void *) -1) { + + xColorItem *expanddefs; + int i; + VisualPtr bVisual; + int rs, gs, bs; + + if (nColors == 0) return; + + DBG("StoreColors\n"); + + expanddefs = malloc(sizeof(xColorItem) + * (1 << pScrPriv->myDepth)); + if (!expanddefs) return; + + bVisual = pScrPriv->bVisual; + + DBG("StoreColors\n"); + + rs = xxComputeCmapShift(bVisual->redMask); + gs = xxComputeCmapShift(bVisual->greenMask); + bs = xxComputeCmapShift(bVisual->blueMask); + + if ((pmap->pVisual->class | DynamicClass) == DirectColor) { + nColors = miExpandDirectColors(pmap, nColors, pColors, expanddefs); + pColors = expanddefs; + } + + for (i = 0; i < nColors; i++) { + DBG_ARGS(("index: %i r 0x%x g 0x%x b 0x%x\n", pColors->pixel, + pColors->red, pColors->green, pColors->blue)); + pCmapPriv->cmap[pColors->pixel] = MARK_DIRTY + | (Shift(pColors->red, rs) & bVisual->redMask) + | (Shift(pColors->green, gs) & bVisual->greenMask) + | (Shift(pColors->blue, bs) & bVisual->blueMask); + pColors++; + } + + free(expanddefs); + + pCmapPriv->dirty = TRUE; + pScrPriv->colormapDirty = TRUE; + + return; + } + + unwrap(pScrPriv,pmap->pScreen, StoreColors); + pmap->pScreen->StoreColors(pmap,nColors,pColors); + wrap(pScrPriv,pmap->pScreen,StoreColors,xxStoreColors); +} + +static void +xxInstallColormap(ColormapPtr pmap) +{ + int i; + xxScrPriv(pmap->pScreen); + xxCmapPriv(pmap); + + if (pCmapPriv != (void *) -1) { + Pixel *pixels; + xrgb *colors; + int i; + VisualPtr pVisual; + xColorItem *defs; + + DBG("InstallColormap\n"); + + if (xxCmapInstalled(pmap) != -1) + return; + + if (!pScrPriv->numInstalledColormaps) { + unwrap(pScrPriv,pmap->pScreen, InstallColormap); + pmap->pScreen->InstallColormap(pScrPriv->baseCmap); + wrap(pScrPriv,pmap->pScreen,InstallColormap,xxInstallColormap); + } + + pixels = malloc(sizeof(Pixel) * (1 << pScrPriv->myDepth)); + colors = malloc(sizeof(xrgb) * (1 << pScrPriv->myDepth)); + defs = malloc(sizeof(xColorItem) * (1 << pScrPriv->myDepth)); + + if (!pixels || !colors) + return; + + /* if we have more than max installed delete the oldest */ + if (pScrPriv->numInstalledColormaps == MAX_NUM_XX_INSTALLED_CMAPS) + xxInstalledCmapDelete(pmap->pScreen,0); + + pScrPriv->InstalledCmaps[pScrPriv->numInstalledColormaps] = pmap; + pScrPriv->numInstalledColormaps++; + + pVisual = pScrPriv->bVisual; + + for (i = 0; i < (1 << pScrPriv->myDepth); i++) + pixels[i] = i; + + QueryColors (pmap, (1 << pScrPriv->myDepth), pixels, colors); + + for (i = 0; i < (1 << pScrPriv->myDepth); i++) { + defs[i].pixel = pixels[i]; + defs[i].red = colors[i].red; + defs[i].green = colors[i].green; + defs[i].blue = colors[i].blue; + defs[i].flags = DoRed|DoGreen|DoBlue; + } + xxStoreColors(pmap,(1 << pScrPriv->myDepth),defs); + + free(pixels); + free(colors); + free(defs); + + return; + } + + for (i = pScrPriv->numInstalledColormaps; i ; i--) + WalkTree(pmap->pScreen, TellLostMap, + (char *)&pScrPriv->InstalledCmaps[i-1]->mid); + + pScrPriv->numInstalledColormaps = 0; + + unwrap(pScrPriv,pmap->pScreen, InstallColormap); + pmap->pScreen->InstallColormap(pmap); + wrap(pScrPriv,pmap->pScreen,InstallColormap,xxInstallColormap); +} + +static void +xxUninstallColormap(ColormapPtr pmap) +{ + xxScrPriv(pmap->pScreen); + xxCmapPriv(pmap); + + if (pCmapPriv != (void *) -1) { + int num; + + if ((num = xxCmapInstalled(pmap)) == -1) + return; + + DBG("UninstallColormap\n"); + xxInstalledCmapDelete(pmap->pScreen,num); + + return; + } + + unwrap(pScrPriv,pmap->pScreen, UninstallColormap); + pmap->pScreen->UninstallColormap(pmap); + wrap(pScrPriv,pmap->pScreen,UninstallColormap,xxUninstallColormap); + +} + +static int +xxListInstalledColormaps(ScreenPtr pScreen, Colormap *pCmapIds) +{ + int n,i; + xxScrPriv(pScreen); + + unwrap(pScrPriv,pScreen, ListInstalledColormaps); + n = pScreen->ListInstalledColormaps(pScreen, pCmapIds); + wrap (pScrPriv,pScreen,ListInstalledColormaps,xxListInstalledColormaps); + + pCmapIds += n; + + for (i = 0; i < pScrPriv->numInstalledColormaps; i++) { + *pCmapIds++ = pScrPriv->InstalledCmaps[i]->mid; + n++; + } + + return n; +} + +static Bool +xxCreateWindow(WindowPtr pWin) +{ + xxScrPriv(pWin->drawable.pScreen); + + if (pWin->drawable.class != InputOutput + || pScrPriv->myDepth != pWin->drawable.depth) { + Bool ret; + DBG("CreateWindow NoPseudo\n"); + unwrap (pScrPriv, pWin->drawable.pScreen, CreateWindow); + ret = pWin->drawable.pScreen->CreateWindow(pWin); + wrap(pScrPriv, pWin->drawable.pScreen, CreateWindow, xxCreateWindow); + + return ret; + } + + DBG("CreateWindow\n"); + + pWin->devPrivates[fbWinPrivateIndex].ptr = (void *) pScrPriv->pPixmap; + PRINT_RECTS(pScrPriv->region); + if (!pWin->parent) { + RegionEmpty(&pScrPriv->region); + } + PRINT_RECTS(pScrPriv->region); + + return TRUE; +} + +static void +xxWalkChildren(WindowPtr pWin, RegionPtr pReg, PixmapPtr pPixmap) +{ + + WindowPtr pCurWin = pWin; + + do { + if (fbGetWindowPixmap(pCurWin) == pPixmap) { + DBG("WalkWindow Add\n"); + RegionUnion(pReg,pReg, + &pCurWin->borderClip); + } else { + DBG("WalkWindow Sub\n"); + RegionSubtract(pReg,pReg, + &pCurWin->borderClip); + } + if (pCurWin->lastChild) + xxWalkChildren(pCurWin->lastChild,pReg, pPixmap); + } while ((pCurWin = pCurWin->prevSib)); +} + +static void +xxPickMyWindows(WindowPtr pWin, RegionPtr pRgn) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + xxScrPriv(pScreen); + + if (fbGetWindowPixmap(pWin) == pScrPriv->pPixmap) { + RegionUnion(pRgn,pRgn,&pWin->borderClip); + } + if (pWin->lastChild) + xxWalkChildren(pWin->lastChild,pRgn,pScrPriv->pPixmap); +} + +static void +xxCopyWindow(WindowPtr pWin, + DDXPointRec ptOldOrg, + RegionPtr prgnSrc) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + xxScrPriv(pScreen); + RegionRec rgn; + RegionRec rgn_new; + int dx, dy; + PixmapPtr pPixmap = fbGetWindowPixmap(pWin); + + DBG("xxCopyWindow\n"); + + dx = ptOldOrg.x - pWin->drawable.x; + dy = ptOldOrg.y - pWin->drawable.y; + + RegionNull(&rgn_new); + RegionUnion(&rgn_new,&rgn_new,prgnSrc); + RegionTranslate(&rgn_new,-dx,-dy); + + RegionNull(&rgn); + xxPickMyWindows(pWin,&rgn); + + unwrap (pScrPriv, pScreen, CopyWindow); + pWin->devPrivates[fbWinPrivateIndex].ptr = fbGetScreenPixmap(pScreen); + pScreen->CopyWindow(pWin, ptOldOrg, prgnSrc); + pWin->devPrivates[fbWinPrivateIndex].ptr = pPixmap; + wrap(pScrPriv, pScreen, CopyWindow, xxCopyWindow); + + RegionIntersect(&rgn,&rgn,&rgn_new); + if (RegionNotEmpty(&rgn)) { + fbCopyRegion(&pScrPriv->pPixmap->drawable,&pScrPriv->pPixmap->drawable, + 0,&rgn,dx,dy,fbCopyWindowProc,0,(void*)0); + RegionTranslate(&rgn,dx,dy); + RegionIntersect(&rgn_new,&pScrPriv->region,&rgn); + RegionSubtract(&pScrPriv->region,&pScrPriv->region,&rgn); + RegionTranslate(&rgn_new,-dx,-dy); + RegionUnion(&pScrPriv->region,&pScrPriv->region,&rgn_new); + } +#if 1 + RegionUninit(&rgn_new); + RegionUninit(&rgn); +#endif +} + +static void +xxWindowExposures (WindowPtr pWin, + RegionPtr prgn, + RegionPtr other_exposed) +{ + xxScrPriv(pWin->drawable.pScreen); + + if (fbGetWindowPixmap(pWin) == pScrPriv->pPixmap) { + DBG("WindowExposures\n"); + PRINT_RECTS(pScrPriv->region); + RegionUnion(&pScrPriv->region, + &pScrPriv->region, + prgn); + PRINT_RECTS(pScrPriv->region); + } else { + DBG("WindowExposures NonPseudo\n"); + PRINT_RECTS(pScrPriv->region); + RegionSubtract(&pScrPriv->region, + &pScrPriv->region, + prgn); + PRINT_RECTS(pScrPriv->region); + } + unwrap (pScrPriv, pWin->drawable.pScreen, WindowExposures); + pWin->drawable.pScreen->WindowExposures(pWin, prgn, other_exposed); + wrap(pScrPriv, pWin->drawable.pScreen, WindowExposures, xxWindowExposures); +} + +static void +xxPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what) +{ + xxScrPriv(pWin->drawable.pScreen); + RegionRec rgni; + + DBG("xxPaintWindow\n"); + + RegionNull(&rgni); +#if 0 + RegionUnion(&rgni, &rgni, &pWin->borderClip); + RegionIntersect(&rgni, &rgni, pRegion); +#else + RegionUnion(&rgni, &rgni, pRegion); +#endif + switch (what) { + case PW_BORDER: + RegionSubtract(&rgni, &rgni, &pWin->winSize); + if (fbGetWindowPixmap(pWin) == pScrPriv->pPixmap) { + DBG("PaintWindowBorder\n"); + RegionUnion(&pScrPriv->region, + &pScrPriv->region, &rgni); + } else { + DBG("PaintWindowBorder NoOverlay\n"); + RegionSubtract(&pScrPriv->region, + &pScrPriv->region, &rgni); + } + unwrap (pScrPriv, pWin->drawable.pScreen, PaintWindowBorder); + pWin->drawable.pScreen->PaintWindowBorder (pWin, pRegion, what); + wrap(pScrPriv, pWin->drawable.pScreen, PaintWindowBorder, + xxPaintWindow); + break; + case PW_BACKGROUND: + switch (pWin->backgroundState) { + case None: + break; + default: + RegionIntersect(&rgni, + &rgni,&pWin->winSize); + if (fbGetWindowPixmap(pWin) == pScrPriv->pPixmap) { + DBG("PaintWindowBackground\n"); + RegionUnion(&pScrPriv->region, + &pScrPriv->region, &rgni); + } else { + DBG("PaintWindowBackground NoOverlay\n"); + RegionSubtract(&pScrPriv->region, + &pScrPriv->region, &rgni); + } + break; + } + + unwrap (pScrPriv, pWin->drawable.pScreen, PaintWindowBackground); + pWin->drawable.pScreen->PaintWindowBackground (pWin, pRegion, what); + wrap(pScrPriv, pWin->drawable.pScreen, PaintWindowBackground, + xxPaintWindow); + break; + } + PRINT_RECTS(rgni); + PRINT_RECTS(pScrPriv->region); +#if 1 + RegionUninit(&rgni); +#endif +} + +static void +xxCopyPseudocolorRegion(ScreenPtr pScreen, RegionPtr pReg, + xxCmapPrivPtr pCmapPriv) +{ + xxScrPriv(pScreen); + CARD32 mask = (1 << pScrPriv->myDepth) - 1; + int num = RegionNumRects(pReg); + BoxPtr pbox = RegionRects(pReg); + int width, height; + CARD8 *src; + CARD16 *dst, *dst_base; + int dst_stride; + register CARD32 *cmap = pCmapPriv->cmap; + register CARD8 *s; + register CARD16 *d; + int w; + + fbPrepareAccess((DrawablePtr)pScreen->devPrivate); + + dst_base = (CARD16*) ((PixmapPtr)pScreen->devPrivate)->devPrivate.ptr; + dst_stride = (int)((PixmapPtr)pScreen->devPrivate)->devKind + / sizeof (CARD16); + + while (num--) { + height = pbox->y2 - pbox->y1; + width = pbox->x2 - pbox->x1; + + src = (unsigned char *) pScrPriv->pBits + + (pbox->y1 * pScreen->width) + pbox->x1; + dst = dst_base + (pbox->y1 * dst_stride) + pbox->x1; + while (height--) { + w = width; + s = src; + d = dst; + + while(w--) { + *(d++) = (CARD16)*(cmap + ((*(s++)) & mask)); + } + src += pScreen->width; + dst += dst_stride; + } + pbox++; + } + + fbFinishAccess(&((PixmapPtr)pScreen->devPrivate)->drawable); +} + +static void +xxUpdateCmapPseudocolorRegion(ScreenPtr pScreen, RegionPtr pReg, + xxCmapPrivPtr pCmapPriv) +{ + xxScrPriv(pScreen); + CARD32 mask = (1 << pScrPriv->myDepth) - 1; + int num = RegionNumRects(pReg); + BoxPtr pbox = RegionRects(pReg); + int width, height; + CARD8 *src; + CARD16 *dst, *dst_base; + int dst_stride; + register CARD32 val; + register CARD32 *cmap = pCmapPriv->cmap; + register CARD8 *s; + register CARD16 *d; + int w; + + dst_base = (CARD16*) ((PixmapPtr)pScreen->devPrivate)->devPrivate.ptr; + dst_stride = (int)((PixmapPtr)pScreen->devPrivate)->devKind + / sizeof (CARD16); + + while (num--) { + + height = pbox->y2 - pbox->y1; + width = pbox->x2 - pbox->x1; + + src = (unsigned char *) pScrPriv->pBits + + (pbox->y1 * pScreen->width) + pbox->x1; + dst = dst_base + (pbox->y1 * dst_stride) + pbox->x1; + while (height--) { + w = width; + s = src; + d = dst; + while(w--) { + val = *(cmap + ((*(s++)) & mask)); + if (val & MARK_DIRTY) { + *d = (CARD16) val; + } + d++; + } + src += pScreen->width; + dst += dst_stride; + } + pbox++; + } +} + +static void +xxGetWindowRegion(WindowPtr pWin,RegionPtr winreg) +{ + RegionNull(winreg); + /* get visible part of the border ...Argh */ + RegionSubtract(winreg,&pWin->borderSize, + &pWin->winSize); + RegionIntersect(winreg,winreg, + &pWin->borderClip); + /* add window interior excluding children */ + RegionUnion(winreg,winreg, + &pWin->clipList); +} + +static int +xxUpdateRegion(WindowPtr pWin, void * unused) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + xxScrPriv(pScreen); + ColormapPtr pmap = (void *) -1; + RegionRec winreg, rgni; + + if (pScrPriv->myDepth == pWin->drawable.depth) { + xxCmapPrivPtr pCmapPriv = (void *)-1; + xxGetWindowRegion(pWin,&winreg); + + if (pScrPriv->colormapDirty) { + + pmap = (ColormapPtr)LookupIDByType(wColormap(pWin),RT_COLORMAP); + if (!pmap) + goto CONTINUE; /* return ? */ + + pCmapPriv = xxGetCmapPriv(pmap); + if (pCmapPriv == (void *) -1) + return WT_WALKCHILDREN; + if (!pCmapPriv->dirty) + goto CONTINUE; + + RegionNull(&rgni); + /* This will be taken care of when damaged regions are updated */ + RegionSubtract(&rgni, &winreg, &pScrPriv->region); + if (RegionNotEmpty(&rgni)) + xxUpdateCmapPseudocolorRegion(pScreen,&rgni, pCmapPriv); + } + CONTINUE: + + RegionNull(&rgni); + RegionIntersect(&rgni, &winreg, &pScrPriv->region); + + if (RegionNotEmpty(&rgni)) { + if (pmap == (void *) -1) { + pmap = + (ColormapPtr)LookupIDByType(wColormap(pWin),RT_COLORMAP); + if (!pmap) /* return ? */ + pmap = (ColormapPtr)LookupIDByType(pScreen->defColormap, + RT_COLORMAP); + pCmapPriv = xxGetCmapPriv(pmap); + } + + if (pCmapPriv != (void *)-1) + xxCopyPseudocolorRegion(pScreen,&rgni, pCmapPriv); + RegionSubtract(&pScrPriv->region, &pScrPriv->region, + &rgni); + } +#if 1 + RegionUninit(&rgni); + RegionUninit(&winreg); +#endif + } + return WT_WALKCHILDREN; +} + + +static void +xxUpdateFb(ScreenPtr pScreen) +{ + xxScrPriv(pScreen); + + DBG("Update FB\n"); + PRINT_RECTS(pScrPriv->region); + + if (pScrPriv->sync) + pScrPriv->sync(pScreen); /*@!@*/ + + WalkTree(pScreen,xxUpdateRegion,NULL); +#if 0 + if (RegionNotEmpty(&pScrPriv->region)) { + ColormapPtr pmap = (void *) -1; + xxCmapPrivPtr pCmapPriv; + + pmap = (ColormapPtr)LookupIDByType(pScreen->defColormap, + RT_COLORMAP); + pCmapPriv = xxGetCmapPriv(pmap); + if (pCmapPriv != (void *)-1) + xxCopyPseudocolorRegion(pScreen,&pScrPriv->region, pCmapPriv); + RegionSubtract(&pScrPriv->region, &pScrPriv->region, + &pScrPriv->region); + } +#endif + if (pScrPriv->colormapDirty) { + xxCmapPrivPtr pCmap = pScrPriv->Cmaps; + + while (pCmap) { + int j; + + if (pCmap->dirty) { + for (j = 0; j < (1 << pScrPriv->myDepth); j++) + pCmap->cmap[j] &= ~MARK_DIRTY; + pCmap->dirty = FALSE; + } + pCmap = pCmap->next; + } + pScrPriv->colormapDirty = FALSE; + } +} + +static void +xxBlockHandler (void * data, + OSTimePtr pTimeout, + void * pRead) +{ + ScreenPtr pScreen = (ScreenPtr) data; + xxScrPriv(pScreen); + + if (RegionNotEmpty(&pScrPriv->region) || pScrPriv->colormapDirty) + xxUpdateFb (pScreen); +} + +static void +xxWakeupHandler (void * data, int i, pointer LastSelectMask) +{ +} + +Bool +xxSetup(ScreenPtr pScreen, int myDepth, int baseDepth, char* addr, xxSyncFunc sync) +{ + xxScrPrivPtr pScrPriv; + DepthPtr pDepths; + ColormapPtr pDefMap; + int i,j,k; + +#ifdef RENDER + PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); +#endif + + if (xxGeneration != serverGeneration) { + xxScrPrivateIndex = AllocateScreenPrivateIndex (); + if (xxScrPrivateIndex == -1) + return FALSE; + xxColormapPrivateIndex + = AllocateColormapPrivateIndex (xxInitColormapDummy); + if (xxColormapPrivateIndex == -1) + return FALSE; + xxGCPrivateIndex = AllocateGCPrivateIndex (); + if (xxGCPrivateIndex == -1) + return FALSE; + xxGeneration = serverGeneration; + } + + if (!AllocateGCPrivate (pScreen, xxGCPrivateIndex, sizeof (xxGCPrivRec))) + return FALSE; + + pScrPriv = (xxScrPrivPtr) malloc (sizeof (xxScrPrivRec)); + if (!pScrPriv) + return FALSE; + + if (baseDepth) + pScrPriv->depth = baseDepth; + else { + pDepths = pScreen->allowedDepths; + for (i = 0; i < pScreen->numDepths; i++, pDepths++) + if (pDepths->depth != myDepth) + pScrPriv->depth = pDepths->depth; + } + if (!pScrPriv->depth) + return FALSE; + + pDepths = pScreen->allowedDepths; + for (i = 0; i < pScreen->numDepths; i++, pDepths++) + if (pDepths->depth == pScrPriv->depth) { + for (j = 0; i < pDepths->numVids; j++) { + for (k = 0; k < pScreen->numVisuals; k++) { + if (pScreen->visuals[k].vid + == pDepths[i].vids[j] + && pScreen->visuals[k].class == TrueColor) { + pScrPriv->bVisual = &pScreen->visuals[k]; + goto DONE; + } + } + } + } + + DONE: + if (!pScrPriv->bVisual) + return FALSE; + + pScrPriv->myDepth = myDepth; + pScrPriv->numInstalledColormaps = 0; + pScrPriv->colormapDirty = FALSE; + pScrPriv->Cmaps = NULL; + pScrPriv->sync = sync; + + pScreen->maxInstalledCmaps += MAX_NUM_XX_INSTALLED_CMAPS; + pScrPriv->InstalledCmaps = calloc(MAX_NUM_XX_INSTALLED_CMAPS, + sizeof(ColormapPtr)); + if (!pScrPriv->InstalledCmaps) + return FALSE; + + + if (!RegisterBlockAndWakeupHandlers (xxBlockHandler, + xxWakeupHandler, + (void *) pScreen)) + return FALSE; + + wrap (pScrPriv, pScreen, CloseScreen, xxCloseScreen); + wrap (pScrPriv, pScreen, CreateScreenResources, xxCreateScreenResources); + wrap (pScrPriv, pScreen, CreateWindow, xxCreateWindow); + wrap (pScrPriv, pScreen, CopyWindow, xxCopyWindow); + wrap (pScrPriv, pScreen, PaintWindowBorder, xxPaintWindow); + wrap (pScrPriv, pScreen, PaintWindowBackground, xxPaintWindow); +#if 0 /* can we leave this out even with backing store enabled ? */ + wrap (pScrPriv, pScreen, WindowExposures, xxWindowExposures); +#endif + wrap (pScrPriv, pScreen, CreateGC, xxCreateGC); + wrap (pScrPriv, pScreen, CreateColormap, xxCreateColormap); + wrap (pScrPriv, pScreen, DestroyColormap, xxDestroyColormap); + wrap (pScrPriv, pScreen, InstallColormap, xxInstallColormap); + wrap (pScrPriv, pScreen, UninstallColormap, xxUninstallColormap); + wrap (pScrPriv, pScreen, ListInstalledColormaps, xxListInstalledColormaps); + wrap (pScrPriv, pScreen, StoreColors, xxStoreColors); +#ifdef RENDER + if (ps) { + wrap (pScrPriv, ps, Glyphs, xxGlyphs); + wrap (pScrPriv, ps, Composite, xxComposite); + } +#endif + pScrPriv->addr = addr; + pScreen->devPrivates[xxScrPrivateIndex].ptr = (void *) pScrPriv; + + pDefMap = (ColormapPtr) LookupIDByType(pScreen->defColormap, RT_COLORMAP); + if (!xxInitColormapPrivate(pDefMap)) + return FALSE; + + return TRUE; +} + +GCFuncs xxGCFuncs = { + xxValidateGC, xxChangeGC, xxCopyGC, xxDestroyGC, + xxChangeClip, xxDestroyClip, xxCopyClip +}; + +static GCOps xxGCOps = { + xxFillSpans, xxSetSpans, + xxPutImage, xxCopyArea, + xxCopyPlane, xxPolyPoint, + xxPolylines, xxPolySegment, + xxPolyRectangle, xxPolyArc, + xxFillPolygon, xxPolyFillRect, + xxPolyFillArc, xxPolyText8, + xxPolyText16, xxImageText8, + xxImageText16, xxImageGlyphBlt, + xxPolyGlyphBlt, xxPushPixels, + {NULL} /* devPrivate */ +}; + +#define IS_VISIBLE(pDraw) (pDraw->type == DRAWABLE_WINDOW \ + && (fbGetWindowPixmap((WindowPtr) pDraw) == pScrPriv->pPixmap)) + +#define TRANSLATE_BOX(box, pDraw) { \ + box.x1 += pDraw->x; \ + box.x2 += pDraw->x; \ + box.y1 += pDraw->y; \ + box.y2 += pDraw->y; \ + } + +#define TRIM_BOX(box, pGC) { \ + BoxPtr extents = &pGC->pCompositeClip->extents;\ + if(box.x1 < extents->x1) box.x1 = extents->x1; \ + if(box.x2 > extents->x2) box.x2 = extents->x2; \ + if(box.y1 < extents->y1) box.y1 = extents->y1; \ + if(box.y2 > extents->y2) box.y2 = extents->y2; \ + } + +#define BOX_NOT_EMPTY(box) \ + (((box.x2 - box.x1) > 0) && ((box.y2 - box.y1) > 0)) + + +#define _ADD_BOX(box,pGC) {\ + if (BOX_NOT_EMPTY(box)) { \ + RegionRec region; \ + ScreenPtr pScreen = pGC->pScreen;\ + RegionInit(®ion, &box, 1); \ + RegionIntersect(®ion,®ion,\ + (pGC)->pCompositeClip);\ + if (RegionNotEmpty(®ion)) { \ + xxScrPriv(pScreen);\ + PRINT_RECTS(pScrPriv->region);\ + RegionUnion(&pScrPriv->region,&pScrPriv->region,®ion);\ + PRINT_RECTS(pScrPriv->region);\ + RegionUninit(®ion);\ + }\ + }\ +} + +#define TRANSLATE_AND_ADD_BOX(box,pGC) {\ + TRANSLATE_BOX(box,pDraw); \ + TRIM_BOX(box,pGC); \ + _ADD_BOX(box,pGC); \ +} + +#define ADD_BOX(box,pGC) { \ + TRIM_BOX(box,pGC); \ + _ADD_BOX(box,pGC); \ +} + +#define XX_GC_FUNC_PROLOGUE(pGC) \ + xxGCPriv(pGC); \ + unwrap(pGCPriv, pGC, funcs); \ + if (pGCPriv->ops) unwrap(pGCPriv, pGC, ops) + +#define XX_GC_FUNC_EPILOGUE(pGC) \ + wrap(pGCPriv, pGC, funcs, &xxGCFuncs); \ + if (pGCPriv->ops) wrap(pGCPriv, pGC, ops, &xxGCOps) + +static Bool +xxCreateGC(GCPtr pGC) +{ + ScreenPtr pScreen = pGC->pScreen; + xxScrPriv(pScreen); + xxGCPriv(pGC); + Bool ret; + + unwrap (pScrPriv, pScreen, CreateGC); + if((ret = (*pScreen->CreateGC) (pGC))) { + pGCPriv->ops = NULL; + pGCPriv->funcs = pGC->funcs; + pGC->funcs = &xxGCFuncs; + } + wrap (pScrPriv, pScreen, CreateGC, xxCreateGC); + + return ret; +} + +static void +xxValidateGC( + GCPtr pGC, + unsigned long changes, + DrawablePtr pDraw +){ + XX_GC_FUNC_PROLOGUE (pGC); + (*pGC->funcs->ValidateGC)(pGC, changes, pDraw); + if(pDraw->type == DRAWABLE_WINDOW) + pGCPriv->ops = pGC->ops; /* just so it's not NULL */ + else + pGCPriv->ops = NULL; + XX_GC_FUNC_EPILOGUE (pGC); +} + +static void +xxDestroyGC(GCPtr pGC) +{ + XX_GC_FUNC_PROLOGUE (pGC); + (*pGC->funcs->DestroyGC)(pGC); + XX_GC_FUNC_EPILOGUE (pGC); +} + +static void +xxChangeGC ( + GCPtr pGC, + unsigned long mask +){ + XX_GC_FUNC_PROLOGUE (pGC); + (*pGC->funcs->ChangeGC) (pGC, mask); + XX_GC_FUNC_EPILOGUE (pGC); +} + +static void +xxCopyGC ( + GCPtr pGCSrc, + unsigned long mask, + GCPtr pGCDst +){ + XX_GC_FUNC_PROLOGUE (pGCDst); + (*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst); + XX_GC_FUNC_EPILOGUE (pGCDst); +} + +static void +xxChangeClip ( + GCPtr pGC, + int type, + void * pvalue, + int nrects +){ + XX_GC_FUNC_PROLOGUE (pGC); + (*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects); + XX_GC_FUNC_EPILOGUE (pGC); +} + +static void +xxCopyClip(GCPtr pgcDst, GCPtr pgcSrc) +{ + XX_GC_FUNC_PROLOGUE (pgcDst); + (* pgcDst->funcs->CopyClip)(pgcDst, pgcSrc); + XX_GC_FUNC_EPILOGUE (pgcDst); +} + +static void +xxDestroyClip(GCPtr pGC) +{ + XX_GC_FUNC_PROLOGUE (pGC); + (* pGC->funcs->DestroyClip)(pGC); + XX_GC_FUNC_EPILOGUE (pGC); +} + +#define XX_GC_OP_PROLOGUE(pGC,pDraw) \ + xxScrPriv(pDraw->pScreen); \ + xxGCPriv(pGC); \ + GCFuncs *oldFuncs = pGC->funcs; \ + unwrap(pGCPriv, pGC, funcs); \ + unwrap(pGCPriv, pGC, ops); \ + +#define XX_GC_OP_EPILOGUE(pGC,pDraw) \ + wrap(pGCPriv, pGC, funcs, oldFuncs); \ + wrap(pGCPriv, pGC, ops, &xxGCOps) + +static void +xxFillSpans( + DrawablePtr pDraw, + GC *pGC, + int nInit, + DDXPointPtr pptInit, + int *pwidthInit, + int fSorted +){ + XX_GC_OP_PROLOGUE(pGC, pDraw); + + if(IS_VISIBLE(pDraw) && nInit) { + DDXPointPtr ppt = pptInit; + int *pwidth = pwidthInit; + int i = nInit; + BoxRec box; + + DBG("FillSpans\n"); + box.x1 = ppt->x; + box.x2 = box.x1 + *pwidth; + box.y2 = box.y1 = ppt->y; + + while(--i) { + ppt++; + pwidthInit++; + if(box.x1 > ppt->x) box.x1 = ppt->x; + if(box.x2 < (ppt->x + *pwidth)) + box.x2 = ppt->x + *pwidth; + if(box.y1 > ppt->y) box.y1 = ppt->y; + else if(box.y2 < ppt->y) box.y2 = ppt->y; + } + + box.y2++; + + (*pGC->ops->FillSpans)(pDraw, pGC, nInit, pptInit, pwidthInit, fSorted); + + + TRANSLATE_AND_ADD_BOX(box, pGC); + } else + (*pGC->ops->FillSpans)(pDraw, pGC, nInit, pptInit, pwidthInit, fSorted); + + XX_GC_OP_EPILOGUE(pGC, pDraw); +} + +static void +xxSetSpans( + DrawablePtr pDraw, + GCPtr pGC, + char *pcharsrc, + DDXPointPtr pptInit, + int *pwidthInit, + int nspans, + int fSorted +){ + XX_GC_OP_PROLOGUE(pGC, pDraw); + + if(IS_VISIBLE(pDraw) && nspans) { + DDXPointPtr ppt = pptInit; + int *pwidth = pwidthInit; + int i = nspans; + BoxRec box; + + DBG("SetSpans\n"); + box.x1 = ppt->x; + box.x2 = box.x1 + *pwidth; + box.y2 = box.y1 = ppt->y; + + while(--i) { + ppt++; + pwidth++; + if(box.x1 > ppt->x) box.x1 = ppt->x; + if(box.x2 < (ppt->x + *pwidth)) + box.x2 = ppt->x + *pwidth; + if(box.y1 > ppt->y) box.y1 = ppt->y; + else if(box.y2 < ppt->y) box.y2 = ppt->y; + } + + box.y2++; + + (*pGC->ops->SetSpans)(pDraw, pGC, pcharsrc, pptInit, + pwidthInit, nspans, fSorted); + + TRANSLATE_AND_ADD_BOX(box, pGC); + } else + (*pGC->ops->SetSpans)(pDraw, pGC, pcharsrc, pptInit, + pwidthInit, nspans, fSorted); + + XX_GC_OP_EPILOGUE(pGC, pDraw); +} + +static void +xxPutImage( + DrawablePtr pDraw, + GCPtr pGC, + int depth, + int x, int y, int w, int h, + int leftPad, + int format, + char *pImage +){ + XX_GC_OP_PROLOGUE(pGC, pDraw); + (*pGC->ops->PutImage)(pDraw, pGC, depth, x, y, w, h, + leftPad, format, pImage); + XX_GC_OP_EPILOGUE(pGC, pDraw); + if(IS_VISIBLE(pDraw)) { + BoxRec box; + + DBG("PutImage\n"); + box.x1 = x + pDraw->x; + box.x2 = box.x1 + w; + box.y1 = y + pDraw->y; + box.y2 = box.y1 + h; + + ADD_BOX(box, pGC); + } +} + +static RegionPtr +xxCopyArea( + DrawablePtr pSrc, + DrawablePtr pDst, + GC *pGC, + int srcx, int srcy, + int width, int height, + int dstx, int dsty +){ + RegionPtr ret; + XX_GC_OP_PROLOGUE(pGC, pDst); + DBG("xxCopyArea\n"); + ret = (*pGC->ops->CopyArea)(pSrc, pDst, + pGC, srcx, srcy, width, height, dstx, dsty); + XX_GC_OP_EPILOGUE(pGC, pDst); + + if(IS_VISIBLE(pDst)) { + BoxRec box; + + DBG("CopyArea\n"); + box.x1 = dstx + pDst->x; + box.x2 = box.x1 + width; + box.y1 = dsty + pDst->y; + box.y2 = box.y1 + height; + + ADD_BOX(box, pGC); + } + + return ret; +} + +static RegionPtr +xxCopyPlane( + DrawablePtr pSrc, + DrawablePtr pDst, + GCPtr pGC, + int srcx, int srcy, + int width, int height, + int dstx, int dsty, + unsigned long bitPlane +){ + RegionPtr ret; + XX_GC_OP_PROLOGUE(pGC, pDst); + ret = (*pGC->ops->CopyPlane)(pSrc, pDst, + pGC, srcx, srcy, width, height, dstx, dsty, bitPlane); + XX_GC_OP_EPILOGUE(pGC, pDst); + + if(IS_VISIBLE(pDst)) { + BoxRec box; + + DBG("CopyPlane\n"); + box.x1 = dstx + pDst->x; + box.x2 = box.x1 + width; + box.y1 = dsty + pDst->y; + box.y2 = box.y1 + height; + + ADD_BOX(box, pGC); + } + + return ret; +} + +static void +xxPolyPoint( + DrawablePtr pDraw, + GCPtr pGC, + int mode, + int npt, + xPoint *pptInit +){ + XX_GC_OP_PROLOGUE(pGC, pDraw); + (*pGC->ops->PolyPoint)(pDraw, pGC, mode, npt, pptInit); + XX_GC_OP_EPILOGUE(pGC, pDraw); + + if(IS_VISIBLE(pDraw) && npt) { + BoxRec box; + + DBG("PolyPoint\n"); + box.x2 = box.x1 = pptInit->x; + box.y2 = box.y1 = pptInit->y; + + /* this could be slow if the points were spread out */ + + while(--npt) { + pptInit++; + if(box.x1 > pptInit->x) box.x1 = pptInit->x; + else if(box.x2 < pptInit->x) box.x2 = pptInit->x; + if(box.y1 > pptInit->y) box.y1 = pptInit->y; + else if(box.y2 < pptInit->y) box.y2 = pptInit->y; + } + + box.x2++; + box.y2++; + + TRANSLATE_AND_ADD_BOX(box, pGC); + } +} + +static void +xxPolylines( + DrawablePtr pDraw, + GCPtr pGC, + int mode, + int npt, + DDXPointPtr pptInit +){ + XX_GC_OP_PROLOGUE(pGC, pDraw); + (*pGC->ops->Polylines)(pDraw, pGC, mode, npt, pptInit); + XX_GC_OP_EPILOGUE(pGC, pDraw); + + + if(IS_VISIBLE(pDraw) && npt) { + BoxRec box; + int extra = pGC->lineWidth >> 1; + + DBG("PolyLine\n"); + box.x2 = box.x1 = pptInit->x; + box.y2 = box.y1 = pptInit->y; + + if(npt > 1) { + if(pGC->joinStyle == JoinMiter) + extra = 6 * pGC->lineWidth; + else if(pGC->capStyle == CapProjecting) + extra = pGC->lineWidth; + } + + if(mode == CoordModePrevious) { + int x = box.x1; + int y = box.y1; + while(--npt) { + pptInit++; + x += pptInit->x; + y += pptInit->y; + if(box.x1 > x) box.x1 = x; + else if(box.x2 < x) box.x2 = x; + if(box.y1 > y) box.y1 = y; + else if(box.y2 < y) box.y2 = y; + } + } else { + while(--npt) { + pptInit++; + if(box.x1 > pptInit->x) box.x1 = pptInit->x; + else if(box.x2 < pptInit->x) box.x2 = pptInit->x; + if(box.y1 > pptInit->y) box.y1 = pptInit->y; + else if(box.y2 < pptInit->y) box.y2 = pptInit->y; + } + } + + box.x2++; + box.y2++; + + if(extra) { + box.x1 -= extra; + box.x2 += extra; + box.y1 -= extra; + box.y2 += extra; + } + + TRANSLATE_AND_ADD_BOX(box, pGC); + } +} + +static void +xxPolySegment( + DrawablePtr pDraw, + GCPtr pGC, + int nseg, + xSegment *pSeg + ){ + XX_GC_OP_PROLOGUE(pGC, pDraw); + (*pGC->ops->PolySegment)(pDraw, pGC, nseg, pSeg); + XX_GC_OP_EPILOGUE(pGC, pDraw); + + if(IS_VISIBLE(pDraw) && nseg) { + BoxRec box; + int extra = pGC->lineWidth; + + DBG("PolySegment\n"); + if(pGC->capStyle != CapProjecting) + extra >>= 1; + + if(pSeg->x2 > pSeg->x1) { + box.x1 = pSeg->x1; + box.x2 = pSeg->x2; + } else { + box.x2 = pSeg->x1; + box.x1 = pSeg->x2; + } + + if(pSeg->y2 > pSeg->y1) { + box.y1 = pSeg->y1; + box.y2 = pSeg->y2; + } else { + box.y2 = pSeg->y1; + box.y1 = pSeg->y2; + } + + while(--nseg) { + pSeg++; + if(pSeg->x2 > pSeg->x1) { + if(pSeg->x1 < box.x1) box.x1 = pSeg->x1; + if(pSeg->x2 > box.x2) box.x2 = pSeg->x2; + } else { + if(pSeg->x2 < box.x1) box.x1 = pSeg->x2; + if(pSeg->x1 > box.x2) box.x2 = pSeg->x1; + } + if(pSeg->y2 > pSeg->y1) { + if(pSeg->y1 < box.y1) box.y1 = pSeg->y1; + if(pSeg->y2 > box.y2) box.y2 = pSeg->y2; + } else { + if(pSeg->y2 < box.y1) box.y1 = pSeg->y2; + if(pSeg->y1 > box.y2) box.y2 = pSeg->y1; + } + } + + box.x2++; + box.y2++; + + if(extra) { + box.x1 -= extra; + box.x2 += extra; + box.y1 -= extra; + box.y2 += extra; + } + + TRANSLATE_AND_ADD_BOX(box, pGC); + } +} + +static void +xxPolyRectangle( + DrawablePtr pDraw, + GCPtr pGC, + int nRects, + xRectangle *pRects +){ + XX_GC_OP_PROLOGUE(pGC, pDraw); + (*pGC->ops->PolyRectangle)(pDraw, pGC, nRects, pRects); + XX_GC_OP_EPILOGUE(pGC, pDraw); + + if(IS_VISIBLE(pDraw) && nRects) + { + BoxRec box; + int offset1, offset2, offset3; + + DBG("PolyRectangle\n"); + offset2 = pGC->lineWidth; + if(!offset2) offset2 = 1; + offset1 = offset2 >> 1; + offset3 = offset2 - offset1; + + while(nRects--) + { + box.x1 = pRects->x - offset1; + box.y1 = pRects->y - offset1; + box.x2 = box.x1 + pRects->width + offset2; + box.y2 = box.y1 + offset2; + TRANSLATE_AND_ADD_BOX(box, pGC); + box.x1 = pRects->x - offset1; + box.y1 = pRects->y + offset3; + box.x2 = box.x1 + offset2; + box.y2 = box.y1 + pRects->height - offset2; + TRANSLATE_AND_ADD_BOX(box, pGC); + box.x1 = pRects->x + pRects->width - offset1; + box.y1 = pRects->y + offset3; + box.x2 = box.x1 + offset2; + box.y2 = box.y1 + pRects->height - offset2; + TRANSLATE_AND_ADD_BOX(box, pGC); + box.x1 = pRects->x - offset1; + box.y1 = pRects->y + pRects->height - offset1; + box.x2 = box.x1 + pRects->width + offset2; + box.y2 = box.y1 + offset2; + TRANSLATE_AND_ADD_BOX(box, pGC); + + pRects++; + } + } +} + +static void +xxPolyArc( + DrawablePtr pDraw, + GCPtr pGC, + int narcs, + xArc *parcs +){ + XX_GC_OP_PROLOGUE(pGC, pDraw); + (*pGC->ops->PolyArc)(pDraw, pGC, narcs, parcs); + XX_GC_OP_EPILOGUE(pGC, pDraw); + + if(IS_VISIBLE(pDraw) && narcs) { + int extra = pGC->lineWidth >> 1; + BoxRec box; + + DBG("PolyArc\n"); + box.x1 = parcs->x; + box.x2 = box.x1 + parcs->width; + box.y1 = parcs->y; + box.y2 = box.y1 + parcs->height; + + /* should I break these up instead ? */ + + while(--narcs) { + parcs++; + if(box.x1 > parcs->x) box.x1 = parcs->x; + if(box.x2 < (parcs->x + parcs->width)) + box.x2 = parcs->x + parcs->width; + if(box.y1 > parcs->y) box.y1 = parcs->y; + if(box.y2 < (parcs->y + parcs->height)) + box.y2 = parcs->y + parcs->height; + } + + if(extra) { + box.x1 -= extra; + box.x2 += extra; + box.y1 -= extra; + box.y2 += extra; + } + + box.x2++; + box.y2++; + + TRANSLATE_AND_ADD_BOX(box, pGC); + } +} + +static void +xxFillPolygon( + DrawablePtr pDraw, + GCPtr pGC, + int shape, + int mode, + int count, + DDXPointPtr pptInit +){ + XX_GC_OP_PROLOGUE(pGC, pDraw); + + if(IS_VISIBLE(pDraw) && (count > 2)) { + DDXPointPtr ppt = pptInit; + int i = count; + BoxRec box; + + DBG("FillPolygon\n"); + box.x2 = box.x1 = ppt->x; + box.y2 = box.y1 = ppt->y; + + if(mode != CoordModeOrigin) { + int x = box.x1; + int y = box.y1; + while(--i) { + ppt++; + x += ppt->x; + y += ppt->y; + if(box.x1 > x) box.x1 = x; + else if(box.x2 < x) box.x2 = x; + if(box.y1 > y) box.y1 = y; + else if(box.y2 < y) box.y2 = y; + } + } else { + while(--i) { + ppt++; + if(box.x1 > ppt->x) box.x1 = ppt->x; + else if(box.x2 < ppt->x) box.x2 = ppt->x; + if(box.y1 > ppt->y) box.y1 = ppt->y; + else if(box.y2 < ppt->y) box.y2 = ppt->y; + } + } + + box.x2++; + box.y2++; + + (*pGC->ops->FillPolygon)(pDraw, pGC, shape, mode, count, pptInit); + + TRANSLATE_AND_ADD_BOX(box, pGC); + } else + (*pGC->ops->FillPolygon)(pDraw, pGC, shape, mode, count, pptInit); + + XX_GC_OP_EPILOGUE(pGC, pDraw); +} + +static void +xxPolyFillRect( + DrawablePtr pDraw, + GCPtr pGC, + int nRectsInit, + xRectangle *pRectsInit +){ + XX_GC_OP_PROLOGUE(pGC, pDraw); + + if(IS_VISIBLE(pDraw) && nRectsInit) { + BoxRec box; + xRectangle *pRects = pRectsInit; + int nRects = nRectsInit; + + DBG("PolyFillRect\n"); + box.x1 = pRects->x; + box.x2 = box.x1 + pRects->width; + box.y1 = pRects->y; + box.y2 = box.y1 + pRects->height; + + while(--nRects) { + pRects++; + if(box.x1 > pRects->x) box.x1 = pRects->x; + if(box.x2 < (pRects->x + pRects->width)) + box.x2 = pRects->x + pRects->width; + if(box.y1 > pRects->y) box.y1 = pRects->y; + if(box.y2 < (pRects->y + pRects->height)) + box.y2 = pRects->y + pRects->height; + } + + /* cfb messes with the pRectsInit so we have to do our + calculations first */ + + (*pGC->ops->PolyFillRect)(pDraw, pGC, nRectsInit, pRectsInit); + + TRANSLATE_AND_ADD_BOX(box, pGC); + } else + (*pGC->ops->PolyFillRect)(pDraw, pGC, nRectsInit, pRectsInit); + + XX_GC_OP_EPILOGUE(pGC, pDraw); +} + +static void +xxPolyFillArc( + DrawablePtr pDraw, + GCPtr pGC, + int narcs, + xArc *parcs +){ + XX_GC_OP_PROLOGUE(pGC, pDraw); + (*pGC->ops->PolyFillArc)(pDraw, pGC, narcs, parcs); + XX_GC_OP_EPILOGUE(pGC, pDraw); + + if(IS_VISIBLE(pDraw) && narcs) { + BoxRec box; + + DBG("PolyFillArc\n"); + box.x1 = parcs->x; + box.x2 = box.x1 + parcs->width; + box.y1 = parcs->y; + box.y2 = box.y1 + parcs->height; + + /* should I break these up instead ? */ + + while(--narcs) { + parcs++; + if(box.x1 > parcs->x) box.x1 = parcs->x; + if(box.x2 < (parcs->x + parcs->width)) + box.x2 = parcs->x + parcs->width; + if(box.y1 > parcs->y) box.y1 = parcs->y; + if(box.y2 < (parcs->y + parcs->height)) + box.y2 = parcs->y + parcs->height; + } + + TRANSLATE_AND_ADD_BOX(box, pGC); + } +} + +static int +xxPolyText8( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + char *chars +){ + int width; + + XX_GC_OP_PROLOGUE(pGC, pDraw); + width = (*pGC->ops->PolyText8)(pDraw, pGC, x, y, count, chars); + XX_GC_OP_EPILOGUE(pGC, pDraw); + + width -= x; + + if(IS_VISIBLE(pDraw) && (width > 0)) { + BoxRec box; + + DBG("PolyText8\n"); + /* ugh */ + box.x1 = pDraw->x + x + FONTMINBOUNDS(pGC->font, leftSideBearing); + box.x2 = pDraw->x + x + FONTMAXBOUNDS(pGC->font, rightSideBearing); + + if(count > 1) { + if(width > 0) box.x2 += width; + else box.x1 += width; + } + + box.y1 = pDraw->y + y - FONTMAXBOUNDS(pGC->font, ascent); + box.y2 = pDraw->y + y + FONTMAXBOUNDS(pGC->font, descent); + + ADD_BOX(box, pGC); + } + + return (width + x); +} + +static int +xxPolyText16( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + unsigned short *chars +){ + int width; + + XX_GC_OP_PROLOGUE(pGC, pDraw); + width = (*pGC->ops->PolyText16)(pDraw, pGC, x, y, count, chars); + XX_GC_OP_EPILOGUE(pGC, pDraw); + + width -= x; + + if(IS_VISIBLE(pDraw) && (width > 0)) { + BoxRec box; + + DBG("PolyText16\n"); + /* ugh */ + box.x1 = pDraw->x + x + FONTMINBOUNDS(pGC->font, leftSideBearing); + box.x2 = pDraw->x + x + FONTMAXBOUNDS(pGC->font, rightSideBearing); + + if(count > 1) { + if(width > 0) box.x2 += width; + else box.x1 += width; + } + + box.y1 = pDraw->y + y - FONTMAXBOUNDS(pGC->font, ascent); + box.y2 = pDraw->y + y + FONTMAXBOUNDS(pGC->font, descent); + + ADD_BOX(box, pGC); + } + + return (width + x); +} + +static void +xxImageText8( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + char *chars +){ + XX_GC_OP_PROLOGUE(pGC, pDraw); + (*pGC->ops->ImageText8)(pDraw, pGC, x, y, count, chars); + XX_GC_OP_EPILOGUE(pGC, pDraw); + + if(IS_VISIBLE(pDraw) && count) { + int top, bot, Min, Max; + BoxRec box; + + DBG("ImageText8\n"); + top = max(FONTMAXBOUNDS(pGC->font, ascent), FONTASCENT(pGC->font)); + bot = max(FONTMAXBOUNDS(pGC->font, descent), FONTDESCENT(pGC->font)); + + Min = count * FONTMINBOUNDS(pGC->font, characterWidth); + if(Min > 0) Min = 0; + Max = count * FONTMAXBOUNDS(pGC->font, characterWidth); + if(Max < 0) Max = 0; + + /* ugh */ + box.x1 = pDraw->x + x + Min + + FONTMINBOUNDS(pGC->font, leftSideBearing); + box.x2 = pDraw->x + x + Max + + FONTMAXBOUNDS(pGC->font, rightSideBearing); + + box.y1 = pDraw->y + y - top; + box.y2 = pDraw->y + y + bot; + + ADD_BOX(box, pGC); + } +} + +static void +xxImageText16( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + unsigned short *chars +){ + XX_GC_OP_PROLOGUE(pGC, pDraw); + (*pGC->ops->ImageText16)(pDraw, pGC, x, y, count, chars); + XX_GC_OP_EPILOGUE(pGC, pDraw); + + if(IS_VISIBLE(pDraw) && count) { + int top, bot, Min, Max; + BoxRec box; + + DBG("ImageText16\n"); + top = max(FONTMAXBOUNDS(pGC->font, ascent), FONTASCENT(pGC->font)); + bot = max(FONTMAXBOUNDS(pGC->font, descent), FONTDESCENT(pGC->font)); + + Min = count * FONTMINBOUNDS(pGC->font, characterWidth); + if(Min > 0) Min = 0; + Max = count * FONTMAXBOUNDS(pGC->font, characterWidth); + if(Max < 0) Max = 0; + + /* ugh */ + box.x1 = pDraw->x + x + Min + + FONTMINBOUNDS(pGC->font, leftSideBearing); + box.x2 = pDraw->x + x + Max + + FONTMAXBOUNDS(pGC->font, rightSideBearing); + + box.y1 = pDraw->y + y - top; + box.y2 = pDraw->y + y + bot; + + ADD_BOX(box, pGC); + } +} + +static void +xxImageGlyphBlt( + DrawablePtr pDraw, + GCPtr pGC, + int x, int y, + unsigned int nglyph, + CharInfoPtr *ppci, + void * pglyphBase +){ + XX_GC_OP_PROLOGUE(pGC, pDraw); + (*pGC->ops->ImageGlyphBlt)(pDraw, pGC, x, y, nglyph, + ppci, pglyphBase); + XX_GC_OP_EPILOGUE(pGC, pDraw); + + if(IS_VISIBLE(pDraw) && nglyph) { + int top, bot, width = 0; + BoxRec box; + + DBG("ImageGlyphBlt\n"); + top = max(FONTMAXBOUNDS(pGC->font, ascent), FONTASCENT(pGC->font)); + bot = max(FONTMAXBOUNDS(pGC->font, descent), FONTDESCENT(pGC->font)); + + box.x1 = ppci[0]->metrics.leftSideBearing; + if(box.x1 > 0) box.x1 = 0; + box.x2 = ppci[nglyph - 1]->metrics.rightSideBearing - + ppci[nglyph - 1]->metrics.characterWidth; + if(box.x2 < 0) box.x2 = 0; + + box.x2 += pDraw->x + x; + box.x1 += pDraw->x + x; + + while(nglyph--) { + width += (*ppci)->metrics.characterWidth; + ppci++; + } + + if(width > 0) + box.x2 += width; + else + box.x1 += width; + + box.y1 = pDraw->y + y - top; + box.y2 = pDraw->y + y + bot; + + ADD_BOX(box, pGC); + } +} + +static void +xxPolyGlyphBlt( + DrawablePtr pDraw, + GCPtr pGC, + int x, int y, + unsigned int nglyph, + CharInfoPtr *ppci, + void * pglyphBase +){ + XX_GC_OP_PROLOGUE(pGC, pDraw); + (*pGC->ops->PolyGlyphBlt)(pDraw, pGC, x, y, nglyph, + ppci, pglyphBase); + XX_GC_OP_EPILOGUE(pGC, pDraw); + + if(IS_VISIBLE(pDraw) && nglyph) { + BoxRec box; + + DBG("PolyGlyphBlt\n"); + /* ugh */ + box.x1 = pDraw->x + x + ppci[0]->metrics.leftSideBearing; + box.x2 = pDraw->x + x + ppci[nglyph - 1]->metrics.rightSideBearing; + + if(nglyph > 1) { + int width = 0; + + while(--nglyph) { + width += (*ppci)->metrics.characterWidth; + ppci++; + } + + if(width > 0) box.x2 += width; + else box.x1 += width; + } + + box.y1 = pDraw->y + y - FONTMAXBOUNDS(pGC->font, ascent); + box.y2 = pDraw->y + y + FONTMAXBOUNDS(pGC->font, descent); + + ADD_BOX(box, pGC); + } +} + +static void +xxPushPixels( + GCPtr pGC, + PixmapPtr pBitMap, + DrawablePtr pDraw, + int dx, int dy, int xOrg, int yOrg +){ + XX_GC_OP_PROLOGUE(pGC, pDraw); + (*pGC->ops->PushPixels)(pGC, pBitMap, pDraw, dx, dy, xOrg, yOrg); + XX_GC_OP_EPILOGUE(pGC, pDraw); + + if(IS_VISIBLE(pDraw)) { + BoxRec box; + + DBG("PushPixels\n"); + box.x1 = xOrg + pDraw->x; + box.x2 = box.x1 + dx; + box.y1 = yOrg + pDraw->y; + box.y2 = box.y1 + dy; + + ADD_BOX(box, pGC); + } +} + + +#ifdef RENDER +#define RENDER_MAKE_BOX(pDrawable,X,Y,W,H) { \ + box.x1 = X + pDrawable->x; \ + box.x2 = X + pDrawable->x + W; \ + box.y1 = Y + pDrawable->y; \ + box.y2 = Y + pDrawable->y + H; \ +} + +#define RENDER_ADD_BOX(pScreen,box) {\ + if (BOX_NOT_EMPTY(box)) { \ + RegionRec region; \ + xxScrPriv(pScreen);\ + ScreenPtr pScreen = pScreen;\ + RegionInit(®ion, &box, 1); \ + PRINT_RECTS(pScrPriv->region);\ + RegionUnion(&pScrPriv->region,&pScrPriv->region,®ion);\ + PRINT_RECTS(pScrPriv->region);\ + RegionUninit(®ion);\ + }\ +} + +static void +xxComposite (CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, + INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask, + INT16 xDst, INT16 yDst, CARD16 width, CARD16 height) +{ + ScreenPtr pScreen = pDst->pDrawable->pScreen; + PictureScreenPtr ps = GetPictureScreen(pScreen); + xxScrPriv(pScreen); + BoxRec box; + + unwrap (pScrPriv, ps, Composite); + (*ps->Composite) (op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask, + xDst, yDst, width, height); + wrap (pScrPriv, ps, Composite, xxComposite); + if (pDst->pDrawable->type == DRAWABLE_WINDOW) { + RENDER_MAKE_BOX(pDst->pDrawable, xDst, yDst, width, height); + RENDER_ADD_BOX(pScreen,box); + } +} + + +static void +xxGlyphs (CARD8 op, PicturePtr pSrc, PicturePtr pDst, + PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, int nlist, + GlyphListPtr list, GlyphPtr *glyphs) +{ + ScreenPtr pScreen = pDst->pDrawable->pScreen; + PictureScreenPtr ps = GetPictureScreen(pScreen); + xxScrPriv(pScreen); + int x, y; + int n; + GlyphPtr glyph; + BoxRec box; + + unwrap (pScrPriv, ps, Glyphs); + (*ps->Glyphs) (op, pSrc, pDst, maskFormat, xSrc, ySrc, + nlist, list, glyphs); + wrap (pScrPriv, ps, Glyphs, xxGlyphs); + if (pDst->pDrawable->type == DRAWABLE_WINDOW) + { + x = xSrc; + y = ySrc; + while (nlist--) + { + x += list->xOff; + y += list->yOff; + n = list->len; + while (n--) + { + glyph = *glyphs++; + RENDER_MAKE_BOX(pDst->pDrawable, + x - glyph->info.x, y - glyph->info.y, + glyph->info.width, glyph->info.height); + RENDER_ADD_BOX(pScreen,box); + x += glyph->info.xOff; + y += glyph->info.yOff; + } + list++; + } + } +} +#endif + +void +xxPrintVisuals(void) +{ + int k,i,j; + DepthPtr pDepth; + VisualPtr pVisual; + + for (k = 0; k < screenInfo.numScreens; k++) { + ScreenPtr pScreen = screenInfo.screens[k]; + + pDepth = pScreen->allowedDepths; + for (i = 0; i < pScreen->numDepths; i++, pDepth++) + for (j = 0; j < pDepth->numVids; j++) { + ErrorF("depth: %i vid: 0x%lx\n", + pDepth->depth, pDepth->vids[j]); + } + + pVisual = pScreen->visuals; + for (i = 0; i < pScreen->numVisuals; i++, pVisual++) + ErrorF("vid: 0x%x rm: 0x%lx gm: 0x%lx bm: 0x%lx\n", + (unsigned int)pVisual->vid, + pVisual->redMask, + pVisual->greenMask, + pVisual->blueMask); + } +} + + diff --git a/nx-X11/programs/Xserver/fb/fbpseudocolor.h b/nx-X11/programs/Xserver/fb/fbpseudocolor.h new file mode 100644 index 0000000000..64de71db86 --- /dev/null +++ b/nx-X11/programs/Xserver/fb/fbpseudocolor.h @@ -0,0 +1,20 @@ +#ifndef _FB_XX_H_ +# define _FB_XX_H_ + +typedef void (*xxSyncFunc)(ScreenPtr); +extern Bool xxSetup(ScreenPtr pScreen, int myDepth, + int baseDepth, char *addr, xxSyncFunc sync); +extern void xxPrintVisuals(void); + + +#endif /* _FB_XX_H_ */ + + + + + + + + + + diff --git a/nx-X11/programs/Xserver/fb/fbpush.c b/nx-X11/programs/Xserver/fb/fbpush.c index 6979b6f1b3..33eaf37983 100644 --- a/nx-X11/programs/Xserver/fb/fbpush.c +++ b/nx-X11/programs/Xserver/fb/fbpush.c @@ -1,6 +1,4 @@ /* - * Id: fbpush.c,v 1.1 1999/11/02 03:54:45 keithp Exp $ - * * Copyright © 1998 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its @@ -58,7 +56,7 @@ fbPushPattern (DrawablePtr pDrawable, w = width; s = src; src += srcStride; - bits = *s++; + bits = READ(s++); xspan = x; while (w) { @@ -73,7 +71,7 @@ fbPushPattern (DrawablePtr pDrawable, bitsMask = FbStipRight (bitsMask, 1); if (!bitsMask) { - bits = *s++; + bits = READ(s++); bitsMask = FbBitsMask(0,1); } } while (bits & bitsMask); @@ -92,7 +90,7 @@ fbPushPattern (DrawablePtr pDrawable, bitsMask = FbStipRight (bitsMask, 1); if (!bitsMask) { - bits = *s++; + bits = READ(s++); bitsMask = FbBitsMask(0,1); } } while (!(bits & bitsMask)); @@ -165,6 +163,7 @@ fbPushFill (DrawablePtr pDrawable, fbAnd(GXnoop,(FbBits) 0,FB_ALLONES), fbXor(GXnoop,(FbBits) 0,FB_ALLONES)); } + fbFinishAccess (pDrawable); } else { diff --git a/nx-X11/programs/Xserver/fb/fbrop.h b/nx-X11/programs/Xserver/fb/fbrop.h index f3768a265d..1685ee8362 100644 --- a/nx-X11/programs/Xserver/fb/fbrop.h +++ b/nx-X11/programs/Xserver/fb/fbrop.h @@ -1,6 +1,4 @@ /* - * Id: fbrop.h,v 1.1 1999/11/02 03:54:45 keithp Exp $ - * * Copyright © 1998 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its diff --git a/nx-X11/programs/Xserver/fb/fbscreen.c b/nx-X11/programs/Xserver/fb/fbscreen.c index b0e6d9a6b3..7d3d387d1d 100644 --- a/nx-X11/programs/Xserver/fb/fbscreen.c +++ b/nx-X11/programs/Xserver/fb/fbscreen.c @@ -1,6 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/fb/fbscreen.c,v 1.6 2005/07/03 07:01:23 daniels Exp $ - * Id: fbscreen.c,v 1.1 1999/11/02 03:54:45 keithp Exp $ - * +/* * Copyright © 1998 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its @@ -83,7 +81,6 @@ fbQueryBestSize (int class, } } -#ifndef FB_OLD_SCREEN PixmapPtr _fbGetWindowPixmap (WindowPtr pWindow) { @@ -99,7 +96,6 @@ _fbSetWindowPixmap (WindowPtr pWindow, PixmapPtr pPixmap) pWindow->devPrivates[fbWinPrivateIndex].ptr = (void *) pPixmap; #endif } -#endif Bool fbSetupScreen(ScreenPtr pScreen, @@ -143,7 +139,6 @@ fbSetupScreen(ScreenPtr pScreen, pScreen->ResolveColor = fbResolveColor; pScreen->BitmapToRegion = fbPixmapToRegion; -#ifndef FB_OLD_SCREEN pScreen->GetWindowPixmap = _fbGetWindowPixmap; pScreen->SetWindowPixmap = _fbSetWindowPixmap; @@ -152,11 +147,23 @@ fbSetupScreen(ScreenPtr pScreen, pScreen->BackingStoreFuncs.SetClipmaskRgn = 0; pScreen->BackingStoreFuncs.GetImagePixmap = 0; pScreen->BackingStoreFuncs.GetSpansPixmap = 0; -#endif return TRUE; } +#ifdef FB_ACCESS_WRAPPER +Bool +wfbFinishScreenInit(ScreenPtr pScreen, + void * pbits, + int xsize, + int ysize, + int dpix, + int dpiy, + int width, + int bpp, + SetupWrapProcPtr setupWrap, + FinishWrapProcPtr finishWrap) +#else Bool fbFinishScreenInit(ScreenPtr pScreen, void * pbits, @@ -166,6 +173,7 @@ fbFinishScreenInit(ScreenPtr pScreen, int dpiy, int width, int bpp) +#endif { VisualPtr visuals; DepthPtr depths; @@ -224,6 +232,10 @@ fbFinishScreenInit(ScreenPtr pScreen, fbGetScreenPrivate(pScreen)->win32bpp = 32; fbGetScreenPrivate(pScreen)->pix32bpp = 32; } +#ifdef FB_ACCESS_WRAPPER + fbGetScreenPrivate(pScreen)->setupWrap = setupWrap; + fbGetScreenPrivate(pScreen)->finishWrap = finishWrap; +#endif #endif rootdepth = 0; if (!fbInitVisuals (&visuals, &depths, &nvisuals, &ndepths, &rootdepth, @@ -231,11 +243,7 @@ fbFinishScreenInit(ScreenPtr pScreen, return FALSE; if (! miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width, rootdepth, ndepths, depths, - defaultVisual, nvisuals, visuals -#ifdef FB_OLD_MISCREENINIT - , (miBSFuncPtr) 0 -#endif - )) + defaultVisual, nvisuals, visuals)) return FALSE; /* overwrite miCloseScreen with our own */ pScreen->CloseScreen = fbCloseScreen; @@ -258,6 +266,27 @@ fbFinishScreenInit(ScreenPtr pScreen, } /* dts * (inch/dot) * (25.4 mm / inch) = mm */ +#ifdef FB_ACCESS_WRAPPER +Bool +wfbScreenInit(ScreenPtr pScreen, + void * pbits, + int xsize, + int ysize, + int dpix, + int dpiy, + int width, + int bpp, + SetupWrapProcPtr setupWrap, + FinishWrapProcPtr finishWrap) +{ + if (!fbSetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, width, bpp)) + return FALSE; + if (!wfbFinishScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, + width, bpp, setupWrap, finishWrap)) + return FALSE; + return TRUE; +} +#else Bool fbScreenInit(ScreenPtr pScreen, void * pbits, @@ -275,26 +304,4 @@ fbScreenInit(ScreenPtr pScreen, return FALSE; return TRUE; } - - -#ifdef FB_OLD_SCREEN -const miBSFuncRec fbBSFuncRec = { - fbSaveAreas, - fbRestoreAreas, - (void (*)(GCPtr, RegionPtr)) 0, - (PixmapPtr (*)(void)) 0, - (PixmapPtr (*)(void)) 0, -}; -#endif - -#if 0 -void -fbInitializeBackingStore (ScreenPtr pScreen) -{ -#ifdef FB_OLD_SCREEN - miInitializeBackingStore (pScreen, (miBSFuncRec *) &fbBSFuncRec); -#else - miInitializeBackingStore (pScreen); -#endif -} #endif diff --git a/nx-X11/programs/Xserver/fb/fbseg.c b/nx-X11/programs/Xserver/fb/fbseg.c index db3240e1bd..4ef44b8a7c 100644 --- a/nx-X11/programs/Xserver/fb/fbseg.c +++ b/nx-X11/programs/Xserver/fb/fbseg.c @@ -1,6 +1,4 @@ /* - * Id: fbseg.c,v 1.1 1999/11/02 03:54:45 keithp Exp $ - * * Copyright © 1998 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its @@ -79,7 +77,7 @@ fbBresSolid (DrawablePtr pDrawable, mask = fbBresShiftMask(mask,signdx,dstBpp); if (!mask) { - *dst = FbDoMaskRRop (*dst, and, xor, bits); + WRITE(dst, FbDoMaskRRop (READ(dst), and, xor, bits)); bits = 0; dst += signdx; mask = mask0; @@ -87,20 +85,20 @@ fbBresSolid (DrawablePtr pDrawable, e += e1; if (e >= 0) { - *dst = FbDoMaskRRop (*dst, and, xor, bits); + WRITE(dst, FbDoMaskRRop (READ(dst), and, xor, bits)); bits = 0; dst += dstStride; e += e3; } } if (bits) - *dst = FbDoMaskRRop (*dst, and, xor, bits); + WRITE(dst, FbDoMaskRRop (READ(dst), and, xor, bits)); } else { while (len--) { - *dst = FbDoMaskRRop (*dst, and, xor, mask); + WRITE(dst, FbDoMaskRRop (READ(dst), and, xor, mask)); dst += dstStride; e += e1; if (e >= 0) @@ -115,6 +113,8 @@ fbBresSolid (DrawablePtr pDrawable, } } } + + fbFinishAccess (pDrawable); } void @@ -164,9 +164,9 @@ fbBresDash (DrawablePtr pDrawable, while (len--) { if (even) - *dst = FbDoMaskRRop (*dst, and, xor, mask); + WRITE(dst, FbDoMaskRRop (READ(dst), and, xor, mask)); else if (doOdd) - *dst = FbDoMaskRRop (*dst, bgand, bgxor, mask); + WRITE(dst, FbDoMaskRRop (READ(dst), bgand, bgxor, mask)); if (axis == X_AXIS) { mask = fbBresShiftMask(mask,signdx,dstBpp); @@ -199,6 +199,8 @@ fbBresDash (DrawablePtr pDrawable, } FbDashStep (dashlen, even); } + + fbFinishAccess (pDrawable); } void @@ -371,13 +373,13 @@ fbBresSolid24RRop (DrawablePtr pDrawable, FbMaskStip (x, 24, leftMask, nl, rightMask); if (leftMask) { - *d = FbDoMaskRRop (*d, andT, xorT, leftMask); + WRITE(d, FbDoMaskRRop (READ(d), andT, xorT, leftMask)); d++; andT = FbNext24Stip (andT); xorT = FbNext24Stip (xorT); } if (rightMask) - *d = FbDoMaskRRop (*d, andT, xorT, rightMask); + WRITE(d, FbDoMaskRRop (READ(d), andT, xorT, rightMask)); if (axis == X_AXIS) { x1 += signdx; @@ -399,6 +401,8 @@ fbBresSolid24RRop (DrawablePtr pDrawable, } } } + + fbFinishAccess (pDrawable); } static void @@ -468,13 +472,13 @@ fbBresDash24RRop (DrawablePtr pDrawable, FbMaskStip (x, 24, leftMask, nl, rightMask); if (leftMask) { - *d = FbDoMaskRRop (*d, andT, xorT, leftMask); + WRITE(d, FbDoMaskRRop (READ(d), andT, xorT, leftMask)); d++; andT = FbNext24Stip (andT); xorT = FbNext24Stip (xorT); } if (rightMask) - *d = FbDoMaskRRop (*d, andT, xorT, rightMask); + WRITE(d, FbDoMaskRRop (READ(d), andT, xorT, rightMask)); } if (axis == X_AXIS) { @@ -498,6 +502,8 @@ fbBresDash24RRop (DrawablePtr pDrawable, } FbDashStep (dashlen, even); } + + fbFinishAccess (pDrawable); } #endif diff --git a/nx-X11/programs/Xserver/fb/fbsetsp.c b/nx-X11/programs/Xserver/fb/fbsetsp.c index 4b3db1eda8..61dc4dc30d 100644 --- a/nx-X11/programs/Xserver/fb/fbsetsp.c +++ b/nx-X11/programs/Xserver/fb/fbsetsp.c @@ -1,6 +1,4 @@ /* - * Id: fbsetsp.c,v 1.1 1999/11/02 03:54:45 keithp Exp $ - * * Copyright © 1998 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its @@ -99,5 +97,6 @@ fbSetSpans (DrawablePtr pDrawable, pwidth++; } fbValidateDrawable (pDrawable); + fbFinishAccess (pDrawable); } diff --git a/nx-X11/programs/Xserver/fb/fbsolid.c b/nx-X11/programs/Xserver/fb/fbsolid.c index 99e479f491..53fcae0718 100644 --- a/nx-X11/programs/Xserver/fb/fbsolid.c +++ b/nx-X11/programs/Xserver/fb/fbsolid.c @@ -68,12 +68,12 @@ fbSolid (FbBits *dst, n = nmiddle; if (!and) while (n--) - *dst++ = xor; + WRITE(dst++, xor); else while (n--) { - *dst = FbDoRRop (*dst, and, xor); - dst++; + WRITE(dst, FbDoRRop (READ(dst), and, xor)); + dst++; } if (endmask) FbDoRightMaskByteRRop(dst,endbyte,endmask,and,xor); @@ -158,26 +158,26 @@ fbSolid24 (FbBits *dst, { if (startmask) { - *dst = FbDoMaskRRop(*dst, andS, xorS, startmask); - dst++; + WRITE(dst, FbDoMaskRRop(READ(dst), andS, xorS, startmask)); + dst++; } n = nmiddle; if (!and0) { while (n >= 3) { - *dst++ = xor0; - *dst++ = xor1; - *dst++ = xor2; + WRITE(dst++, xor0); + WRITE(dst++, xor1); + WRITE(dst++, xor2); n -= 3; } if (n) { - *dst++ = xor0; + WRITE(dst++, xor0); n--; if (n) { - *dst++ = xor1; + WRITE(dst++, xor1); } } } @@ -185,28 +185,28 @@ fbSolid24 (FbBits *dst, { while (n >= 3) { - *dst = FbDoRRop (*dst, and0, xor0); - dst++; - *dst = FbDoRRop (*dst, and1, xor1); - dst++; - *dst = FbDoRRop (*dst, and2, xor2); - dst++; + WRITE(dst, FbDoRRop (READ(dst), and0, xor0)); + dst++; + WRITE(dst, FbDoRRop (READ(dst), and1, xor1)); + dst++; + WRITE(dst, FbDoRRop (READ(dst), and2, xor2)); + dst++; n -= 3; } if (n) { - *dst = FbDoRRop (*dst, and0, xor0); - dst++; + WRITE(dst, FbDoRRop (READ(dst), and0, xor0)); + dst++; n--; if (n) { - *dst = FbDoRRop (*dst, and1, xor1); - dst++; + WRITE(dst, FbDoRRop (READ(dst), and1, xor1)); + dst++; } } } if (endmask) - *dst = FbDoMaskRRop (*dst, andE, xorE, endmask); + WRITE(dst, FbDoMaskRRop (READ(dst), andE, xorE, endmask)); dst += dstStride; } } diff --git a/nx-X11/programs/Xserver/fb/fbstipple.c b/nx-X11/programs/Xserver/fb/fbstipple.c index 486fa2030d..7d13263677 100644 --- a/nx-X11/programs/Xserver/fb/fbstipple.c +++ b/nx-X11/programs/Xserver/fb/fbstipple.c @@ -1,6 +1,4 @@ /* - * Id: fbstipple.c,v 1.1 1999/11/02 03:54:45 keithp Exp $ - * * Copyright © 1998 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its @@ -147,16 +145,15 @@ fbEvenStipple (FbBits *dst, /* * Get pointer to stipple mask array for this depth */ - fbBits = 0; /* unused */ - if (pixelsPerDst <= 8) - fbBits = fbStippleTable[pixelsPerDst]; + /* fbStippleTable covers all valid bpp (4,8,16,32) */ + fbBits = fbStippleTable[pixelsPerDst]; while (height--) { /* * Extract stipple bits for this scanline; */ - bits = *s; + bits = READ(s); s += stipStride; if (s == stipEnd) s = stip; @@ -200,12 +197,12 @@ fbEvenStipple (FbBits *dst, n = nmiddle; if (!and) while (n--) - *dst++ = xor; + WRITE(dst++, xor); else { while (n--) { - *dst = FbDoRRop (*dst, and, xor); + WRITE(dst, FbDoRRop (READ(dst), and, xor)); dst++; } } diff --git a/nx-X11/programs/Xserver/fb/fbtile.c b/nx-X11/programs/Xserver/fb/fbtile.c index 0d0cfe174f..05a27a17b2 100644 --- a/nx-X11/programs/Xserver/fb/fbtile.c +++ b/nx-X11/programs/Xserver/fb/fbtile.c @@ -1,6 +1,4 @@ /* - * Id: fbtile.c,v 1.1 1999/11/02 03:54:45 keithp Exp $ - * * Copyright © 1998 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its @@ -42,6 +40,7 @@ fbEvenTile (FbBits *dst, int height, FbBits *tile, + FbStride tileStride, int tileHeight, int alu, @@ -68,9 +67,9 @@ fbEvenTile (FbBits *dst, /* * Compute tile start scanline and rotation parameters */ - tileEnd = tile + tileHeight; + tileEnd = tile + tileHeight * tileStride; modulus (- yRot, tileHeight, tileY); - t = tile + tileY; + t = tile + tileY * tileStride; modulus (- xRot, FB_UNIT, tileX); rot = tileX; @@ -80,8 +79,9 @@ fbEvenTile (FbBits *dst, /* * Pick up bits for this scanline */ - bits = *t++; - if (t == tileEnd) t = tile; + bits = READ(t); + t += tileStride; + if (t >= tileEnd) t = tile; bits = FbRotLeft(bits,rot); and = fbAnd(alu,bits,pm); xor = fbXor(alu,bits,pm); @@ -94,11 +94,11 @@ fbEvenTile (FbBits *dst, n = nmiddle; if (!and) while (n--) - *dst++ = xor; + WRITE(dst++, xor); else while (n--) { - *dst = FbDoRRop (*dst, and, xor); + WRITE(dst, FbDoRRop (READ(dst), and, xor)); dst++; } if (endmask) @@ -194,7 +194,7 @@ fbTile (FbBits *dst, { if (FbEvenTile (tileWidth)) fbEvenTile (dst, dstStride, dstX, width, height, - tile, tileHeight, + tile, tileStride, tileHeight, alu, pm, xRot, yRot); else fbOddTile (dst, dstStride, dstX, width, height, diff --git a/nx-X11/programs/Xserver/fb/fbtrap.c b/nx-X11/programs/Xserver/fb/fbtrap.c index c9951b00da..830603ae73 100644 --- a/nx-X11/programs/Xserver/fb/fbtrap.c +++ b/nx-X11/programs/Xserver/fb/fbtrap.c @@ -1,6 +1,4 @@ /* - * $Id: fbtrap.c,v 1.5 2005/07/03 07:01:23 daniels Exp $ - * * Copyright © 2004 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its @@ -42,59 +40,14 @@ fbAddTraps (PicturePtr pPicture, int ntrap, xTrap *traps) { - FbBits *buf; - int bpp; - int width; - int stride; - int height; - int pxoff, pyoff; - - xFixed x_off_fixed; - xFixed y_off_fixed; - RenderEdge l, r; - xFixed t, b; - - fbGetDrawable (pPicture->pDrawable, buf, stride, bpp, pxoff, pyoff); + pixman_image_t *image = image_from_pict (pPicture, FALSE); - width = pPicture->pDrawable->width; - height = pPicture->pDrawable->height; - x_off += pxoff; - y_off += pyoff; + if (!image) + return; - x_off_fixed = IntToxFixed(y_off); - y_off_fixed = IntToxFixed(y_off); + pixman_add_traps (image, x_off, y_off, ntrap, (pixman_trap_t *)traps); - while (ntrap--) - { - t = traps->top.y + y_off_fixed; - if (t < 0) - t = 0; - t = RenderSampleCeilY (t, bpp); - - b = traps->bot.y + y_off_fixed; - if (xFixedToInt (b) >= height) - b = IntToxFixed (height) - 1; - b = RenderSampleFloorY (b, bpp); - - if (b >= t) - { - /* initialize edge walkers */ - RenderEdgeInit (&l, bpp, t, - traps->top.l + x_off_fixed, - traps->top.y + y_off_fixed, - traps->bot.l + x_off_fixed, - traps->bot.y + y_off_fixed); - - RenderEdgeInit (&r, bpp, t, - traps->top.r + x_off_fixed, - traps->top.y + y_off_fixed, - traps->bot.r + x_off_fixed, - traps->bot.y + y_off_fixed); - - fbRasterizeEdges (buf, bpp, width, stride, &l, &r, t, b); - } - traps++; - } + free_pixman_pict (pPicture, image); } void @@ -103,46 +56,14 @@ fbRasterizeTrapezoid (PicturePtr pPicture, int x_off, int y_off) { - FbBits *buf; - int bpp; - int width; - int stride; - int height; - int pxoff, pyoff; - - xFixed y_off_fixed; - RenderEdge l, r; - xFixed t, b; - - if (!xTrapezoidValid (trap)) + pixman_image_t *image = image_from_pict (pPicture, FALSE); + + if (!image) return; - fbGetDrawable (pPicture->pDrawable, buf, stride, bpp, pxoff, pyoff); + pixman_rasterize_trapezoid (image, (pixman_trapezoid_t *)trap, x_off, y_off); - width = pPicture->pDrawable->width; - height = pPicture->pDrawable->height; - x_off += pxoff; - y_off += pyoff; - - y_off_fixed = IntToxFixed(y_off); - t = trap->top + y_off_fixed; - if (t < 0) - t = 0; - t = RenderSampleCeilY (t, bpp); - - b = trap->bottom + y_off_fixed; - if (xFixedToInt (b) >= height) - b = IntToxFixed (height) - 1; - b = RenderSampleFloorY (b, bpp); - - if (b >= t) - { - /* initialize edge walkers */ - RenderLineFixedEdgeInit (&l, bpp, t, &trap->left, x_off, y_off); - RenderLineFixedEdgeInit (&r, bpp, t, &trap->right, x_off, y_off); - - fbRasterizeEdges (buf, bpp, width, stride, &l, &r, t, b); - } + free_pixman_pict (pPicture, image); } static int diff --git a/nx-X11/programs/Xserver/fb/fbutil.c b/nx-X11/programs/Xserver/fb/fbutil.c index 4be0f233c7..5e232971e4 100644 --- a/nx-X11/programs/Xserver/fb/fbutil.c +++ b/nx-X11/programs/Xserver/fb/fbutil.c @@ -1,6 +1,4 @@ /* - * Id: fbutil.c,v 1.1 1999/11/02 03:54:45 keithp Exp $ - * * Copyright © 1998 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its diff --git a/nx-X11/programs/Xserver/fb/fbwindow.c b/nx-X11/programs/Xserver/fb/fbwindow.c index c4e28de5ba..91b7f7c94d 100644 --- a/nx-X11/programs/Xserver/fb/fbwindow.c +++ b/nx-X11/programs/Xserver/fb/fbwindow.c @@ -1,6 +1,4 @@ /* - * Id: fbwindow.c,v 1.1 1999/11/02 03:54:45 keithp Exp $ - * * Copyright © 1998 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its @@ -114,6 +112,9 @@ fbCopyWindowProc (DrawablePtr pSrcDrawable, upsidedown); pbox++; } + + fbFinishAccess (pDstDrawable); + fbFinishAccess (pSrcDrawable); } void @@ -137,7 +138,7 @@ fbCopyWindow(WindowPtr pWin, #ifdef COMPOSITE if (pPixmap->screen_x || pPixmap->screen_y) - RegionTranslate(&rgnDst, + RegionTranslate(&rgnDst, -pPixmap->screen_x, -pPixmap->screen_y); #endif @@ -215,20 +216,39 @@ fbFillRegionSolid (DrawablePtr pDrawable, int n = RegionNumRects(pRegion); BoxPtr pbox = RegionRects(pRegion); +#ifndef FB_ACCESS_WRAPPER + int try_mmx = 0; + if (!and) + try_mmx = 1; +#endif + fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff); while (n--) { - fbSolid (dst + (pbox->y1 + dstYoff) * dstStride, - dstStride, - (pbox->x1 + dstXoff) * dstBpp, - dstBpp, - (pbox->x2 - pbox->x1) * dstBpp, - pbox->y2 - pbox->y1, - and, xor); +#ifndef FB_ACCESS_WRAPPER + if (!try_mmx || !pixman_fill (dst, dstStride, dstBpp, + pbox->x1 + dstXoff, pbox->y1 + dstYoff, + (pbox->x2 - pbox->x1), + (pbox->y2 - pbox->y1), + xor)) + { +#endif + fbSolid (dst + (pbox->y1 + dstYoff) * dstStride, + dstStride, + (pbox->x1 + dstXoff) * dstBpp, + dstBpp, + (pbox->x2 - pbox->x1) * dstBpp, + pbox->y2 - pbox->y1, + and, xor); +#ifndef FB_ACCESS_WRAPPER + } +#endif fbValidateDrawable (pDrawable); pbox++; } + + fbFinishAccess (pDrawable); } #ifdef PANORAMIX @@ -291,6 +311,9 @@ fbFillRegionTiled (DrawablePtr pDrawable, yRot - (pbox->y1 + dstYoff)); pbox++; } + + fbFinishAccess (&pTile->drawable); + fbFinishAccess (pDrawable); } void diff --git a/nx-X11/programs/Xserver/fb/wfbrename.h b/nx-X11/programs/Xserver/fb/wfbrename.h new file mode 100644 index 0000000000..5ea9092f8f --- /dev/null +++ b/nx-X11/programs/Xserver/fb/wfbrename.h @@ -0,0 +1,201 @@ +#define fb16Lane wfb16Lane +#define fb24_32CopyMtoN wfb24_32CopyMtoN +#define fb24_32CreateScreenResources wfb24_32CreateScreenResources +#define fb24_32GetImage wfb24_32GetImage +#define fb24_32GetSpans wfb24_32GetSpans +#define fb24_32ModifyPixmapHeader wfb24_32ModifyPixmapHeader +#define fb24_32PutZImage wfb24_32PutZImage +#define fb24_32ReformatTile wfb24_32ReformatTile +#define fb24_32SetSpans wfb24_32SetSpans +#define fb32Lane wfb32Lane +#define fb8Lane wfb8Lane +#define fbAddTraps wfbAddTraps +#define fbAddTriangles wfbAddTriangles +#define fbAllocatePrivates wfbAllocatePrivates +#define fbArc16 wfbArc16 +#define fbArc24 wfbArc24 +#define fbArc32 wfbArc32 +#define fbArc8 wfbArc8 +#define fbBlt wfbBlt +#define fbBlt24 wfbBlt24 +#define fbBltOne wfbBltOne +#define fbBltOne24 wfbBltOne24 +#define fbBltPlane wfbBltPlane +#define fbBltStip wfbBltStip +#define fbBres wfbBres +#define fbBresDash wfbBresDash +#define fbBresDash16 wfbBresDash16 +#define fbBresDash24 wfbBresDash24 +#define fbBresDash32 wfbBresDash32 +#define fbBresDash8 wfbBresDash8 +#define fbBresFill wfbBresFill +#define fbBresFillDash wfbBresFillDash +#define fbBresSolid wfbBresSolid +#define fbBresSolid16 wfbBresSolid16 +#define fbBresSolid24 wfbBresSolid24 +#define fbBresSolid32 wfbBresSolid32 +#define fbBresSolid8 wfbBresSolid8 +#define fbChangeWindowAttributes wfbChangeWindowAttributes +#define fbClearVisualTypes wfbClearVisualTypes +#define fbCloseScreen wfbCloseScreen +#define fbComposite wfbComposite +#define fbCompositeGeneral wfbCompositeGeneral +#define fbCompositeSolidMask_nx1xn wfbCompositeSolidMask_nx1xn +#define fbCompositeSolidMask_nx8888x0565C wfbCompositeSolidMask_nx8888x0565C +#define fbCompositeSolidMask_nx8888x8888C wfbCompositeSolidMask_nx8888x8888C +#define fbCompositeSolidMask_nx8x0565 wfbCompositeSolidMask_nx8x0565 +#define fbCompositeSolidMask_nx8x0888 wfbCompositeSolidMask_nx8x0888 +#define fbCompositeSolidMask_nx8x8888 wfbCompositeSolidMask_nx8x8888 +#define fbCompositeSrc_0565x0565 wfbCompositeSrc_0565x0565 +#define fbCompositeSrc_8888x0565 wfbCompositeSrc_8888x0565 +#define fbCompositeSrc_8888x0888 wfbCompositeSrc_8888x0888 +#define fbCompositeSrc_8888x8888 wfbCompositeSrc_8888x8888 +#define fbCompositeSrcAdd_1000x1000 wfbCompositeSrcAdd_1000x1000 +#define fbCompositeSrcAdd_8000x8000 wfbCompositeSrcAdd_8000x8000 +#define fbCompositeSrcAdd_8888x8888 wfbCompositeSrcAdd_8888x8888 +#define fbCopy1toN wfbCopy1toN +#define fbCopyArea wfbCopyArea +#define fbCopyNto1 wfbCopyNto1 +#define fbCopyNtoN wfbCopyNtoN +#define fbCopyPlane wfbCopyPlane +#define fbCopyRegion wfbCopyRegion +#define fbCopyWindow wfbCopyWindow +#define fbCopyWindowProc wfbCopyWindowProc +#define fbCreateDefColormap wfbCreateDefColormap +#define fbCreateGC wfbCreateGC +#define fbCreatePixmap wfbCreatePixmap +#define fbCreatePixmapBpp wfbCreatePixmapBpp +#define fbCreateWindow wfbCreateWindow +#define fbDestroyPixmap wfbDestroyPixmap +#define fbDestroyWindow wfbDestroyWindow +#define fbDoCopy wfbDoCopy +#define fbDots wfbDots +#define fbDots16 wfbDots16 +#define fbDots24 wfbDots24 +#define fbDots32 wfbDots32 +#define fbDots8 wfbDots8 +#define fbEvenStipple wfbEvenStipple +#define fbEvenTile wfbEvenTile +#define fbExpandDirectColors wfbExpandDirectColors +#define fbFill wfbFill +#define fbFillRegionSolid wfbFillRegionSolid +#define fbFillRegionTiled wfbFillRegionTiled +#define fbFillSpans wfbFillSpans +#define fbFixCoordModePrevious wfbFixCoordModePrevious +#define fbGCFuncs wfbGCFuncs +#define fbGCOps wfbGCOps +#define fbGCPrivateIndex wfbGCPrivateIndex +#define fbGeneration wfbGeneration +#define fbGetGCPrivateIndex wfbGetGCPrivateIndex +#define fbGetImage wfbGetImage +#define fbGetScreenPrivateIndex wfbGetScreenPrivateIndex +#define fbGetSpans wfbGetSpans +#define _fbGetWindowPixmap _wfbGetWindowPixmap +#define fbGetWinPrivateIndex wfbGetWinPrivateIndex +#define fbGlyph16 wfbGlyph16 +#define fbGlyph24 wfbGlyph24 +#define fbGlyph32 wfbGlyph32 +#define fbGlyph8 wfbGlyph8 +#define fbGlyphIn wfbGlyphIn +#define fbHasVisualTypes wfbHasVisualTypes +#define fbImageGlyphBlt wfbImageGlyphBlt +#define fbIn wfbIn +#define fbInitializeColormap wfbInitializeColormap +#define fbInitVisuals wfbInitVisuals +#define fbInstallColormap wfbInstallColormap +#define fbLaneTable wfbLaneTable +#define fbListInstalledColormaps wfbListInstalledColormaps +#define fbMapWindow wfbMapWindow +#define FbMergeRopBits wFbMergeRopBits +#define fbOddStipple wfbOddStipple +#define fbOddTile wfbOddTile +#define fbOver wfbOver +#define fbOver24 wfbOver24 +#define fbOverlayCloseScreen wfbOverlayCloseScreen +#define fbOverlayCopyWindow wfbOverlayCopyWindow +#define fbOverlayCreateScreenResources wfbOverlayCreateScreenResources +#define fbOverlayCreateWindow wfbOverlayCreateWindow +#define fbOverlayFinishScreenInit wfbOverlayFinishScreenInit +#define fbOverlayGeneration wfbOverlayGeneration +#define fbOverlayGetScreenPrivateIndex wfbOverlayGetScreenPrivateIndex +#define fbOverlayPaintKey wfbOverlayPaintKey +#define fbOverlayPaintWindow wfbOverlayPaintWindow +#define fbOverlayScreenPrivateIndex wfbOverlayScreenPrivateIndex +#define fbOverlaySetupScreen wfbOverlaySetupScreen +#define fbOverlayUpdateLayerRegion wfbOverlayUpdateLayerRegion +#define fbOverlayWindowExposures wfbOverlayWindowExposures +#define fbOverlayWindowLayer wfbOverlayWindowLayer +#define fbPadPixmap wfbPadPixmap +#define fbPaintWindow wfbPaintWindow +#define fbPictureInit wfbPictureInit +#define fbPixmapToRegion wfbPixmapToRegion +#define fbPolyArc wfbPolyArc +#define fbPolyFillRect wfbPolyFillRect +#define fbPolyGlyphBlt wfbPolyGlyphBlt +#define fbPolyLine wfbPolyLine +#define fbPolyline16 wfbPolyline16 +#define fbPolyline24 wfbPolyline24 +#define fbPolyline32 wfbPolyline32 +#define fbPolyline8 wfbPolyline8 +#define fbPolyPoint wfbPolyPoint +#define fbPolySegment wfbPolySegment +#define fbPolySegment16 wfbPolySegment16 +#define fbPolySegment24 wfbPolySegment24 +#define fbPolySegment32 wfbPolySegment32 +#define fbPolySegment8 wfbPolySegment8 +#define fbPositionWindow wfbPositionWindow +#define fbPushFill wfbPushFill +#define fbPushImage wfbPushImage +#define fbPushPattern wfbPushPattern +#define fbPushPixels wfbPushPixels +#define fbPutImage wfbPutImage +#define fbPutXYImage wfbPutXYImage +#define fbPutZImage wfbPutZImage +#define fbQueryBestSize wfbQueryBestSize +#define fbRasterizeEdges wfbRasterizeEdges +#define fbRasterizeTrapezoid wfbRasterizeTrapezoid +#define fbRealizeFont wfbRealizeFont +#define fbReduceRasterOp wfbReduceRasterOp +#define fbReplicatePixel wfbReplicatePixel +#define fbResolveColor wfbResolveColor +#define fbRestoreAreas wfbRestoreAreas +#define fbSaveAreas wfbSaveAreas +#define fbScreenPrivateIndex wfbScreenPrivateIndex +#define fbSegment wfbSegment +#define fbSelectBres wfbSelectBres +#define fbSetSpans wfbSetSpans +#define fbSetupScreen wfbSetupScreen +#define fbSetVisualTypes wfbSetVisualTypes +#define fbSetVisualTypesAndMasks wfbSetVisualTypesAndMasks +#define _fbSetWindowPixmap _wfbSetWindowPixmap +#define fbSolid wfbSolid +#define fbSolid24 wfbSolid24 +#define fbSolidBoxClipped wfbSolidBoxClipped +#define fbStipple wfbStipple +#define fbStipple1Bits wfbStipple1Bits +#define fbStipple24Bits wfbStipple24Bits +#define fbStipple2Bits wfbStipple2Bits +#define fbStipple4Bits wfbStipple4Bits +#define fbStipple8Bits wfbStipple8Bits +#define fbStippleTable wfbStippleTable +#define fbTile wfbTile +#define fbTransparentSpan wfbTransparentSpan +#define fbUninstallColormap wfbUninstallColormap +#define fbUnmapWindow wfbUnmapWindow +#define fbUnrealizeFont wfbUnrealizeFont +#define fbValidateGC wfbValidateGC +#define fbWalkCompositeRegion wfbWalkCompositeRegion +#define fbWinPrivateIndex wfbWinPrivateIndex +#define fbZeroLine wfbZeroLine +#define fbZeroSegment wfbZeroSegment +#define free_pixman_pict wfb_free_pixman_pict +#define image_from_pict wfb_image_from_pict +#define xxScrPrivateIndex wfbxxScrPrivateIndex +#define xxGCPrivateIndex wfbxxGCPrivateIndex +#define xxColormapPrivateIndex wfbxxColormapPrivateIndex +#define xxGeneration wfbxxGeneration +#define xxPrintVisuals wfbxxPrintVisuals +#define xxGCFuncs wfbxxGCFuncs +#define xxGCOps wfbxxGCOps +#define xxSetup wfbxxSetup +#define composeFunctions wfbComposeFunctions diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c index 597359cf19..5eb32d9ff0 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Events.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c @@ -53,6 +53,7 @@ #include "Keystroke.h" #include "Events.h" #include "Pointer.h" +#include "mipointer.h" #include "Rootless.h" #include "Splash.h" #include "Trap.h" @@ -143,6 +144,8 @@ int nxagentDebugInput = 0; extern Bool nxagentRootlessTreesMatch(void); #endif +extern xEvent *nxagentEvents; + extern Selection *CurrentSelections; extern int NumCurrentSelections; @@ -820,6 +823,57 @@ static int nxagentChangeVisibilityPrivate(WindowPtr pWin, void * ptr) return WT_WALKCHILDREN; } +/* + update_last_event_time: update nxagentLastEventTime with the + current time + use_time: if != NULL and <= current time use this timestamp instead + of the current time + + FIXME: unfortunately xorg does not offer a way to pass an own event + time for an event to queue. So use_time is currently ignored, but + expected to be used by some callers. The effects of this are + currently unknown. + + Maybe we can modify the time to the generated events in + nxagentEvents prior to enqueueing them. + + */ +void nxagentQueueKeyEvent(int type, unsigned int keycode, Bool update_last_event_time, Time use_time) +{ + Time now = GetTimeInMillis(); + +#if 0 + xEvent x = { + .u.u.type = type, + .u.u.detail = keycode, + .u.keyButtonPointer.time = now, + }; + + if (use_time != 0) + { + if (use_time > now) + { + x.u.keyButtonPointer.time = now; + } + else + { + x.u.keyButtonPointer.time = use_time; + } + } +#endif + + if (update_last_event_time) + nxagentLastEventTime = now; + +#if 0 + mieqEnqueue(&x); +#else + int n = GetKeyboardEvents(nxagentEvents, nxagentKeyboardDevice, type, keycode); + for (int i = 0; i < n; i++) + mieqEnqueue(nxagentKeyboardDevice, nxagentEvents + i); +#endif +} + void nxagentDispatchEvents(PredicateFuncPtr predicate) { XEvent X; @@ -1159,33 +1213,16 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already nxagentXkbNumTrap = 0; } - /* Calculate the time elapsed between this and the last event - we received. Add this delta to time we recorded for the - last KeyPress event we passed on to our clients. */ - memset(&x, 0, sizeof(xEvent)); - x.u.u.type = KeyRelease; - x.u.u.detail = nxagentConvertKeycode(X.xkey.keycode); - x.u.keyButtonPointer.time = nxagentLastKeyPressTime + - (X.xkey.time - nxagentLastServerTime); - nxagentLastServerTime = X.xkey.time; - nxagentLastEventTime = GetTimeInMillis(); - - if (x.u.keyButtonPointer.time > nxagentLastEventTime) - { - x.u.keyButtonPointer.time = nxagentLastEventTime; - } - - /* do not send a KeyRelease for a special keystroke since we - also did not send a KeyPress event in that case */ - if (!(nxagentCheckSpecialKeystroke(&X.xkey, &result)) && (sendKey == 1)) + if (!(nxagentCheckSpecialKeystroke(&X.xkey, &result)) && sendKey == 1) { - #ifdef TEST - fprintf(stderr, "%s: passing KeyRelease event to clients\n", __func__); - #endif - - mieqEnqueue(&x); + /* FIXME: Current implementation ignored the last + * parameter (desired event time)! */ + nxagentQueueKeyEvent(KeyRelease, + nxagentConvertKeycode(X.xkey.keycode), + True, + nxagentLastKeyPressTime + (X.xkey.time - nxagentLastServerTime)); CriticalOutputPending = 1; @@ -1279,7 +1316,20 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already } #endif + x.u.keyButtonPointer.time = nxagentLastEventTime = GetTimeInMillis(); + +#if 0 mieqEnqueue(&x); +#else + int valuators[2]; + valuators[0] = x.u.keyButtonPointer.rootX; + valuators[1] = x.u.keyButtonPointer.rootY; + int n = GetPointerEvents(nxagentEvents, nxagentPointerDevice, ButtonRelease, + inputInfo.pointer -> button -> map[nxagentReversePointerMap[X.xbutton.button]], + POINTER_ABSOLUTE, 0, 2, valuators); + for (int i = 0; i < n; i++) + mieqEnqueue(nxagentPointerDevice, nxagentEvents + i); +#endif CriticalOutputPending = 1; } @@ -1333,7 +1383,6 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already memset(&x, 0, sizeof(xEvent)); x.u.u.type = ButtonRelease; x.u.u.detail = inputInfo.pointer -> button -> map[nxagentReversePointerMap[X.xbutton.button]]; - x.u.keyButtonPointer.time = nxagentLastEventTime = GetTimeInMillis(); if (nxagentOption(Rootless)) { @@ -1353,7 +1402,19 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already } #endif + nxagentLastEventTime = GetTimeInMillis(); +#if 0 mieqEnqueue(&x); +#else + int valuators[2]; + valuators[0] = x.u.keyButtonPointer.rootX; + valuators[1] = x.u.keyButtonPointer.rootY; + int n = GetPointerEvents(nxagentEvents, nxagentPointerDevice, ButtonPress, + inputInfo.pointer -> button -> map[nxagentReversePointerMap[X.xbutton.button]], + POINTER_ABSOLUTE, 0, 2, valuators); + for (int i = 0; i < n; i++) + mieqEnqueue(nxagentPointerDevice, nxagentEvents + i); +#endif CriticalOutputPending = 1; } @@ -1449,7 +1510,19 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already } #endif +#if 0 mieqEnqueue(&x); +#else + /* FIXME: drop the event x altogether; this is just to make it compile */ + //miPointerAbsoluteCursor(x.u.keyButtonPointer.rootX, x.u.keyButtonPointer.rootY, x.u.keyButtonPointer.time); + int valuators[2]; + valuators[0] = x.u.keyButtonPointer.rootX; + valuators[1] = x.u.keyButtonPointer.rootY; + int n = GetPointerEvents(nxagentEvents, nxagentPointerDevice, MotionNotify, + 0, POINTER_ABSOLUTE, 0, 2, valuators); + for (int i = 0; i < n; i++) + mieqEnqueue(nxagentPointerDevice, nxagentEvents + i); +#endif } /* @@ -1602,11 +1675,6 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already if (!nxagentOption(Rootless) || inputInfo.keyboard->key->modifierMap[i * 8 + k]) { - memset(&x, 0, sizeof(xEvent)); - x.u.u.type = KeyRelease; - x.u.u.detail = i * 8 + k; - x.u.keyButtonPointer.time = nxagentLastEventTime = GetTimeInMillis(); - if (nxagentOption(ViewOnly) == 0 && nxagentOption(Shadow)) { XEvent xM = {0}; @@ -1619,7 +1687,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already NXShadowEvent(nxagentDisplay, xM); } - mieqEnqueue(&x); + nxagentQueueKeyEvent(KeyRelease, i * 8 + k, True, 0); } } } @@ -1754,8 +1822,19 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already x.u.keyButtonPointer.time = nxagentLastEventTime = GetTimeInMillis(); +#if 0 mieqEnqueue(&x); - +#else + /* FIXME: drop the event x altogether; this is just to make it compile */ + //miPointerAbsoluteCursor(x.u.keyButtonPointer.rootX, x.u.keyButtonPointer.rootY, x.u.keyButtonPointer.time); + int valuators[2]; + valuators[0] = x.u.keyButtonPointer.rootX; + valuators[1] = x.u.keyButtonPointer.rootY; + int n = GetPointerEvents(nxagentEvents, nxagentPointerDevice, MotionNotify, + 0, POINTER_ABSOLUTE, 0, 2, valuators); + for (int i = 0; i < n; i++) + mieqEnqueue(nxagentPointerDevice, nxagentEvents + i); +#endif nxagentDirectInstallColormaps(pScreen); } } @@ -2295,20 +2374,10 @@ int nxagentHandleKeyPress(XEvent *X, enum HandleEventResult *result) nxagentXkbState.Num = (~nxagentXkbState.Num & 1); } - nxagentLastServerTime = X -> xkey.time; - - nxagentLastEventTime = nxagentLastKeyPressTime = GetTimeInMillis(); - - xEvent x = {0}; - x.u.u.type = KeyPress; - x.u.u.detail = nxagentConvertKeycode(X -> xkey.keycode); - x.u.keyButtonPointer.time = nxagentLastKeyPressTime; - - #ifdef TEST - fprintf(stderr, "%s: passing KeyPress event to clients\n", __func__); - #endif + nxagentQueueKeyEvent(KeyPress, nxagentConvertKeycode(X -> xkey.keycode), True, 0); - mieqEnqueue(&x); + nxagentLastServerTime = X -> xkey.time; + nxagentLastKeyPressTime = nxagentLastEventTime; CriticalOutputPending = 1; @@ -3668,20 +3737,8 @@ void nxagentDisablePointerEvents(void) void nxagentSendFakeKey(int key) { - Time now = GetTimeInMillis(); - - xEvent fake = {0}; - fake.u.u.type = KeyPress; - fake.u.u.detail = key; - fake.u.keyButtonPointer.time = now; - - mieqEnqueue(&fake); - - fake.u.u.type = KeyRelease; - fake.u.u.detail = key; - fake.u.keyButtonPointer.time = now; - - mieqEnqueue(&fake); + nxagentQueueKeyEvent(KeyPress, key, False, 0); + nxagentQueueKeyEvent(KeyRelease, key, False, 0); } int nxagentInitXkbKeyboardState(void) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Imakefile b/nx-X11/programs/Xserver/hw/nxagent/Imakefile index e37f97e84b..2fbe0786c4 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Imakefile +++ b/nx-X11/programs/Xserver/hw/nxagent/Imakefile @@ -19,6 +19,7 @@ SRCS = \ NXshm.c \ NXglxext.c \ NXxvdisp.c \ + NXmiglyph.c \ NXresource.c \ NXmitrap.c \ Args.c \ @@ -75,6 +76,7 @@ OBJS = \ NXshm.o \ NXglxext.o \ NXxvdisp.o \ + NXmiglyph.o \ NXresource.o \ NXmitrap.o \ Args.o \ @@ -129,6 +131,7 @@ INCLUDES = \ -I../../../../extras/Mesa/include \ -I$(XBUILDINCDIR) \ -I../../mi \ + -I../../Xi \ -I../../include \ -I../../os \ -I../../miext/cw \ diff --git a/nx-X11/programs/Xserver/hw/nxagent/Init.c b/nx-X11/programs/Xserver/hw/nxagent/Init.c index 3cba1a89dd..bdfd36daeb 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Init.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Init.c @@ -200,6 +200,8 @@ void checkX2goAgent(void) nxagentX2go = False; } +xEvent *nxagentEvents = NULL; + /* * Called at X server's initialization. */ @@ -404,15 +406,18 @@ void nxagentNotifyConnection(int fd, int ready, void *data) void InitInput(int argc, char *argv[]) { - void *ptr, *kbd; + nxagentKeyboardDevice = AddInputDevice(nxagentKeyboardProc, True); + nxagentPointerDevice = AddInputDevice(nxagentPointerProc, True); - ptr = AddInputDevice(nxagentPointerProc, True); - kbd = AddInputDevice(nxagentKeyboardProc, True); + if (!nxagentEvents) + nxagentEvents = (xEvent *) calloc(sizeof(xEvent), GetMaximumEventsNum()); + if (!nxagentEvents) + FatalError("couldn't allocate room for events\n"); - RegisterPointerDevice(ptr); - RegisterKeyboardDevice(kbd); + RegisterKeyboardDevice(nxagentKeyboardDevice); + RegisterPointerDevice(nxagentPointerDevice); - mieqInit(kbd, ptr); + mieqInit(); /* * Add the display descriptor to the set of descriptors awaited by diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c index 950aec839f..d7b2a42b13 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c @@ -87,6 +87,8 @@ void nxagentKeycodeConversionSetup(void); static void nxagentWriteKeyboardDir(void); static void nxagentWriteKeyboardFile(char *rules, char *model, char *layout, char *variant, char *options); +extern void XkbFreePrivates(DeviceIntPtr device); + #endif /* XKB */ /* @@ -150,6 +152,8 @@ static char *nxagentRemoteOptions = NULL; #endif /* XKB */ +DeviceIntPtr nxagentKeyboardDevice = NULL; + /* * Save the values queried from X server. */ @@ -270,6 +274,11 @@ void nxagentBell(int volume, DeviceIntPtr pDev, void * ctrl, int cls) XBell(nxagentDisplay, volume); } +void DDXRingBell(int volume, int pitch, int duration) +{ + XBell(nxagentDisplay, volume); +} + void nxagentChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl) { #ifdef XKB @@ -373,6 +382,9 @@ int nxagentKeyboardProc(DeviceIntPtr pDev, int onoff) { case DEVICE_INIT: + if (!pDev->name) + pDev->name = strdup("NX keyboard"); + #ifdef TEST fprintf(stderr, "%s: Called for [DEVICE_INIT].\n", __func__); #endif @@ -822,15 +834,15 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio fprintf(stderr, "%s: Called for [DEVICE_CLOSE].\n", __func__); #endif + XkbFreePrivates(pDev); + break; } return Success; } -Bool LegalModifier(key, pDev) - unsigned int key; - DevicePtr pDev; +Bool LegalModifier(unsigned int key, DeviceIntPtr pDev) { return TRUE; } diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.h b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.h index dbfb47733b..f5dce47778 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.h @@ -92,6 +92,7 @@ extern XkbWrapperRec nxagentXkbWrapper; extern char *nxagentKeyboard; +extern DeviceIntPtr nxagentKeyboardDevice; /* * Keyboard device procedure * and utility functions. diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c b/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c index e804acbd2d..c649a365a1 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c @@ -52,13 +52,13 @@ Copyright 1987, 1989 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, +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 +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. +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 @@ -240,11 +240,11 @@ InitSelections(void) void Dispatch(void) { - register int *clientReady; /* array of request ready clients */ - register int result; - register ClientPtr client; - register int nready; - register HWEventQueuePtr* icheck = checkForInput; + int *clientReady; /* array of request ready clients */ + int result; + ClientPtr client; + int nready; + HWEventQueuePtr* icheck = checkForInput; long start_tick; nextFreeClientID = 1; @@ -281,6 +281,10 @@ Dispatch(void) if (!clientReady) return; +#ifdef XSERVER_DTRACE + LoadRequestNames(); +#endif + #ifdef NXAGENT_SERVER #ifdef WATCH @@ -365,7 +369,6 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio #endif /* NXAGENT_SERVER */ nready = WaitForSomething(clientReady); - #ifdef NXAGENT_SERVER #ifdef BLOCKS fprintf(stderr, "[Begin dispatch]\n"); @@ -375,7 +378,7 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio fprintf(stderr, "******Dispatch: Running with [%d] clients ready.\n", nready); #endif - + #ifdef NXAGENT_ONSTART /* @@ -398,9 +401,9 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio clientReady[0] = SmartScheduleClient (clientReady, nready); nready = 1; } - /***************** - * Handle events in round robin fashion, doing input between - * each round + /***************** + * Handle events in round robin fashion, doing input between + * each round *****************/ while (!dispatchException && (--nready >= 0)) @@ -442,6 +445,7 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio /* Update currentTime so request time checks, such as for input * device grabs, are calculated correctly */ UpdateCurrentTimeIf(); + #ifdef NXAGENT_SERVER #ifdef TEST fprintf(stderr, "******Dispatch: Reading request from client [%d].\n", @@ -450,7 +454,7 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio #endif /* NXAGENT_SERVER */ result = ReadRequestFromClient(client); - if (result <= 0) + if (result <= 0) { if (result < 0) CloseDownClient(client); @@ -481,6 +485,11 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio #endif client->sequence++; +#ifdef XSERVER_DTRACE + XSERVER_REQUEST_START(GetRequestName(MAJOROP), MAJOROP, + ((xReq *)client->requestBuffer)->length, + client->index, client->requestBuffer); +#endif if (result > (maxBigRequestSize << 2)) result = BadLength; else @@ -515,10 +524,15 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio #endif } +#ifdef XSERVER_DTRACE + XSERVER_REQUEST_DONE(GetRequestName(MAJOROP), MAJOROP, + client->sequence, client->index, result); +#endif + if (!SmartScheduleSignalEnable) SmartScheduleTime = GetTimeInMillis(); - if (result != Success) + if (result != Success) { if (client->noClientException != Success) CloseDownClient(client); @@ -545,10 +559,9 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio #if defined(DDXBEFORERESET) ddxBeforeReset (); #endif - #ifdef NXAGENT_SERVER /* FIXME: maybe move the code up to the KillAllClients() call to ddxBeforeReset? */ - if ((dispatchException & DE_RESET) && + if ((dispatchException & DE_RESET) && (serverGeneration > nxagentMaxAllowedResets)) { dispatchException &= ~DE_RESET; @@ -566,7 +579,7 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio * error on the display and wait until the * NX transport is gone. */ - + fprintf(stderr, "Session: Terminating session at '%s'.\n", GetTimeAsString()); saveAgentState("TERMINATING"); @@ -581,20 +594,22 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio } saveAgentState("TERMINATED"); #endif /* NXAGENT_SERVER */ - KillAllClients(); free(clientReady); dispatchException &= ~DE_RESET; +#ifdef XSERVER_DTRACE + FreeRequestNames(); +#endif } #undef MAJOROP int -ProcReparentWindow(register ClientPtr client) +ProcReparentWindow(ClientPtr client) { - register WindowPtr pWin, pParent; + WindowPtr pWin, pParent; REQUEST(xReparentWindowReq); - register int result; + int result; REQUEST_SIZE_MATCH(xReparentWindowReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, @@ -618,24 +633,24 @@ ProcReparentWindow(register ClientPtr client) if ((pWin->drawable.class != InputOnly) && (pParent->drawable.class == InputOnly)) return BadMatch; - result = ReparentWindow(pWin, pParent, + result = ReparentWindow(pWin, pParent, (short)stuff->x, (short)stuff->y, client); if (client->noClientException != Success) return(client->noClientException); else return(result); } - else + else return (BadMatch); } int -ProcQueryTree(register ClientPtr client) +ProcQueryTree(ClientPtr client) { xQueryTreeReply reply = {0}; int numChildren = 0; - register WindowPtr pChild, pWin, pHead; + WindowPtr pChild, pWin, pHead; Window *childIDs = (Window *)NULL; REQUEST(xResourceReq); @@ -683,10 +698,10 @@ ProcQueryTree(register ClientPtr client) childIDs[curChild++] = pChild->drawable.id; #endif } - + reply.nChildren = numChildren; reply.length = (numChildren * sizeof(Window)) >> 2; - + WriteReplyToClient(client, sizeof(xQueryTreeReply), &reply); if (numChildren) { @@ -700,7 +715,7 @@ ProcQueryTree(register ClientPtr client) int -ProcConvertSelection(register ClientPtr client) +ProcConvertSelection(ClientPtr client) { Bool paramsOkay; xEvent event; @@ -738,7 +753,7 @@ ProcConvertSelection(register ClientPtr client) int i; i = 0; - while ((i < NumCurrentSelections) && + while ((i < NumCurrentSelections) && CurrentSelections[i].selection != stuff->selection) i++; if ((i < NumCurrentSelections) && #ifdef NXAGENT_SERVER @@ -753,11 +768,11 @@ ProcConvertSelection(register ClientPtr client) CurrentSelections[i].pWin)) #endif ) - { + { memset(&event, 0, sizeof(xEvent)); event.u.u.type = SelectionRequest; event.u.selectionRequest.time = stuff->time; - event.u.selectionRequest.owner = + event.u.selectionRequest.owner = CurrentSelections[i].window; event.u.selectionRequest.requestor = stuff->requestor; event.u.selectionRequest.selection = stuff->selection; @@ -779,7 +794,7 @@ ProcConvertSelection(register ClientPtr client) NoEventMask /* CantBeFiltered */, NullGrab); return (client->noClientException); } - else + else { client->errorValue = stuff->property; return (BadAtom); @@ -788,7 +803,7 @@ ProcConvertSelection(register ClientPtr client) int -ProcOpenFont(register ClientPtr client) +ProcOpenFont(ClientPtr client) { int err; REQUEST(xOpenFontReq); @@ -823,7 +838,7 @@ ProcOpenFont(register ClientPtr client) } int -ProcCloseFont(register ClientPtr client) +ProcCloseFont(ClientPtr client) { FontPtr pFont; REQUEST(xResourceReq); @@ -880,7 +895,7 @@ ProcCloseFont(register ClientPtr client) int -ProcListFonts(register ClientPtr client) +ProcListFonts(ClientPtr client) { REQUEST(xListFontsReq); @@ -896,13 +911,12 @@ ProcListFonts(register ClientPtr client) #endif nxagentListRemoteFonts(tmp, stuff -> maxNames < nxagentMaxFontNames ? nxagentMaxFontNames : stuff->maxNames); #endif - - return ListFonts(client, (unsigned char *) &stuff[1], stuff->nbytes, + return ListFonts(client, (unsigned char *) &stuff[1], stuff->nbytes, stuff->maxNames); } int -ProcListFontsWithInfo(register ClientPtr client) +ProcListFontsWithInfo(ClientPtr client) { REQUEST(xListFontsWithInfoReq); @@ -923,7 +937,7 @@ ProcListFontsWithInfo(register ClientPtr client) } int -ProcFreePixmap(register ClientPtr client) +ProcFreePixmap(ClientPtr client) { PixmapPtr pMap; @@ -932,7 +946,7 @@ ProcFreePixmap(register ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); pMap = (PixmapPtr)SecurityLookupIDByType(client, stuff->id, RT_PIXMAP, DixDestroyAccess); - if (pMap) + if (pMap) { #ifdef NXAGENT_SERVER @@ -971,7 +985,7 @@ ProcFreePixmap(register ClientPtr client) FreeResource(stuff->id, RT_NONE); return(client->noClientException); } - else + else { client->errorValue = stuff->id; return (BadPixmap); @@ -980,7 +994,7 @@ ProcFreePixmap(register ClientPtr client) int -ProcSetScreenSaver (register ClientPtr client) +ProcSetScreenSaver (ClientPtr client) { int blankingOption, exposureOption; REQUEST(xSetScreenSaverReq); @@ -1035,7 +1049,7 @@ ProcSetScreenSaver (register ClientPtr client) } else { - ScreenSaverBlanking = blankingOption; + ScreenSaverBlanking = blankingOption; } if (exposureOption == DefaultExposures) @@ -1083,7 +1097,7 @@ ProcSetScreenSaver (register ClientPtr client) } -int ProcForceScreenSaver(register ClientPtr client) +int ProcForceScreenSaver(ClientPtr client) { REQUEST(xForceScreenSaverReq); @@ -1135,7 +1149,7 @@ int ProcForceScreenSaver(register ClientPtr client) *********************/ void -CloseDownClient(register ClientPtr client) +CloseDownClient(ClientPtr client) { #ifdef NXAGENT_SERVER /* diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXglyph.c b/nx-X11/programs/Xserver/hw/nxagent/NXglyph.c index 022ef09f45..09b9ac7c93 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXglyph.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXglyph.c @@ -132,6 +132,17 @@ AddGlyph (GlyphSetPtr glyphSet, GlyphPtr glyph, Glyph id) gr = FindGlyphRef (&globalGlyphs[glyphSet->fdepth], hash, TRUE, glyph); if (gr->glyph && gr->glyph != DeletedGlyph) { + PictureScreenPtr ps; + int i; + + for (i = 0; i < screenInfo.numScreens; i++) + { + ps = GetPictureScreenIfSet (screenInfo.screens[i]); + if (ps) + (*ps->UnrealizeGlyph) (screenInfo.screens[i], glyph); + } + if (glyph->devPrivates) + free (glyph->devPrivates); free (glyph); glyph = gr->glyph; } @@ -248,201 +259,3 @@ ResizeGlyphHash (GlyphHashPtr hash, CARD32 change, Bool global) CheckDuplicates (hash, "ResizeGlyphHash bottom"); return TRUE; } - -void -miGlyphs (CARD8 op, - PicturePtr pSrc, - PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, - INT16 ySrc, - int nlist, - GlyphListPtr list, - GlyphPtr *glyphs) -{ - PixmapPtr pPixmap = 0; - PicturePtr pPicture; - PixmapPtr pMaskPixmap = 0; - PicturePtr pMask; - ScreenPtr pScreen = pDst->pDrawable->pScreen; - int width = 0, height = 0; - int x, y; - int xDst = list->xOff, yDst = list->yOff; - int n; - GlyphPtr glyph; - int error; - 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)); - } - else - { - nxagentGlyphsExtents = (BoxPtr) malloc(sizeof(BoxRec)); - - GlyphExtents (nlist, list, glyphs, &extents); - - memcpy(nxagentGlyphsExtents, &extents, sizeof(BoxRec)); - } -#else - GlyphExtents (nlist, list, glyphs, &extents); -#endif - - if (extents.x2 <= extents.x1 || extents.y2 <= extents.y1) - return; - width = extents.x2 - extents.x1; - height = extents.y2 - extents.y1; - pMaskPixmap = (*pScreen->CreatePixmap) (pScreen, width, height, - maskFormat->depth, - CREATE_PIXMAP_USAGE_SCRATCH); - - if (!pMaskPixmap) - return; - - component_alpha = NeedsComponent(maskFormat->format); - pMask = CreatePicture (0, &pMaskPixmap->drawable, - maskFormat, CPComponentAlpha, &component_alpha, - serverClient, &error); - - if (!pMask) - { - (*pScreen->DestroyPixmap) (pMaskPixmap); - return; - } - pGC = GetScratchGC (pMaskPixmap->drawable.depth, pScreen); - ValidateGC (&pMaskPixmap->drawable, pGC); - rect.x = 0; - rect.y = 0; - rect.width = width; - rect.height = height; - (*pGC->ops->PolyFillRect) (&pMaskPixmap->drawable, pGC, 1, &rect); - FreeScratchGC (pGC); - x = -extents.x1; - y = -extents.y1; - } - else - { - pMask = pDst; - x = 0; - y = 0; - } - pPicture = 0; - while (nlist--) - { - x += list->xOff; - y += list->yOff; - n = list->len; - - while (n--) - { - glyph = *glyphs++; - if (!pPicture) - { - pPixmap = GetScratchPixmapHeader (pScreen, glyph->info.width, glyph->info.height, - list->format->depth, - list->format->depth, - 0, (void *) (glyph + 1)); - if (!pPixmap) - return; - component_alpha = NeedsComponent(list->format->format); - pPicture = CreatePicture (0, &pPixmap->drawable, list->format, - CPComponentAlpha, &component_alpha, - serverClient, &error); - if (!pPicture) - { - FreeScratchPixmapHeader (pPixmap); - return; - } - } - (*pScreen->ModifyPixmapHeader) (pPixmap, - 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 - * "ValidatePicture" that makes a check on the Drawable serial - * number instead of the picture serial number, failing thus - * the clip mask update. - */ - - pPicture->pDrawable->serialNumber = NEXT_SERIAL_NUMBER; -#endif - pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER; - if (maskFormat) - { - CompositePicture (PictOpAdd, - pPicture, - None, - pMask, - 0, 0, - 0, 0, - x - glyph->info.x, - y - glyph->info.y, - glyph->info.width, - glyph->info.height); - } - else - { - CompositePicture (op, - pSrc, - pPicture, - pDst, - xSrc + (x - glyph->info.x) - xDst, - ySrc + (y - glyph->info.y) - yDst, - 0, 0, - x - glyph->info.x, - y - glyph->info.y, - glyph->info.width, - glyph->info.height); - } - x += glyph->info.xOff; - y += glyph->info.yOff; - } - - list++; - if (pPicture) - { - FreeScratchPixmapHeader (pPixmap); - FreePicture ((void *) pPicture, 0); - pPicture = 0; - pPixmap = 0; - } - } - if (maskFormat) - { - x = extents.x1; - y = extents.y1; - CompositePicture (op, - pSrc, - pMask, - pDst, - xSrc + x - xDst, - ySrc + y - yDst, - 0, 0, - x, y, - width, height); - - FreePicture ((void *) pMask, (XID) 0); - (*pScreen->DestroyPixmap) (pMaskPixmap); - } - -} diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXmiglyph.c b/nx-X11/programs/Xserver/hw/nxagent/NXmiglyph.c new file mode 100644 index 0000000000..b102d64532 --- /dev/null +++ b/nx-X11/programs/Xserver/hw/nxagent/NXmiglyph.c @@ -0,0 +1,242 @@ +/**************************************************************************/ +/* */ +/* 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. */ +/* */ +/**************************************************************************/ + +/* + * $XFree86: xc/programs/Xserver/render/miglyph.c,v 1.4 2000/11/20 07:13:13 keithp Exp $ + * + * Copyright © 2000 SuSE, Inc. + * + * 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 SuSE not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. SuSE makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE + * 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. + * + * Author: Keith Packard, SuSE, Inc. + */ + +#include "Render.h" + +#include "../../render/miglyph.c" + +void +miGlyphs (CARD8 op, + PicturePtr pSrc, + PicturePtr pDst, + PictFormatPtr maskFormat, + INT16 xSrc, + INT16 ySrc, + int nlist, + GlyphListPtr list, + GlyphPtr *glyphs) +{ + PixmapPtr pPixmap = 0; + PicturePtr pPicture; + PixmapPtr pMaskPixmap = 0; + PicturePtr pMask; + ScreenPtr pScreen = pDst->pDrawable->pScreen; + int width = 0, height = 0; + int x, y; + int xDst = list->xOff, yDst = list->yOff; + int n; + GlyphPtr glyph; + int error; + BoxRec extents; + CARD32 component_alpha; + + /* + * Get rid of the warning. + */ + + extents.x1 = 0; + extents.y1 = 0; + + if (maskFormat) + { + GCPtr pGC; + xRectangle rect; + + if (nxagentGlyphsExtents != NullBox) + { + memcpy(&extents, nxagentGlyphsExtents, sizeof(BoxRec)); + } + else + { + nxagentGlyphsExtents = (BoxPtr) malloc(sizeof(BoxRec)); + + miGlyphExtents (nlist, list, glyphs, &extents); + + memcpy(nxagentGlyphsExtents, &extents, sizeof(BoxRec)); + } + + if (extents.x2 <= extents.x1 || extents.y2 <= extents.y1) + return; + width = extents.x2 - extents.x1; + height = extents.y2 - extents.y1; + pMaskPixmap = (*pScreen->CreatePixmap) (pScreen, width, height, maskFormat->depth, 0); + + if (!pMaskPixmap) + return; + + component_alpha = NeedsComponent(maskFormat->format); + pMask = CreatePicture (0, &pMaskPixmap->drawable, + maskFormat, CPComponentAlpha, &component_alpha, + serverClient, &error); + + if (!pMask) + { + (*pScreen->DestroyPixmap) (pMaskPixmap); + return; + } + pGC = GetScratchGC (pMaskPixmap->drawable.depth, pScreen); + ValidateGC (&pMaskPixmap->drawable, pGC); + rect.x = 0; + rect.y = 0; + rect.width = width; + rect.height = height; + (*pGC->ops->PolyFillRect) (&pMaskPixmap->drawable, pGC, 1, &rect); + FreeScratchGC (pGC); + x = -extents.x1; + y = -extents.y1; + } + else + { + pMask = pDst; + x = 0; + y = 0; + } + pPicture = 0; + while (nlist--) + { + x += list->xOff; + y += list->yOff; + n = list->len; + + while (n--) + { + glyph = *glyphs++; + if (!pPicture) + { + pPixmap = GetScratchPixmapHeader (pScreen, glyph->info.width, glyph->info.height, + list->format->depth, + list->format->depth, + 0, (void *) (glyph + 1)); + if (!pPixmap) + return; + component_alpha = NeedsComponent(list->format->format); + pPicture = CreatePicture (0, &pPixmap->drawable, list->format, + CPComponentAlpha, &component_alpha, + serverClient, &error); + if (!pPicture) + { + FreeScratchPixmapHeader (pPixmap); + return; + } + } + (*pScreen->ModifyPixmapHeader) (pPixmap, + glyph->info.width, glyph->info.height, + 0, 0, -1, (void *) (glyph + 1)); + + /* + * The following line fixes a problem with glyphs that appeared + * as clipped. It was a side effect due the validate function + * "ValidatePicture" that makes a check on the Drawable serial + * number instead of the picture serial number, failing thus + * the clip mask update. + */ + + pPicture->pDrawable->serialNumber = NEXT_SERIAL_NUMBER; + + pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER; + if (maskFormat) + { + CompositePicture (PictOpAdd, + pPicture, + None, + pMask, + 0, 0, + 0, 0, + x - glyph->info.x, + y - glyph->info.y, + glyph->info.width, + glyph->info.height); + } + else + { + CompositePicture (op, + pSrc, + pPicture, + pDst, + xSrc + (x - glyph->info.x) - xDst, + ySrc + (y - glyph->info.y) - yDst, + 0, 0, + x - glyph->info.x, + y - glyph->info.y, + glyph->info.width, + glyph->info.height); + } + x += glyph->info.xOff; + y += glyph->info.yOff; + } + + list++; + if (pPicture) + { + FreeScratchPixmapHeader (pPixmap); + FreePicture ((void *) pPicture, 0); + pPicture = 0; + pPixmap = 0; + } + } + if (maskFormat) + { + x = extents.x1; + y = extents.y1; + CompositePicture (op, + pSrc, + pMask, + pDst, + xSrc + x - xDst, + ySrc + y - yDst, + 0, 0, + x, y, + width, height); + + FreePicture ((void *) pMask, (XID) 0); + (*pScreen->DestroyPixmap) (pMaskPixmap); + } + +} diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXrender.c b/nx-X11/programs/Xserver/hw/nxagent/NXrender.c index 76a375db2b..74b5546884 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXrender.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXrender.c @@ -70,11 +70,11 @@ #endif /* - * From NXglyph.c. + * From NXmiglyph.c. */ extern -void GlyphExtents(int nlist, GlyphListPtr list, +void miGlyphExtents(int nlist, GlyphListPtr list, GlyphPtr *glyphs, BoxPtr extents); /* @@ -1182,7 +1182,7 @@ ProcRenderCompositeGlyphs (ClientPtr client) nxagentGlyphsExtents = (BoxPtr) malloc(sizeof(BoxRec)); - GlyphExtents(nlist, listsBase, glyphsBase, nxagentGlyphsExtents); + miGlyphExtents(nlist, listsBase, glyphsBase, nxagentGlyphsExtents); nxagentGlyphs(stuff -> op, pSrc, diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXshm.c b/nx-X11/programs/Xserver/hw/nxagent/NXshm.c index 83deb74c4d..11a3f4aee4 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXshm.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXshm.c @@ -86,81 +86,59 @@ extern int nxagentImageLength(int, int, int, int, int); 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 xTrue. 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 + * sharedPixmaps 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 array 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 diff --git a/nx-X11/programs/Xserver/hw/nxagent/Pointer.c b/nx-X11/programs/Xserver/hw/nxagent/Pointer.c index b5d47623ad..7806f7861e 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Pointer.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Pointer.c @@ -53,6 +53,7 @@ is" without express or implied warranty. #include "Pointer.h" #include "Events.h" #include "Options.h" +#include "xkbsrv.h" #include "compext/Compext.h" @@ -72,6 +73,8 @@ is" without express or implied warranty. unsigned char nxagentReversePointerMap[MAXBUTTONS]; +DeviceIntPtr nxagentPointerDevice = NULL; + void nxagentChangePointerControl(DeviceIntPtr pDev, PtrCtrl *ctrl) { /* @@ -107,6 +110,9 @@ int nxagentPointerProc(DeviceIntPtr pDev, int onoff) { case DEVICE_INIT: + if (!pDev->name) + pDev->name = strdup("NX pointer"); + #ifdef TEST fprintf(stderr, "%s: Called for [DEVICE_INIT].\n", __func__); #endif @@ -122,9 +128,9 @@ int nxagentPointerProc(DeviceIntPtr pDev, int onoff) for (int i = 0; i <= nmap; i++) map[i] = i; /* buttons are already mapped */ InitPointerDeviceStruct((DevicePtr) pDev, map, nmap, - miPointerGetMotionEvents, + GetMotionHistory, nxagentChangePointerControl, - miPointerGetMotionBufferSize()); + GetMotionHistorySize(), 2); break; case DEVICE_ON: @@ -163,6 +169,8 @@ int nxagentPointerProc(DeviceIntPtr pDev, int onoff) fprintf(stderr, "%s: Called for [DEVICE_CLOSE].\n", __func__); #endif + XkbFreePrivates(pDev); + break; } diff --git a/nx-X11/programs/Xserver/hw/nxagent/Pointer.h b/nx-X11/programs/Xserver/hw/nxagent/Pointer.h index 85162d4a50..37d70af4c1 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Pointer.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Pointer.h @@ -53,6 +53,8 @@ is" without express or implied warranty. extern unsigned char nxagentReversePointerMap[MAXBUTTONS]; +extern DeviceIntPtr nxagentPointerDevice; + void nxagentChangePointerControl(DeviceIntPtr pDev, PtrCtrl *ctrl); int nxagentPointerProc(DeviceIntPtr pDev, int onoff); diff --git a/nx-X11/programs/Xserver/include/dix.h b/nx-X11/programs/Xserver/include/dix.h index dd9dc761d5..e13d4fa98c 100644 --- a/nx-X11/programs/Xserver/include/dix.h +++ b/nx-X11/programs/Xserver/include/dix.h @@ -268,6 +268,7 @@ typedef struct _WorkQueue *WorkQueuePtr; extern ClientPtr *clients; extern ClientPtr serverClient; extern int currentMaxClients; +extern char dispatchExceptionAtReset; typedef int HWEventQueueType; typedef HWEventQueueType* HWEventQueuePtr; @@ -298,8 +299,6 @@ extern int dixDestroyPixmap( void * /*value*/, XID /*pid*/); -extern void CloseDownRetainedResources(void); - extern void InitClient( ClientPtr /*client*/, int /*i*/, @@ -329,17 +328,6 @@ extern int SendConnSetup( ClientPtr /*client*/, char* /*reason*/); -extern int DoGetImage( - ClientPtr /*client*/, - int /*format*/, - Drawable /*drawable*/, - int /*x*/, - int /*y*/, - int /*width*/, - int /*height*/, - Mask /*planemask*/, - xGetImageReply ** /*im_return*/); - #if defined(DDXBEFORERESET) extern void ddxBeforeReset (void); #endif @@ -488,6 +476,12 @@ extern void FreeAllAtoms(void); extern void InitAtoms(void); +/* main.c */ + +extern void SetVendorRelease(int release); + +extern void SetVendorString(char *string); + /* events.c */ extern void SetMaskForEvent( @@ -660,6 +654,9 @@ extern int TryClientEvents( extern void WindowsRestructured(void); +#ifdef PANORAMIX +extern void ReinitializeRootWindow(WindowPtr win, int xoff, int yoff); +#endif #ifdef RANDR void @@ -674,6 +671,8 @@ extern Bool AllocateClientPrivate( int /*index*/, unsigned /*amount*/); +extern int ffs(int i); + /* * callback manager stuff */ diff --git a/nx-X11/programs/Xserver/include/dixevents.h b/nx-X11/programs/Xserver/include/dixevents.h index 2a9458f086..62c8672779 100644 --- a/nx-X11/programs/Xserver/include/dixevents.h +++ b/nx-X11/programs/Xserver/include/dixevents.h @@ -102,4 +102,8 @@ extern int ProcUngrabButton(ClientPtr /* client */); extern int ProcRecolorCursor(ClientPtr /* client */); +#ifdef PANORAMIX +extern void PostSyntheticMotion(int x, int y, int screen, unsigned long time); +#endif + #endif /* DIXEVENTS_H */ diff --git a/nx-X11/programs/Xserver/include/exevents.h b/nx-X11/programs/Xserver/include/exevents.h index 1169a6c4e0..bf5849c04b 100644 --- a/nx-X11/programs/Xserver/include/exevents.h +++ b/nx-X11/programs/Xserver/include/exevents.h @@ -30,6 +30,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifndef EXEVENTS_H #define EXEVENTS_H +#include + extern void RegisterOtherDevice ( DeviceIntPtr /* device */); @@ -129,6 +131,7 @@ extern int SetModifierMapping( KeyClassPtr * /* k */); extern void SendDeviceMappingNotify( + ClientPtr /* client, */, CARD8 /* request, */, KeyCode /* firstKeyCode */, CARD8 /* count */, @@ -148,10 +151,6 @@ extern void DeleteWindowFromAnyExtEvents( WindowPtr /* pWin */, Bool /* freeResources */); -extern void DeleteDeviceFromAnyExtEvents( - WindowPtr /* pWin */, - DeviceIntPtr /* dev */); - extern int MaybeSendDeviceMotionNotifyHint ( deviceKeyButtonPointer * /* pEvents */, Mask /* mask */); @@ -164,11 +163,6 @@ extern void CheckDeviceGrabAndHintWindow ( ClientPtr /* client */, Mask /* deliveryMask */); -extern Mask DeviceEventMaskForClient( - DeviceIntPtr /* dev */, - WindowPtr /* pWin */, - ClientPtr /* client */); - extern void MaybeStopDeviceHint( DeviceIntPtr /* dev */, ClientPtr /* client */); @@ -179,4 +173,10 @@ extern int DeviceEventSuppressForWindow( Mask /* mask */, int /* maskndx */); +void SendEventToAllWindows( + DeviceIntPtr /* dev */, + Mask /* mask */, + xEvent * /* ev */, + int /* count */); + #endif /* EXEVENTS_H */ diff --git a/nx-X11/programs/Xserver/include/extinit.h b/nx-X11/programs/Xserver/include/extinit.h index b1a0f215d6..e616b6d931 100644 --- a/nx-X11/programs/Xserver/include/extinit.h +++ b/nx-X11/programs/Xserver/include/extinit.h @@ -37,87 +37,6 @@ XInputExtensionInit( void ); - -int -ProcIDispatch ( - ClientPtr /* client */ - ); - -int -SProcIDispatch( - ClientPtr /* client */ - ); - -void -SReplyIDispatch ( - ClientPtr /* client */, - int /* len */, - xGrabDeviceReply * /* rep */ - ); - -void -SEventIDispatch ( - xEvent * /* from */, - xEvent * /* to */ - ); - -void -SEventDeviceValuator ( - deviceValuator * /* from */, - deviceValuator * /* to */ - ); - -void -SEventFocus ( - deviceFocus * /* from */, - deviceFocus * /* to */ - ); - -void -SDeviceStateNotifyEvent ( - deviceStateNotify * /* from */, - deviceStateNotify * /* to */ - ); - -void -SDeviceKeyStateNotifyEvent ( - deviceKeyStateNotify * /* from */, - deviceKeyStateNotify * /* to */ - ); - -void -SDeviceButtonStateNotifyEvent ( - deviceButtonStateNotify * /* from */, - deviceButtonStateNotify * /* to */ - ); - -void -SChangeDeviceNotifyEvent ( - changeDeviceNotify * /* from */, - changeDeviceNotify * /* to */ - ); - -void -SDeviceMappingNotifyEvent ( - deviceMappingNotify * /* from */, - deviceMappingNotify * /* to */ - ); - -void -FixExtensionEvents ( - ExtensionEntry * /* extEntry */ - ); - -void -RestoreExtensionEvents ( - void - ); - -void -IResetProc( - ExtensionEntry * /* unused */ - ); - void AssignTypeAndName ( DeviceIntPtr /* dev */, @@ -125,41 +44,9 @@ AssignTypeAndName ( char * /* name */ ); -void -MakeDeviceTypeAtoms ( - void -); - DeviceIntPtr LookupDeviceIntRec ( CARD8 /* id */ ); -void -SetExclusiveAccess ( - Mask /* mask */ - ); - -void -AllowPropagateSuppress ( - Mask /* mask */ - ); - -Mask -GetNextExtEventMask ( - void -); - -void -SetMaskForExtEvent( - Mask /* mask */, - int /* event */ - ); - -void -SetEventInfo( - Mask /* mask */, - int /* constant */ - ); - #endif /* EXTINIT_H */ diff --git a/nx-X11/programs/Xserver/include/hotplug.h b/nx-X11/programs/Xserver/include/hotplug.h new file mode 100644 index 0000000000..c0ed31e7c7 --- /dev/null +++ b/nx-X11/programs/Xserver/include/hotplug.h @@ -0,0 +1,41 @@ +/* + * Copyright © 2006-2007 Daniel Stone + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. + * + * Author: Daniel Stone + */ + +#ifndef HOTPLUG_H +#define HOTPLUG_H + +/* + * config_init/fini are for dbus and hal access, we do not need this + * for nx so we make them no-ops + */ +#define config_init() /**/ +#define config_fini() /**/ + +/* +void config_init(void); +void config_fini(void); +*/ + +#endif /* HOTPLUG_H */ diff --git a/nx-X11/programs/Xserver/include/input.h b/nx-X11/programs/Xserver/include/input.h index 7cfbf32a70..d7757fc189 100644 --- a/nx-X11/programs/Xserver/include/input.h +++ b/nx-X11/programs/Xserver/include/input.h @@ -59,6 +59,10 @@ SOFTWARE. #define DEVICE_OFF 2 #define DEVICE_CLOSE 3 +#define POINTER_RELATIVE (1 << 1) +#define POINTER_ABSOLUTE (1 << 2) +#define POINTER_ACCELERATE (1 << 3) + #define MAP_LENGTH 256 #define DOWN_LENGTH 32 /* 256/8 => number of bytes to hold 256 bits */ #define NullGrab ((GrabPtr)NULL) @@ -161,21 +165,24 @@ extern void ResetDevicePrivateIndex(void); extern KeybdCtrl defaultKeyboardControl; extern PtrCtrl defaultPointerControl; -#undef AddInputDevice -extern DevicePtr AddInputDevice( - DeviceProc /*deviceProc*/, - Bool /*autoStart*/); +typedef struct _InputOption { + char *key; + char *value; + struct _InputOption *next; +} InputOption; -#define AddInputDevice(deviceProc, autoStart) \ - _AddInputDevice(deviceProc, autoStart) +extern void InitCoreDevices(void); -extern DeviceIntPtr _AddInputDevice( +extern DeviceIntPtr AddInputDevice( DeviceProc /*deviceProc*/, Bool /*autoStart*/); extern Bool EnableDevice( DeviceIntPtr /*device*/); +extern Bool ActivateDevice( + DeviceIntPtr /*device*/); + extern Bool DisableDevice( DeviceIntPtr /*device*/); @@ -183,29 +190,15 @@ extern int InitAndStartDevices(void); extern void CloseDownDevices(void); -extern void RemoveDevice( +extern int RemoveDevice( DeviceIntPtr /*dev*/); extern int NumMotionEvents(void); -#undef RegisterPointerDevice extern void RegisterPointerDevice( - DevicePtr /*device*/); - -#define RegisterPointerDevice(device) \ - _RegisterPointerDevice(device) - -extern void _RegisterPointerDevice( DeviceIntPtr /*device*/); -#undef RegisterKeyboardDevice extern void RegisterKeyboardDevice( - DevicePtr /*device*/); - -#define RegisterKeyboardDevice(device) \ - _RegisterKeyboardDevice(device) - -extern void _RegisterKeyboardDevice( DeviceIntPtr /*device*/); extern DevicePtr LookupKeyboardDevice(void); @@ -247,6 +240,9 @@ extern Bool InitValuatorClassDeviceStruct( int /*numMotionEvents*/, int /*mode*/); +extern Bool InitAbsoluteClassDeviceStruct( + DeviceIntPtr /*device*/); + extern Bool InitFocusClassDeviceStruct( DeviceIntPtr /*device*/); @@ -316,7 +312,8 @@ extern Bool InitPointerDeviceStruct( int /*numButtons*/, ValuatorMotionProcPtr /*motionProc*/, PtrCtrlProcPtr /*controlProc*/, - int /*numMotionEvents*/); + int /*numMotionEvents*/, + int /*numAxes*/); extern Bool InitKeyboardDeviceStruct( DevicePtr /*device*/, @@ -378,7 +375,7 @@ extern void CoreProcessKeyboardEvent( extern Bool LegalModifier( unsigned int /*key*/, - DevicePtr /*pDev*/); + DeviceIntPtr /*pDev*/); extern void ProcessInputEvents(void); @@ -386,4 +383,76 @@ extern void InitInput( int /*argc*/, char ** /*argv*/); +extern int GetMaximumEventsNum(void); + +extern int GetPointerEvents( + xEvent *events, + DeviceIntPtr pDev, + int type, + int buttons, + int flags, + int first_valuator, + int num_valuators, + int *valuators); + +extern int GetKeyboardEvents( + xEvent *events, + DeviceIntPtr pDev, + int type, + int key_code); + +extern int GetKeyboardValuatorEvents( + xEvent *events, + DeviceIntPtr pDev, + int type, + int key_code, + int first_valuator, + int num_valuator, + int *valuators); + +extern int GetProximityEvents( + xEvent *events, + DeviceIntPtr pDev, + int type, + int first_valuator, + int num_valuators, + int *valuators); + +extern void PostSyntheticMotion( + int x, + int y, + int screen, + unsigned long time); + +extern int GetMotionHistorySize( + void); + +extern void AllocateMotionHistory( + DeviceIntPtr pDev); + +extern int GetMotionHistory( + DeviceIntPtr pDev, + xTimecoord *buff, + unsigned long start, + unsigned long stop, + ScreenPtr pScreen); + +extern void SwitchCoreKeyboard(DeviceIntPtr pDev); +extern void SwitchCorePointer(DeviceIntPtr pDev); + +extern DeviceIntPtr LookupDeviceIntRec( + CARD8 deviceid); + +/* Implemented by the DDX. */ +extern int NewInputDeviceRequest( + InputOption *options, + DeviceIntPtr *dev); +extern void DeleteInputDeviceRequest( + DeviceIntPtr dev); + +extern void DDXRingBell( + int volume, + int pitch, + int duration); + #endif /* INPUT_H */ diff --git a/nx-X11/programs/Xserver/include/inputstr.h b/nx-X11/programs/Xserver/include/inputstr.h index 5bc7be2ffc..73fd4b12e8 100644 --- a/nx-X11/programs/Xserver/include/inputstr.h +++ b/nx-X11/programs/Xserver/include/inputstr.h @@ -62,6 +62,8 @@ SOFTWARE. #define EMASKSIZE MAX_DEVICES +extern int CoreDevicePrivatesIndex; + /* Kludge: OtherClients and InputClients must be compatible, see code */ typedef struct _OtherClients { @@ -91,15 +93,15 @@ typedef struct _OtherInputMasks { */ #define MasksPerDetailMask 8 /* 256 keycodes and 256 possible - modifier combinations, but only - 3 buttons. */ + modifier combinations, but only + 3 buttons. */ - typedef struct _DetailRec { /* Grab details may be bit masks */ - unsigned short exact; - Mask *pMask; - } DetailRec; +typedef struct _DetailRec { /* Grab details may be bit masks */ + unsigned short exact; + Mask *pMask; +} DetailRec; - typedef struct _GrabRec { +typedef struct _GrabRec { GrabPtr next; /* for chain of passive grabs */ XID resource; DeviceIntPtr device; @@ -120,6 +122,7 @@ typedef struct _OtherInputMasks { typedef struct _KeyClassRec { CARD8 down[DOWN_LENGTH]; + CARD8 postdown[DOWN_LENGTH]; KeyCode *modifierKeyMap; KeySymsRec curKeySyms; int modifierKeyCount[8]; @@ -129,6 +132,8 @@ typedef struct _KeyClassRec { unsigned short prev_state; #ifdef XKB struct _XkbSrvInfo *xkbInfo; +#else + void *pad0; #endif } KeyClassRec, *KeyClassPtr; @@ -142,17 +147,20 @@ typedef struct _AxisInfo { typedef struct _ValuatorClassRec { ValuatorMotionProcPtr GetMotionProc; - int numMotionEvents; - WindowPtr motionHintWindow; - AxisInfoPtr axes; - unsigned short numAxes; - int *axisVal; - /* the next two are only written by xtest and never read currently. They exist - to satisfy the compiler. Once Xi is updated, too, they will be a regular member - anyway */ - int lastx, lasty; /* last event recorded, not posted to - * client; see dix/devices.c */ - CARD8 mode; + int numMotionEvents; + int first_motion; + int last_motion; + void *motion; + + WindowPtr motionHintWindow; + + AxisInfoPtr axes; + unsigned short numAxes; + int *axisVal; + int lastx, lasty; /* last event recorded, not posted to + * client; see dix/devices.c */ + int dxremaind, dyremaind; /* for acceleration */ + CARD8 mode; } ValuatorClassRec, *ValuatorClassPtr; typedef struct _ButtonClassRec { @@ -163,7 +171,9 @@ typedef struct _ButtonClassRec { CARD8 down[DOWN_LENGTH]; CARD8 map[MAP_LENGTH]; #ifdef XKB - union _XkbAction * xkb_acts; + union _XkbAction *xkb_acts; +#else + void *pad0; #endif } ButtonClassRec, *ButtonClassPtr; @@ -180,6 +190,26 @@ typedef struct _ProximityClassRec { char pad; } ProximityClassRec, *ProximityClassPtr; +typedef struct _AbsoluteClassRec { + /* Calibration. */ + int min_x; + int max_x; + int min_y; + int max_y; + int flip_x; + int flip_y; + int rotation; + int button_threshold; + + /* Area. */ + int offset_x; + int offset_y; + int width; + int height; + int screen; + XID following; +} AbsoluteClassRec, *AbsoluteClassPtr; + typedef struct _KbdFeedbackClassRec *KbdFeedbackPtr; typedef struct _PtrFeedbackClassRec *PtrFeedbackPtr; typedef struct _IntegerFeedbackClassRec *IntegerFeedbackPtr; @@ -194,6 +224,8 @@ typedef struct _KbdFeedbackClassRec { KbdFeedbackPtr next; #ifdef XKB struct _XkbSrvLedInfo *xkb_sli; +#else + void *pad0; #endif } KbdFeedbackClassRec; @@ -228,6 +260,8 @@ typedef struct _LedFeedbackClassRec { LedFeedbackPtr next; #ifdef XKB struct _XkbSrvLedInfo *xkb_sli; +#else + void *pad0; #endif } LedFeedbackClassRec; @@ -253,6 +287,8 @@ typedef struct _DeviceIntRec { used to initialize, turn on, or turn off the device */ Bool inited; /* TRUE if INIT returns Success */ + Bool enabled; /* TRUE if ON returns Success */ + Bool coreEvents; /* TRUE if device also sends core */ GrabPtr grab; /* the grabber - used by DIX */ struct { Bool frozen; @@ -279,6 +315,7 @@ typedef struct _DeviceIntRec { ButtonClassPtr button; FocusClassPtr focus; ProximityClassPtr proximity; + AbsoluteClassPtr absolute; KbdFeedbackPtr kbdfeed; PtrFeedbackPtr ptrfeed; IntegerFeedbackPtr intfeed; @@ -286,8 +323,11 @@ typedef struct _DeviceIntRec { BellFeedbackPtr bell; LedFeedbackPtr leds; #ifdef XKB - struct _XkbInterest * xkb_interest; + struct _XkbInterest *xkb_interest; +#else + void *pad0; #endif + char *config_info; /* used by the hotplug layer */ DevUnion *devPrivates; int nPrivates; DeviceUnwrapProc unwrapProc; diff --git a/nx-X11/programs/Xserver/include/misc.h b/nx-X11/programs/Xserver/include/misc.h index 27137cd504..8c48345a9a 100644 --- a/nx-X11/programs/Xserver/include/misc.h +++ b/nx-X11/programs/Xserver/include/misc.h @@ -156,7 +156,7 @@ typedef struct _xReq *xReqPtr; #define max(a, b) (((a) > (b)) ? (a) : (b)) /* abs() is a function, not a macro; include the file declaring * it in case we haven't done that yet. - */ + */ #include #ifndef Fabs #define Fabs(a) ((a) > 0.0 ? (a) : -(a)) /* floating absolute value */ @@ -183,7 +183,6 @@ typedef struct _xReq *xReqPtr; */ #include -#endif #undef MAXSHORT #define MAXSHORT SHRT_MAX #undef MINSHORT @@ -197,6 +196,8 @@ typedef struct _xReq *xReqPtr; #include #include /* for fopen, etc... */ +#endif + /** * Calculate the number of bytes needed to hold bits. * @param bits The minimum number of bits needed. diff --git a/nx-X11/programs/Xserver/include/protocol-versions.h b/nx-X11/programs/Xserver/include/protocol-versions.h index 7c5ea64836..88cac40965 100644 --- a/nx-X11/programs/Xserver/include/protocol-versions.h +++ b/nx-X11/programs/Xserver/include/protocol-versions.h @@ -38,11 +38,7 @@ /* Damage */ #define SERVER_DAMAGE_MAJOR_VERSION 1 -#ifndef NXAGENT_SERVER #define SERVER_DAMAGE_MINOR_VERSION 1 -#else /* !defined(NXAGENT_SERVER) */ -#define SERVER_DAMAGE_MINOR_VERSION 0 -#endif /* !defined(NXAGENT_SERVER) */ #ifndef NXAGENT_SERVER /* DRI3 */ diff --git a/nx-X11/programs/Xserver/include/regionstr.h b/nx-X11/programs/Xserver/include/regionstr.h index 959b9c4238..085dec2abe 100644 --- a/nx-X11/programs/Xserver/include/regionstr.h +++ b/nx-X11/programs/Xserver/include/regionstr.h @@ -282,6 +282,8 @@ RegionEqual(RegionPtr reg1, RegionPtr reg2) return pixman_region_equal (reg1, reg2); } +extern void InitRegions (void); + extern RegionPtr RegionCreate( BoxPtr /*rect*/, int /*size*/); diff --git a/nx-X11/programs/Xserver/include/servermd.h b/nx-X11/programs/Xserver/include/servermd.h index f6e82a2330..74b90b38a8 100644 --- a/nx-X11/programs/Xserver/include/servermd.h +++ b/nx-X11/programs/Xserver/include/servermd.h @@ -48,22 +48,480 @@ SOFTWARE. #ifndef SERVERMD_H #define SERVERMD_H 1 -#include /* for X_LITTLE_ENDIAN/X_BIG_ENDIAN */ +/* + * Machine dependent values: + * GLYPHPADBYTES should be chosen with consideration for the space-time + * trade-off. Padding to 0 bytes means that there is no wasted space + * in the font bitmaps (both on disk and in memory), but that access of + * the bitmaps will cause odd-address memory references. Padding to + * 2 bytes would ensure even address memory references and would + * be suitable for a 68010-class machine, but at the expense of wasted + * space in the font bitmaps. Padding to 4 bytes would be good + * for real 32 bit machines, etc. Be sure that you tell the font + * compiler what kind of padding you want because its defines are + * kept separate from this. See server/include/font.h for how + * GLYPHPADBYTES is used. + * + * Along with this, you should choose an appropriate value for + * GETLEFTBITS_ALIGNMENT, which is used in ddx/mfb/maskbits.h. This + * constant choses what kind of memory references are guarenteed during + * font access; either 1, 2 or 4, for byte, word or longword access, + * respectively. For instance, if you have decided to to have + * GLYPHPADBYTES == 4, then it is pointless for you to have a + * GETLEFTBITS_ALIGNMENT > 1, because the padding of the fonts has already + * guarenteed you that your fonts are longword aligned. On the other + * hand, even if you have chosen GLYPHPADBYTES == 1 to save space, you may + * also decide that the computing involved in aligning the pointer is more + * costly than an odd-address access; you choose GETLEFTBITS_ALIGNMENT == 1. + * + * Next, choose the tuning parameters which are appropriate for your + * hardware; these modify the behaviour of the raw frame buffer code + * in ddx/mfb and ddx/cfb. Defining these incorrectly will not cause + * the server to run incorrectly, but defining these correctly will + * cause some noticeable speed improvements: + * + * AVOID_MEMORY_READ - (8-bit cfb only) + * When stippling pixels on the screen (polytext and pushpixels), + * don't read long words from the display and mask in the + * appropriate values. Rather, perform multiple byte/short/long + * writes as appropriate. This option uses many more instructions + * but runs much faster when the destination is much slower than + * the CPU and at least 1 level of write buffer is availible (2 + * is much better). Defined currently for SPARC and MIPS. + * + * FAST_CONSTANT_OFFSET_MODE - (cfb and mfb) + * This define is used on machines which have no auto-increment + * addressing mode, but do have an effectively free constant-offset + * addressing mode. Currently defined for MIPS and SPARC, even though + * I remember the cg6 as performing better without it (cg3 definitely + * performs better with it). + * + * LARGE_INSTRUCTION_CACHE - + * This define increases the number of times some loops are + * unrolled. On 68020 machines (with 256 bytes of i-cache), + * this define will slow execution down as instructions miss + * the cache frequently. On machines with real i-caches, this + * reduces loop overhead, causing a slight performance improvement. + * Currently defined for MIPS and SPARC + * + * FAST_UNALIGNED_READS - + * For machines with more memory bandwidth than CPU, this + * define uses unaligned reads for 8-bit BitBLT instead of doing + * aligned reads and combining the results with shifts and + * logical-ors. Currently defined for 68020 and vax. + * PLENTIFUL_REGISTERS - + * For machines with > 20 registers. Currently used for + * unrolling the text painting code a bit more. Currently + * defined for MIPS. + * SHARED_IDCACHE - + * For non-Harvard RISC machines, those which share the same + * CPU memory bus for instructions and data. This unrolls some + * solid fill loops which are otherwise best left rolled up. + * Currently defined for SPARC. + */ -#if X_BYTE_ORDER == X_LITTLE_ENDIAN -#define IMAGE_BYTE_ORDER LSBFirst +#ifdef vax + +#define IMAGE_BYTE_ORDER LSBFirst /* Values for the VAX only */ #define BITMAP_BIT_ORDER LSBFirst -#elif X_BYTE_ORDER == X_BIG_ENDIAN +#define GLYPHPADBYTES 1 +#define GETLEFTBITS_ALIGNMENT 4 +#define FAST_UNALIGNED_READS + +#endif /* vax */ + +#ifdef __arm32__ + +#define IMAGE_BYTE_ORDER LSBFirst + +# if defined(XF86MONOVGA) || defined(XF86VGA16) || defined(XF86MONO) +# define BITMAP_BIT_ORDER MSBFirst +# else +# define BITMAP_BIT_ORDER LSBFirst +# endif + +# if defined(XF86MONOVGA) || defined(XF86VGA16) +# define BITMAP_SCANLINE_UNIT 8 +# endif + +#define GLYPHPADBYTES 4 +#define GETLEFTBITS_ALIGNMENT 1 +#define LARGE_INSTRUCTION_CACHE +#define AVOID_MEMORY_READ + +#endif /* __arm32__ */ + +#if defined (hpux) || defined __hppa__ + #define IMAGE_BYTE_ORDER MSBFirst #define BITMAP_BIT_ORDER MSBFirst +#define GLYPHPADBYTES 4 /* to make fb work */ +#define GETLEFTBITS_ALIGNMENT 1 /* PA forces longs to 4 */ + /* byte boundries */ +#define AVOID_MEMORY_READ +#define FAST_CONSTANT_OFFSET_MODE +#define LARGE_INSTRUCTION_CACHE +#define PLENTIFUL_REGISTERS + +#endif /* hpux || __hppa__ */ + +#if defined(__powerpc__) || defined(__ppc__) + +#define IMAGE_BYTE_ORDER MSBFirst +#define BITMAP_BIT_ORDER MSBFirst +#define GLYPHPADBYTES 4 +#define GETLEFTBITS_ALIGNMENT 1 + +/* XXX Should this be for Lynx only? */ +#ifdef Lynx +#define BITMAP_SCANLINE_UNIT 8 +#endif + +#define LARGE_INSTRUCTION_CACHE +#define FAST_CONSTANT_OFFSET_MODE +#define PLENTIFUL_REGISTERS +#define AVOID_MEMORY_READ + +#define FAST_MEMCPY + +#endif /* PowerPC */ + +#if defined(__sh__) + +#if defined(__BIG_ENDIAN__) +# define IMAGE_BYTE_ORDER MSBFirst +# define BITMAP_BIT_ORDER MSBFirst +# define GLYPHPADBYTES 4 +# define GETLEFTBITS_ALIGNMENT 1 +#else +# define IMAGE_BYTE_ORDER LSBFirst +# define BITMAP_BIT_ORDER LSBFirst +# define GLYPHPADBYTES 4 +# define GETLEFTBITS_ALIGNMENT 1 +#endif + +#define AVOID_MEMORY_READ +#define FAST_CONSTANT_OFFSET_MODE +#define LARGE_INSTRUCTION_CACHE +#define PLENTIFUL_REGISTERS + +#endif /* SuperH */ + + +#if (defined(sun) && (defined(__sparc) || defined(sparc))) || \ + (defined(__uxp__) && (defined(sparc) || defined(mc68000))) || \ + defined(__sparc__) || defined(__mc68000__) + +#if defined(__sparc) || defined(__sparc__) +# if !defined(sparc) +# define sparc 1 +# endif +#endif + +#if defined(sun386) || defined(sun5) +# define IMAGE_BYTE_ORDER LSBFirst /* Values for the SUN only */ +# define BITMAP_BIT_ORDER LSBFirst +#else +# define IMAGE_BYTE_ORDER MSBFirst /* Values for the SUN only */ +# define BITMAP_BIT_ORDER MSBFirst +#endif + +#ifdef sparc +# define AVOID_MEMORY_READ +# define LARGE_INSTRUCTION_CACHE +# define FAST_CONSTANT_OFFSET_MODE +# define SHARED_IDCACHE +#endif + +#ifdef mc68020 +#define FAST_UNALIGNED_READS +#endif + +#define GLYPHPADBYTES 4 +#define GETLEFTBITS_ALIGNMENT 1 + +#endif /* sun && !(i386 && SVR4) */ + + +#if defined(AIXV3) + +#define IMAGE_BYTE_ORDER MSBFirst /* Values for the RISC/6000 */ +#define BITMAP_BIT_ORDER MSBFirst +#define GLYPHPADBYTES 4 +#define GETLEFTBITS_ALIGNMENT 1 + +#define LARGE_INSTRUCTION_CACHE +#define FAST_CONSTANT_OFFSET_MODE +#define PLENTIFUL_REGISTERS +#define AVOID_MEMORY_READ + +#define FAST_MEMCPY +#endif /* AIXV3 */ + +#if defined(ibm032) || defined (ibm) + +#ifdef i386 +# define IMAGE_BYTE_ORDER LSBFirst /* Value for PS/2 only */ +#else +# define IMAGE_BYTE_ORDER MSBFirst /* Values for the RT only*/ +#endif +#define BITMAP_BIT_ORDER MSBFirst +#define GLYPHPADBYTES 1 +#define GETLEFTBITS_ALIGNMENT 4 +/* ibm pcc doesn't understand pragmas. */ + +#ifdef i386 +#define BITMAP_SCANLINE_UNIT 8 +#endif + +#endif /* ibm */ + +#if defined (M4310) || defined(M4315) || defined(M4317) || defined(M4319) || defined(M4330) + +#define IMAGE_BYTE_ORDER MSBFirst /* Values for Pegasus only */ +#define BITMAP_BIT_ORDER MSBFirst +#define GLYPHPADBYTES 4 +#define GETLEFTBITS_ALIGNMENT 1 + +#define FAST_UNALIGNED_READS + +#endif /* tektronix */ + +#ifdef macII + +#define IMAGE_BYTE_ORDER MSBFirst /* Values for the MacII only */ +#define BITMAP_BIT_ORDER MSBFirst +#define GLYPHPADBYTES 4 +#define GETLEFTBITS_ALIGNMENT 1 + +/* might want FAST_UNALIGNED_READS for frame buffers with < 1us latency */ + +#endif /* macII */ + +#if (defined(mips) || defined(__mips)) && !defined(sgi) + +#if defined(MIPSEL) || defined(__MIPSEL__) +# define IMAGE_BYTE_ORDER LSBFirst /* Values for the PMAX only */ +# define BITMAP_BIT_ORDER LSBFirst +# define GLYPHPADBYTES 4 +# define GETLEFTBITS_ALIGNMENT 1 #else -#error "Too weird to live." +# define IMAGE_BYTE_ORDER MSBFirst /* Values for the MIPS only */ +# define BITMAP_BIT_ORDER MSBFirst +# define GLYPHPADBYTES 4 +# define GETLEFTBITS_ALIGNMENT 1 +#endif + +#define AVOID_MEMORY_READ +#define FAST_CONSTANT_OFFSET_MODE +#define LARGE_INSTRUCTION_CACHE +#define PLENTIFUL_REGISTERS + +#endif /* mips */ + +#if defined(__alpha) || defined(__alpha__) || defined(__alphaCross) +# define IMAGE_BYTE_ORDER LSBFirst /* Values for the Alpha only */ + +# if defined(XF86MONOVGA) || defined(XF86VGA16) || defined(XF86MONO) +# define BITMAP_BIT_ORDER MSBFirst +# else +# define BITMAP_BIT_ORDER LSBFirst +# endif + +# if defined(XF86MONOVGA) || defined(XF86VGA16) +# define BITMAP_SCANLINE_UNIT 8 +# endif + +# define GLYPHPADBYTES 4 +# define GETLEFTBITS_ALIGNMENT 1 +# define FAST_CONSTANT_OFFSET_MODE +# define LARGE_INSTRUCTION_CACHE +# define PLENTIFUL_REGISTERS + +#endif /* alpha */ + +#if defined (linux) && defined (__s390__) + +#define IMAGE_BYTE_ORDER MSBFirst +#define BITMAP_BIT_ORDER MSBFirst +#define GLYPHPADBYTES 4 +#define GETLEFTBITS_ALIGNMENT 1 + +#define BITMAP_SCANLINE_UNIT 8 +#define LARGE_INSTRUCTION_CACHE +#define FAST_CONSTANT_OFFSET_MODE +#define FAST_UNALIGNED_READ + +#define FAST_MEMCPY + +#endif /* linux/s390 */ + +#if defined (linux) && defined (__s390x__) + +#define IMAGE_BYTE_ORDER MSBFirst +#define BITMAP_BIT_ORDER MSBFirst +#define GLYPHPADBYTES 4 +#define GETLEFTBITS_ALIGNMENT 1 + +#define BITMAP_SCANLINE_UNIT 8 +#define LARGE_INSTRUCTION_CACHE +#define FAST_CONSTANT_OFFSET_MODE +#define FAST_UNALIGNED_READ + +#define FAST_MEMCPY +#endif /* linux/s390x */ + + +#if defined(__ia64__) || defined(ia64) +# define IMAGE_BYTE_ORDER LSBFirst + +# if defined(XF86MONOVGA) || defined(XF86VGA16) || defined(XF86MONO) +# define BITMAP_BIT_ORDER MSBFirst +# else +# define BITMAP_BIT_ORDER LSBFirst +# endif + +# if defined(XF86MONOVGA) || defined(XF86VGA16) +# define BITMAP_SCANLINE_UNIT 8 +# endif + +# define GLYPHPADBYTES 4 +# define GETLEFTBITS_ALIGNMENT 1 +# define FAST_CONSTANT_OFFSET_MODE +# define LARGE_INSTRUCTION_CACHE +# define PLENTIFUL_REGISTERS + +#endif /* ia64 */ + +#if defined(__amd64__) || defined(amd64) || defined(__amd64) +# define IMAGE_BYTE_ORDER LSBFirst + +# if defined(XF86MONOVGA) || defined(XF86VGA16) || defined(XF86MONO) +# define BITMAP_BIT_ORDER MSBFirst +# else +# define BITMAP_BIT_ORDER LSBFirst +# endif + +# if defined(XF86MONOVGA) || defined(XF86VGA16) +# define BITMAP_SCANLINE_UNIT 8 +# endif + +# define GLYPHPADBYTES 4 +# define GETLEFTBITS_ALIGNMENT 1 +# define LARGE_INSTRUCTION_CACHE +# define FAST_CONSTANT_OFFSET_MODE +/* ???? */ +# define FAST_UNALIGNED_READS +#endif /* AMD64 */ + +#ifdef stellar + +#define IMAGE_BYTE_ORDER MSBFirst /* Values for the stellar only*/ +#define BITMAP_BIT_ORDER MSBFirst +#define GLYPHPADBYTES 4 +#define GETLEFTBITS_ALIGNMENT 4 +#define IMAGE_BUFSIZE (64*1024) +/* + * Use SysV random number generator. + */ +#define random rand + +#endif /* stellar */ + +#ifdef luna + +#define IMAGE_BYTE_ORDER MSBFirst /* Values for the OMRON only*/ +#define BITMAP_BIT_ORDER MSBFirst +#define GLYPHPADBYTES 4 +#define GETLEFTBITS_ALIGNMENT 1 + +#ifndef mc68000 +#define FAST_CONSTANT_OFFSET_MODE +#define AVOID_MEMORY_READ +#define LARGE_INSTRUCTION_CACHE +#define PLENTIFUL_REGISTERS +#endif + +#endif /* luna */ + +#if (defined(SVR4) && defined(i386)) || \ + defined(__alpha__) || defined(__alpha) || \ + defined(__i386__) || defined(__i386) || \ + defined(__QNX__) || \ + defined(__s390x__) || defined(__s390__) + +#ifndef IMAGE_BYTE_ORDER +#define IMAGE_BYTE_ORDER LSBFirst +#endif + +#ifndef BITMAP_BIT_ORDER +# if defined(XF86MONOVGA) || defined(XF86VGA16) || defined(XF86MONO) +# define BITMAP_BIT_ORDER MSBFirst +# else +# define BITMAP_BIT_ORDER LSBFirst +# endif +#endif + +#ifndef BITMAP_SCANLINE_UNIT +# if defined(XF86MONOVGA) || defined(XF86VGA16) +# define BITMAP_SCANLINE_UNIT 8 +# endif #endif #ifndef GLYPHPADBYTES #define GLYPHPADBYTES 4 #endif - + +#define GETLEFTBITS_ALIGNMENT 1 +#define AVOID_MEMORY_READ +#ifdef XSVGA +#define AVOID_GLYPHBLT +#define FAST_CONSTANT_OFFSET_MODE +#define FAST_MEMCPY +#define NO_ONE_RECT +#endif + +#endif /* SVR4 / BSD / i386 */ + +#if defined (linux) && defined (__mc68000__) + +#define IMAGE_BYTE_ORDER MSBFirst +#define BITMAP_BIT_ORDER MSBFirst +#define FAST_UNALIGNED_READS +#define GLYPHPADBYTES 4 +#define GETLEFTBITS_ALIGNMENT 1 + +#endif /* linux/m68k */ + +#ifdef sgi + +#define IMAGE_BYTE_ORDER MSBFirst +#define BITMAP_BIT_ORDER MSBFirst +#define GLYPHPADBYTES 4 +#define GETLEFTBITS_ALIGNMENT 1 +#define AVOID_MEMORY_READ +#define FAST_CONSTANT_OFFSET_MODE +#define LARGE_INSTRUCTION_CACHE +#define PLENTIFUL_REGISTERS + +#endif + +/* linux on the Compaq Itsy */ +#if defined(linux) && defined(__arm__) +#define IMAGE_BYTE_ORDER LSBFirst +#define BITMAP_BIT_ORDER LSBFirst +#define GLYPHPADBYTES 4 +#define GETLEFTBITS_ALIGNMENT 1 +#endif + +/* linux on IBM S/390 */ +#if defined (linux) && defined (__s390__) +#define IMAGE_BYTE_ORDER MSBFirst +#define BITMAP_BIT_ORDER MSBFirst +#define GLYPHPADBYTES 4 +#define GETLEFTBITS_ALIGNMENT 1 +#endif /* linux/s390 */ + /* size of buffer to use with GetImage, measured in bytes. There's obviously * a trade-off between the amount of stack (or whatever ALLOCATE_LOCAL gives * you) used and the number of times the ddx routine has to be called. diff --git a/nx-X11/programs/Xserver/include/swaprep.h b/nx-X11/programs/Xserver/include/swaprep.h index 8a9dcf0360..bebd3a8140 100644 --- a/nx-X11/programs/Xserver/include/swaprep.h +++ b/nx-X11/programs/Xserver/include/swaprep.h @@ -91,9 +91,6 @@ extern void SQueryPointerReply( int /* size */, xQueryPointerReply * /* pRep */); -extern void SwapTimecoord( - xTimecoord * /* pCoord */); - extern void SwapTimeCoordWrite( ClientPtr /* pClient */, int /* size */, @@ -174,9 +171,6 @@ extern void SAllocColorPlanesReply( int /* size */, xAllocColorPlanesReply * /* pRep */); -extern void SwapRGB( - xrgb * /* prgb */); - extern void SQColorsExtend( ClientPtr /* pClient */, int /* size */, @@ -255,18 +249,6 @@ extern void WriteSConnectionInfo( unsigned long /* size */, char * /* pInfo */); -extern void SwapConnSetup( - xConnSetup * /* pConnSetup */, - xConnSetup * /* pConnSetupT */); - -extern void SwapWinRoot( - xWindowRoot * /* pRoot */, - xWindowRoot * /* pRootT */); - -extern void SwapVisual( - xVisualType * /* pVis */, - xVisualType * /* pVisT */); - extern void SwapConnSetupPrefix( xConnSetupPrefix * /* pcspFrom */, xConnSetupPrefix * /* pcspTo */); diff --git a/nx-X11/programs/Xserver/include/window.h b/nx-X11/programs/Xserver/include/window.h index 6e93e8ff8d..4d147ba564 100644 --- a/nx-X11/programs/Xserver/include/window.h +++ b/nx-X11/programs/Xserver/include/window.h @@ -92,14 +92,6 @@ extern Bool CreateRootWindow( extern void InitRootWindow( WindowPtr /*pWin*/); -extern void ClippedRegionFromBox( - WindowPtr /*pWin*/, - RegionPtr /*Rgn*/, - int /*x*/, - int /*y*/, - int /*w*/, - int /*h*/); - typedef WindowPtr (* RealChildHeadProc) (WindowPtr pWin); void RegisterRealChildHeadProc (RealChildHeadProc proc); @@ -204,12 +196,6 @@ extern void UnmapSubwindows( extern void HandleSaveSet( ClientPtr /*client*/); -extern Bool VisibleBoundingBoxFromPoint( - WindowPtr /*pWin*/, - int /*x*/, - int /*y*/, - BoxPtr /*box*/); - extern Bool PointInWindowIsVisible( WindowPtr /*pWin*/, int /*x*/, @@ -234,9 +220,6 @@ extern void CheckWindowOptionalNeed( extern Bool MakeWindowOptional( WindowPtr /*pWin*/); -extern void DisposeWindowOptional( - WindowPtr /*pWin*/); - extern WindowPtr MoveWindowInStack( WindowPtr /*pWin*/, WindowPtr /*pNextSib*/); @@ -254,6 +237,8 @@ void ResizeChildrenWinSize( int /*dw*/, int /*dh*/); +extern void ShapeExtensionInit(void); + extern void SendShapeNotify( WindowPtr /* pWin */, int /* which */ ); @@ -268,7 +253,5 @@ extern void DisableMapUnmapEvents( WindowPtr /* pWin */ ); extern void EnableMapUnmapEvents( WindowPtr /* pWin */ ); -extern Bool MapUnmapEventsEnabled( - WindowPtr /* pWin */ ); #endif /* WINDOW_H */ diff --git a/nx-X11/programs/Xserver/include/xkbsrv.h b/nx-X11/programs/Xserver/include/xkbsrv.h index 1447f5ce75..928da4e84f 100644 --- a/nx-X11/programs/Xserver/include/xkbsrv.h +++ b/nx-X11/programs/Xserver/include/xkbsrv.h @@ -124,6 +124,24 @@ typedef struct _XkbEventCause { #define _BEEP_LED_CHANGE 14 #define _BEEP_BOUNCE_REJECT 15 +struct _XkbSrvInfo; /* definition see below */ + +typedef struct _XkbFilter { + CARD16 keycode; + CARD8 what; + CARD8 active; + CARD8 filterOthers; + CARD32 priv; + XkbAction upAction; + int (*filter)( + struct _XkbSrvInfo* /* xkbi */, + struct _XkbFilter * /* filter */, + unsigned /* keycode */, + XkbAction * /* action */ + ); + struct _XkbFilter *next; +} XkbFilterRec,*XkbFilterPtr; + typedef struct _XkbSrvInfo { XkbStateRec prev_state; XkbStateRec state; @@ -167,6 +185,9 @@ typedef struct _XkbSrvInfo { OsTimerPtr bounceKeysTimer; OsTimerPtr repeatKeyTimer; OsTimerPtr krgTimer; + + int szFilters; + XkbFilterPtr filters; } XkbSrvInfoRec, *XkbSrvInfoPtr; #define XkbSLI_IsDefault (1L<<0) @@ -218,6 +239,14 @@ typedef struct _XkbSrvLedInfo { typedef struct { ProcessInputProc processInputProc; + /* If processInputProc is set to something different than realInputProc, + * UNWRAP and COND_WRAP will not touch processInputProc and update only + * realInputProc. This ensures that + * processInputProc == (frozen ? EnqueueEvent : realInputProc) + * + * WRAP_PROCESS_INPUT_PROC should only be called during initialization, + * since it may destroy this invariant. + */ ProcessInputProc realInputProc; DeviceUnwrapProc unwrapProc; } xkbDeviceInfoRec, *xkbDeviceInfoPtr; @@ -239,13 +268,19 @@ typedef struct oldprocs->unwrapProc = device->unwrapProc; \ device->unwrapProc = unwrapproc; -#define UNWRAP_PROCESS_INPUT_PROC(device, oldprocs) \ - device->public.processInputProc = oldprocs->processInputProc; \ +#define UNWRAP_PROCESS_INPUT_PROC(device, oldprocs, backupproc) \ + backupproc = device->public.realInputProc; \ + if (device->public.processInputProc == device->public.realInputProc)\ + device->public.processInputProc = oldprocs->realInputProc; \ device->public.realInputProc = oldprocs->realInputProc; \ device->unwrapProc = oldprocs->unwrapProc; +extern int xkbDevicePrivateIndex; #define XKBDEVICEINFO(dev) ((xkbDeviceInfoPtr) (dev)->devPrivates[xkbDevicePrivateIndex].ptr) +extern void xkbUnwrapProc(DeviceIntPtr, DeviceHandleProc, pointer); +extern void XkbFreePrivates(DeviceIntPtr); + /***====================================================================***/ extern void XkbFreePrivates(DeviceIntPtr); @@ -291,8 +326,9 @@ extern CARD32 xkbDebugFlags; #define _XkbErrCode3(a,b,c) _XkbErrCode2(a,(((unsigned int)(b))<<16)|(c)) #define _XkbErrCode4(a,b,c,d) _XkbErrCode3(a,b,((((unsigned int)(c))<<8)|(d))) -extern int DeviceKeyPress,DeviceKeyRelease; +extern int DeviceKeyPress,DeviceKeyRelease,DeviceMotionNotify; extern int DeviceButtonPress,DeviceButtonRelease; +extern int DeviceEnterNotify,DeviceLeaveNotify; #ifdef XINPUT #define _XkbIsPressEvent(t) (((t)==KeyPress)||((t)==DeviceKeyPress)) @@ -461,21 +497,6 @@ extern Bool XkbCheckActionVMods( unsigned int /* changed */ ); -extern Bool XkbApplyVModChanges( - XkbSrvInfoPtr /* xkbi */, - unsigned int /* changed */, - XkbChangesPtr /* pChanges */, - unsigned int * /* needChecksRtrn */, - XkbEventCausePtr /* cause */ -); - -extern void XkbApplyVModChangesToAllDevices( - DeviceIntPtr /* dev */, - XkbDescPtr /* xkb */, - unsigned int /* changed */, - XkbEventCausePtr /* cause */ -); - extern unsigned int XkbMaskForVMask( XkbDescPtr /* xkb */, unsigned int /* vmask */ @@ -1065,7 +1086,6 @@ extern Bool XkbDDXNamesFromRules( XkbComponentNamesPtr /* names */ ); - extern Bool XkbDDXApplyConfig( XPointer /* cfg_in */, XkbSrvInfoPtr /* xkbi */ diff --git a/nx-X11/programs/Xserver/mi/Imakefile b/nx-X11/programs/Xserver/mi/Imakefile index 46e5191ad5..149cbc1adb 100644 --- a/nx-X11/programs/Xserver/mi/Imakefile +++ b/nx-X11/programs/Xserver/mi/Imakefile @@ -27,11 +27,6 @@ NULL = #include -#if ! HasCbrt -CBRT_SRC = cbrt.c -CBRT_OBJ = cbrt.o -#endif - #if HasFfs FFS_DEFINES = -DHAS_FFS #endif @@ -39,8 +34,7 @@ FFS_DEFINES = -DHAS_FFS MIINITEXTSRC = miinitext.c MIINITEXTOBJ = miinitext.o -SRCS = $(CBRT_SRC) \ - mivaltree.c \ +SRCS = mivaltree.c \ mipolyseg.c \ mipolyrect.c \ mipoly.c \ @@ -77,8 +71,7 @@ SRCS = $(CBRT_SRC) \ miexpose.c \ $(NULL) -OBJS = $(CBRT_OBJ) \ - mivaltree.o \ +OBJS = mivaltree.o \ mipolyseg.o \ mipolyrect.o \ mipoly.o \ @@ -144,6 +137,7 @@ INCLUDES = -I. \ -I../xfixes \ -I../damageext \ -I../miext/damage \ + -I../Xi \ -I$(XINCLUDESRC) \ -I$(EXTINCSRC) \ -I$(SERVERSRC)/Xext \ @@ -162,10 +156,6 @@ NormalLibraryTarget(mi,$(OBJS)) LintLibraryTarget(mi,$(SRCS)) NormalLintTarget($(SRCS)) -#ifndef Win32Architecture -NormalLibraryTarget(cbrt,cbrt.o) -#endif - SpecialCObjectRule(miinitext,$(ICONFIGFILES),$(EXT_DEFINES)) SpecialCObjectRule(miscrinit,$(ICONFIGFILES),$(EXT_DEFINES)) diff --git a/nx-X11/programs/Xserver/mi/mi.h b/nx-X11/programs/Xserver/mi/mi.h index a1ad969ac2..680fced6d7 100644 --- a/nx-X11/programs/Xserver/mi/mi.h +++ b/nx-X11/programs/Xserver/mi/mi.h @@ -85,18 +85,6 @@ extern RegionPtr miCopyArea( int /*yOut*/ ); -extern void miOpqStipDrawable( - DrawablePtr /*pDraw*/, - GCPtr /*pGC*/, - RegionPtr /*prgnSrc*/, - MiBits * /*pbits*/, - int /*srcx*/, - int /*w*/, - int /*h*/, - int /*dstx*/, - int /*dsty*/ -); - extern RegionPtr miCopyPlane( DrawablePtr /*pSrcDrawable*/, DrawablePtr /*pDstDrawable*/, @@ -144,15 +132,6 @@ extern void miRecolorCursor( /* midash.c */ -extern miDashPtr miDashLine( - int /*npt*/, - DDXPointPtr /*ppt*/, - unsigned int /*nDash*/, - unsigned char * /*pDash*/, - unsigned int /*offset*/, - int * /*pnseg*/ -); - extern void miStepDash( int /*dist*/, int * /*pDashIndex*/, @@ -169,11 +148,11 @@ typedef struct _DeviceRec *DevicePtr; #endif extern Bool mieqInit( - DevicePtr /*pKbd*/, - DevicePtr /*pPtr*/ + void ); extern void mieqEnqueue( + DeviceIntPtr /*pDev*/, xEventPtr /*e*/ ); @@ -186,6 +165,9 @@ extern void mieqProcessInputEvents( void ); +typedef void (*mieqHandler)(int, xEventPtr, DeviceIntPtr, int); +void mieqSetHandler(int event, mieqHandler handler); + /* miexpose.c */ extern RegionPtr miHandleExposures( @@ -323,16 +305,6 @@ extern void miPolySegment( /* mipolytext.c */ -extern int miPolyText( - DrawablePtr /*pDraw*/, - GCPtr /*pGC*/, - int /*x*/, - int /*y*/, - int /*count*/, - char * /*chars*/, - FontEncoding /*fontEncoding*/ -); - extern int miPolyText8( DrawablePtr /*pDraw*/, GCPtr /*pGC*/, @@ -351,16 +323,6 @@ extern int miPolyText16( unsigned short * /*chars*/ ); -extern int miImageText( - DrawablePtr /*pDraw*/, - GCPtr /*pGC*/, - int /*x*/, - int /*y*/, - int /*count*/, - char * /*chars*/, - FontEncoding /*fontEncoding*/ -); - extern void miImageText8( DrawablePtr /*pDraw*/, GCPtr /*pGC*/, @@ -391,28 +353,26 @@ extern void miPushPixels( int /*yOrg*/ ); +/* miregion.c */ + /* see also region.h */ -extern Bool RegionRectAlloc( +extern Bool miRectAlloc( RegionPtr /*pRgn*/, int /*n*/ ); -extern void RegionSetExtents( - RegionPtr /*pReg*/ -); - extern int miFindMaxBand( RegionPtr /*prgn*/ ); #ifdef DEBUG -extern Bool RegionIsValid( +extern Bool miValidRegion( RegionPtr /*prgn*/ ); #endif -extern Bool RegionBroken(RegionPtr pReg); +extern Bool miRegionBroken(RegionPtr pReg); /* miscrinit.c */ @@ -426,10 +386,6 @@ extern Bool miModifyPixmapHeader( void * /*pPixData*/ ); -extern Bool miCloseScreen( - ScreenPtr /*pScreen*/ -); - extern Bool miCreateScreenResources( ScreenPtr /*pScreen*/ ); @@ -511,14 +467,6 @@ extern void miWideDash( DDXPointPtr /*pPts*/ ); -extern void miMiter( - void -); - -extern void miNotMiter( - void -); - /* miwindow.c */ extern void miClearToBackground( diff --git a/nx-X11/programs/Xserver/mi/miarc.c b/nx-X11/programs/Xserver/mi/miarc.c index 5695e24af3..bdbb01907c 100644 --- a/nx-X11/programs/Xserver/mi/miarc.c +++ b/nx-X11/programs/Xserver/mi/miarc.c @@ -51,14 +51,7 @@ SOFTWARE. #include #endif -#if defined(_XOPEN_SOURCE) \ - || (defined(sun) && defined(__SVR4)) #include -#else -#define _XOPEN_SOURCE /* to get prototype for hypot on some systems */ -#include -#undef _XOPEN_SOURCE -#endif #include #include #include "misc.h" @@ -75,10 +68,19 @@ static double miDsin(double a); static double miDcos(double a); static double miDasin(double v); static double miDatan2(double dy, double dx); -double cbrt(double); -#ifdef ICEILTEMPDECL -ICEILTEMPDECL +/* FIXME: this is really a makefile thing */ +#define HAVE_CBRT + +#ifndef HAVE_CBRT +static double +cbrt(double x) +{ + if (x > 0.0) + return pow(x, 1.0/3.0); + else + return -pow(-x, 1.0/3.0); +} #endif /* @@ -104,37 +106,16 @@ ICEILTEMPDECL #undef max #undef min -#if defined (__GNUC__) && !defined (__STRICT_ANSI__) -#define USE_INLINE -#endif - -#ifdef USE_INLINE -inline static const int max (const int x, const int y) -{ - return x>y? x:y; -} - -inline static const int min (const int x, const int y) -{ - return xy? x:y; } -static int -min (int x, int y) +_X_INLINE static int min (const int x, const int y) { return xlineWidth; int a0, a1, startAngle, endAngle; - miArcFacePtr temp; + miArcFacePtr temp; if (!l) l = 1; @@ -425,15 +406,8 @@ static unsigned long lrustamp; static arcCacheRec *lastCacheHit = &arcCache[0]; static RESTYPE cacheType; -/* - * External so it can be called when low on memory. - * Call with a zero ID in that case. - */ -/*ARGSUSED*/ -int -miFreeArcCache (data, id) - void * data; - XID id; +static int +miFreeArcCache (void * data, XID id) { int k; arcCacheRec *cent; @@ -461,11 +435,11 @@ miComputeCircleSpans( xArc *parc, miArcSpanData *spdata) { - register miArcSpan *span; + miArcSpan *span; int doinner; - register int x, y, e; + int x, y, e; int xk, yk, xm, ym, dx, dy; - register int slw, inslw; + int slw, inslw; int inx = 0, iny, ine = 0; int inxk = 0, inyk = 0, inxm = 0, inym = 0; @@ -529,7 +503,7 @@ miComputeEllipseSpans( xArc *parc, miArcSpanData *spdata) { - register miArcSpan *span; + miArcSpan *span; double w, h, r, xorg; double Hs, Hf, WH, K, Vk, Nk, Fk, Vr, N, Nc, Z, rs; double A, T, b, d, x, y, t, inx, outx = 0.0, hepp, hepm; @@ -859,13 +833,13 @@ tailX( static miArcSpanData * miComputeWideEllipse( - int lw, - register xArc *parc, - Bool *mustFree) + int lw, + xArc *parc, + Bool *mustFree) { - register miArcSpanData *spdata; - register arcCacheRec *cent, *lruent; - register int k; + miArcSpanData *spdata; + arcCacheRec *cent, *lruent; + int k; arcCacheRec fakeent; if (!lw) @@ -943,14 +917,14 @@ miFillWideEllipse( xArc *parc) { DDXPointPtr points; - register DDXPointPtr pts; + DDXPointPtr pts; int *widths; - register int *wids; + int *wids; miArcSpanData *spdata; Bool mustFree; - register miArcSpan *span; - register int xorg, yorgu, yorgl; - register int n; + miArcSpan *span; + int xorg, yorgu, yorgl; + int n; yorgu = parc->height + pGC->lineWidth; n = (sizeof(int) * 2) * yorgu; @@ -1077,20 +1051,20 @@ miPolyArc(pDraw, pGC, narcs, parcs) int narcs; xArc *parcs; { - register int i; - xArc *parc; - int xMin, xMax, yMin, yMax; - int pixmapWidth = 0, pixmapHeight = 0; - int xOrg = 0, yOrg = 0; - int width; - Bool fTricky; - DrawablePtr pDrawTo; - CARD32 fg, bg; - GCPtr pGCTo; - miPolyArcPtr polyArcs; - int cap[2], join[2]; - int iphase; - int halfWidth; + int i; + xArc *parc; + int xMin, xMax, yMin, yMax; + int pixmapWidth = 0, pixmapHeight = 0; + int xOrg = 0, yOrg = 0; + int width; + Bool fTricky; + DrawablePtr pDrawTo; + CARD32 fg, bg; + GCPtr pGCTo; + miPolyArcPtr polyArcs; + int cap[2], join[2]; + int iphase; + int halfWidth; width = pGC->lineWidth; if(width == 0 && pGC->lineStyle == LineSolid) @@ -1635,20 +1609,20 @@ miDatan2 (double dy, double dx) /* MIGETARCPTS -- Converts an arc into a set of line segments -- a helper * routine for filled arc and line (round cap) code. * Returns the number of points in the arc. Note that it takes a pointer - * to a pointer to where it should put the points and an index (cpt). + * to a void * to where it should put the points and an index (cpt). * This procedure allocates the space necessary to fit the arc points. * Sometimes it's convenient for those points to be at the end of an existing * array. (For example, if we want to leave a spare point to make sectors * instead of segments.) So we pass in the malloc()ed chunk that contains the * array and an index saying where we should start stashing the points. - * If there isn't an array already, we just pass in a null pointer and - * count on realloc() to handle the null pointer correctly. + * If there isn't an array already, we just pass in a null void * and + * count on realloc() to handle the null void * correctly. */ static int miGetArcPts( SppArcPtr parc, /* points to an arc */ int cpt, /* number of points already in arc list */ - SppPointPtr *ppPts) /* pointer to pointer to arc-list -- modified */ + SppPointPtr *ppPts) /* void * to void * to arc-list -- modified */ { double st, /* Start Theta, start angle */ et, /* End Theta, offset from start theta */ @@ -3137,12 +3111,12 @@ struct finalSpanChunk { static struct finalSpanChunk *chunks; -struct finalSpan * -realAllocSpan () +static struct finalSpan * +realAllocSpan (void) { - register struct finalSpanChunk *newChunk; - register struct finalSpan *span; - register int i; + struct finalSpanChunk *newChunk; + struct finalSpan *span; + int i; newChunk = (struct finalSpanChunk *) malloc (sizeof (struct finalSpanChunk)); if (!newChunk) @@ -3180,14 +3154,14 @@ fillSpans ( DrawablePtr pDrawable, GCPtr pGC) { - register struct finalSpan *span; - register DDXPointPtr xSpan; - register int *xWidth; - register int i; - register struct finalSpan **f; - register int spany; - DDXPointPtr xSpans; - int *xWidths; + struct finalSpan *span; + DDXPointPtr xSpan; + int *xWidth; + int i; + struct finalSpan **f; + int spany; + DDXPointPtr xSpans; + int *xWidths; if (nspans == 0) return; @@ -3281,13 +3255,13 @@ realFindSpan (int y) static void newFinalSpan ( int y, - register int xmin, - register int xmax) + int xmin, + int xmax) { - register struct finalSpan *x; - register struct finalSpan **f; - struct finalSpan *oldx; - struct finalSpan *prev; + struct finalSpan *x; + struct finalSpan **f; + struct finalSpan *oldx; + struct finalSpan *prev; f = findSpan (y); if (!f) diff --git a/nx-X11/programs/Xserver/mi/mibitblt.c b/nx-X11/programs/Xserver/mi/mibitblt.c index 67d36a7423..bcc59ca5a1 100644 --- a/nx-X11/programs/Xserver/mi/mibitblt.c +++ b/nx-X11/programs/Xserver/mi/mibitblt.c @@ -76,12 +76,12 @@ extern int ffs(int); RegionPtr miCopyArea(pSrcDrawable, pDstDrawable, pGC, xIn, yIn, widthSrc, heightSrc, xOut, yOut) - register DrawablePtr pSrcDrawable; - register DrawablePtr pDstDrawable; - GCPtr pGC; - int xIn, yIn; - int widthSrc, heightSrc; - int xOut, yOut; + DrawablePtr pSrcDrawable; + DrawablePtr pDstDrawable; + GCPtr pGC; + int xIn, yIn; + int widthSrc, heightSrc; + int xOut, yOut; { DDXPointPtr ppt, pptFirst; unsigned int *pwidthFirst, *pwidth, *pbits; @@ -358,7 +358,7 @@ miGetPlane( * Now get the bit and insert into a bitmap in XY format. */ bit = (pixel >> planeNum) & 1; -#ifndef XFree86Server +#if 0 /* XXX assuming bit order == byte order */ #if BITMAP_BIT_ORDER == LSBFirst bit <<= k; @@ -400,13 +400,9 @@ miGetPlane( * Note how the clipped out bits of the bitmap are always the background * color so that the stipple never causes FillRect to draw them. */ -void -miOpqStipDrawable(pDraw, pGC, prgnSrc, pbits, srcx, w, h, dstx, dsty) - DrawablePtr pDraw; - GCPtr pGC; - RegionPtr prgnSrc; - MiBits *pbits; - int srcx, w, h, dstx, dsty; +static void +miOpqStipDrawable(DrawablePtr pDraw, GCPtr pGC, RegionPtr prgnSrc, + MiBits *pbits, int srcx, int w, int h, int dstx, int dsty) { int oldfill, i; unsigned long oldfg; diff --git a/nx-X11/programs/Xserver/mi/mibstore.c b/nx-X11/programs/Xserver/mi/mibstore.c index e31db1d935..1b4a3ec1a1 100644 --- a/nx-X11/programs/Xserver/mi/mibstore.c +++ b/nx-X11/programs/Xserver/mi/mibstore.c @@ -150,11 +150,11 @@ static void miBSClearBackingRegion(WindowPtr pWin, RegionPtr pRgn); #define copyData(src,dst,n,morecopy) \ { \ - register short *srcCopy = (short *)(src); \ - register short *dstCopy = (short *)(dst); \ - register int i; \ - register int bsx = pBackingStore->x; \ - register int bsy = pBackingStore->y; \ + short *srcCopy = (short *)(src); \ + short *dstCopy = (short *)(dst); \ + int i; \ + int bsx = pBackingStore->x; \ + int bsy = pBackingStore->y; \ for (i = n; --i >= 0; ) \ { \ *dstCopy++ = *srcCopy++ - bsx; \ @@ -289,9 +289,6 @@ static void miBSPolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, static void miBSPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDst, int w, int h, int x, int y); -#ifdef NEED_LINEHELPER -static void miBSLineHelper(void); -#endif static GCOps miBSGCOps = { miBSFillSpans, miBSSetSpans, miBSPutImage, @@ -301,9 +298,6 @@ static GCOps miBSGCOps = { miBSPolyFillArc, miBSPolyText8, miBSPolyText16, miBSImageText8, miBSImageText16, miBSImageGlyphBlt, miBSPolyGlyphBlt, miBSPushPixels -#ifdef NEED_LINEHELPER - , miBSLineHelper -#endif }; #define FUNC_PROLOGUE(pGC, pPriv) \ @@ -952,8 +946,8 @@ miBSFillSpans(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted) DrawablePtr pDrawable; GCPtr pGC; int nInit; /* number of spans to fill */ - DDXPointPtr pptInit; /* pointer to list of start points */ - int *pwidthInit; /* pointer to list of n widths */ + DDXPointPtr pptInit; /* void * to list of start points */ + int *pwidthInit; /* void * to list of n widths */ int fSorted; { DDXPointPtr pptCopy, pptReset; @@ -1014,7 +1008,7 @@ miBSSetSpans(pDrawable, pGC, psrc, ppt, pwidth, nspans, fSorted) DrawablePtr pDrawable; GCPtr pGC; char *psrc; - register DDXPointPtr ppt; + DDXPointPtr ppt; int *pwidth; int nspans; int fSorted; @@ -1154,8 +1148,8 @@ miBSDoCopy( } *boxes; /* Array of box/drawable pairs covering * source box. */ int *sequence; /* Sequence of boxes to move */ - register int i, j, k, l, y; - register BoxPtr pBox; + int i, j, k, l, y; + BoxPtr pBox; int dx, dy, nrects; Bool graphicsExposures; CopyPlaneProcPtr pixCopyProc; @@ -1595,7 +1589,7 @@ static RegionPtr miBSCopyPlane (pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty, plane) DrawablePtr pSrc; DrawablePtr pDst; - register GC *pGC; + GC *pGC; int srcx, srcy; int w, @@ -1905,9 +1899,9 @@ miBSPolyArc(pDrawable, pGC, narcs, parcs) static void miBSFillPolygon(pDrawable, pGC, shape, mode, count, pPts) DrawablePtr pDrawable; - register GCPtr pGC; + GCPtr pGC; int shape, mode; - register int count; + int count; DDXPointPtr pPts; { DDXPointPtr pPtsCopy; @@ -2231,24 +2225,6 @@ miBSPushPixels(pGC, pBitMap, pDst, w, h, x, y) EPILOGUE (pGC); } -#ifdef NEED_LINEHELPER -/*- - *----------------------------------------------------------------------- - * miBSLineHelper -- - * - * Results: should never be called - * - * Side Effects: server dies - * - *----------------------------------------------------------------------- - */ -static void -miBSLineHelper() -{ - FatalError("miBSLineHelper called\n"); -} -#endif - /*- *----------------------------------------------------------------------- * miBSClearBackingStore -- @@ -2568,7 +2544,7 @@ static void miBSAllocate(pWin) WindowPtr pWin; { - register miBSWindowPtr pBackingStore; + miBSWindowPtr pBackingStore; if (pWin->drawable.pScreen->backingStoreSupport == NotUseful) return; @@ -2809,9 +2785,9 @@ miResizeBackingStore( */ static void miBSSaveDoomedAreas(pWin, pObscured, dx, dy) - register WindowPtr pWin; - RegionPtr pObscured; - int dx, dy; + WindowPtr pWin; + RegionPtr pObscured; + int dx, dy; { miBSWindowPtr pBackingStore; ScreenPtr pScreen; @@ -2916,14 +2892,14 @@ miBSSaveDoomedAreas(pWin, pObscured, dx, dy) */ static RegionPtr miBSRestoreAreas(pWin, prgnExposed) - register WindowPtr pWin; + WindowPtr pWin; RegionPtr prgnExposed; { PixmapPtr pBackingPixmap; miBSWindowPtr pBackingStore; RegionPtr prgnSaved; RegionPtr prgnRestored; - register ScreenPtr pScreen; + ScreenPtr pScreen; RegionPtr exposures = prgnExposed; pScreen = pWin->drawable.pScreen; @@ -3114,15 +3090,15 @@ miBSTranslateBackingStore(pWin, windx, windy, oldClip, oldx, oldy) int oldx; /* old window position */ int oldy; { - register miBSWindowPtr pBackingStore; - register RegionPtr pSavedRegion; - register RegionPtr newSaved, doomed; - register ScreenPtr pScreen; - BoxRec extents; - int scrdx; /* bit translation distance on screen */ - int scrdy; - int dx; /* distance window moved on screen */ - int dy; + miBSWindowPtr pBackingStore; + RegionPtr pSavedRegion; + RegionPtr newSaved, doomed; + ScreenPtr pScreen; + BoxRec extents; + int scrdx; /* bit translation distance on screen */ + int scrdy; + int dx; /* distance window moved on screen */ + int dy; pScreen = pWin->drawable.pScreen; pBackingStore = (miBSWindowPtr)(pWin->backStorage); @@ -3832,9 +3808,9 @@ miBSExposeCopy (pSrc, pDst, pGC, prgnExposed, srcx, srcy, dstx, dsty, plane) miBSWindowPtr pBackingStore; CopyPlaneProcPtr copyProc; GCPtr pScratchGC; - register BoxPtr pBox; - register int i; - register int dx, dy; + BoxPtr pBox; + int i; + int dx, dy; BITS32 gcMask; if (!RegionNotEmpty(prgnExposed)) diff --git a/nx-X11/programs/Xserver/mi/mibstore.h b/nx-X11/programs/Xserver/mi/mibstore.h index 5f3597074b..23abde26e5 100644 --- a/nx-X11/programs/Xserver/mi/mibstore.h +++ b/nx-X11/programs/Xserver/mi/mibstore.h @@ -12,7 +12,6 @@ * software for any purpose. It is provided "as is" without * express or implied warranty. * - * "$Xorg: mibstore.h,v 1.3 2000/08/17 19:53:37 cpqbld Exp $ */ diff --git a/nx-X11/programs/Xserver/mi/micmap.c b/nx-X11/programs/Xserver/mi/micmap.c index 3fd016712d..1af4ee5883 100644 --- a/nx-X11/programs/Xserver/mi/micmap.c +++ b/nx-X11/programs/Xserver/mi/micmap.c @@ -1,4 +1,3 @@ -/* $XConsortium: cfbcmap.c,v 4.19 94/04/17 20:28:46 dpw Exp $ */ /************************************************************ Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA. @@ -126,8 +125,8 @@ miResolveColor(unsigned short *pred, unsigned short *pgreen, Bool miInitializeColormap(ColormapPtr pmap) { - register unsigned i; - register VisualPtr pVisual; + unsigned i; + VisualPtr pVisual; unsigned lim, maxent, shift; pVisual = pmap->pVisual; @@ -212,13 +211,13 @@ int miExpandDirectColors(ColormapPtr pmap, int ndef, xColorItem *indefs, xColorItem *outdefs) { - register int red, green, blue; - int maxred, maxgreen, maxblue; - int stepred, stepgreen, stepblue; - VisualPtr pVisual; - register int pixel; - register int nresult; - register int i; + int red, green, blue; + int maxred, maxgreen, maxblue; + int stepred, stepgreen, stepblue; + VisualPtr pVisual; + int pixel; + int nresult; + int i; pVisual = pmap->pVisual; @@ -386,7 +385,7 @@ static int miVisualPriority[] = { static miVisualsPtr miVisuals; void -miClearVisualTypes() +miClearVisualTypes(void) { miVisualsPtr v; @@ -691,7 +690,7 @@ miDoInitVisuals(VisualPtr *visualp, DepthPtr *depthp, int *nvisualp, } void -miResetInitVisuals() +miResetInitVisuals(void) { miInitVisualsProc = miDoInitVisuals; } diff --git a/nx-X11/programs/Xserver/mi/midash.c b/nx-X11/programs/Xserver/mi/midash.c index 33fac339ba..80be85ea1d 100644 --- a/nx-X11/programs/Xserver/mi/midash.c +++ b/nx-X11/programs/Xserver/mi/midash.c @@ -52,229 +52,6 @@ SOFTWARE. #include "mistruct.h" #include "mifpoly.h" -static miDashPtr CheckDashStorage(miDashPtr *ppseg, int nseg, int *pnsegMax); - -/* return a list of DashRec. there will be an extra -entry at the end holding the last point of the polyline. - this means that the code that actually draws dashes can -get a pair of points for every dash. only the point in the last -dash record is useful; the other fields are not used. - nseg is the number of segments, not the number of points. - -example: - - dash1.start - dash2.start - dash3.start - last-point - -defines a list of segments - (dash1.pt, dash2.pt) - (dash2.pt, dash3.pt) - (dash3.pt, last-point) -and nseg == 3. - -NOTE: - EVEN_DASH == ~ODD_DASH - -NOTE ALSO: - miDashLines may return 0 segments, going from pt[0] to pt[0] with one dash. -*/ - -miDashPtr -miDashLine(npt, ppt, nDash, pDash, offset, pnseg) -int npt; -DDXPointPtr ppt; -unsigned int nDash; -unsigned char *pDash; -unsigned int offset; -int *pnseg; -{ - DDXPointRec pt1, pt2; - int lenCur; /* npt used from this dash */ - int lenMax; /* npt in this dash */ - int iDash = 0; /* index of current dash */ - int which; /* EVEN_DASH or ODD_DASH */ - miDashPtr pseg; /* list of dash segments */ - miDashPtr psegBase; /* start of list */ - int nseg = 0; /* number of dashes so far */ - int nsegMax = 0; /* num segs we can fit in this list */ - - int x, y, len; - int adx, ady, signdx, signdy; - int du, dv, e1, e2, e, base_e = 0; - - lenCur = offset; - which = EVEN_DASH; - while(lenCur >= pDash[iDash]) - { - lenCur -= pDash[iDash]; - iDash++; - if (iDash >= nDash) - iDash = 0; - which = ~which; - } - lenMax = pDash[iDash]; - - psegBase = (miDashPtr)NULL; - pt2 = ppt[0]; /* just in case there is only one point */ - - while(--npt) - { - if (PtEqual(ppt[0], ppt[1])) - { - ppt++; - continue; /* no duplicated points in polyline */ - } - pt1 = *ppt++; - pt2 = *ppt; - - adx = pt2.x - pt1.x; - ady = pt2.y - pt1.y; - signdx = sign(adx); - signdy = sign(ady); - adx = abs(adx); - ady = abs(ady); - - if (adx > ady) - { - du = adx; - dv = ady; - len = adx; - } - else - { - du = ady; - dv = adx; - len = ady; - } - - e1 = dv * 2; - e2 = e1 - 2*du; - e = e1 - du; - x = pt1.x; - y = pt1.y; - - nseg++; - pseg = CheckDashStorage(&psegBase, nseg, &nsegMax); - if (!pseg) - return (miDashPtr)NULL; - pseg->pt = pt1; - pseg->e1 = e1; - pseg->e2 = e2; - base_e = pseg->e = e; - pseg->which = which; - pseg->newLine = 1; - - while (len--) - { - if (adx > ady) - { - /* X_AXIS */ - if (((signdx > 0) && (e < 0)) || - ((signdx <=0) && (e <=0)) - ) - { - e += e1; - } - else - { - y += signdy; - e += e2; - } - x += signdx; - } - else - { - /* Y_AXIS */ - if (((signdx > 0) && (e < 0)) || - ((signdx <=0) && (e <=0)) - ) - { - e +=e1; - } - else - { - x += signdx; - e += e2; - } - y += signdy; - } - - lenCur++; - if (lenCur >= lenMax && (len || npt <= 1)) - { - nseg++; - pseg = CheckDashStorage(&psegBase, nseg, &nsegMax); - if (!pseg) - return (miDashPtr)NULL; - pseg->pt.x = x; - pseg->pt.y = y; - pseg->e1 = e1; - pseg->e2 = e2; - pseg->e = e; - which = ~which; - pseg->which = which; - pseg->newLine = 0; - - /* move on to next dash */ - iDash++; - if (iDash >= nDash) - iDash = 0; - lenMax = pDash[iDash]; - lenCur = 0; - } - } /* while len-- */ - } /* while --npt */ - - if (lenCur == 0 && nseg != 0) - { - nseg--; - which = ~which; - } - *pnseg = nseg; - pseg = CheckDashStorage(&psegBase, nseg+1, &nsegMax); - if (!pseg) - return (miDashPtr)NULL; - pseg->pt = pt2; - pseg->e = base_e; - pseg->which = which; - pseg->newLine = 0; - return psegBase; -} - - -#define NSEGDELTA 16 - -/* returns a pointer to the pseg[nseg-1], growing the storage as -necessary. this interface seems unnecessarily cumbersome. - -*/ - -static -miDashPtr -CheckDashStorage( - miDashPtr *ppseg, /* base pointer */ - int nseg, /* number of segment we want to write to */ - int *pnsegMax) /* size (in segments) of list so far */ -{ - if (nseg > *pnsegMax) - { - miDashPtr newppseg; - - *pnsegMax += NSEGDELTA; - newppseg = (miDashPtr)realloc(*ppseg, - (*pnsegMax)*sizeof(miDashRec)); - if (!newppseg) - { - free(*ppseg); - return (miDashPtr)NULL; - } - *ppseg = newppseg; - } - return(*ppseg+(nseg-1)); -} - void miStepDash (dist, pDashIndex, pDash, numInDashList, pDashOffset) int dist; /* distance to step */ diff --git a/nx-X11/programs/Xserver/mi/midispcur.c b/nx-X11/programs/Xserver/mi/midispcur.c index 92d0fb15c5..f97621a0d2 100644 --- a/nx-X11/programs/Xserver/mi/midispcur.c +++ b/nx-X11/programs/Xserver/mi/midispcur.c @@ -180,7 +180,9 @@ miDCCloseScreen (pScreen) tossPix (pScreenPriv->pSave); tossPix (pScreenPriv->pTemp); #ifdef ARGB_CURSOR +#if 0 /* This has been free()d before */ tossPict (pScreenPriv->pRootPicture); +#endif tossPict (pScreenPriv->pTempPicture); #endif free ((void *) pScreenPriv); diff --git a/nx-X11/programs/Xserver/mi/mieq.c b/nx-X11/programs/Xserver/mi/mieq.c index fefb222c4b..96aa876794 100644 --- a/nx-X11/programs/Xserver/mi/mieq.c +++ b/nx-X11/programs/Xserver/mi/mieq.c @@ -1,5 +1,4 @@ /* - * $Xorg: mieq.c,v 1.4 2001/02/09 02:05:20 xorgcvs Exp $ * Copyright 1990, 1998 The Open Group @@ -33,6 +32,10 @@ in this Software without prior written authorization from The Open Group. * */ +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + # include # include # include @@ -41,7 +44,12 @@ in this Software without prior written authorization from The Open Group. # include "pixmapstr.h" # include "inputstr.h" # include "mi.h" +# include "mipointer.h" # include "scrnintstr.h" +# include +# include +# include "extinit.h" +# include "exglobals.h" #ifdef DPMSExtension # include "dpmsproc.h" @@ -49,37 +57,40 @@ in this Software without prior written authorization from The Open Group. # include #endif -#define QUEUE_SIZE 256 +#define QUEUE_SIZE 512 typedef struct _Event { - xEvent event; - ScreenPtr pScreen; + xEvent event[7]; + int nevents; + ScreenPtr pScreen; + DeviceIntPtr pDev; /* device this event _originated_ from */ } EventRec, *EventPtr; typedef struct _EventQueue { - HWEventQueueType head, tail; /* long for SetInputCheck */ - CARD32 lastEventTime; /* to avoid time running backwards */ - Bool lastMotion; - EventRec events[QUEUE_SIZE]; /* static allocation for signals */ - DevicePtr pKbd, pPtr; /* device pointer, to get funcs */ - ScreenPtr pEnqueueScreen; /* screen events are being delivered to */ - ScreenPtr pDequeueScreen; /* screen events are being dispatched to */ + HWEventQueueType head, tail; /* long for SetInputCheck */ + CARD32 lastEventTime; /* to avoid time running backwards */ + int lastMotion; /* device ID if last event motion? */ + EventRec events[QUEUE_SIZE]; /* static allocation for signals */ + ScreenPtr pEnqueueScreen; /* screen events are being delivered to */ + ScreenPtr pDequeueScreen; /* screen events are being dispatched to */ + mieqHandler handlers[128]; /* custom event handler */ } EventQueueRec, *EventQueuePtr; static EventQueueRec miEventQueue; Bool -mieqInit (pKbd, pPtr) - DevicePtr pKbd, pPtr; +mieqInit(void) { + int i; + miEventQueue.head = miEventQueue.tail = 0; miEventQueue.lastEventTime = GetTimeInMillis (); - miEventQueue.pKbd = pKbd; - miEventQueue.pPtr = pPtr; miEventQueue.lastMotion = FALSE; miEventQueue.pEnqueueScreen = screenInfo.screens[0]; miEventQueue.pDequeueScreen = miEventQueue.pEnqueueScreen; - SetInputCheck (&miEventQueue.head, &miEventQueue.tail); + for (i = 0; i < 128; i++) + miEventQueue.handlers[i] = NULL; + SetInputCheck(&miEventQueue.head, &miEventQueue.tail); return TRUE; } @@ -91,114 +102,152 @@ mieqInit (pKbd, pPtr) */ void -mieqEnqueue (e) - xEvent *e; +mieqEnqueue(DeviceIntPtr pDev, xEvent *e) { - HWEventQueueType oldtail, newtail; - Bool isMotion; - - oldtail = miEventQueue.tail; - isMotion = e->u.u.type == MotionNotify; - if (isMotion && miEventQueue.lastMotion && oldtail != miEventQueue.head) - { - if (oldtail == 0) - oldtail = QUEUE_SIZE; - oldtail = oldtail - 1; + unsigned int oldtail = miEventQueue.tail, newtail; + int isMotion = 0; + deviceValuator *v = (deviceValuator *) e; + EventPtr laste = &miEventQueue.events[(oldtail - 1) % + QUEUE_SIZE]; + deviceKeyButtonPointer *lastkbp = (deviceKeyButtonPointer *) + &laste->event[0]; + + if (e->u.u.type == MotionNotify) + isMotion = inputInfo.pointer->id; + else if (e->u.u.type == DeviceMotionNotify) + isMotion = pDev->id; + + /* We silently steal valuator events: just tack them on to the last + * motion event they need to be attached to. Sigh. */ + if (e->u.u.type == DeviceValuator) { + if (laste->nevents > 6) { + ErrorF("mieqEnqueue: more than six valuator events; dropping.\n"); + return; + } + if (oldtail == miEventQueue.head || + !(lastkbp->type == DeviceMotionNotify || + lastkbp->type == DeviceButtonPress || + lastkbp->type == DeviceButtonRelease || + lastkbp->type == ProximityIn || + lastkbp->type == ProximityOut) || + ((lastkbp->deviceid & DEVICE_BITS) != + (v->deviceid & DEVICE_BITS))) { + ErrorF("mieqEnequeue: out-of-order valuator event; dropping.\n"); + return; + } + memcpy(&(laste->event[laste->nevents++]), e, sizeof(xEvent)); + return; + } + + if (isMotion && isMotion == miEventQueue.lastMotion && + oldtail != miEventQueue.head) { + oldtail = (oldtail - 1) % QUEUE_SIZE; } - else - { - newtail = oldtail + 1; - if (newtail == QUEUE_SIZE) - newtail = 0; - /* Toss events which come in late */ - if (newtail == miEventQueue.head) + else { + newtail = (oldtail + 1) % QUEUE_SIZE; + /* Toss events which come in late. Usually this means your server's + * stuck in an infinite loop somewhere, but SIGIO is still getting + * handled. */ + if (newtail == miEventQueue.head) { + ErrorF("tossed event which came in late\n"); return; + } miEventQueue.tail = newtail; } - miEventQueue.lastMotion = isMotion; - miEventQueue.events[oldtail].event = *e; - /* - * Make sure that event times don't go backwards - this - * is "unnecessary", but very useful - */ + + memcpy(&(miEventQueue.events[oldtail].event[0]), e, sizeof(xEvent)); + miEventQueue.events[oldtail].nevents = 1; + + /* Make sure that event times don't go backwards - this + * is "unnecessary", but very useful. */ if (e->u.keyButtonPointer.time < miEventQueue.lastEventTime && miEventQueue.lastEventTime - e->u.keyButtonPointer.time < 10000) - { - miEventQueue.events[oldtail].event.u.keyButtonPointer.time = + miEventQueue.events[oldtail].event[0].u.keyButtonPointer.time = miEventQueue.lastEventTime; - } + miEventQueue.lastEventTime = - miEventQueue.events[oldtail].event.u.keyButtonPointer.time; + miEventQueue.events[oldtail].event[0].u.keyButtonPointer.time; miEventQueue.events[oldtail].pScreen = miEventQueue.pEnqueueScreen; + miEventQueue.events[oldtail].pDev = pDev; + + miEventQueue.lastMotion = isMotion; } void -mieqSwitchScreen (pScreen, fromDIX) - ScreenPtr pScreen; - Bool fromDIX; +mieqSwitchScreen(ScreenPtr pScreen, Bool fromDIX) { miEventQueue.pEnqueueScreen = pScreen; if (fromDIX) miEventQueue.pDequeueScreen = pScreen; } -/* - * Call this from ProcessInputEvents() - */ - -void mieqProcessInputEvents () +void +mieqSetHandler(int event, mieqHandler handler) { - EventRec *e; - int x, y; - xEvent xe; + if (handler && miEventQueue.handlers[event] != handler) + ErrorF("mieq: warning: overriding existing handler %p with %p for " + "event %d\n", miEventQueue.handlers[event], handler, event); + + miEventQueue.handlers[event] = handler; +} - while (miEventQueue.head != miEventQueue.tail) - { - if (screenIsSaved == SCREEN_SAVER_ON) - SaveScreens (SCREEN_SAVER_OFF, ScreenSaverReset); +/* Call this from ProcessInputEvents(). */ +void +mieqProcessInputEvents(void) +{ + EventRec *e = NULL; + int x = 0, y = 0; + DeviceIntPtr dev = NULL; + while (miEventQueue.head != miEventQueue.tail) { + if (screenIsSaved == SCREEN_SAVER_ON) + SaveScreens (SCREEN_SAVER_OFF, ScreenSaverReset); #ifdef DPMSExtension - else if (DPMSPowerLevel != DPMSModeOn) - SetScreenSaverTimer(); + else if (DPMSPowerLevel != DPMSModeOn) + SetScreenSaverTimer(); - if (DPMSPowerLevel != DPMSModeOn) - DPMSSet(DPMSModeOn); + if (DPMSPowerLevel != DPMSModeOn) + DPMSSet(DPMSModeOn); #endif - e = &miEventQueue.events[miEventQueue.head]; - /* - * Assumption - screen switching can only occur on motion events - */ - if (e->pScreen != miEventQueue.pDequeueScreen) - { - miEventQueue.pDequeueScreen = e->pScreen; - x = e->event.u.keyButtonPointer.rootX; - y = e->event.u.keyButtonPointer.rootY; - if (miEventQueue.head == QUEUE_SIZE - 1) - miEventQueue.head = 0; - else - ++miEventQueue.head; - NewCurrentScreen (miEventQueue.pDequeueScreen, x, y); - } - else - { - xe = e->event; - if (miEventQueue.head == QUEUE_SIZE - 1) - miEventQueue.head = 0; - else - ++miEventQueue.head; - switch (xe.u.u.type) - { - case KeyPress: - case KeyRelease: - (*miEventQueue.pKbd->processInputProc) - (&xe, (DeviceIntPtr)miEventQueue.pKbd, 1); - break; - default: - (*miEventQueue.pPtr->processInputProc) - (&xe, (DeviceIntPtr)miEventQueue.pPtr, 1); - break; - } - } + e = &miEventQueue.events[miEventQueue.head]; + /* Assumption - screen switching can only occur on motion events. */ + miEventQueue.head = (miEventQueue.head + 1) % QUEUE_SIZE; + + if (e->pScreen != miEventQueue.pDequeueScreen) { + miEventQueue.pDequeueScreen = e->pScreen; + x = e->event[0].u.keyButtonPointer.rootX; + y = e->event[0].u.keyButtonPointer.rootY; + NewCurrentScreen (miEventQueue.pDequeueScreen, x, y); + } + else { + /* If someone's registered a custom event handler, let them + * steal it. */ + if (miEventQueue.handlers[e->event->u.u.type]) { + miEventQueue.handlers[e->event->u.u.type](miEventQueue.pDequeueScreen->myNum, + e->event, dev, + e->nevents); + return; + } + + /* If this is a core event, make sure our keymap, et al, is + * changed to suit. */ + if (e->event[0].u.u.type == KeyPress || + e->event[0].u.u.type == KeyRelease) { + SwitchCoreKeyboard(e->pDev); + dev = inputInfo.keyboard; + } + else if (e->event[0].u.u.type == MotionNotify || + e->event[0].u.u.type == ButtonPress || + e->event[0].u.u.type == ButtonRelease) { + SwitchCorePointer(e->pDev); + dev = inputInfo.pointer; + } + else { + dev = e->pDev; + } + + dev->public.processInputProc(e->event, dev, e->nevents); + } } } diff --git a/nx-X11/programs/Xserver/mi/miexpose.c b/nx-X11/programs/Xserver/mi/miexpose.c index 40272f9628..b72a4069c3 100644 --- a/nx-X11/programs/Xserver/mi/miexpose.c +++ b/nx-X11/programs/Xserver/mi/miexpose.c @@ -129,15 +129,15 @@ exposing is done by the backing store's GraphicsExpose function, of course. RegionPtr miHandleExposures(pSrcDrawable, pDstDrawable, pGC, srcx, srcy, width, height, dstx, dsty, plane) - register DrawablePtr pSrcDrawable; - register DrawablePtr pDstDrawable; + DrawablePtr pSrcDrawable; + DrawablePtr pDstDrawable; GCPtr pGC; int srcx, srcy; int width, height; int dstx, dsty; unsigned long plane; { - register ScreenPtr pscr; + ScreenPtr pscr; RegionPtr prgnSrcClip; /* drawable-relative source clip */ RegionRec rgnSrcRec; RegionPtr prgnDstClip; /* drawable-relative dest clip */ @@ -386,9 +386,9 @@ miSendGraphicsExpose (client, pRgn, drawable, major, minor) if (pRgn && !RegionNil(pRgn)) { xEvent *pEvent; - register xEvent *pe; - register BoxPtr pBox; - register int i; + xEvent *pe; + BoxPtr pBox; + int i; int numRects; numRects = RegionNumRects(pRgn); @@ -430,12 +430,12 @@ void miSendExposures(pWin, pRgn, dx, dy) WindowPtr pWin; RegionPtr pRgn; - register int dx, dy; + int dx, dy; { - register BoxPtr pBox; + BoxPtr pBox; int numRects; - register xEvent *pEvent, *pe; - register int i; + xEvent *pEvent, *pe; + int i; pBox = RegionRects(pRgn); numRects = RegionNumRects(pRgn); @@ -492,7 +492,7 @@ miSendExposures(pWin, pRgn, dx, dy) void miWindowExposures(pWin, prgn, other_exposed) WindowPtr pWin; - register RegionPtr prgn, other_exposed; + RegionPtr prgn, other_exposed; { RegionPtr exposures = prgn; if (pWin->backStorage && prgn) @@ -626,7 +626,7 @@ tossGC ( void miPaintWindow(pWin, prgn, what) -register WindowPtr pWin; +WindowPtr pWin; RegionPtr prgn; int what; { @@ -654,10 +654,10 @@ int what; BoxRec box = {0}; WindowPtr pBgWin; GCPtr pGC; - register int i; - register BoxPtr pbox; - register ScreenPtr pScreen = pWin->drawable.pScreen; - register xRectangle *prect; + int i; + BoxPtr pbox; + ScreenPtr pScreen = pWin->drawable.pScreen; + xRectangle *prect; int numRects; gcmask = 0; diff --git a/nx-X11/programs/Xserver/mi/mifillarc.c b/nx-X11/programs/Xserver/mi/mifillarc.c index c967f3ab26..00d59c2ee3 100644 --- a/nx-X11/programs/Xserver/mi/mifillarc.c +++ b/nx-X11/programs/Xserver/mi/mifillarc.c @@ -54,8 +54,8 @@ Author: Bob Scheifler, MIT X Consortium void miFillArcSetup(arc, info) - register xArc *arc; - register miFillArcRec *info; + xArc *arc; + miFillArcRec *info; { info->y = arc->height >> 1; info->dy = arc->height & 1; @@ -107,10 +107,8 @@ miFillArcSetup(arc, info) } } -void -miFillArcDSetup(arc, info) - register xArc *arc; - register miFillArcDRec *info; +static void +miFillArcDSetup(xArc *arc, miFillArcDRec *info) { /* h^2 * (2x - 2xorg)^2 = w^2 * h^2 - w^2 * (2y - 2yorg)^2 */ /* even: xorg = yorg = 0 odd: xorg = .5, yorg = -.5 */ @@ -141,13 +139,13 @@ miFillArcDSetup(arc, info) static void miGetArcEdge( - register xArc *arc, - register miSliceEdgePtr edge, + xArc *arc, + miSliceEdgePtr edge, int k, Bool top, Bool left ) { - register int xady, y; + int xady, y; y = arc->height >> 1; if (!(arc->width & 1)) @@ -188,15 +186,9 @@ miGetArcEdge( } } -void -miEllipseAngleToSlope (angle, width, height, dxp, dyp, d_dxp, d_dyp) - int angle; - int width; - int height; - int *dxp; - int *dyp; - double *d_dxp; - double *d_dyp; +static void +miEllipseAngleToSlope (int angle, int width, int height, int *dxp, int *dyp, + double *d_dxp, double *d_dyp) { int dx, dy; double d_dx, d_dy, scale; @@ -271,13 +263,13 @@ miEllipseAngleToSlope (angle, width, height, dxp, dyp, d_dxp, d_dyp) static void miGetPieEdge( - register xArc *arc, - register int angle, - register miSliceEdgePtr edge, + xArc *arc, + int angle, + miSliceEdgePtr edge, Bool top, Bool left ) { - register int k; + int k; int dx, dy; miEllipseAngleToSlope (angle, arc->width, arc->height, &dx, &dy, 0, 0); @@ -316,11 +308,11 @@ miGetPieEdge( void miFillArcSliceSetup(arc, slice, pGC) - register xArc *arc; - register miArcSliceRec *slice; + xArc *arc; + miArcSliceRec *slice; GCPtr pGC; { - register int angle1, angle2; + int angle1, angle2; angle1 = arc->angle1; if (arc->angle2 < 0) @@ -550,14 +542,14 @@ miFillEllipseI( GCPtr pGC, xArc *arc ) { - register int x, y, e; + int x, y, e; int yk, xk, ym, xm, dx, dy, xorg, yorg; int slw; miFillArcRec info; DDXPointPtr points; - register DDXPointPtr pts; + DDXPointPtr pts; int *widths; - register int *wids; + int *wids; points = (DDXPointPtr)malloc(sizeof(DDXPointRec) * arc->height); if (!points) @@ -593,14 +585,14 @@ miFillEllipseD( GCPtr pGC, xArc *arc ) { - register int x, y; + int x, y; int xorg, yorg, dx, dy, slw; double e, yk, xk, ym, xm; miFillArcDRec info; DDXPointPtr points; - register DDXPointPtr pts; + DDXPointPtr pts; int *widths; - register int *wids; + int *wids; points = (DDXPointPtr)malloc(sizeof(DDXPointRec) * arc->height); if (!points) @@ -659,14 +651,14 @@ miFillArcSliceI( xArc *arc ) { int yk, xk, ym, xm, dx, dy, xorg, yorg, slw; - register int x, y, e; + int x, y, e; miFillArcRec info; miArcSliceRec slice; int ya, xl, xr, xc; DDXPointPtr points; - register DDXPointPtr pts; + DDXPointPtr pts; int *widths; - register int *wids; + int *wids; miFillArcSetup(arc, &info); miFillArcSliceSetup(arc, &slice, pGC); @@ -721,16 +713,16 @@ miFillArcSliceD( GCPtr pGC, xArc *arc ) { - register int x, y; + int x, y; int dx, dy, xorg, yorg, slw; double e, yk, xk, ym, xm; miFillArcDRec info; miArcSliceRec slice; int ya, xl, xr, xc; DDXPointPtr points; - register DDXPointPtr pts; + DDXPointPtr pts; int *widths; - register int *wids; + int *wids; miFillArcDSetup(arc, &info); miFillArcSliceSetup(arc, &slice, pGC); @@ -790,8 +782,8 @@ miPolyFillArc(pDraw, pGC, narcs, parcs) int narcs; xArc *parcs; { - register int i; - register xArc *arc; + int i; + xArc *arc; for(i = narcs, arc = parcs; --i >= 0; arc++) { diff --git a/nx-X11/programs/Xserver/mi/mifillarc.h b/nx-X11/programs/Xserver/mi/mifillarc.h index 0afee1c5e8..3e3bb9858b 100644 --- a/nx-X11/programs/Xserver/mi/mifillarc.h +++ b/nx-X11/programs/Xserver/mi/mifillarc.h @@ -176,35 +176,11 @@ typedef struct _miArcSlice { #define miFillInArcLower(slw) (((iny + dy) != 0) && \ ((slw > 1) || (ine != inxk))) -extern int miFreeArcCache( - void * /*data*/, - XID /*id*/ -); - -extern struct finalSpan *realAllocSpan( - void -); - extern void miFillArcSetup( xArc * /*arc*/, miFillArcRec * /*info*/ ); -extern void miFillArcDSetup( - xArc * /*arc*/, - miFillArcDRec * /*info*/ -); - -extern void miEllipseAngleToSlope( - int /*angle*/, - int /*width*/, - int /*height*/, - int * /*dxp*/, - int * /*dyp*/, - double * /*d_dxp*/, - double * /*d_dyp*/ -); - extern void miFillArcSliceSetup( xArc * /*arc*/, miArcSliceRec * /*slice*/, diff --git a/nx-X11/programs/Xserver/mi/mifillrct.c b/nx-X11/programs/Xserver/mi/mifillrct.c index ba1d29141e..6796c96dcd 100644 --- a/nx-X11/programs/Xserver/mi/mifillrct.c +++ b/nx-X11/programs/Xserver/mi/mifillrct.c @@ -74,16 +74,16 @@ miPolyFillRect(pDrawable, pGC, nrectFill, prectInit) xRectangle *prectInit; /* Pointer to first rectangle to fill */ { int i; - register int height; - register int width; - register xRectangle *prect; - int xorg; - register int yorg; - int maxheight; - DDXPointPtr pptFirst; - register DDXPointPtr ppt; - int *pwFirst; - register int *pw; + int height; + int width; + xRectangle *prect; + int xorg; + int yorg; + int maxheight; + DDXPointPtr pptFirst; + DDXPointPtr ppt; + int *pwFirst; + int *pw; if (pGC->miTranslate) { diff --git a/nx-X11/programs/Xserver/mi/mifpoly.h b/nx-X11/programs/Xserver/mi/mifpoly.h index 8f05076014..1c89486c6b 100644 --- a/nx-X11/programs/Xserver/mi/mifpoly.h +++ b/nx-X11/programs/Xserver/mi/mifpoly.h @@ -48,6 +48,8 @@ SOFTWARE. #ifndef __MIFPOLY_H__ #define __MIFPOLY_H__ +#include + #define EPSILON 0.000001 #define ISEQUAL(a,b) (Fabs((a) - (b)) <= EPSILON) #define UNEQUAL(a,b) (Fabs((a) - (b)) > EPSILON) @@ -66,20 +68,11 @@ SOFTWARE. #define SQSECANT 108.856472512142 /* 1/sin^2(11/2) - for 11o miter cutoff */ #define D2SECANT 5.21671526231167 /* 1/2*sin(11/2) - max extension per width */ -#ifdef NOINLINEICEIL -#define ICEIL(x) ((int)ceil(x)) -#else -#ifdef __GNUC__ -static __inline int ICEIL(double x) +static _X_INLINE int ICEIL(double x) { int _cTmp = x; return ((x == _cTmp) || (x < 0.0)) ? _cTmp : _cTmp+1; } -#else -#define ICEIL(x) ((((x) == (_cTmp = (x))) || ((x) < 0.0)) ? _cTmp : _cTmp+1) -#define ICEILTEMPDECL static int _cTmp; -#endif -#endif /* Point with sub-pixel positioning. In this case we use doubles, but * see mifpolycon.c for other suggestions diff --git a/nx-X11/programs/Xserver/mi/mifpolycon.c b/nx-X11/programs/Xserver/mi/mifpolycon.c index d544555e01..230e687735 100644 --- a/nx-X11/programs/Xserver/mi/mifpolycon.c +++ b/nx-X11/programs/Xserver/mi/mifpolycon.c @@ -55,13 +55,9 @@ SOFTWARE. #include "pixmapstr.h" #include "mifpoly.h" -static int GetFPolyYBounds(register SppPointPtr pts, int n, double yFtrans, +static int GetFPolyYBounds(SppPointPtr pts, int n, double yFtrans, int *by, int *ty); -#ifdef ICEILTEMPDECL -ICEILTEMPDECL -#endif - /* * Written by Todd Newman; April. 1987. * @@ -101,7 +97,7 @@ miFillSppPoly(dst, pgc, count, ptsIn, xTrans, yTrans, xFtrans, yFtrans) *width, *FirstWidth, /* output buffer */ *Marked; /* set if this vertex has been used */ - register int left, right, /* indices to first endpoints */ + int left, right, /* indices to first endpoints */ nextleft, nextright; /* indices to second endpoints */ DDXPointPtr ptsOut, @@ -251,13 +247,13 @@ miFillSppPoly(dst, pgc, count, ptsIn, xTrans, yTrans, xFtrans, yFtrans) static int GetFPolyYBounds( - register SppPointPtr pts, + SppPointPtr pts, int n, double yFtrans, int *by, int *ty) { - register SppPointPtr ptMin; + SppPointPtr ptMin; double ymin, ymax; SppPointPtr ptsStart = pts; diff --git a/nx-X11/programs/Xserver/mi/migc.c b/nx-X11/programs/Xserver/mi/migc.c index afd5031a49..d9c3c48418 100644 --- a/nx-X11/programs/Xserver/mi/migc.c +++ b/nx-X11/programs/Xserver/mi/migc.c @@ -31,7 +31,6 @@ from The Open Group. #include #endif -#include "regionstr.h" #include "scrnintstr.h" #include "gcstruct.h" #include "pixmapstr.h" @@ -202,7 +201,7 @@ miComputeCompositeClip(pGC, pDrawable) /* * if there is no client clip, we can get by with just keeping the - * pointer we got, and remembering whether or not should destroy (or + * void * we got, and remembering whether or not should destroy (or * maybe re-use) it later. this way, we avoid unnecessary copying of * regions. (this wins especially if many clients clip by children * and have no client clip.) diff --git a/nx-X11/programs/Xserver/mi/miglblt.c b/nx-X11/programs/Xserver/mi/miglblt.c index 462534bb60..ae4f3c3e6f 100644 --- a/nx-X11/programs/Xserver/mi/miglblt.c +++ b/nx-X11/programs/Xserver/mi/miglblt.c @@ -97,18 +97,18 @@ miPolyGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase) { int width, height; PixmapPtr pPixmap; - int nbyLine; /* bytes per line of padded pixmap */ + int nbyLine; /* bytes per line of padded pixmap */ FontPtr pfont; GCPtr pGCtmp; - register int i; - register int j; - unsigned char *pbits; /* buffer for PutImage */ - register unsigned char *pb; /* temp pointer into buffer */ - register CharInfoPtr pci; /* currect char info */ - register unsigned char *pglyph; /* pointer bits in glyph */ - int gWidth, gHeight; /* width and height of glyph */ - register int nbyGlyphWidth; /* bytes per scanline of glyph */ - int nbyPadGlyph; /* server padded line of glyph */ + int i; + int j; + unsigned char *pbits; /* buffer for PutImage */ + unsigned char *pb; /* temp void * into buffer */ + CharInfoPtr pci; /* currect char info */ + unsigned char *pglyph; /* void * bits in glyph */ + int gWidth, gHeight; /* width and height of glyph */ + int nbyGlyphWidth; /* bytes per scanline of glyph */ + int nbyPadGlyph; /* server padded line of glyph */ XID gcvals[3]; diff --git a/nx-X11/programs/Xserver/mi/miinitext.c b/nx-X11/programs/Xserver/mi/miinitext.c index 319cb1f2d5..3a0b455bbe 100644 --- a/nx-X11/programs/Xserver/mi/miinitext.c +++ b/nx-X11/programs/Xserver/mi/miinitext.c @@ -143,11 +143,7 @@ typedef void (*InitExtension)(void); #ifdef MITSHM #define _XSHM_SERVER_ -#ifdef LEGACY_XEXT_PROTO #include -#else -#include -#endif #endif #ifdef XTEST #define _XTEST_SERVER_ @@ -156,6 +152,9 @@ typedef void (*InitExtension)(void); #ifdef XKB #include #endif +#ifdef XACE +#include "xace.h" +#endif #ifdef XCSECURITY #define _SECURITY_SERVER #include @@ -214,25 +213,30 @@ extern void RecordExtensionInit(void); #ifdef DBE extern void DbeExtensionInit(void); #endif +#ifdef XACE +extern void XaceExtensionInit(void); +#endif #ifdef XCSECURITY +extern void SecurityExtensionSetup(void); extern void SecurityExtensionInit(void); #endif #ifdef XF86BIGFONT extern void XFree86BigfontExtensionInit(void); #endif #ifdef GLXEXT -/* -typedef struct __GLXprovider __GLXprovider; -extern __GLXprovider __glXMesaProvider; -extern void GlxPushProvider(__GLXprovider *impl); -*/ -#ifndef __DARWIN__ -extern void GlxExtensionInit(void); -#else -extern void DarwinGlxExtensionInit(void); +// typedef struct __GLXprovider __GLXprovider; +#ifdef INXDARWINAPP +extern __GLXprovider* __DarwinglXMesaProvider; +extern void DarwinGlxPushProvider(__GLXprovider *impl); +extern void DarwinGlxExtensionInit(INITARGS); extern void DarwinGlxWrapInitVisuals(miInitVisualsProcPtr *); -#endif -#endif +#else +// extern __GLXprovider __glXMesaProvider; +// extern void GlxPushProvider(__GLXprovider *impl); +extern void GlxExtensionInit(void); +extern void GlxWrapInitVisuals(miInitVisualsProcPtr *); +#endif // INXDARWINAPP +#endif // GLXEXT #ifdef XF86DRI extern void XFree86DRIExtensionInit(void); #endif @@ -367,12 +371,16 @@ void EnableDisableExtensionError(char *name, Bool enable) ErrorF(" %s\n", ext->name); } + /*ARGSUSED*/ void InitExtensions(argc, argv) int argc; char *argv[]; { +#ifdef XCSECURITY + SecurityExtensionSetup(); +#endif #ifdef PANORAMIX # if !defined(PRINT_ONLY_SERVER) && !defined(NO_PANORAMIX) if (!noPanoramiXExtension) PanoramiXExtensionInit(); @@ -384,7 +392,7 @@ InitExtensions(argc, argv) #ifdef MITSHM if (!noMITShmExtension) ShmExtensionInit(); #endif -#if defined(XINPUT) && !defined(NO_HW_ONLY_EXTS) +#if defined(XINPUT) if (!noXInputExtension) XInputExtensionInit(); #endif #ifdef XTEST @@ -408,7 +416,7 @@ InitExtensions(argc, argv) #ifdef XSYNC if (!noSyncExtension) SyncExtensionInit(); #endif -#if defined(XKB) && !defined(PRINT_ONLY_SERVER) && !defined(NO_HW_ONLY_EXTS) +#if defined(XKB) && !defined(PRINT_ONLY_SERVER) if (!noXkbExtension) XkbExtensionInit(); #endif #ifdef XCMISC @@ -420,6 +428,9 @@ InitExtensions(argc, argv) #ifdef DBE if (!noDbeExtension) DbeExtensionInit(); #endif +#ifdef XACE + XaceExtensionInit(); +#endif #ifdef XCSECURITY if (!noSecurityExtension) SecurityExtensionInit(); #endif @@ -434,16 +445,16 @@ InitExtensions(argc, argv) if (!noXFree86DRIExtension) XFree86DRIExtensionInit(); #endif #endif + #ifdef GLXEXT - /* - GlxPushProvider(&__glXMesaProvider); - */ -#ifndef __DARWIN__ - if (!noGlxExtension) GlxExtensionInit(); -#else +#ifdef INXDARWINAPP + DarwinGlxPushProvider(__DarwinglXMesaProvider); if (!noGlxExtension) DarwinGlxExtensionInit(); -#endif -#endif +#else + // GlxPushProvider(&__glXMesaProvider); + if (!noGlxExtension) GlxExtensionInit(); +#endif // INXDARWINAPP +#endif // GLXEXT #ifdef XFIXES /* must be before Render to layer DisplayCursor correctly */ if (!noXFixesExtension) XFixesExtensionInit(); @@ -473,9 +484,8 @@ InitVisualWrap() { miResetInitVisuals(); #ifdef GLXEXT -#ifdef __DARWIN__ +#ifdef INXDARWINAPP DarwinGlxWrapInitVisuals(&miInitVisualsProc); -#endif -#endif +#endif // INXDARWINAPP +#endif // GLXEXT } - diff --git a/nx-X11/programs/Xserver/mi/miline.h b/nx-X11/programs/Xserver/mi/miline.h index 7028485f0d..b97b8cf9d7 100644 --- a/nx-X11/programs/Xserver/mi/miline.h +++ b/nx-X11/programs/Xserver/mi/miline.h @@ -109,7 +109,7 @@ extern void miSetZeroLineBias( } #define SWAPINT(i, j) \ -{ register int _t = i; i = j; j = _t; } +{ int _t = i; i = j; j = _t; } #define SWAPPT(i, j) \ { DDXPointRec _t; _t = i; i = j; j = _t; } diff --git a/nx-X11/programs/Xserver/mi/mioverlay.c b/nx-X11/programs/Xserver/mi/mioverlay.c index c0d923a0f8..649d1a585f 100644 --- a/nx-X11/programs/Xserver/mi/mioverlay.c +++ b/nx-X11/programs/Xserver/mi/mioverlay.c @@ -54,8 +54,8 @@ typedef struct { } miOverlayScreenRec, *miOverlayScreenPtr; static unsigned long miOverlayGeneration = 0; -int miOverlayWindowIndex = -1; -int miOverlayScreenIndex = -1; +static int miOverlayWindowIndex = -1; +static int miOverlayScreenIndex = -1; static void RebuildTree(WindowPtr); static Bool HasUnderlayChildren(WindowPtr); @@ -1019,7 +1019,7 @@ miOverlayMoveWindow( static void miOverlayWindowExposures( WindowPtr pWin, - register RegionPtr prgn, + RegionPtr prgn, RegionPtr other_exposed ){ RegionPtr exposures = prgn; @@ -1106,7 +1106,7 @@ miOverlayRecomputeExposures ( WindowPtr pWin, void * value ){ - register ScreenPtr pScreen; + ScreenPtr pScreen; miOverlayTwoRegions *pValid = (miOverlayTwoRegions*)value; miOverlayTreePtr pTree = MIOVERLAY_GET_WINDOW_TREE(pWin); @@ -1161,10 +1161,10 @@ miOverlayResizeWindow( DDXPointRec oldpt; RegionPtr oldRegion = NULL, oldRegion2 = NULL; WindowPtr pFirstChange; - register WindowPtr pChild; + WindowPtr pChild; RegionPtr gravitate[StaticGravity + 1]; RegionPtr gravitate2[StaticGravity + 1]; - register unsigned g; + unsigned g; int nx, ny; /* destination x,y */ int newx, newy; /* new inner window position */ RegionPtr pRegion = NULL; @@ -1669,7 +1669,7 @@ miOverlayChangeBorderWidth( unsigned int width ){ int oldwidth; - register ScreenPtr pScreen; + ScreenPtr pScreen; Bool WasViewable = (Bool)(pWin->viewable); Bool HadBorder; #ifdef DO_SAVE_UNDERS diff --git a/nx-X11/programs/Xserver/mi/mipointer.c b/nx-X11/programs/Xserver/mi/mipointer.c index 5a874a4a0e..62baa41715 100644 --- a/nx-X11/programs/Xserver/mi/mipointer.c +++ b/nx-X11/programs/Xserver/mi/mipointer.c @@ -1,8 +1,3 @@ -/* - * mipointer.c - */ - - /* Copyright 1989, 1998 The Open Group @@ -43,6 +38,7 @@ in this Software without prior written authorization from The Open Group. # include "mipointrst.h" # include "cursorstr.h" # include "dixstruct.h" +# include "inputstr.h" # include int miPointerScreenIndex; @@ -52,7 +48,7 @@ static unsigned long miPointerGeneration = 0; #define SetupScreen(s) miPointerScreenPtr pScreenPriv = GetScreenPrivate(s) /* - * until more than one pointer device exists. + * until more than one void * device exists. */ static miPointerRec miPointer; @@ -69,6 +65,8 @@ static Bool miPointerSetCursorPosition(ScreenPtr pScreen, int x, int y, static Bool miPointerCloseScreen(ScreenPtr pScreen); static void miPointerMove(ScreenPtr pScreen, int x, int y, unsigned long time); +static xEvent* events; /* for WarpPointer MotionNotifies */ + Bool miPointerInitialize (pScreen, spriteFuncs, screenFuncs, waitForUpdate) ScreenPtr pScreen; @@ -114,7 +112,7 @@ miPointerInitialize (pScreen, spriteFuncs, screenFuncs, waitForUpdate) pScreen->RecolorCursor = miRecolorCursor; pScreen->PointerNonInterestBox = miPointerPointerNonInterestBox; /* - * set up the pointer object + * set up the void * object */ miPointer.pScreen = NULL; miPointer.pSpriteScreen = NULL; @@ -127,7 +125,9 @@ miPointerInitialize (pScreen, spriteFuncs, screenFuncs, waitForUpdate) miPointer.confined = FALSE; miPointer.x = 0; miPointer.y = 0; - miPointer.history_start = miPointer.history_end = 0; + + events = NULL; + return TRUE; } @@ -143,6 +143,8 @@ miPointerCloseScreen (pScreen) miPointer.pSpriteScreen = 0; pScreen->CloseScreen = pScreenPriv->CloseScreen; free ((void *) pScreenPriv); + free ((void *) events); + events = NULL; return (*pScreen->CloseScreen) (pScreen); } @@ -177,7 +179,7 @@ miPointerDisplayCursor (pScreen, pCursor) { miPointer.pCursor = pCursor; miPointer.pScreen = pScreen; - miPointerUpdate (); + miPointerUpdateSprite(inputInfo.pointer); return TRUE; } @@ -228,7 +230,7 @@ miPointerSetCursorPosition(pScreen, x, y, generateEvent) /* device dependent - must pend signal and call miPointerWarpCursor */ (*pScreenPriv->screenFuncs->WarpCursor) (pScreen, x, y); if (!generateEvent) - miPointerUpdate(); + miPointerUpdateSprite(inputInfo.pointer); return TRUE; } @@ -269,39 +271,6 @@ miPointerWarpCursor (pScreen, x, y) * Pointer/CursorDisplay interface routines */ -int -miPointerGetMotionBufferSize () -{ - return MOTION_SIZE; -} - -int -miPointerGetMotionEvents (pPtr, coords, start, stop, pScreen) - DeviceIntPtr pPtr; - xTimecoord *coords; - unsigned long start, stop; - ScreenPtr pScreen; -{ - int i; - int count = 0; - miHistoryPtr h; - - for (i = miPointer.history_start; i != miPointer.history_end;) - { - h = &miPointer.history[i]; - if (h->event.time >= stop) - break; - if (h->event.time >= start) - { - *coords++ = h->event; - count++; - } - if (++i == MOTION_SIZE) i = 0; - } - return count; -} - - /* * miPointerUpdate * @@ -310,19 +279,30 @@ miPointerGetMotionEvents (pPtr, coords, start, stop, pScreen) void miPointerUpdate () +{ + miPointerUpdateSprite(inputInfo.pointer); +} + +void +miPointerUpdateSprite (DeviceIntPtr pDev) { ScreenPtr pScreen; miPointerScreenPtr pScreenPriv; CursorPtr pCursor; int x, y, devx, devy; + if (!pDev || !(pDev->coreEvents || pDev == inputInfo.pointer)) + return; + pScreen = miPointer.pScreen; + if (!pScreen) + return; + x = miPointer.x; y = miPointer.y; devx = miPointer.devx; devy = miPointer.devy; - if (!pScreen) - return; + pScreenPriv = GetScreenPrivate (pScreen); /* * if the cursor has switched screens, disable the sprite @@ -379,15 +359,21 @@ miPointerUpdate () */ void -miPointerDeltaCursor (dx, dy, time) - int dx, dy; - unsigned long time; +miPointerDeltaCursor (int dx, int dy, unsigned long time) { - miPointerAbsoluteCursor (miPointer.x + dx, miPointer.y + dy, time); + int x = miPointer.x + dx, y = miPointer.y + dy; + + miPointerSetPosition(inputInfo.pointer, &x, &y, time); } void miPointerSetNewScreen(int screen_no, int x, int y) +{ + miPointerSetScreen(inputInfo.pointer, screen_no, x, y); +} + +void +miPointerSetScreen(DeviceIntPtr pDev, int screen_no, int x, int y) { miPointerScreenPtr pScreenPriv; ScreenPtr pScreen; @@ -403,17 +389,47 @@ miPointerSetNewScreen(int screen_no, int x, int y) ScreenPtr miPointerCurrentScreen () { - return (miPointer.pScreen); + return miPointerGetScreen(inputInfo.pointer); } -/* - * miPointerAbsoluteCursor. The void * has moved to x,y - */ +ScreenPtr +miPointerGetScreen(DeviceIntPtr pDev) +{ + return miPointer.pScreen; +} + +/* Move the void * to x, y on the current screen, update the sprite, and + * the motion history. Generates no events. Does not return changed x + * and y if they are clipped; use miPointerSetPosition instead. */ +void +miPointerAbsoluteCursor (int x, int y, unsigned long time) +{ + miPointerSetPosition(inputInfo.pointer, &x, &y, time); +} + +/* Move the void * on the current screen, and update the sprite. */ +static void +miPointerMoved (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y, + unsigned long time) +{ + SetupScreen(pScreen); + + if (pDev && (pDev->coreEvents || pDev == inputInfo.pointer) && + !pScreenPriv->waitForUpdate && pScreen == miPointer.pSpriteScreen) + { + miPointer.devx = x; + miPointer.devy = y; + if(!miPointer.pCursor->bits->emptyMask) + (*pScreenPriv->spriteFuncs->MoveCursor) (pScreen, x, y); + } + + miPointer.x = x; + miPointer.y = y; + miPointer.pScreen = pScreen; +} void -miPointerAbsoluteCursor (x, y, time) - int x, y; - unsigned long time; +miPointerSetPosition(DeviceIntPtr pDev, int *x, int *y, unsigned long time) { miPointerScreenPtr pScreenPriv; ScreenPtr pScreen; @@ -422,13 +438,17 @@ miPointerAbsoluteCursor (x, y, time) pScreen = miPointer.pScreen; if (!pScreen) return; /* called before ready */ - if (x < 0 || x >= pScreen->width || y < 0 || y >= pScreen->height) + + if (!pDev || !(pDev->coreEvents || pDev == inputInfo.pointer)) + return; + + if (*x < 0 || *x >= pScreen->width || *y < 0 || *y >= pScreen->height) { pScreenPriv = GetScreenPrivate (pScreen); if (!miPointer.confined) { newScreen = pScreen; - (*pScreenPriv->screenFuncs->CursorOffScreen) (&newScreen, &x, &y); + (*pScreenPriv->screenFuncs->CursorOffScreen) (&newScreen, x, y); if (newScreen != pScreen) { pScreen = newScreen; @@ -440,106 +460,61 @@ miPointerAbsoluteCursor (x, y, time) } } } - /* - * constrain the hot-spot to the current - * limits - */ - if (x < miPointer.limits.x1) - x = miPointer.limits.x1; - if (x >= miPointer.limits.x2) - x = miPointer.limits.x2 - 1; - if (y < miPointer.limits.y1) - y = miPointer.limits.y1; - if (y >= miPointer.limits.y2) - y = miPointer.limits.y2 - 1; - if (miPointer.x == x && miPointer.y == y && miPointer.pScreen == pScreen) + /* Constrain the sprite to the current limits. */ + if (*x < miPointer.limits.x1) + *x = miPointer.limits.x1; + if (*x >= miPointer.limits.x2) + *x = miPointer.limits.x2 - 1; + if (*y < miPointer.limits.y1) + *y = miPointer.limits.y1; + if (*y >= miPointer.limits.y2) + *y = miPointer.limits.y2 - 1; + + if (miPointer.x == *x && miPointer.y == *y && miPointer.pScreen == pScreen) return; - miPointerMove (pScreen, x, y, time); + + miPointerMoved(pDev, pScreen, *x, *y, time); +} + +void +miPointerPosition (int *x, int *y) +{ + miPointerGetPosition(inputInfo.pointer, x, y); } void -miPointerPosition (x, y) - int *x, *y; +miPointerGetPosition(DeviceIntPtr pDev, int *x, int *y) { *x = miPointer.x; *y = miPointer.y; } -/* - * miPointerMove. The void * has moved to x,y on current screen - */ - -static void -miPointerMove (pScreen, x, y, time) - ScreenPtr pScreen; - int x, y; - unsigned long time; +void +miPointerMove (ScreenPtr pScreen, int x, int y, unsigned long time) { - SetupScreen(pScreen); - xEvent xE; - miHistoryPtr history; - int prev, end, start; + int i, nevents; + int valuators[2]; - if (!pScreenPriv->waitForUpdate && pScreen == miPointer.pSpriteScreen) - { - miPointer.devx = x; - miPointer.devy = y; - if(!miPointer.pCursor->bits->emptyMask) - (*pScreenPriv->spriteFuncs->MoveCursor) (pScreen, x, y); - } - miPointer.x = x; - miPointer.y = y; - miPointer.pScreen = pScreen; + miPointerMoved(inputInfo.pointer, pScreen, x, y, time); + + /* generate motion notify */ + valuators[0] = x; + valuators[1] = y; - xE.u.u.type = MotionNotify; - xE.u.keyButtonPointer.rootX = x; - xE.u.keyButtonPointer.rootY = y; - xE.u.keyButtonPointer.time = time; - (*pScreenPriv->screenFuncs->EnqueueEvent) (&xE); - - end = miPointer.history_end; - start = miPointer.history_start; - prev = end - 1; - if (end == 0) - prev = MOTION_SIZE - 1; - history = &miPointer.history[prev]; - if (end == start || history->event.time != time) + if (!events) { - history = &miPointer.history[end]; - if (++end == MOTION_SIZE) - end = 0; - if (end == start) - { - start = end + 1; - if (start == MOTION_SIZE) - start = 0; - miPointer.history_start = start; - } - miPointer.history_end = end; - } - history->event.x = x; - history->event.y = y; - history->event.time = time; - history->pScreen = pScreen; -} + events = (xEvent*)calloc(sizeof(xEvent), GetMaximumEventsNum()); -void -_miRegisterPointerDevice (pScreen, pDevice) - ScreenPtr pScreen; - DeviceIntPtr pDevice; -{ - miPointer.pPointer = (DevicePtr)pDevice; -} + if (!events) + { + FatalError("Could not allocate event store.\n"); + return; + } + } -/* obsolete: for binary compatibility */ + nevents = GetPointerEvents(events, inputInfo.pointer, MotionNotify, 0, + POINTER_ABSOLUTE, 0, 2, valuators); -#ifdef miRegisterPointerDevice -#undef miRegisterPointerDevice -void -miRegisterPointerDevice (pScreen, pDevice) - ScreenPtr pScreen; - DevicePtr pDevice; -{ - miPointer.pPointer = pDevice; + for (i = 0; i < nevents; i++) + mieqEnqueue(inputInfo.pointer, &events[i]); } -#endif /* miRegisterPointerDevice */ diff --git a/nx-X11/programs/Xserver/mi/mipointer.h b/nx-X11/programs/Xserver/mi/mipointer.h index 4fd326fcef..1bce42c26c 100644 --- a/nx-X11/programs/Xserver/mi/mipointer.h +++ b/nx-X11/programs/Xserver/mi/mipointer.h @@ -1,9 +1,3 @@ -/* - * mipointer.h - * - */ - - /* Copyright 1989, 1998 The Open Group @@ -73,6 +67,7 @@ typedef struct _miPointerScreenFuncRec { int /* y */ ); void (*EnqueueEvent)( + DeviceIntPtr /* pDev */, xEventPtr /* event */ ); void (*NewEventScreen)( @@ -97,11 +92,11 @@ extern void miPointerWarpCursor( ScreenPtr /*pScreen*/, int /*x*/, int /*y*/ -); +) _X_DEPRECATED; extern int miPointerGetMotionBufferSize( void -); +) _X_DEPRECATED; extern int miPointerGetMotionEvents( DeviceIntPtr /*pPtr*/, @@ -111,49 +106,65 @@ extern int miPointerGetMotionEvents( ScreenPtr /*pScreen*/ ); +/* Deprecated in favour of miPointerUpdateSprite. */ extern void miPointerUpdate( void -); +) _X_DEPRECATED; +/* Deprecated in favour of miSetPointerPosition. */ extern void miPointerDeltaCursor( int /*dx*/, int /*dy*/, unsigned long /*time*/ -); - +) _X_DEPRECATED; extern void miPointerAbsoluteCursor( int /*x*/, int /*y*/, unsigned long /*time*/ -); +) _X_DEPRECATED; +/* Deprecated in favour of miGetPointerPosition. */ extern void miPointerPosition( int * /*x*/, int * /*y*/ -); - -#undef miRegisterPointerDevice -extern void miRegisterPointerDevice( - ScreenPtr /*pScreen*/, - DevicePtr /*pDevice*/ -); +) _X_DEPRECATED; +/* Deprecated in favour of miPointerSetScreen. */ extern void miPointerSetNewScreen( int, /*screen_no*/ - int, /*x*/ - int /*y*/ -); + int, /*x*/ + int /*y*/ +) _X_DEPRECATED; + +/* Deprecated in favour of miPointerGetScreen. */ extern ScreenPtr miPointerCurrentScreen( void -); - -#define miRegisterPointerDevice(pScreen,pDevice) \ - _miRegisterPointerDevice(pScreen,pDevice) - -extern void _miRegisterPointerDevice( - ScreenPtr /*pScreen*/, - DeviceIntPtr /*pDevice*/ -); +) _X_DEPRECATED; + +extern ScreenPtr miPointerGetScreen( + DeviceIntPtr pDev); +extern void miPointerSetScreen( + DeviceIntPtr pDev, + int screen_num, + int x, + int y); + +/* Returns the current cursor position. */ +extern void miPointerGetPosition( + DeviceIntPtr pDev, + int *x, + int *y); + +/* Moves the cursor to the specified position. May clip the co-ordinates: + * x and y are modified in-place. */ +extern void miPointerSetPosition( + DeviceIntPtr pDev, + int *x, + int *y, + unsigned long time); + +extern void miPointerUpdateSprite( + DeviceIntPtr pDev); extern int miPointerScreenIndex; diff --git a/nx-X11/programs/Xserver/mi/mipointrst.h b/nx-X11/programs/Xserver/mi/mipointrst.h index f1fbfe4f9d..782961c282 100644 --- a/nx-X11/programs/Xserver/mi/mipointrst.h +++ b/nx-X11/programs/Xserver/mi/mipointrst.h @@ -32,25 +32,15 @@ in this Software without prior written authorization from The Open Group. #include "mipointer.h" #include "scrnintstr.h" -#define MOTION_SIZE 256 - -typedef struct { - xTimecoord event; - ScreenPtr pScreen; -} miHistoryRec, *miHistoryPtr; - typedef struct { ScreenPtr pScreen; /* current screen */ ScreenPtr pSpriteScreen;/* screen containing current sprite */ CursorPtr pCursor; /* current cursor */ CursorPtr pSpriteCursor;/* cursor on screen */ BoxRec limits; /* current constraints */ - Bool confined; /* pointer can't change screens */ + Bool confined; /* void * can't change screens */ int x, y; /* hot spot location */ int devx, devy; /* sprite position */ - DevicePtr pPointer; /* pointer device structure */ - miHistoryRec history[MOTION_SIZE]; - int history_start, history_end; } miPointerRec, *miPointerPtr; typedef struct { diff --git a/nx-X11/programs/Xserver/mi/mipoly.c b/nx-X11/programs/Xserver/mi/mipoly.c index 97fe6669e5..e528e69402 100644 --- a/nx-X11/programs/Xserver/mi/mipoly.c +++ b/nx-X11/programs/Xserver/mi/mipoly.c @@ -69,14 +69,14 @@ SOFTWARE. void miFillPolygon(dst, pgc, shape, mode, count, pPts) DrawablePtr dst; - register GCPtr pgc; + GCPtr pgc; int shape, mode; - register int count; + int count; DDXPointPtr pPts; { int i; - register int xorg, yorg; - register DDXPointPtr ppt; + int xorg, yorg; + DDXPointPtr ppt; if (count == 0) return; diff --git a/nx-X11/programs/Xserver/mi/mipoly.h b/nx-X11/programs/Xserver/mi/mipoly.h index 8e04f67371..c1bab4943d 100644 --- a/nx-X11/programs/Xserver/mi/mipoly.h +++ b/nx-X11/programs/Xserver/mi/mipoly.h @@ -180,14 +180,6 @@ typedef struct _ScanLineListBlock { /* mipolyutil.c */ -extern Bool miInsertEdgeInET( - EdgeTable * /*ET*/, - EdgeTableEntry * /*ETE*/, - int /*scanline*/, - ScanLineListBlock ** /*SLLBlock*/, - int * /*iSLLBlock*/ -); - extern Bool miCreateETandAET( int /*count*/, DDXPointPtr /*pts*/, diff --git a/nx-X11/programs/Xserver/mi/mipolycon.c b/nx-X11/programs/Xserver/mi/mipolycon.c index 39d13f914a..b4e242393e 100644 --- a/nx-X11/programs/Xserver/mi/mipolycon.c +++ b/nx-X11/programs/Xserver/mi/mipolycon.c @@ -78,9 +78,9 @@ miFillConvexPoly(dst, pgc, count, ptsIn) int count; /* number of points */ DDXPointPtr ptsIn; /* the points */ { - register int xl = 0, xr = 0; /* x vals of left and right edges */ - register int dl = 0, dr = 0; /* decision variables */ - register int ml = 0, m1l = 0;/* left edge slope and slope+1 */ + int xl = 0, xr = 0; /* x vals of left and right edges */ + int dl = 0, dr = 0; /* decision variables */ + int ml = 0, m1l = 0;/* left edge slope and slope+1 */ int mr = 0, m1r = 0; /* right edge slope and slope+1 */ int incr1l = 0, incr2l = 0; /* left edge error increments */ int incr1r = 0, incr2r = 0; /* right edge error increments */ @@ -221,7 +221,7 @@ miFillConvexPoly(dst, pgc, count, ptsIn) static int getPolyYBounds(DDXPointPtr pts, int n, int *by, int *ty) { - register DDXPointPtr ptMin; + DDXPointPtr ptMin; int ymin, ymax; DDXPointPtr ptsStart = pts; diff --git a/nx-X11/programs/Xserver/mi/mipolygen.c b/nx-X11/programs/Xserver/mi/mipolygen.c index 9eb7568d4d..7d6f663198 100644 --- a/nx-X11/programs/Xserver/mi/mipolygen.c +++ b/nx-X11/programs/Xserver/mi/mipolygen.c @@ -72,12 +72,12 @@ miFillGeneralPoly(dst, pgc, count, ptsIn) int count; /* number of points */ DDXPointPtr ptsIn; /* the points */ { - register EdgeTableEntry *pAET; /* the Active Edge Table */ - register int y; /* the current scanline */ - register int nPts = 0; /* number of pts in buffer */ - register EdgeTableEntry *pWETE; /* Winding Edge Table */ - register ScanLineList *pSLL; /* Current ScanLineList */ - register DDXPointPtr ptsOut; /* ptr to output buffers */ + EdgeTableEntry *pAET; /* the Active Edge Table */ + int y; /* the current scanline */ + int nPts = 0; /* number of pts in buffer */ + EdgeTableEntry *pWETE; /* Winding Edge Table */ + ScanLineList *pSLL; /* Current ScanLineList */ + DDXPointPtr ptsOut; /* ptr to output buffers */ int *width; DDXPointRec FirstPoint[NUMPTSTOBUFFER]; /* the output buffers */ int FirstWidth[NUMPTSTOBUFFER]; diff --git a/nx-X11/programs/Xserver/mi/mipolypnt.c b/nx-X11/programs/Xserver/mi/mipolypnt.c index ff35213b6f..0721de554e 100644 --- a/nx-X11/programs/Xserver/mi/mipolypnt.c +++ b/nx-X11/programs/Xserver/mi/mipolypnt.c @@ -70,7 +70,7 @@ miPolyPoint(pDrawable, pGC, mode, npt, pptInit) XID fsOld, fsNew; int *pwidthInit, *pwidth; int i; - register xPoint *ppt; + xPoint *ppt; /* make pointlist origin relative */ if (mode == CoordModePrevious) diff --git a/nx-X11/programs/Xserver/mi/mipolytext.c b/nx-X11/programs/Xserver/mi/mipolytext.c index fcc834f605..5b3f1750d4 100644 --- a/nx-X11/programs/Xserver/mi/mipolytext.c +++ b/nx-X11/programs/Xserver/mi/mipolytext.c @@ -66,30 +66,6 @@ SOFTWARE. #include "dixfontstr.h" #include "mi.h" -int -miPolyText(pDraw, pGC, x, y, count, chars, fontEncoding) - DrawablePtr pDraw; - GCPtr pGC; - int x, y; - int count; - char *chars; - FontEncoding fontEncoding; -{ - unsigned long n, i; - int w; - CharInfoPtr charinfo[255]; /* encoding only has 1 byte for count */ - - GetGlyphs(pGC->font, (unsigned long)count, (unsigned char *)chars, - fontEncoding, &n, charinfo); - w = 0; - for (i=0; i < n; i++) w += charinfo[i]->metrics.characterWidth; - if (n != 0) - (*pGC->ops->PolyGlyphBlt)( - pDraw, pGC, x, y, n, charinfo, FONTGLYPHS(pGC->font)); - return x+w; -} - - int miPolyText8(pDraw, pGC, x, y, count, chars) DrawablePtr pDraw; @@ -112,7 +88,6 @@ miPolyText8(pDraw, pGC, x, y, count, chars) return x+w; } - int miPolyText16(pDraw, pGC, x, y, count, chars) DrawablePtr pDraw; @@ -136,31 +111,6 @@ miPolyText16(pDraw, pGC, x, y, count, chars) return x+w; } - -int -miImageText(pDraw, pGC, x, y, count, chars, fontEncoding) - DrawablePtr pDraw; - GCPtr pGC; - int x, y; - int count; - char *chars; - FontEncoding fontEncoding; -{ - unsigned long n, i; - FontPtr font = pGC->font; - int w; - CharInfoPtr charinfo[255]; - - GetGlyphs(font, (unsigned long)count, (unsigned char *)chars, - fontEncoding, &n, charinfo); - w = 0; - for (i=0; i < n; i++) w += charinfo[i]->metrics.characterWidth; - if (n !=0 ) - (*pGC->ops->ImageGlyphBlt)(pDraw, pGC, x, y, n, charinfo, FONTGLYPHS(font)); - return x+w; -} - - void miImageText8(pDraw, pGC, x, y, count, chars) DrawablePtr pDraw; @@ -179,7 +129,6 @@ miImageText8(pDraw, pGC, x, y, count, chars) (*pGC->ops->ImageGlyphBlt)(pDraw, pGC, x, y, n, charinfo, FONTGLYPHS(font)); } - void miImageText16(pDraw, pGC, x, y, count, chars) DrawablePtr pDraw; diff --git a/nx-X11/programs/Xserver/mi/mipolyutil.c b/nx-X11/programs/Xserver/mi/mipolyutil.c index 5e1b0a6092..f15e329d49 100644 --- a/nx-X11/programs/Xserver/mi/mipolyutil.c +++ b/nx-X11/programs/Xserver/mi/mipolyutil.c @@ -73,16 +73,12 @@ SOFTWARE. * bucket. Finally, we can insert it. * */ -Bool -miInsertEdgeInET(ET, ETE, scanline, SLLBlock, iSLLBlock) - EdgeTable *ET; - EdgeTableEntry *ETE; - int scanline; - ScanLineListBlock **SLLBlock; - int *iSLLBlock; +static Bool +miInsertEdgeInET(EdgeTable *ET, EdgeTableEntry *ETE, int scanline, + ScanLineListBlock **SLLBlock, int *iSLLBlock) { - register EdgeTableEntry *start, *prev; - register ScanLineList *pSLL, *pPrevSLL; + EdgeTableEntry *start, *prev; + ScanLineList *pSLL, *pPrevSLL; ScanLineListBlock *tmpSLLBlock; /* @@ -97,7 +93,7 @@ miInsertEdgeInET(ET, ETE, scanline, SLLBlock, iSLLBlock) } /* - * reassign pSLL (pointer to ScanLineList) if necessary + * reassign pSLL (void * to ScanLineList) if necessary */ if ((!pSLL) || (pSLL->scanline > scanline)) { @@ -166,15 +162,15 @@ miInsertEdgeInET(ET, ETE, scanline, SLLBlock, iSLLBlock) Bool miCreateETandAET(count, pts, ET, AET, pETEs, pSLLBlock) - register int count; - register DDXPointPtr pts; + int count; + DDXPointPtr pts; EdgeTable *ET; EdgeTableEntry *AET; - register EdgeTableEntry *pETEs; + EdgeTableEntry *pETEs; ScanLineListBlock *pSLLBlock; { - register DDXPointPtr top, bottom; - register DDXPointPtr PrevPt, CurrPt; + DDXPointPtr top, bottom; + DDXPointPtr PrevPt, CurrPt; int iSLLBlock = 0; int dy; @@ -262,10 +258,10 @@ miCreateETandAET(count, pts, ET, AET, pETEs, pSLLBlock) void miloadAET(AET, ETEs) - register EdgeTableEntry *AET, *ETEs; + EdgeTableEntry *AET, *ETEs; { - register EdgeTableEntry *pPrevAET; - register EdgeTableEntry *tmp; + EdgeTableEntry *pPrevAET; + EdgeTableEntry *tmp; pPrevAET = AET; AET = AET->next; @@ -310,11 +306,11 @@ miloadAET(AET, ETEs) */ void micomputeWAET(AET) - register EdgeTableEntry *AET; + EdgeTableEntry *AET; { - register EdgeTableEntry *pWETE; - register int inside = 1; - register int isInside = 0; + EdgeTableEntry *pWETE; + int inside = 1; + int isInside = 0; AET->nextWETE = (EdgeTableEntry *)NULL; pWETE = AET; @@ -349,12 +345,12 @@ micomputeWAET(AET) int miInsertionSort(AET) - register EdgeTableEntry *AET; + EdgeTableEntry *AET; { - register EdgeTableEntry *pETEchase; - register EdgeTableEntry *pETEinsert; - register EdgeTableEntry *pETEchaseBackTMP; - register int changed = 0; + EdgeTableEntry *pETEchase; + EdgeTableEntry *pETEinsert; + EdgeTableEntry *pETEchaseBackTMP; + int changed = 0; AET = AET->next; while (AET) @@ -386,9 +382,9 @@ miInsertionSort(AET) */ void miFreeStorage(pSLLBlock) - register ScanLineListBlock *pSLLBlock; + ScanLineListBlock *pSLLBlock; { - register ScanLineListBlock *tmpSLLBlock; + ScanLineListBlock *tmpSLLBlock; while (pSLLBlock) { diff --git a/nx-X11/programs/Xserver/mi/mipushpxl.c b/nx-X11/programs/Xserver/mi/mipushpxl.c index 2bea5ef854..9b09e33d9d 100644 --- a/nx-X11/programs/Xserver/mi/mipushpxl.c +++ b/nx-X11/programs/Xserver/mi/mipushpxl.c @@ -100,15 +100,15 @@ miPushPixels(pGC, pBitMap, pDrawable, dx, dy, xOrg, yOrg) int dx, dy, xOrg, yOrg; { int h, dxDivPPW, ibEnd; - MiBits *pwLineStart; - register MiBits *pw, *pwEnd; - register MiBits msk; - register int ib, w; - register int ipt; /* index into above arrays */ + MiBits *pwLineStart; + MiBits *pw, *pwEnd; + MiBits msk; + int ib, w; + int ipt; /* index into above arrays */ Bool fInBox; DDXPointRec pt[NPT], ptThisLine; int width[NPT]; -#ifdef XFree86Server +#if 1 MiBits startmask; if (screenInfo.bitmapBitOrder == IMAGE_BYTE_ORDER) if (screenInfo.bitmapBitOrder == LSBFirst) @@ -148,7 +148,7 @@ miPushPixels(pGC, pBitMap, pDrawable, dx, dy, xOrg, yOrg) while(pw < pwEnd) { w = *pw; -#ifdef XFree86Server +#if 1 msk = startmask; #else msk = (MiBits)(-1) ^ SCRRIGHT((MiBits)(-1), 1); @@ -181,7 +181,7 @@ miPushPixels(pGC, pBitMap, pDrawable, dx, dy, xOrg, yOrg) fInBox = FALSE; } } -#ifdef XFree86Server +#if 1 /* This is not quite right, but it'll do for now */ if (screenInfo.bitmapBitOrder == IMAGE_BYTE_ORDER) if (screenInfo.bitmapBitOrder == LSBFirst) @@ -204,7 +204,7 @@ miPushPixels(pGC, pBitMap, pDrawable, dx, dy, xOrg, yOrg) { /* Process final partial word on line */ w = *pw; -#ifdef XFree86Server +#if 1 msk = startmask; #else msk = (MiBits)(-1) ^ SCRRIGHT((MiBits)(-1), 1); @@ -237,7 +237,7 @@ miPushPixels(pGC, pBitMap, pDrawable, dx, dy, xOrg, yOrg) fInBox = FALSE; } } -#ifdef XFree86Server +#if 1 /* This is not quite right, but it'll do for now */ if (screenInfo.bitmapBitOrder == IMAGE_BYTE_ORDER) if (screenInfo.bitmapBitOrder == LSBFirst) diff --git a/nx-X11/programs/Xserver/mi/miscrinit.c b/nx-X11/programs/Xserver/mi/miscrinit.c index cb46d1fa7d..5078460b35 100644 --- a/nx-X11/programs/Xserver/mi/miscrinit.c +++ b/nx-X11/programs/Xserver/mi/miscrinit.c @@ -53,7 +53,7 @@ from The Open Group. typedef struct { - void * pbits; /* pointer to framebuffer */ + void * pbits; /* void * to framebuffer */ int width; /* delta to add to a framebuffer addr to move one row down */ } miScreenInitParmsRec, *miScreenInitParmsPtr; @@ -125,11 +125,8 @@ miModifyPixmapHeader(pPixmap, width, height, depth, bitsPerPixel, devKind, return TRUE; } - -/*ARGSUSED*/ -Bool -miCloseScreen (pScreen) - ScreenPtr pScreen; +static Bool +miCloseScreen (ScreenPtr pScreen) { return ((*pScreen->DestroyPixmap)((PixmapPtr)pScreen->devPrivate)); } @@ -183,7 +180,7 @@ miCreateScreenResources(pScreen) Bool miScreenDevPrivateInit(pScreen, width, pbits) - register ScreenPtr pScreen; + ScreenPtr pScreen; int width; void * pbits; { @@ -205,8 +202,8 @@ miScreenDevPrivateInit(pScreen, width, pbits) Bool miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width, rootDepth, numDepths, depths, rootVisual, numVisuals, visuals) - register ScreenPtr pScreen; - void * pbits; /* pointer to screen bits */ + ScreenPtr pScreen; + void * pbits; /* void * to screen bits */ int xsize, ysize; /* in pixels */ int dpix, dpiy; /* dots per inch */ int width; /* pixel width of frame buffer */ @@ -310,7 +307,7 @@ miAllocateGCPrivateIndex() } int miZeroLineScreenIndex; -unsigned int miZeroLineGeneration = 0; +static unsigned int miZeroLineGeneration = 0; void miSetZeroLineBias(pScreen, bias) diff --git a/nx-X11/programs/Xserver/mi/mispans.c b/nx-X11/programs/Xserver/mi/mispans.c index a8762d3233..e40bca61ed 100644 --- a/nx-X11/programs/Xserver/mi/mispans.c +++ b/nx-X11/programs/Xserver/mi/mispans.c @@ -78,9 +78,7 @@ void miInitSpanGroup(spanGroup) #define YMIN(spans) (spans->points[0].y) #define YMAX(spans) (spans->points[spans->count-1].y) -void miSubtractSpans (spanGroup, sub) - SpanGroup *spanGroup; - Spans *sub; +static void miSubtractSpans (SpanGroup *spanGroup, Spans *sub) { int i, subCount, spansCount; int ymin, ymax, xmin, xmax; @@ -188,8 +186,8 @@ void miAppendSpans(spanGroup, otherGroup, spans) SpanGroup *otherGroup; Spans *spans; { - register int ymin, ymax; - register int spansCount; + int ymin, ymax; + int spansCount; spansCount = spans->count; if (spansCount > 0) { @@ -226,21 +224,21 @@ void miFreeSpanGroup(spanGroup) } static void QuickSortSpansX( - register DDXPointRec points[], - register int widths[], - register int numSpans ) + DDXPointRec points[], + int widths[], + int numSpans ) { - register int x; - register int i, j, m; - register DDXPointPtr r; + int x; + int i, j, m; + DDXPointPtr r; /* Always called with numSpans > 1 */ /* Sorts only by x, as all y should be the same */ #define ExchangeSpans(a, b) \ { \ - DDXPointRec tpt; \ - register int tw; \ + DDXPointRec tpt; \ + int tw; \ \ tpt = points[a]; points[a] = points[b]; points[b] = tpt; \ tw = widths[a]; widths[a] = widths[b]; widths[b] = tw; \ @@ -249,7 +247,7 @@ static void QuickSortSpansX( do { if (numSpans < 9) { /* Do insertion sort */ - register int xprev; + int xprev; xprev = points[0].x; i = 1; @@ -313,14 +311,14 @@ static void QuickSortSpansX( static int UniquifySpansX( - Spans *spans, - register DDXPointRec *newPoints, - register int *newWidths ) + Spans *spans, + DDXPointRec *newPoints, + int *newWidths ) { - register int newx1, newx2, oldpt, i, y; - register DDXPointRec *oldPoints; - register int *oldWidths; - int *startNewWidths; + int newx1, newx2, oldpt, i, y; + DDXPointRec *oldPoints; + int *oldWidths; + int *startNewWidths; /* Always called with numSpans > 1 */ /* Uniquify the spans, and stash them into newPoints and newWidths. Return the @@ -364,9 +362,8 @@ static int UniquifySpansX( return (newWidths - startNewWidths) + 1; } /* UniquifySpansX */ -void -miDisposeSpanGroup (spanGroup) - SpanGroup *spanGroup; +static void +miDisposeSpanGroup (SpanGroup *spanGroup) { int i; Spans *spans; @@ -384,16 +381,16 @@ void miFillUniqueSpanGroup(pDraw, pGC, spanGroup) GCPtr pGC; SpanGroup *spanGroup; { - register int i; - register Spans *spans; - register Spans *yspans; - register int *ysizes; - register int ymin, ylength; + int i; + Spans *spans; + Spans *yspans; + int *ysizes; + int ymin, ylength; /* Outgoing spans for one big call to FillSpans */ - register DDXPointPtr points; - register int *widths; - register int count; + DDXPointPtr points; + int *widths; + int count; if (spanGroup->count == 0) return; @@ -538,24 +535,3 @@ void miFillUniqueSpanGroup(pDraw, pGC, spanGroup) spanGroup->ymin = MAXSHORT; spanGroup->ymax = MINSHORT; } - - -void miFillSpanGroup(pDraw, pGC, spanGroup) - DrawablePtr pDraw; - GCPtr pGC; - SpanGroup *spanGroup; -{ - register int i; - register Spans *spans; - - for (i = 0, spans = spanGroup->group; i != spanGroup->count; i++, spans++) { - (*pGC->ops->FillSpans) - (pDraw, pGC, spans->count, spans->points, spans->widths, TRUE); - free(spans->points); - free(spans->widths); - } - - spanGroup->count = 0; - spanGroup->ymin = MAXSHORT; - spanGroup->ymax = MINSHORT; -} /* FillSpanGroup */ diff --git a/nx-X11/programs/Xserver/mi/mispans.h b/nx-X11/programs/Xserver/mi/mispans.h index 0f980bff75..f7176de0e0 100644 --- a/nx-X11/programs/Xserver/mi/mispans.h +++ b/nx-X11/programs/Xserver/mi/mispans.h @@ -48,8 +48,8 @@ SOFTWARE. typedef struct { int count; /* number of spans */ - DDXPointPtr points; /* pointer to list of start points */ - int *widths; /* pointer to list of widths */ + DDXPointPtr points; /* void * to list of start points */ + int *widths; /* void * to list of widths */ } Spans; typedef struct { @@ -71,13 +71,6 @@ extern void miAppendSpans( Spans * /*spans*/ ); -/* Paint a span group, possibly with some overlap */ -extern void miFillSpanGroup( - DrawablePtr /*pDraw*/, - GCPtr /*pGC*/, - SpanGroup * /*spanGroup*/ -); - /* Paint a span group, insuring that each pixel is painted at most once */ extern void miFillUniqueSpanGroup( DrawablePtr /*pDraw*/, @@ -90,16 +83,7 @@ extern void miFreeSpanGroup( SpanGroup * /*spanGroup*/ ); -extern void miSubtractSpans( - SpanGroup * /*spanGroup*/, - Spans * /*sub*/ -); - -extern void miDisposeSpanGroup( - SpanGroup * /*spanGroup*/ -); - -extern int RegionClipSpans( +extern int miClipSpans( RegionPtr /*prgnDst*/, DDXPointPtr /*ppt*/, int * /*pwidth*/, diff --git a/nx-X11/programs/Xserver/mi/misprite.c b/nx-X11/programs/Xserver/mi/misprite.c index 62acb5d29e..f2d510f0ee 100644 --- a/nx-X11/programs/Xserver/mi/misprite.c +++ b/nx-X11/programs/Xserver/mi/misprite.c @@ -319,11 +319,11 @@ miSpriteGetSpans (pDrawable, wMax, ppt, pwidth, nspans, pdstStart) if (pDrawable->type == DRAWABLE_WINDOW && pScreenPriv->isUp) { - register DDXPointPtr pts; - register int *widths; - register int nPts; - register int xorg, - yorg; + DDXPointPtr pts; + int *widths; + int nPts; + int xorg, + yorg; xorg = pDrawable->x; yorg = pDrawable->y; diff --git a/nx-X11/programs/Xserver/mi/mivaltree.c b/nx-X11/programs/Xserver/mi/mivaltree.c index 21534cee05..26d85f4613 100644 --- a/nx-X11/programs/Xserver/mi/mivaltree.c +++ b/nx-X11/programs/Xserver/mi/mivaltree.c @@ -112,13 +112,13 @@ miShapedWindowIn (pScreen, universe, bounding, rect, x, y) ScreenPtr pScreen; RegionPtr universe, bounding; BoxPtr rect; - register int x, y; + int x, y; { - BoxRec box; - register BoxPtr boundBox; - int nbox; - Bool someIn, someOut; - register int t, x1, y1, x2, y2; + BoxRec box; + BoxPtr boundBox; + int nbox; + Bool someIn, someOut; + int t, x1, y1, x2, y2; nbox = RegionNumRects (bounding); boundBox = RegionRects (bounding); @@ -179,6 +179,17 @@ miRegisterRedirectBorderClipProc (SetRedirectBorderClipProcPtr setBorderClip, miGetRedirectBorderClipProc = getBorderClip; } +/* + * Manual redirected windows are treated as transparent; they do not obscure + * siblings or parent windows + */ + +#ifdef COMPOSITE +#define TreatAsTransparent(w) ((w)->redirectDraw == RedirectDrawManual) +#else +#define TreatAsTransparent(w) FALSE +#endif + #define HasParentRelativeBorder(w) (!(w)->borderIsPixel && \ HasBorder(w) && \ (w)->backgroundState == ParentRelative) @@ -202,16 +213,16 @@ miRegisterRedirectBorderClipProc (SetRedirectBorderClipProcPtr setBorderClip, */ static void miComputeClips ( - register WindowPtr pParent, - register ScreenPtr pScreen, - register RegionPtr universe, + WindowPtr pParent, + ScreenPtr pScreen, + RegionPtr universe, VTKind kind, RegionPtr exposed ) /* for intermediate calculations */ { int dx, dy; RegionRec childUniverse; - register WindowPtr pChild; + WindowPtr pChild; int oldVis, newVis; BoxRec borderSize; RegionRec childUnion; @@ -241,7 +252,7 @@ miComputeClips ( /* * In redirected drawing case, reset universe to borderSize */ - if (pParent->redirectDraw) + if (pParent->redirectDraw != RedirectDrawNone) { if (miSetRedirectBorderClipProc) (*miSetRedirectBorderClipProc) (pParent, universe); @@ -250,7 +261,7 @@ miComputeClips ( #endif oldVis = pParent->visibility; - switch (RegionContainsRect(universe, &borderSize)) + switch (RegionContainsRect(universe, &borderSize)) { case rgnIN: newVis = VisibilityUnobscured; @@ -409,7 +420,7 @@ miComputeClips ( RegionSubtract(&pParent->valdata->after.borderExposed, exposed, &pParent->winSize); - RegionCopy(&pParent->borderClip, universe); + RegionCopy(&pParent->borderClip, universe); /* * To get the right clipList for the parent, and to make doubly sure @@ -417,10 +428,10 @@ miComputeClips ( * border from the universe before proceeding. */ - RegionIntersect(universe, universe, &pParent->winSize); + RegionIntersect(universe, universe, &pParent->winSize); } else - RegionCopy(&pParent->borderClip, universe); + RegionCopy(&pParent->borderClip, universe); if ((pChild = pParent->firstChild) && pParent->mapped) { @@ -432,7 +443,7 @@ miComputeClips ( { for (; pChild; pChild = pChild->nextSib) { - if (pChild->viewable) + if (pChild->viewable && !TreatAsTransparent(pChild)) RegionAppend(&childUnion, &pChild->borderSize); } } @@ -440,7 +451,7 @@ miComputeClips ( { for (pChild = pParent->lastChild; pChild; pChild = pChild->prevSib) { - if (pChild->viewable) + if (pChild->viewable && !TreatAsTransparent(pChild)) RegionAppend(&childUnion, &pChild->borderSize); } } @@ -472,7 +483,7 @@ miComputeClips ( * from the current universe, thus denying its space to any * other sibling. */ - if (overlap) + if (overlap && !TreatAsTransparent (pChild)) RegionSubtract(universe, universe, &pChild->borderSize); } @@ -498,7 +509,7 @@ miComputeClips ( else if (newVis != VisibilityFullyObscured && newVis != VisibilityNotViewable) { - RegionSubtract(&pParent->valdata->after.exposed, + RegionSubtract(&pParent->valdata->after.exposed, universe, &pParent->clipList); } @@ -535,10 +546,10 @@ miComputeClips ( static void miTreeObscured( - register WindowPtr pParent ) + WindowPtr pParent ) { - register WindowPtr pChild; - register int oldVis; + WindowPtr pChild; + int oldVis; pChild = pParent; while (1) @@ -609,8 +620,8 @@ miValidateTree (pParent, pChild, kind) RegionRec childUnion; /* the space covered by borderSize for * all marked children */ RegionRec exposed; /* For intermediate calculations */ - register ScreenPtr pScreen; - register WindowPtr pWin; + ScreenPtr pScreen; + WindowPtr pWin; Bool overlap; int viewvals; Bool forward; @@ -644,7 +655,7 @@ miValidateTree (pParent, pChild, kind) for (pWin = pParent->firstChild; pWin != pChild; pWin = pWin->nextSib) { - if (pWin->viewable) + if (pWin->viewable && !TreatAsTransparent (pWin)) RegionSubtract(&totalClip, &totalClip, &pWin->borderSize); } for (pWin = pChild; pWin; pWin = pWin->nextSib) @@ -666,7 +677,7 @@ miValidateTree (pParent, pChild, kind) { RegionPtr pBorderClip = &pWin->borderClip; #ifdef COMPOSITE - if (pWin->redirectDraw && miGetRedirectBorderClipProc) + if (pWin->redirectDraw != RedirectDrawNone && miGetRedirectBorderClipProc) pBorderClip = (*miGetRedirectBorderClipProc)(pWin); #endif RegionAppend(&totalClip, pBorderClip ); @@ -685,7 +696,7 @@ miValidateTree (pParent, pChild, kind) { RegionPtr pBorderClip = &pWin->borderClip; #ifdef COMPOSITE - if (pWin->redirectDraw && miGetRedirectBorderClipProc) + if (pWin->redirectDraw != RedirectDrawNone && miGetRedirectBorderClipProc) pBorderClip = (*miGetRedirectBorderClipProc)(pWin); #endif RegionAppend(&totalClip, pBorderClip ); @@ -724,7 +735,7 @@ miValidateTree (pParent, pChild, kind) if (forward) { for (pWin = pChild; pWin; pWin = pWin->nextSib) - if (pWin->valdata && pWin->viewable) + if (pWin->valdata && pWin->viewable && !TreatAsTransparent (pWin)) RegionAppend(&childUnion, &pWin->borderSize); } @@ -733,7 +744,7 @@ miValidateTree (pParent, pChild, kind) pWin = pParent->lastChild; while (1) { - if (pWin->valdata && pWin->viewable) + if (pWin->valdata && pWin->viewable && !TreatAsTransparent (pWin)) RegionAppend(&childUnion, &pWin->borderSize); if (pWin == pChild) @@ -757,7 +768,7 @@ miValidateTree (pParent, pChild, kind) &totalClip, &pWin->borderSize); miComputeClips (pWin, pScreen, &childClip, kind, &exposed); - if (overlap) + if (overlap && !TreatAsTransparent (pWin)) { RegionSubtract(&totalClip, &totalClip, diff --git a/nx-X11/programs/Xserver/mi/miwideline.c b/nx-X11/programs/Xserver/mi/miwideline.c index eefed600ce..4cd480b5f7 100644 --- a/nx-X11/programs/Xserver/mi/miwideline.c +++ b/nx-X11/programs/Xserver/mi/miwideline.c @@ -52,14 +52,10 @@ from The Open Group. #include "miwideline.h" #include "mi.h" -#ifdef ICEILTEMPDECL -ICEILTEMPDECL -#endif - -static void miLineArc(DrawablePtr pDraw, register GCPtr pGC, +static void miLineArc(DrawablePtr pDraw, GCPtr pGC, unsigned long pixel, SpanDataPtr spanData, - register LineFacePtr leftFace, - register LineFacePtr rightFace, + LineFacePtr leftFace, + LineFacePtr rightFace, double xorg, double yorg, Bool isInt); @@ -67,24 +63,18 @@ static void miLineArc(DrawablePtr pDraw, register GCPtr pGC, * spans-based polygon filler */ -void -miFillPolyHelper (pDrawable, pGC, pixel, spanData, y, overall_height, - left, right, left_count, right_count) - DrawablePtr pDrawable; - GCPtr pGC; - unsigned long pixel; - SpanDataPtr spanData; - int y; /* start y coordinate */ - int overall_height; /* height of entire segment */ - PolyEdgePtr left, right; - int left_count, right_count; +static void +miFillPolyHelper (DrawablePtr pDrawable, GCPtr pGC, unsigned long pixel, + SpanDataPtr spanData, int y, int overall_height, + PolyEdgePtr left, PolyEdgePtr right, + int left_count, int right_count) { - register int left_x = 0, left_e = 0; + int left_x = 0, left_e = 0; int left_stepx = 0; int left_signdx = 0; int left_dy = 0, left_dx = 0; - register int right_x = 0, right_e = 0; + int right_x = 0, right_e = 0; int right_stepx = 0; int right_signdx = 0; int right_dy = 0, right_dx = 0; @@ -92,10 +82,10 @@ miFillPolyHelper (pDrawable, pGC, pixel, spanData, y, overall_height, int height = 0; int left_height = 0, right_height = 0; - register DDXPointPtr ppt; + DDXPointPtr ppt; DDXPointPtr pptInit = NULL; - register int *pwidth; - int *pwidthInit = NULL; + int *pwidth; + int *pwidthInit = NULL; XID oldPixel; int xorg; Spans spanRec; @@ -120,7 +110,7 @@ miFillPolyHelper (pDrawable, pGC, pixel, spanData, y, overall_height, if (pixel != oldPixel) { XID tmpPixel = (XID)pixel; - DoChangeGC (pGC, GCForeground, &tmpPixel, FALSE); + DoChangeGC (pGC, GCForeground, &tmpPixel, FALSE); ValidateGC (pDrawable, pGC); } } @@ -203,8 +193,8 @@ miFillRectPolyHelper ( int w, int h) { - register DDXPointPtr ppt; - register int *pwidth; + DDXPointPtr ppt; + int *pwidth; XID oldPixel; Spans spanRec; xRectangle rect; @@ -219,7 +209,7 @@ miFillRectPolyHelper ( if (pixel != oldPixel) { XID tmpPixel = (XID)pixel; - DoChangeGC (pGC, GCForeground, &tmpPixel, FALSE); + DoChangeGC (pGC, GCForeground, &tmpPixel, FALSE); ValidateGC (pDrawable, pGC); } (*pGC->ops->PolyFillRect) (pDrawable, pGC, 1, &rect); @@ -265,10 +255,10 @@ miFillRectPolyHelper ( miPolyBuildEdge (x0, y0, k, dx, dy, xi, yi, left, edge) double x0, y0; double k; /* x0 * dy - y0 * dx */ - register int dx, dy; + int dx, dy; int xi, yi; int left; - register PolyEdgePtr edge; + PolyEdgePtr edge; { int x, y, e; int xady; @@ -322,23 +312,23 @@ miPolyBuildEdge (x0, y0, k, dx, dy, xi, yi, left, edge) /* static */ int miPolyBuildPoly (vertices, slopes, count, xi, yi, left, right, pnleft, pnright, h) - register PolyVertexPtr vertices; - register PolySlopePtr slopes; - int count; - int xi, yi; - PolyEdgePtr left, right; - int *pnleft, *pnright; - int *h; + PolyVertexPtr vertices; + PolySlopePtr slopes; + int count; + int xi, yi; + PolyEdgePtr left, right; + int *pnleft, *pnright; + int *h; { - int top, bottom; - double miny, maxy; - register int i; - int j; - int clockwise; - int slopeoff; - register int s; - register int nright, nleft; - int y, lasty = 0, bottomy, topy = 0; + int top, bottom; + double miny, maxy; + int i; + int j; + int clockwise; + int slopeoff; + int s; + int nright, nleft; + int y, lasty = 0, bottomy, topy = 0; /* find the top of the polygon */ maxy = miny = vertices[0].y; @@ -467,12 +457,12 @@ miLineOnePoint ( static void miLineJoin ( - DrawablePtr pDrawable, - GCPtr pGC, - unsigned long pixel, - SpanDataPtr spanData, - register LineFacePtr pLeft, - register LineFacePtr pRight) + DrawablePtr pDrawable, + GCPtr pGC, + unsigned long pixel, + SpanDataPtr spanData, + LineFacePtr pLeft, + LineFacePtr pRight) { double mx = 0, my = 0; double denom = 0.0; @@ -624,9 +614,9 @@ miLineArcI ( DDXPointPtr points, int *widths) { - register DDXPointPtr tpts, bpts; - register int *twids, *bwids; - register int x, y, e, ex, slw; + DDXPointPtr tpts, bpts; + int *twids, *bwids; + int x, y, e, ex, slw; tpts = points; twids = widths; @@ -717,8 +707,8 @@ miLineArcD ( int edgey2, Bool edgeleft2) { - register DDXPointPtr pts; - register int *wids; + DDXPointPtr pts; + int *wids; double radius, x0, y0, el, er, yk, xlk, xrk, k; int xbase, ybase, y, boty, xl, xr, xcl, xcr; int ymin, ymax; @@ -873,11 +863,8 @@ miLineArcD ( return (pts - points); } -int -miRoundJoinFace (face, edge, leftEdge) - register LineFacePtr face; - register PolyEdgePtr edge; - Bool *leftEdge; +static int +miRoundJoinFace (LineFacePtr face, PolyEdgePtr edge, Bool *leftEdge) { int y; int dx, dy; @@ -924,7 +911,7 @@ miRoundJoinFace (face, edge, leftEdge) void miRoundJoinClip (pLeft, pRight, edge1, edge2, y1, y2, left1, left2) - register LineFacePtr pLeft, pRight; + LineFacePtr pLeft, pRight; PolyEdgePtr edge1, edge2; int *y1, *y2; Bool *left1, *left2; @@ -949,14 +936,14 @@ miRoundJoinClip (pLeft, pRight, edge1, edge2, y1, y2, left1, left2) int miRoundCapClip (face, isInt, edge, leftEdge) - register LineFacePtr face; + LineFacePtr face; Bool isInt; - register PolyEdgePtr edge; + PolyEdgePtr edge; Bool *leftEdge; { - int y; - register int dx, dy; - double xa, ya, k; + int y; + int dx, dy; + double xa, ya, k; Bool left; dx = -face->dy; @@ -999,15 +986,15 @@ miRoundCapClip (face, isInt, edge, leftEdge) static void miLineArc ( - DrawablePtr pDraw, - register GCPtr pGC, - unsigned long pixel, - SpanDataPtr spanData, - register LineFacePtr leftFace, - register LineFacePtr rightFace, - double xorg, - double yorg, - Bool isInt) + DrawablePtr pDraw, + GCPtr pGC, + unsigned long pixel, + SpanDataPtr spanData, + LineFacePtr leftFace, + LineFacePtr rightFace, + double xorg, + double yorg, + Bool isInt) { DDXPointPtr points; int *widths; @@ -1114,16 +1101,10 @@ miLineArc ( } } -void -miLineProjectingCap (pDrawable, pGC, pixel, spanData, face, isLeft, xorg, yorg, isInt) - DrawablePtr pDrawable; - register GCPtr pGC; - unsigned long pixel; - SpanDataPtr spanData; - register LineFacePtr face; - Bool isLeft; - double xorg, yorg; - Bool isInt; +static void +miLineProjectingCap (DrawablePtr pDrawable, GCPtr pGC, unsigned long pixel, + SpanDataPtr spanData, LineFacePtr face, Bool isLeft, + double xorg, double yorg, Bool isInt) { int xorgi = 0, yorgi = 0; int lw; @@ -1286,18 +1267,18 @@ miLineProjectingCap (pDrawable, pGC, pixel, spanData, face, isLeft, xorg, yorg, static void miWideSegment ( - DrawablePtr pDrawable, - GCPtr pGC, - unsigned long pixel, - SpanDataPtr spanData, - register int x1, - register int y1, - register int x2, - register int y2, - Bool projectLeft, - Bool projectRight, - register LineFacePtr leftFace, - register LineFacePtr rightFace) + DrawablePtr pDrawable, + GCPtr pGC, + unsigned long pixel, + SpanDataPtr spanData, + int x1, + int y1, + int x2, + int y2, + Bool projectLeft, + Bool projectRight, + LineFacePtr leftFace, + LineFacePtr rightFace) { double l, L, r; double xa, ya; @@ -1506,11 +1487,8 @@ miWideSegment ( } } -SpanDataPtr -miSetupSpanData (pGC, spanData, npt) - register GCPtr pGC; - SpanDataPtr spanData; - int npt; +static SpanDataPtr +miSetupSpanData (GCPtr pGC, SpanDataPtr spanData, int npt) { if ((npt < 3 && pGC->capStyle != CapRound) || miSpansEasyRop(pGC->alu)) return (SpanDataPtr) NULL; @@ -1520,11 +1498,8 @@ miSetupSpanData (pGC, spanData, npt) return spanData; } -void -miCleanupSpanData (pDrawable, pGC, spanData) - DrawablePtr pDrawable; - GCPtr pGC; - SpanDataPtr spanData; +static void +miCleanupSpanData (DrawablePtr pDrawable, GCPtr pGC, SpanDataPtr spanData) { if (pGC->lineStyle == LineDoubleDash) { @@ -1552,21 +1527,21 @@ miCleanupSpanData (pDrawable, pGC, spanData) void miWideLine (pDrawable, pGC, mode, npt, pPts) DrawablePtr pDrawable; - register GCPtr pGC; + GCPtr pGC; int mode; - register int npt; - register DDXPointPtr pPts; + int npt; + DDXPointPtr pPts; { - int x1, y1, x2, y2; - SpanDataRec spanDataRec; - SpanDataPtr spanData; - unsigned long pixel; - Bool projectLeft, projectRight; - LineFaceRec leftFace, rightFace, prevRightFace; - LineFaceRec firstFace; - register int first; - Bool somethingDrawn = FALSE; - Bool selfJoin; + int x1, y1, x2, y2; + SpanDataRec spanDataRec; + SpanDataPtr spanData; + long pixel; + Bool projectLeft, projectRight; + LineFaceRec leftFace, rightFace, prevRightFace; + LineFaceRec firstFace; + int first; + Bool somethingDrawn = FALSE; + Bool selfJoin; spanData = miSetupSpanData (pGC, &spanDataRec, npt); pixel = pGC->fgPixel; @@ -1693,7 +1668,7 @@ miWideLine (pDrawable, pGC, mode, npt, pPts) static void miWideDashSegment ( DrawablePtr pDrawable, - register GCPtr pGC, + GCPtr pGC, SpanDataPtr spanData, int *pDashOffset, int *pDashIndex, @@ -2050,27 +2025,27 @@ miWideDashSegment ( void miWideDash (pDrawable, pGC, mode, npt, pPts) DrawablePtr pDrawable; - register GCPtr pGC; + GCPtr pGC; int mode; - register int npt; - register DDXPointPtr pPts; + int npt; + DDXPointPtr pPts; { - int x1, y1, x2, y2; - unsigned long pixel; - Bool projectLeft, projectRight; - LineFaceRec leftFace, rightFace, prevRightFace; - LineFaceRec firstFace; - int first; - int dashIndex, dashOffset; - register int prevDashIndex; - SpanDataRec spanDataRec; - SpanDataPtr spanData; - Bool somethingDrawn = FALSE; - Bool selfJoin; - Bool endIsFg = FALSE, startIsFg = FALSE; - Bool firstIsFg = FALSE, prevIsFg = FALSE; - -#ifndef XFree86Server + int x1, y1, x2, y2; + unsigned long pixel; + Bool projectLeft, projectRight; + LineFaceRec leftFace, rightFace, prevRightFace; + LineFaceRec firstFace; + int first; + int dashIndex, dashOffset; + int prevDashIndex; + SpanDataRec spanDataRec; + SpanDataPtr spanData; + Bool somethingDrawn = FALSE; + Bool selfJoin; + Bool endIsFg = FALSE, startIsFg = FALSE; + Bool firstIsFg = FALSE, prevIsFg = FALSE; + +#if 0 /* XXX backward compatibility */ if (pGC->lineWidth == 0) { @@ -2229,15 +2204,3 @@ miWideDash (pDrawable, pGC, mode, npt, pPts) if (spanData) miCleanupSpanData (pDrawable, pGC, spanData); } - -/* these are stubs to allow old ddx ValidateGCs to work without change */ - -void -miMiter() -{ -} - -void -miNotMiter() -{ -} diff --git a/nx-X11/programs/Xserver/mi/miwideline.h b/nx-X11/programs/Xserver/mi/miwideline.h index 8cfa630088..9d1aa03cbf 100644 --- a/nx-X11/programs/Xserver/mi/miwideline.h +++ b/nx-X11/programs/Xserver/mi/miwideline.h @@ -153,24 +153,6 @@ typedef struct _LineFace { } \ } -extern void miFillPolyHelper( - DrawablePtr /*pDrawable*/, - GCPtr /*pGC*/, - unsigned long /*pixel*/, - SpanDataPtr /*spanData*/, - int /*y*/, - int /*overall_height*/, - PolyEdgePtr /*left*/, - PolyEdgePtr /*right*/, - int /*left_count*/, - int /*right_count*/ -); -extern int miRoundJoinFace( - LineFacePtr /*face*/, - PolyEdgePtr /*edge*/, - Bool * /*leftEdge*/ -); - extern void miRoundJoinClip( LineFacePtr /*pLeft*/, LineFacePtr /*pRight*/, @@ -189,30 +171,6 @@ extern int miRoundCapClip( Bool * /*leftEdge*/ ); -extern void miLineProjectingCap( - DrawablePtr /*pDrawable*/, - GCPtr /*pGC*/, - unsigned long /*pixel*/, - SpanDataPtr /*spanData*/, - LineFacePtr /*face*/, - Bool /*isLeft*/, - double /*xorg*/, - double /*yorg*/, - Bool /*isInt*/ -); - -extern SpanDataPtr miSetupSpanData( - GCPtr /*pGC*/, - SpanDataPtr /*spanData*/, - int /*npt*/ -); - -extern void miCleanupSpanData( - DrawablePtr /*pDrawable*/, - GCPtr /*pGC*/, - SpanDataPtr /*spanData*/ -); - extern int miPolyBuildEdge(double x0, double y0, double k, int dx, int dy, int xi, int yi, int left, PolyEdgePtr edge); extern int miPolyBuildPoly(PolyVertexPtr vertices, PolySlopePtr slopes, diff --git a/nx-X11/programs/Xserver/mi/miwindow.c b/nx-X11/programs/Xserver/mi/miwindow.c index 4e67987d63..1f77211a30 100644 --- a/nx-X11/programs/Xserver/mi/miwindow.c +++ b/nx-X11/programs/Xserver/mi/miwindow.c @@ -160,12 +160,12 @@ miClearToBackground(pWin, x, y, w, h, generateExposures) */ static Bool miCheckSubSaveUnder( - register WindowPtr pParent, /* Parent to check */ + WindowPtr pParent, /* Parent to check */ WindowPtr pFirst, /* first reconfigured window */ RegionPtr pRegion) /* Initial area obscured by saveUnder */ { - register WindowPtr pChild; /* Current child */ - register ScreenPtr pScreen; /* Screen to use */ + WindowPtr pChild; /* Current child */ + ScreenPtr pScreen; /* Screen to use */ RegionRec SubRegion; /* Area of children obscured */ Bool res = FALSE; /* result */ Bool subInited=FALSE;/* SubRegion initialized */ @@ -268,7 +268,7 @@ miCheckSubSaveUnder( */ Bool miChangeSaveUnder(pWin, first) - register WindowPtr pWin; + WindowPtr pWin; WindowPtr first; /* First window to check. * Used when pWin was restacked */ { @@ -307,7 +307,7 @@ miPostChangeSaveUnder(pWin, pFirst) WindowPtr pWin; WindowPtr pFirst; { - register WindowPtr pParent, pChild; + WindowPtr pParent, pChild; ChangeWindowAttributesProcPtr ChangeWindowAttributes; if (!(pParent = pWin->parent)) @@ -340,9 +340,9 @@ miPostChangeSaveUnder(pWin, pFirst) void miMarkWindow(pWin) - register WindowPtr pWin; + WindowPtr pWin; { - register ValidatePtr val; + ValidatePtr val; if (pWin->valdata) return; @@ -360,8 +360,8 @@ miMarkOverlappedWindows(pWin, pFirst, ppLayerWin) WindowPtr pFirst; WindowPtr *ppLayerWin; { - register BoxPtr box; - register WindowPtr pChild, pLast; + BoxPtr box; + WindowPtr pChild, pLast; Bool anyMarked = FALSE; MarkWindowProcPtr MarkWindow = pWin->drawable.pScreen->MarkWindow; @@ -444,8 +444,8 @@ void miHandleValidateExposures(pWin) WindowPtr pWin; { - register WindowPtr pChild; - register ValidatePtr val; + WindowPtr pChild; + ValidatePtr val; WindowExposuresProcPtr WindowExposures; pChild = pWin; @@ -479,7 +479,7 @@ miHandleValidateExposures(pWin) void miMoveWindow(pWin, x, y, pNextSib, kind) - register WindowPtr pWin; + WindowPtr pWin; int x,y; WindowPtr pNextSib; VTKind kind; @@ -490,7 +490,7 @@ miMoveWindow(pWin, x, y, pNextSib, kind) RegionPtr oldRegion = NULL; DDXPointRec oldpt; Bool anyMarked = FALSE; - register ScreenPtr pScreen; + ScreenPtr pScreen; WindowPtr windowToValidate; #ifdef DO_SAVE_UNDERS Bool dosave = FALSE; @@ -568,7 +568,7 @@ miMoveWindow(pWin, x, y, pNextSib, kind) static int miRecomputeExposures ( - register WindowPtr pWin, + WindowPtr pWin, void * value) /* must conform to VisitWindowProcPtr */ { RegionPtr pValid = (RegionPtr)value; @@ -594,7 +594,7 @@ miRecomputeExposures ( void miSlideAndSizeWindow(pWin, x, y, w, h, pSib) - register WindowPtr pWin; + WindowPtr pWin; int x,y; unsigned int w, h; WindowPtr pSib; @@ -610,11 +610,11 @@ miSlideAndSizeWindow(pWin, x, y, w, h, pSib) DDXPointRec oldpt; RegionPtr oldRegion = NULL; Bool anyMarked = FALSE; - register ScreenPtr pScreen; + ScreenPtr pScreen; WindowPtr pFirstChange; - register WindowPtr pChild; + WindowPtr pChild; RegionPtr gravitate[StaticGravity + 1]; - register unsigned g; + unsigned g; int nx, ny; /* destination x,y */ int newx, newy; /* new inner window position */ RegionPtr pRegion = NULL; @@ -971,10 +971,10 @@ miGetLayerWindow(pWin) void miSetShape(pWin) - register WindowPtr pWin; + WindowPtr pWin; { Bool WasViewable = (Bool)(pWin->viewable); - register ScreenPtr pScreen = pWin->drawable.pScreen; + ScreenPtr pScreen = pWin->drawable.pScreen; Bool anyMarked = FALSE; RegionPtr pOldClip = NULL, bsExposed; #ifdef DO_SAVE_UNDERS @@ -1050,7 +1050,7 @@ miSetShape(pWin) * even if it was not created at the beginning of * this function as, at the time, the backing store * was off. miCheckSubSaveUnder() appear to get a - * pointer to the parent, so maybe doesn't change + * void * to the parent, so maybe doesn't change * the attribute of the window itself. This is to * be better investigated. * Update: Red Hat fixed this bug the same way (BZ 676270). @@ -1064,7 +1064,7 @@ miSetShape(pWin) if (bsExposed) { RegionPtr valExposed = NullRegion; - + if (pWin->valdata) valExposed = &pWin->valdata->after.exposed; (*pScreen->WindowExposures) (pWin, valExposed, bsExposed); @@ -1094,12 +1094,12 @@ miSetShape(pWin) void miChangeBorderWidth(pWin, width) - register WindowPtr pWin; + WindowPtr pWin; unsigned int width; { int oldwidth; Bool anyMarked = FALSE; - register ScreenPtr pScreen; + ScreenPtr pScreen; Bool WasViewable = (Bool)(pWin->viewable); Bool HadBorder; #ifdef DO_SAVE_UNDERS diff --git a/nx-X11/programs/Xserver/mi/mizerarc.c b/nx-X11/programs/Xserver/mi/mizerarc.c index 82832fea06..06c2b54c06 100644 --- a/nx-X11/programs/Xserver/mi/mizerarc.c +++ b/nx-X11/programs/Xserver/mi/mizerarc.c @@ -97,8 +97,8 @@ static miZeroArcPtRec oob = {65536, 65536, 0}; Bool miZeroArcSetup(arc, info, ok360) - register xArc *arc; - register miZeroArcRec *info; + xArc *arc; + miZeroArcRec *info; Bool ok360; { int l; @@ -401,14 +401,12 @@ miZeroArcSetup(arc, info, ok360) #define DoPix(idx,xval,yval) if (mask & (1 << idx)) Pixelate(xval, yval); -DDXPointPtr -miZeroArcPts(arc, pts) - xArc *arc; - register DDXPointPtr pts; +static DDXPointPtr +miZeroArcPts(xArc *arc, DDXPointPtr pts) { miZeroArcRec info; - register int x, y, a, b, d, mask; - register int k1, k3, dx, dy; + int x, y, a, b, d, mask; + int k1, k3, dx, dy; Bool do360; do360 = miZeroArcSetup(arc, &info, TRUE); @@ -509,14 +507,14 @@ miZeroArcDashPts( GCPtr pGC, xArc *arc, DashInfo *dinfo, - register DDXPointPtr points, + DDXPointPtr points, int maxPts, - register DDXPointPtr *evenPts, - register DDXPointPtr *oddPts ) + DDXPointPtr *evenPts, + DDXPointPtr *oddPts ) { miZeroArcRec info; - register int x, y, a, b, d, mask; - register int k1, k3, dx, dy; + int x, y, a, b, d, mask; + int k1, k3, dx, dy; int dashRemaining; DDXPointPtr arcPts[4]; DDXPointPtr startPts[5], endPts[5]; @@ -715,11 +713,11 @@ miZeroPolyArc(pDraw, pGC, narcs, parcs) xArc *parcs; { int maxPts = 0; - register int n, maxw = 0; - register xArc *arc; - register int i; + int n, maxw = 0; + xArc *arc; + int i; DDXPointPtr points, pts, oddPts = NULL; - register DDXPointPtr pt; + DDXPointPtr pt; int numPts; Bool dospans; int *widths = NULL; diff --git a/nx-X11/programs/Xserver/mi/mizerarc.h b/nx-X11/programs/Xserver/mi/mizerarc.h index 8119d885ef..28ebbe0309 100644 --- a/nx-X11/programs/Xserver/mi/mizerarc.h +++ b/nx-X11/programs/Xserver/mi/mizerarc.h @@ -124,9 +124,3 @@ extern Bool miZeroArcSetup( miZeroArcRec * /*info*/, Bool /*ok360*/ ); - -extern DDXPointPtr miZeroArcPts( - xArc * /*arc*/, - DDXPointPtr /*pts*/ -); - diff --git a/nx-X11/programs/Xserver/miext/cw/cw.c b/nx-X11/programs/Xserver/miext/cw/cw.c index a45c34dff0..54cd034f1b 100644 --- a/nx-X11/programs/Xserver/miext/cw/cw.c +++ b/nx-X11/programs/Xserver/miext/cw/cw.c @@ -19,7 +19,6 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ -/* $Header: /cvs/xorg/xc/programs/Xserver/miext/cw/cw.c,v 1.23 2005/10/02 08:28:26 anholt Exp $ */ #ifdef HAVE_DIX_CONFIG_H #include @@ -50,7 +49,6 @@ int cwWindowIndex; #ifdef RENDER int cwPictureIndex; #endif -static Bool cwDisabled[MAXSCREENS]; static unsigned long cwGeneration = 0; extern GCOps cwGCOps; @@ -619,9 +617,9 @@ void miInitializeCompositeWrapper(ScreenPtr pScreen) { cwScreenPtr pScreenPriv; - - if (cwDisabled[pScreen->myNum]) - return; +#ifdef RENDER + Bool has_render = GetPictureScreenIfSet(pScreen) != NULL; +#endif if (cwGeneration != serverGeneration) { @@ -631,7 +629,8 @@ miInitializeCompositeWrapper(ScreenPtr pScreen) cwGCIndex = AllocateGCPrivateIndex(); cwWindowIndex = AllocateWindowPrivateIndex(); #ifdef RENDER - cwPictureIndex = AllocatePicturePrivateIndex(); + if (has_render) + cwPictureIndex = AllocatePicturePrivateIndex(); #endif cwGeneration = serverGeneration; } @@ -640,8 +639,10 @@ miInitializeCompositeWrapper(ScreenPtr pScreen) if (!AllocateWindowPrivate(pScreen, cwWindowIndex, 0)) return; #ifdef RENDER - if (!AllocatePicturePrivate(pScreen, cwPictureIndex, 0)) - return; + if (has_render) { + if (!AllocatePicturePrivate(pScreen, cwPictureIndex, 0)) + return; + } #endif pScreenPriv = (cwScreenPtr)malloc(sizeof(cwScreenRec)); if (!pScreenPriv) @@ -661,17 +662,11 @@ miInitializeCompositeWrapper(ScreenPtr pScreen) SCREEN_EPILOGUE(pScreen, GetWindowPixmap, cwGetWindowPixmap); #ifdef RENDER - if (GetPictureScreen (pScreen)) + if (has_render) cwInitializeRender(pScreen); #endif } -void -miDisableCompositeWrapper(ScreenPtr pScreen) -{ - cwDisabled[pScreen->myNum] = TRUE; -} - static Bool cwCloseScreen (ScreenPtr pScreen) { diff --git a/nx-X11/programs/Xserver/miext/cw/cw.h b/nx-X11/programs/Xserver/miext/cw/cw.h index b8792661f0..0821c8a54c 100644 --- a/nx-X11/programs/Xserver/miext/cw/cw.h +++ b/nx-X11/programs/Xserver/miext/cw/cw.h @@ -19,7 +19,6 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ -/* $Header: /cvs/xorg/xc/programs/Xserver/miext/cw/cw.h,v 1.14 2005/12/09 18:32:46 ajax Exp $ */ #ifdef HAVE_DIX_CONFIG_H #include @@ -60,7 +59,7 @@ typedef struct { unsigned long stateChanges; } cwPictureRec, *cwPicturePtr; -#define getCwPicture(pPicture) \ +#define getCwPicture(pPicture) \ (pPicture->pDrawable ? (cwPicturePtr)(pPicture)->devPrivates[cwPictureIndex].ptr : 0) #define setCwPicture(pPicture,p) ((pPicture)->devPrivates[cwPictureIndex].ptr = (void *) (p)) @@ -101,6 +100,7 @@ typedef struct { ValidatePictureProcPtr ValidatePicture; CompositeProcPtr Composite; + GlyphsProcPtr Glyphs; CompositeRectsProcPtr CompositeRects; TrapezoidsProcPtr Trapezoids; @@ -168,7 +168,3 @@ cwFiniRender (ScreenPtr pScreen); void miInitializeCompositeWrapper(ScreenPtr pScreen); - -/* Must be called before miInitializeCompositeWrapper */ -void -miDisableCompositeWrapper(ScreenPtr pScreen); diff --git a/nx-X11/programs/Xserver/miext/cw/cw_ops.c b/nx-X11/programs/Xserver/miext/cw/cw_ops.c index 826a0eecae..e67cd27a20 100644 --- a/nx-X11/programs/Xserver/miext/cw/cw_ops.c +++ b/nx-X11/programs/Xserver/miext/cw/cw_ops.c @@ -19,7 +19,6 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ -/* $Header: /cvs/xorg/xc/programs/Xserver/miext/cw/cw_ops.c,v 1.9 2005/07/03 07:02:01 daniels Exp $ */ #ifdef HAVE_DIX_CONFIG_H #include @@ -28,7 +27,9 @@ #include #include "gcstruct.h" +#include "pixmapstr.h" #include "cw.h" +#include "mi.h" #define SETUP_BACKING_DST(_pDst, _pGC) \ cwGCPtr pGCPrivate = getCwGC (_pGC); \ @@ -43,6 +44,9 @@ &src_off_y) #define PROLOGUE(pGC) do { \ + if (pBackingGC->serialNumber != pBackingDst->serialNumber) { \ + ValidateGC(pBackingDst, pBackingGC); \ + } \ pGC->funcs = pGCPrivate->wrapFuncs;\ pGC->ops = pGCPrivate->wrapOps;\ } while (0) @@ -181,7 +185,7 @@ cwCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, int srcx, int srcy, int w, int h, int dstx, int dsty) { int odstx, odsty; - RegionPtr exposed = NULL; + int osrcx, osrcy; SETUP_BACKING_DST(pDst, pGC); SETUP_BACKING_SRC(pSrc, pGC); @@ -189,19 +193,20 @@ cwCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, int srcx, int srcy, odstx = dstx; odsty = dsty; + osrcx = srcx; + osrcy = srcy; CW_OFFSET_XY_DST(dstx, dsty); CW_OFFSET_XY_SRC(srcx, srcy); - exposed = (*pBackingGC->ops->CopyArea)(pBackingSrc, pBackingDst, - pBackingGC, srcx, srcy, w, h, - dstx, dsty); - - if (exposed != NULL) - RegionTranslate(exposed, odstx - dstx, odsty - dsty); - + (*pBackingGC->ops->CopyArea)(pBackingSrc, pBackingDst, + pBackingGC, srcx, srcy, w, h, + dstx, dsty); + EPILOGUE(pGC); - return exposed; + return miHandleExposures(pSrc, pDst, pGC, + osrcx, osrcy, w, h, + odstx, odsty, 0); } static RegionPtr @@ -209,7 +214,7 @@ cwCopyPlane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, int srcx, int srcy, int w, int h, int dstx, int dsty, unsigned long plane) { int odstx, odsty; - RegionPtr exposed = NULL; + int osrcx, osrcy; SETUP_BACKING_DST(pDst, pGC); SETUP_BACKING_SRC(pSrc, pGC); @@ -217,19 +222,20 @@ cwCopyPlane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, int srcx, int srcy, odstx = dstx; odsty = dsty; + osrcx = srcx; + osrcy = srcy; CW_OFFSET_XY_DST(dstx, dsty); CW_OFFSET_XY_SRC(srcx, srcy); - exposed = (*pBackingGC->ops->CopyPlane)(pBackingSrc, pBackingDst, - pBackingGC, srcx, srcy, w, h, - dstx, dsty, plane); - - if (exposed != NULL) - RegionTranslate(exposed, odstx - dstx, odsty - dsty); + (*pBackingGC->ops->CopyPlane)(pBackingSrc, pBackingDst, + pBackingGC, srcx, srcy, w, h, + dstx, dsty, plane); EPILOGUE(pGC); - return exposed; + return miHandleExposures(pSrc, pDst, pGC, + osrcx, osrcy, w, h, + odstx, odsty, plane); } static void diff --git a/nx-X11/programs/Xserver/miext/cw/cw_render.c b/nx-X11/programs/Xserver/miext/cw/cw_render.c index a44d7c4d27..0be011af1a 100644 --- a/nx-X11/programs/Xserver/miext/cw/cw_render.c +++ b/nx-X11/programs/Xserver/miext/cw/cw_render.c @@ -19,7 +19,6 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ -/* $Header: /cvs/xorg/xc/programs/Xserver/miext/cw/cw_render.c,v 1.14 2005/07/03 07:02:01 daniels Exp $ */ #ifdef HAVE_DIX_CONFIG_H #include @@ -280,6 +279,34 @@ cwComposite (CARD8 op, cwPsWrap(Composite, cwComposite); } +static void +cwGlyphs (CARD8 op, + PicturePtr pSrcPicture, + PicturePtr pDstPicture, + PictFormatPtr maskFormat, + INT16 xSrc, + INT16 ySrc, + int nlists, + GlyphListPtr lists, + GlyphPtr *glyphs) +{ + ScreenPtr pScreen = pDstPicture->pDrawable->pScreen; + cwPsDecl(pScreen); + cwSrcPictureDecl; + cwDstPictureDecl; + + cwPsUnwrap(Glyphs); + if (nlists) + { + lists->xOff += dst_picture_x_off; + lists->yOff += dst_picture_y_off; + } + (*ps->Glyphs) (op, pBackingSrcPicture, pBackingDstPicture, maskFormat, + xSrc + src_picture_x_off, ySrc + src_picture_y_off, + nlists, lists, glyphs); + cwPsWrap(Glyphs, cwGlyphs); +} + static void cwCompositeRects (CARD8 op, PicturePtr pDstPicture, @@ -443,6 +470,7 @@ cwInitializeRender (ScreenPtr pScreen) cwPsWrap(ChangePicture, cwChangePicture); cwPsWrap(ValidatePicture, cwValidatePicture); cwPsWrap(Composite, cwComposite); + cwPsWrap(Glyphs, cwGlyphs); cwPsWrap(CompositeRects, cwCompositeRects); cwPsWrap(Trapezoids, cwTrapezoids); cwPsWrap(Triangles, cwTriangles); @@ -463,6 +491,7 @@ cwFiniRender (ScreenPtr pScreen) cwPsUnwrap(ChangePicture); cwPsUnwrap(ValidatePicture); cwPsUnwrap(Composite); + cwPsUnwrap(Glyphs); cwPsUnwrap(CompositeRects); cwPsUnwrap(Trapezoids); cwPsUnwrap(Triangles); diff --git a/nx-X11/programs/Xserver/miext/damage/damage.c b/nx-X11/programs/Xserver/miext/damage/damage.c index 5ec1181283..5ae4b42dd3 100644 --- a/nx-X11/programs/Xserver/miext/damage/damage.c +++ b/nx-X11/programs/Xserver/miext/damage/damage.c @@ -1,6 +1,4 @@ /* - * $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 @@ -77,6 +75,12 @@ #define pixmapDamage(pPixmap) damagePixPriv(pPixmap) +static int damageScrPrivateIndex; +static int damagePixPrivateIndex; +static int damageGCPrivateIndex; +static int damageWinPrivateIndex; +static int damageGeneration; + static DamagePtr * getDrawableDamageRef (DrawablePtr pDrawable) { @@ -118,6 +122,52 @@ getDrawableDamageRef (DrawablePtr pDrawable) DamagePtr *pPrev = (DamagePtr *) \ &(pWindow->devPrivates[damageWinPrivateIndex].ptr) +static void +DamageReportDamage (DamagePtr pDamage, RegionPtr pDamageRegion) +{ + BoxRec tmpBox; + RegionRec tmpRegion; + Bool was_empty; + + switch (pDamage->damageLevel) { + case DamageReportRawRegion: + (*pDamage->damageReport) (pDamage, pDamageRegion, pDamage->closure); + break; + case DamageReportDeltaRegion: + RegionNull(&tmpRegion); + RegionSubtract(&tmpRegion, pDamageRegion, &pDamage->damage); + if (RegionNotEmpty(&tmpRegion)) { + RegionUnion(&pDamage->damage, &pDamage->damage, + pDamageRegion); + (*pDamage->damageReport) (pDamage, &tmpRegion, pDamage->closure); + } + RegionUninit(&tmpRegion); + break; + case DamageReportBoundingBox: + tmpBox = *RegionExtents(&pDamage->damage); + RegionUnion(&pDamage->damage, &pDamage->damage, + pDamageRegion); + if (!BOX_SAME (&tmpBox, RegionExtents(&pDamage->damage))) { + (*pDamage->damageReport) (pDamage, &pDamage->damage, + pDamage->closure); + } + break; + case DamageReportNonEmpty: + was_empty = !RegionNotEmpty(&pDamage->damage); + RegionUnion(&pDamage->damage, &pDamage->damage, + pDamageRegion); + if (was_empty && RegionNotEmpty(&pDamage->damage)) { + (*pDamage->damageReport) (pDamage, &pDamage->damage, + pDamage->closure); + } + break; + case DamageReportNone: + RegionUnion(&pDamage->damage, &pDamage->damage, + pDamageRegion); + break; + } +} + #if DAMAGE_DEBUG_ENABLE static void _damageDamageRegion (DrawablePtr pDrawable, RegionPtr pRegion, Bool clip, int subWindowMode, const char *where) @@ -135,9 +185,6 @@ damageDamageRegion (DrawablePtr pDrawable, RegionPtr pRegion, Bool clip, RegionRec clippedRec; RegionPtr pDamageRegion; RegionRec pixClip; - Bool was_empty; - RegionRec tmpRegion; - BoxRec tmpBox; int draw_x, draw_y; #ifdef COMPOSITE int screen_x = 0, screen_y = 0; @@ -261,41 +308,18 @@ damageDamageRegion (DrawablePtr pDrawable, RegionPtr pRegion, Bool clip, */ if (draw_x || draw_y) RegionTranslate(pDamageRegion, -draw_x, -draw_y); - - switch (pDamage->damageLevel) { - case DamageReportRawRegion: - (*pDamage->damageReport) (pDamage, pDamageRegion, pDamage->closure); - break; - case DamageReportDeltaRegion: - RegionNull(&tmpRegion); - RegionSubtract(&tmpRegion, pDamageRegion, &pDamage->damage); - if (RegionNotEmpty(&tmpRegion)) - { - RegionUnion(&pDamage->damage, - &pDamage->damage, pDamageRegion); - (*pDamage->damageReport) (pDamage, &tmpRegion, pDamage->closure); - } - RegionUninit(&tmpRegion); - break; - case DamageReportBoundingBox: - tmpBox = *RegionExtents(&pDamage->damage); - RegionUnion(&pDamage->damage, - &pDamage->damage, pDamageRegion); - if (!BOX_SAME (&tmpBox, RegionExtents(&pDamage->damage))) - (*pDamage->damageReport) (pDamage, &pDamage->damage, pDamage->closure); - break; - case DamageReportNonEmpty: - was_empty = !RegionNotEmpty(&pDamage->damage); - RegionUnion(&pDamage->damage, &pDamage->damage, - pDamageRegion); - if (was_empty && RegionNotEmpty(&pDamage->damage)) - (*pDamage->damageReport) (pDamage, &pDamage->damage, pDamage->closure); - break; - case DamageReportNone: - RegionUnion(&pDamage->damage, &pDamage->damage, - pDamageRegion); - break; + + /* If the damage rec has been flagged to report damage after the op has + * completed, then union it into the delayed damage region, which will + * be used for reporting after calling down, and skip the reporting + */ + if (!pDamage->reportAfter) { + DamageReportDamage (pDamage, pDamageRegion); + } else { + RegionUnion(&pDamage->pendingDamage, + &pDamage->pendingDamage, pDamageRegion); } + /* * translate original region back */ @@ -310,6 +334,21 @@ damageDamageRegion (DrawablePtr pDrawable, RegionPtr pRegion, Bool clip, RegionUninit(&clippedRec); } +static void +damageReportPostOp (DrawablePtr pDrawable) +{ + drawableDamage(pDrawable); + + for (; pDamage != NULL; pDamage = pDamage->pNext) + { + if (pDamage->reportAfter) { + DamageReportDamage (pDamage, &pDamage->pendingDamage); + RegionEmpty(&pDamage->pendingDamage); + } + } + +} + #if DAMAGE_DEBUG_ENABLE #define damageDamageBox(d,b,m) _damageDamageBox(d,b,m,__FUNCTION__) static void @@ -334,16 +373,16 @@ static void damageValidateGC(GCPtr, unsigned long, DrawablePtr); static void damageChangeGC(GCPtr, unsigned long); static void damageCopyGC(GCPtr, unsigned long, GCPtr); static void damageDestroyGC(GCPtr); -static void damageChangeClip(GCPtr, int, void *, int); +static void damageChangeClip(GCPtr, int, pointer, int); static void damageDestroyClip(GCPtr); static void damageCopyClip(GCPtr, GCPtr); -GCFuncs damageGCFuncs = { +static GCFuncs damageGCFuncs = { damageValidateGC, damageChangeGC, damageCopyGC, damageDestroyGC, damageChangeClip, damageDestroyClip, damageCopyClip }; -extern GCOps damageGCOps; +static GCOps damageGCOps; static Bool damageCreateGC(GCPtr pGC) @@ -555,6 +594,7 @@ damageComposite (CARD8 op, yDst, width, height); + damageReportPostOp (pDst->pDrawable); wrap (pScrPriv, ps, Composite, damageComposite); } @@ -621,6 +661,7 @@ damageGlyphs (CARD8 op, } unwrap (pScrPriv, ps, Glyphs); (*ps->Glyphs) (op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, list, glyphs); + damageReportPostOp (pDst->pDrawable); wrap (pScrPriv, ps, Glyphs, damageGlyphs); } #endif @@ -673,6 +714,7 @@ damageFillSpans(DrawablePtr pDrawable, (*pGC->ops->FillSpans)(pDrawable, pGC, npt, ppt, pwidth, fSorted); + damageReportPostOp (pDrawable); DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); } @@ -720,6 +762,7 @@ damageSetSpans(DrawablePtr pDrawable, damageDamageBox (pDrawable, &box, pGC->subWindowMode); } (*pGC->ops->SetSpans)(pDrawable, pGC, pcharsrc, ppt, pwidth, npt, fSorted); + damageReportPostOp (pDrawable); DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); } @@ -751,6 +794,7 @@ damagePutImage(DrawablePtr pDrawable, } (*pGC->ops->PutImage)(pDrawable, pGC, depth, x, y, w, h, leftPad, format, pImage); + damageReportPostOp (pDrawable); DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); } @@ -794,6 +838,7 @@ damageCopyArea(DrawablePtr pSrc, ret = (*pGC->ops->CopyArea)(pSrc, pDst, pGC, srcx, srcy, width, height, dstx, dsty); + damageReportPostOp (pDst); DAMAGE_GC_OP_EPILOGUE(pGC, pDst); return ret; } @@ -839,6 +884,7 @@ damageCopyPlane(DrawablePtr pSrc, ret = (*pGC->ops->CopyPlane)(pSrc, pDst, pGC, srcx, srcy, width, height, dstx, dsty, bitPlane); + damageReportPostOp (pDst); DAMAGE_GC_OP_EPILOGUE(pGC, pDst); return ret; } @@ -880,6 +926,7 @@ damagePolyPoint(DrawablePtr pDrawable, damageDamageBox (pDrawable, &box, pGC->subWindowMode); } (*pGC->ops->PolyPoint)(pDrawable, pGC, mode, npt, ppt); + damageReportPostOp (pDrawable); DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); } @@ -953,6 +1000,7 @@ damagePolylines(DrawablePtr pDrawable, damageDamageBox (pDrawable, &box, pGC->subWindowMode); } (*pGC->ops->Polylines)(pDrawable, pGC, mode, npt, ppt); + damageReportPostOp (pDrawable); DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); } @@ -1031,6 +1079,7 @@ damagePolySegment(DrawablePtr pDrawable, damageDamageBox (pDrawable, &box, pGC->subWindowMode); } (*pGC->ops->PolySegment)(pDrawable, pGC, nSeg, pSeg); + damageReportPostOp (pDrawable); DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); } @@ -1092,6 +1141,7 @@ damagePolyRectangle(DrawablePtr pDrawable, } } (*pGC->ops->PolyRectangle)(pDrawable, pGC, nRects, pRects); + damageReportPostOp (pDrawable); DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); } @@ -1144,6 +1194,7 @@ damagePolyArc(DrawablePtr pDrawable, damageDamageBox (pDrawable, &box, pGC->subWindowMode); } (*pGC->ops->PolyArc)(pDrawable, pGC, nArcs, pArcs); + damageReportPostOp (pDrawable); DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); } @@ -1202,6 +1253,7 @@ damageFillPolygon(DrawablePtr pDrawable, } (*pGC->ops->FillPolygon)(pDrawable, pGC, shape, mode, npt, ppt); + damageReportPostOp (pDrawable); DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); } @@ -1240,6 +1292,7 @@ damagePolyFillRect(DrawablePtr pDrawable, damageDamageBox (pDrawable, &box, pGC->subWindowMode); } (*pGC->ops->PolyFillRect)(pDrawable, pGC, nRects, pRects); + damageReportPostOp (pDrawable); DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); } @@ -1281,6 +1334,7 @@ damagePolyFillArc(DrawablePtr pDrawable, damageDamageBox (pDrawable, &box, pGC->subWindowMode); } (*pGC->ops->PolyFillArc)(pDrawable, pGC, nArcs, pArcs); + damageReportPostOp (pDrawable); DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); } @@ -1399,6 +1453,7 @@ damagePolyText16(DrawablePtr pDrawable, FONTLASTROW(pGC->font) == 0 ? Linear16Bit : TwoD16Bit, TT_POLY16); x = (*pGC->ops->PolyText16) (pDrawable, pGC, x, y, count, chars); + damageReportPostOp (pDrawable); DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); return x; } @@ -1415,6 +1470,7 @@ damageImageText8(DrawablePtr pDrawable, damageText (pDrawable, pGC, x, y, (unsigned long) count, chars, Linear8Bit, TT_IMAGE8); (*pGC->ops->ImageText8) (pDrawable, pGC, x, y, count, chars); + damageReportPostOp (pDrawable); DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); } @@ -1431,6 +1487,7 @@ damageImageText16(DrawablePtr pDrawable, FONTLASTROW(pGC->font) == 0 ? Linear16Bit : TwoD16Bit, TT_IMAGE16); (*pGC->ops->ImageText16) (pDrawable, pGC, x, y, count, chars); + damageReportPostOp (pDrawable); DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); } @@ -1448,6 +1505,7 @@ damageImageGlyphBlt(DrawablePtr pDrawable, nglyph, ppci, TRUE, pGC->subWindowMode); (*pGC->ops->ImageGlyphBlt)(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase); + damageReportPostOp (pDrawable); DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); } @@ -1465,6 +1523,7 @@ damagePolyGlyphBlt(DrawablePtr pDrawable, nglyph, ppci, FALSE, pGC->subWindowMode); (*pGC->ops->PolyGlyphBlt)(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase); + damageReportPostOp (pDrawable); DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); } @@ -1498,6 +1557,7 @@ damagePushPixels(GCPtr pGC, damageDamageBox (pDrawable, &box, pGC->subWindowMode); } (*pGC->ops->PushPixels)(pGC, pBitMap, pDrawable, dx, dy, xOrg, yOrg); + damageReportPostOp (pDrawable); DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); } @@ -1577,10 +1637,12 @@ damagePaintWindow(WindowPtr pWindow, if(what == PW_BACKGROUND) { unwrap (pScrPriv, pScreen, PaintWindowBackground); (*pScreen->PaintWindowBackground) (pWindow, prgn, what); + damageReportPostOp (&pWindow->drawable); wrap (pScrPriv, pScreen, PaintWindowBackground, damagePaintWindow); } else { unwrap (pScrPriv, pScreen, PaintWindowBorder); (*pScreen->PaintWindowBorder) (pWindow, prgn, what); + damageReportPostOp (&pWindow->drawable); wrap (pScrPriv, pScreen, PaintWindowBorder, damagePaintWindow); } } @@ -1609,10 +1671,11 @@ damageCopyWindow(WindowPtr pWindow, } unwrap (pScrPriv, pScreen, CopyWindow); (*pScreen->CopyWindow) (pWindow, ptOldOrg, prgnSrc); + damageReportPostOp (&pWindow->drawable); wrap (pScrPriv, pScreen, CopyWindow, damageCopyWindow); } -GCOps damageGCOps = { +static GCOps damageGCOps = { damageFillSpans, damageSetSpans, damagePutImage, damageCopyArea, damageCopyPlane, damagePolyPoint, @@ -1623,9 +1686,6 @@ GCOps damageGCOps = { damagePolyText16, damageImageText8, damageImageText16, damageImageGlyphBlt, damagePolyGlyphBlt, damagePushPixels, -#ifdef NEED_LINEHELPER - NULL, -#endif {NULL} /* devPrivate */ }; @@ -1643,6 +1703,7 @@ damageRestoreAreas (PixmapPtr pPixmap, unwrap (pScrPriv, pScreen, BackingStoreFuncs.RestoreAreas); (*pScreen->BackingStoreFuncs.RestoreAreas) (pPixmap, prgn, xorg, yorg, pWindow); + damageReportPostOp (&pWindow->drawable); wrap (pScrPriv, pScreen, BackingStoreFuncs.RestoreAreas, damageRestoreAreas); } @@ -1715,12 +1776,6 @@ damageCloseScreen (ScreenPtr pScreen) return (*pScreen->CloseScreen) (pScreen); } -int damageScrPrivateIndex; -int damagePixPrivateIndex; -int damageGCPrivateIndex; -int damageWinPrivateIndex; -int damageGeneration; - Bool DamageSetup (ScreenPtr pScreen) { @@ -1759,16 +1814,6 @@ DamageSetup (ScreenPtr pScreen) if (!pScrPriv) return FALSE; -#ifdef COMPOSITE - /* This is a kludge to ensure wrapping order with the composite wrapper. - * If it's done from compinit.c, then DamageSetup may be called before the - * extension init phase, so that cw will be higher in the wrapping chain and - * rewrite drawables before damage gets to it, causing confusion. - */ - if (!noCompositeExtension) - miInitializeCompositeWrapper (pScreen); -#endif - pScrPriv->internalLevel = 0; pScrPriv->pScreenDamage = 0; @@ -1809,12 +1854,14 @@ DamageCreate (DamageReportFunc damageReport, pDamage->pNext = 0; pDamage->pNextWin = 0; RegionNull(&pDamage->damage); + RegionNull(&pDamage->pendingDamage); pDamage->damageLevel = damageLevel; pDamage->isInternal = isInternal; pDamage->closure = closure; pDamage->isWindow = FALSE; pDamage->pDrawable = 0; + pDamage->reportAfter = FALSE; pDamage->damageReport = damageReport; pDamage->damageDestroy = damageDestroy; @@ -1898,6 +1945,7 @@ DamageDestroy (DamagePtr pDamage) if (pDamage->damageDestroy) (*pDamage->damageDestroy) (pDamage, pDamage->closure); RegionUninit(&pDamage->damage); + RegionUninit(&pDamage->pendingDamage); free (pDamage); } @@ -1951,4 +1999,16 @@ DamageDamageRegion (DrawablePtr pDrawable, RegionPtr pRegion) { damageDamageRegion (pDrawable, pRegion, FALSE, -1); + + /* Go back and report this damage for DamagePtrs with reportAfter set, since + * this call isn't part of an in-progress drawing op in the call chain and + * the DDX probably just wants to know about it right away. + */ + damageReportPostOp (pDrawable); +} + +void +DamageSetReportAfterOp (DamagePtr pDamage, Bool reportAfter) +{ + pDamage->reportAfter = reportAfter; } diff --git a/nx-X11/programs/Xserver/miext/damage/damage.h b/nx-X11/programs/Xserver/miext/damage/damage.h index a363e09bb2..4cfc8127de 100644 --- a/nx-X11/programs/Xserver/miext/damage/damage.h +++ b/nx-X11/programs/Xserver/miext/damage/damage.h @@ -1,6 +1,4 @@ /* - * $Id: damage.h,v 1.4 2005/07/03 07:02:01 daniels Exp $ - * * Copyright © 2003 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its @@ -81,4 +79,7 @@ void DamageDamageRegion (DrawablePtr pDrawable, const RegionPtr pRegion); +void +DamageSetReportAfterOp (DamagePtr pDamage, Bool reportAfter); + #endif /* _DAMAGE_H_ */ diff --git a/nx-X11/programs/Xserver/miext/damage/damagestr.h b/nx-X11/programs/Xserver/miext/damage/damagestr.h index 5b671cd3fe..c0bc3a7312 100644 --- a/nx-X11/programs/Xserver/miext/damage/damagestr.h +++ b/nx-X11/programs/Xserver/miext/damage/damagestr.h @@ -1,6 +1,4 @@ /* - * $Id: damagestr.h,v 1.6 2005/07/03 07:02:01 daniels Exp $ - * * Copyright © 2003 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its @@ -48,6 +46,9 @@ typedef struct _damage { DamageReportFunc damageReport; DamageDestroyFunc damageDestroy; + + Bool reportAfter; + RegionRec pendingDamage; } DamageRec; typedef struct _damageScrPriv { @@ -79,11 +80,7 @@ typedef struct _damageGCPriv { GCFuncs *funcs; } DamageGCPrivRec, *DamageGCPrivPtr; -extern int damageScrPrivateIndex; -extern int damagePixPrivateIndex; -extern int damageGCPrivateIndex; -extern int damageWinPrivateIndex; - +/* XXX should move these into damage.c, damageScrPrivateIndex is static */ #define damageGetScrPriv(pScr) \ ((DamageScrPrivPtr) (pScr)->devPrivates[damageScrPrivateIndex].ptr) diff --git a/nx-X11/programs/Xserver/os/WaitFor.c b/nx-X11/programs/Xserver/os/WaitFor.c index 3d53335b31..e2ace8bcb1 100644 --- a/nx-X11/programs/Xserver/os/WaitFor.c +++ b/nx-X11/programs/Xserver/os/WaitFor.c @@ -130,11 +130,13 @@ mffs(fd_mask mask) struct _OsTimerRec { OsTimerPtr next; CARD32 expires; + CARD32 delta; OsTimerCallback callback; void * arg; }; static void DoTimer(OsTimerPtr timer, CARD32 now, OsTimerPtr *prev); +static void CheckAllTimers(void); static OsTimerPtr timers = NULL; /***************** @@ -207,12 +209,20 @@ WaitForSomething(int *pClientsReady) { now = GetTimeInMillis(); timeout = timers->expires - now; - if (timeout < 0) - timeout = 0; - waittime.tv_sec = timeout / MILLI_PER_SECOND; - waittime.tv_usec = (timeout % MILLI_PER_SECOND) * - (1000000 / MILLI_PER_SECOND); - wt = &waittime; + if (timeout > 0 && timeout > timers->delta + 250) { + /* time has rewound. reset the timers. */ + CheckAllTimers(); + } + + if (timers) { + timeout = timers->expires - now; + if (timeout < 0) + timeout = 0; + waittime.tv_sec = timeout / MILLI_PER_SECOND; + waittime.tv_usec = (timeout % MILLI_PER_SECOND) * + (1000000 / MILLI_PER_SECOND); + wt = &waittime; + } } XFD_COPYSET(&AllSockets, &LastSelectMask); } @@ -345,7 +355,6 @@ WaitForSomething(int *pClientsReady) #endif selecterr = GetErrno(); WakeupHandler(i, (void *)&LastSelectMask); - SmartScheduleStartTimer (); if (i <= 0) /* An error or timeout occurred */ @@ -509,6 +518,24 @@ ANYSET(FdMask *src) } #endif +/* If time has rewound, re-run every affected timer. + * Timers might drop out of the list, so we have to restart every time. */ +static void +CheckAllTimers(void) +{ + OsTimerPtr timer; + CARD32 now; + +start: + now = GetTimeInMillis(); + + for (timer = timers; timer; timer = timer->next) { + if (timer->expires - now > timer->delta + 250) { + TimerForce(timer); + goto start; + } + } +} static void DoTimer(OsTimerPtr timer, CARD32 now, OsTimerPtr *prev) @@ -550,8 +577,13 @@ TimerSet(OsTimerPtr timer, int flags, CARD32 millis, } if (!millis) return timer; - if (!(flags & TimerAbsolute)) + if (flags & TimerAbsolute) { + timer->delta = millis - now; + } + else { + timer->delta = millis; millis += now; + } timer->expires = millis; timer->callback = func; timer->arg = arg; @@ -565,7 +597,7 @@ TimerSet(OsTimerPtr timer, int flags, CARD32 millis, for (prev = &timers; *prev && (int) ((*prev)->expires - millis) <= 0; prev = &(*prev)->next) - ; + ; timer->next = *prev; *prev = timer; return timer; diff --git a/nx-X11/programs/Xserver/os/access.c b/nx-X11/programs/Xserver/os/access.c index bea4b968a0..eecde1e30d 100644 --- a/nx-X11/programs/Xserver/os/access.c +++ b/nx-X11/programs/Xserver/os/access.c @@ -1,7 +1,6 @@ /*********************************************************** Copyright 1987, 1998 The Open Group -Copyright 2004 Sun Microsystems, Inc. All rights reserved. @@ -36,13 +35,13 @@ 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, +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 +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. +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 @@ -54,6 +53,29 @@ SOFTWARE. ******************************************************************/ +/* + * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. + */ + #ifdef HAVE_DIX_CONFIG_H #include #endif @@ -157,8 +179,7 @@ SOFTWARE. #include "osdep.h" #ifdef XCSECURITY -#define _SECURITY_SERVER -#include +#include "securitysrv.h" #endif #ifndef PATH_MAX diff --git a/nx-X11/programs/Xserver/os/auth.c b/nx-X11/programs/Xserver/os/auth.c index 491b8c4272..e21f56b1d6 100644 --- a/nx-X11/programs/Xserver/os/auth.c +++ b/nx-X11/programs/Xserver/os/auth.c @@ -68,8 +68,7 @@ from The Open Group. # include # include #ifdef XCSECURITY -#define _SECURITY_SERVER -# include +# include "securitysrv.h" #endif struct protocol { diff --git a/nx-X11/programs/Xserver/os/connection.c b/nx-X11/programs/Xserver/os/connection.c index 7deeec4281..1e628e4d07 100644 --- a/nx-X11/programs/Xserver/os/connection.c +++ b/nx-X11/programs/Xserver/os/connection.c @@ -80,12 +80,11 @@ SOFTWARE. #include +/* FIXME: correct indentation levels after ancient platform support clean-up */ + #if defined(TCPCONN) # include # include - -/* FIXME: correct indentation levels after ancient platform support clean-up */ - # ifdef apollo # ifndef NO_TCP_H # include @@ -100,15 +99,14 @@ SOFTWARE. #endif #include -#include "misc.h" +#include "misc.h" /* for typedef of void * */ #include "osdep.h" #include #include "opaque.h" #include "dixstruct.h" #include "list.h" #ifdef XCSECURITY -#define _SECURITY_SERVER -#include +#include "securitysrv.h" #endif #ifdef X_NOT_POSIX @@ -118,6 +116,11 @@ SOFTWARE. #endif int lastfdesc; /* maximum file descriptor */ +#ifdef HAS_GETPEERUCRED +# include +# include +#endif + fd_set NotifyReadFds; /* mask for other file descriptors */ fd_set NotifyWriteFds; /* mask for other write file descriptors */ @@ -222,7 +225,8 @@ InitConnectionLimits(void) ErrorF("InitConnectionLimits: MaxClients = %d\n", MaxClients); #endif - ConnectionTranslation = (int *)xnfalloc(sizeof(int)*(lastfdesc + 1)); + if (!ConnectionTranslation) + ConnectionTranslation = (int *)xnfalloc(sizeof(int)*(lastfdesc + 1)); } /* @@ -635,8 +639,7 @@ ClientAuthorized(ClientPtr client, _XSERVTransGetPeerAddr (trans_conn, &family, &fromlen, &from) != -1) { - if ( - InvalidHost ((struct sockaddr *) from, fromlen, client)) + if (InvalidHost ((struct sockaddr *) from, fromlen, client)) AuthAudit(client, FALSE, (struct sockaddr *) from, fromlen, proto_n, auth_proto, auth_id); else @@ -866,8 +869,6 @@ CloseDownFileDescriptor(OsCommPtr oc) _XSERVTransDisconnect(oc->trans_conn); _XSERVTransClose(oc->trans_conn); } - FreeOsBuffers(oc); - free(oc); ConnectionTranslation[connection] = 0; FD_CLR(connection, &AllSockets); FD_CLR(connection, &AllClients); @@ -916,9 +917,12 @@ CheckConnections(void) curclient = curoff + (i * (sizeof(fd_mask)*8)); FD_ZERO(&tmask); FD_SET(curclient, &tmask); - r = Select (curclient + 1, &tmask, NULL, NULL, ¬ime); + do { + r = Select (curclient + 1, &tmask, NULL, NULL, ¬ime); + } while (r < 0 && (errno == EINTR || errno == EAGAIN)); if (r < 0) - CloseDownClient(clients[ConnectionTranslation[curclient]]); + if (ConnectionTranslation[curclient] > 0) + CloseDownClient(clients[ConnectionTranslation[curclient]]); mask &= ~((fd_mask)1 << curoff); } } @@ -944,6 +948,8 @@ CloseDownConnection(ClientPtr client) XdmcpCloseDisplay(oc->fd); #endif CloseDownFileDescriptor(oc); + FreeOsBuffers(oc); + free(client->osPrivate); client->osPrivate = (void *)NULL; if (auditTrailLevel > 1) AuditF("client %d disconnected\n", client->index); diff --git a/nx-X11/programs/Xserver/os/io.c b/nx-X11/programs/Xserver/os/io.c index 7f35a81f17..cb2e4c389e 100644 --- a/nx-X11/programs/Xserver/os/io.c +++ b/nx-X11/programs/Xserver/os/io.c @@ -794,8 +794,7 @@ FlushAllOutput(void) if (client->clientGone) continue; oc = (OsCommPtr)client->osPrivate; - if ( - FD_ISSET(oc->fd, &ClientsWithInput)) + if (FD_ISSET(oc->fd, &ClientsWithInput)) { FD_SET(oc->fd, &OutputPending); /* set the bit again */ NewOutputPending = TRUE; diff --git a/nx-X11/programs/Xserver/os/secauth.c b/nx-X11/programs/Xserver/os/secauth.c index 5219b488a7..b9f10808e4 100644 --- a/nx-X11/programs/Xserver/os/secauth.c +++ b/nx-X11/programs/Xserver/os/secauth.c @@ -35,8 +35,7 @@ from The Open Group. #include "swaprep.h" #ifdef XCSECURITY -#define _SECURITY_SERVER -#include +#include "securitysrv.h" #endif static char InvalidPolicyReason[] = "invalid policy specification"; diff --git a/nx-X11/programs/Xserver/os/utils.c b/nx-X11/programs/Xserver/os/utils.c index eed8cbf135..73bc4a3e93 100644 --- a/nx-X11/programs/Xserver/os/utils.c +++ b/nx-X11/programs/Xserver/os/utils.c @@ -85,6 +85,9 @@ OR PERFORMANCE OF THIS SOFTWARE. #include #include +#include +#include +#include #include "misc.h" #include #define XSERV_t @@ -99,6 +102,7 @@ OR PERFORMANCE OF THIS SOFTWARE. # include #endif /* HAS_XFONT2 */ #include "osdep.h" +#include "extension.h" #ifdef X_POSIX_C_SOURCE #define _POSIX_C_SOURCE X_POSIX_C_SOURCE #include @@ -116,7 +120,6 @@ OR PERFORMANCE OF THIS SOFTWARE. #if !defined(SYSV) #include #endif -#include #include #include /* for isspace */ #include @@ -138,8 +141,7 @@ OR PERFORMANCE OF THIS SOFTWARE. #include "xkbsrv.h" #endif #ifdef XCSECURITY -#define _SECURITY_SERVER -#include +#include "securitysrv.h" #endif #ifdef RENDER @@ -517,17 +519,21 @@ GiveUp(int sig) errno = olderrno; } -#ifndef DDXTIME CARD32 GetTimeInMillis(void) { - struct timeval tp; + struct timeval tv; - X_GETTIMEOFDAY(&tp); - return(tp.tv_sec * 1000) + (tp.tv_usec / 1000); -} +#ifdef MONOTONIC_CLOCK + struct timespec tp; + if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0) + return (tp.tv_sec * 1000) + (tp.tv_nsec / 1000000L); #endif + X_GETTIMEOFDAY(&tv); + return(tv.tv_sec * 1000) + (tv.tv_usec / 1000); +} + void AdjustWaitForDelay (void * waitTime, unsigned long newdelay) { @@ -566,7 +572,6 @@ void UseMsg(void) #endif ErrorF("-audit int set audit trail level\n"); ErrorF("-auth file select authorization file\n"); - ErrorF("bc enable bug compatibility\n"); ErrorF("-br create root window with black background\n"); ErrorF("+bs enable any backing store support\n"); ErrorF("-bs disable any backing store support\n"); @@ -903,7 +908,7 @@ ProcessCommandLine(int argc, char *argv[]) #ifdef SERVER_LOCK else if ( strcmp ( argv[i], "-nolock") == 0) { -#if !defined(__CYGWIN__) +#if !defined(__CYGWIN__) if (getuid() != 0) ErrorF("Warning: the -nolock option can only be used by root\n"); else @@ -1223,7 +1228,7 @@ ExpandCommandLine(int *pargc, char ***pargv) { int i; -#if !defined(__CYGWIN__) +#if !defined(__CYGWIN__) if (getuid() != geteuid()) return; #endif diff --git a/nx-X11/programs/Xserver/os/xdmcp.c b/nx-X11/programs/Xserver/os/xdmcp.c index 8da1131ed9..93a9acd312 100644 --- a/nx-X11/programs/Xserver/os/xdmcp.c +++ b/nx-X11/programs/Xserver/os/xdmcp.c @@ -1556,6 +1556,10 @@ get_fromaddr_by_name( , &ai, &aifirst #endif ); +#if defined(IPv6) && defined(AF_INET6) + if (aifirst != NULL) + freeaddrinfo(aifirst); +#endif xdm_from = argv[i]; } diff --git a/nx-X11/programs/Xserver/render/Imakefile b/nx-X11/programs/Xserver/render/Imakefile index 2246a35d98..5d9d1b42b3 100644 --- a/nx-X11/programs/Xserver/render/Imakefile +++ b/nx-X11/programs/Xserver/render/Imakefile @@ -5,12 +5,14 @@ #if (!(defined(NXAgentServer) && NXAgentServer)) NXAGENT_SKIP_SRCS = \ glyph.c \ + miglyph.c \ mitrap.c \ picture.c \ render.c \ $(NULL) NXAGENT_SKIP_OBJS = \ glyph.o \ + miglyph.o \ mitrap.o \ picture.o \ render.o \ diff --git a/nx-X11/programs/Xserver/render/animcur.c b/nx-X11/programs/Xserver/render/animcur.c index 7336cdeff4..ac1115e2cb 100644 --- a/nx-X11/programs/Xserver/render/animcur.c +++ b/nx-X11/programs/Xserver/render/animcur.c @@ -1,4 +1,5 @@ /* + * * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its @@ -86,8 +87,8 @@ static CursorBits animCursorBits = { empty, empty, 2, 1, 1, 0, 0, 1 }; -int AnimCurScreenPrivateIndex = -1; -int AnimCurGeneration; +static int AnimCurScreenPrivateIndex = -1; +static int AnimCurGeneration; #define IsAnimCur(c) ((c)->bits == &animCursorBits) #define GetAnimCur(c) ((AnimCurPtr) ((c) + 1)) @@ -128,7 +129,7 @@ AnimCurCloseScreen (ScreenPtr pScreen) ret = (*pScreen->CloseScreen) (pScreen); free (as); if (screenInfo.numScreens <= 1) - AnimCurScreenPrivateIndex = -1; + AnimCurScreenPrivateIndex = -1; return ret; } diff --git a/nx-X11/programs/Xserver/render/filter.c b/nx-X11/programs/Xserver/render/filter.c index 71b893a755..72e62ab894 100644 --- a/nx-X11/programs/Xserver/render/filter.c +++ b/nx-X11/programs/Xserver/render/filter.c @@ -1,6 +1,4 @@ /* - * $Id: filter.c,v 1.10 2005/07/03 08:53:54 daniels Exp $ - * * Copyright © 2002 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its diff --git a/nx-X11/programs/Xserver/render/glyph.c b/nx-X11/programs/Xserver/render/glyph.c index 93aed401bc..b7e91648fa 100644 --- a/nx-X11/programs/Xserver/render/glyph.c +++ b/nx-X11/programs/Xserver/render/glyph.c @@ -1,4 +1,5 @@ /* + * * Copyright © 2000 SuSE, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its @@ -40,7 +41,6 @@ #include "servermd.h" #include "picturestr.h" #include "glyphstr.h" -#include "mipict.h" #include @@ -79,9 +79,287 @@ static GlyphHashSetRec glyphHashSets[] = { #define NGLYPHHASHSETS (sizeof(glyphHashSets)/sizeof(glyphHashSets[0])) +#ifndef NXAGENT_SERVER +static +#endif const CARD8 glyphDepths[GlyphFormatNum] = { 1, 4, 8, 16, 32 }; -GlyphHashRec globalGlyphs[GlyphFormatNum]; +static GlyphHashRec globalGlyphs[GlyphFormatNum]; + +static int globalTotalGlyphPrivateSize = 0; + +static int glyphPrivateCount = 0; + +void +ResetGlyphPrivates (void) +{ + glyphPrivateCount = 0; +} + +int +AllocateGlyphPrivateIndex (void) +{ + return glyphPrivateCount++; +} + +Bool +AllocateGlyphPrivate (ScreenPtr pScreen, + int index2, + unsigned amount) +{ + PictureScreenPtr ps; + unsigned oldamount; + + ps = GetPictureScreenIfSet (pScreen); + if (!ps) + return FALSE; + + /* Round up sizes for proper alignment */ + amount = ((amount + (sizeof (DevUnion) - 1)) / sizeof (DevUnion)) * + sizeof (DevUnion); + + if (index2 >= ps->glyphPrivateLen) + { + unsigned *nsizes; + nsizes = (unsigned *) realloc (ps->glyphPrivateSizes, + (index2 + 1) * sizeof (unsigned)); + if (!nsizes) + return FALSE; + + while (ps->glyphPrivateLen <= index2) + { + nsizes[ps->glyphPrivateLen++] = 0; + ps->totalGlyphPrivateSize += sizeof (DevUnion); + } + ps->glyphPrivateSizes = nsizes; + } + oldamount = ps->glyphPrivateSizes[index2]; + if (amount > oldamount) + { + ps->glyphPrivateSizes[index2] = amount; + ps->totalGlyphPrivateSize += (amount - oldamount); + } + ps->totalGlyphPrivateSize = BitmapBytePad (ps->totalGlyphPrivateSize * 8); + + return TRUE; +} + +static void +SetGlyphScreenPrivateOffsets (void) +{ + PictureScreenPtr ps; + int offset = 0; + int i; + + for (i = 0; i < screenInfo.numScreens; i++) + { + ps = GetPictureScreenIfSet (screenInfo.screens[i]); + if (ps && ps->totalGlyphPrivateSize) + { + ps->glyphPrivateOffset = offset; + offset += ps->totalGlyphPrivateSize / sizeof (DevUnion); + } + } +} + +static void +SetGlyphPrivatePointers (GlyphPtr glyph) +{ + PictureScreenPtr ps; + int i; + char *ptr; + DevUnion *ppriv; + unsigned *sizes; + unsigned size; + int len; + + for (i = 0; i < screenInfo.numScreens; i++) + { + ps = GetPictureScreenIfSet (screenInfo.screens[i]); + if (ps && ps->totalGlyphPrivateSize) + { + ppriv = glyph->devPrivates + ps->glyphPrivateOffset; + sizes = ps->glyphPrivateSizes; + ptr = (char *) (ppriv + ps->glyphPrivateLen); + for (len = ps->glyphPrivateLen; --len >= 0; ppriv++, sizes++) + { + if ((size = *sizes) != 0) + { + ppriv->ptr = (void *) ptr; + ptr += size; + } + else + ppriv->ptr = (void *) 0; + } + } + } +} + +static Bool +ReallocGlobalGlyphPrivate (GlyphPtr glyph) +{ + PictureScreenPtr ps; + DevUnion *devPrivates; + char *ptr; + int i; + + devPrivates = malloc (globalTotalGlyphPrivateSize); + if (!devPrivates) + return FALSE; + + ptr = (char *) devPrivates; + for (i = 0; i < screenInfo.numScreens; i++) + { + ps = GetPictureScreenIfSet (screenInfo.screens[i]); + if (ps && ps->totalGlyphPrivateSize) + { + if (ps->glyphPrivateOffset != -1) + { + memcpy (ptr, glyph->devPrivates + ps->glyphPrivateOffset, + ps->totalGlyphPrivateSize); + } + else if (ps->totalGlyphPrivateSize) + { + memset (ptr, 0, ps->totalGlyphPrivateSize); + } + + ptr += ps->totalGlyphPrivateSize; + } + } + + if (glyph->devPrivates) + free (glyph->devPrivates); + + glyph->devPrivates = devPrivates; + + return TRUE; +} + +Bool +GlyphInit (ScreenPtr pScreen) +{ + PictureScreenPtr ps = GetPictureScreen (pScreen); + + ps->totalGlyphPrivateSize = 0; + ps->glyphPrivateSizes = 0; + ps->glyphPrivateLen = 0; + ps->glyphPrivateOffset = -1; + + return TRUE; +} + +Bool +GlyphFinishInit (ScreenPtr pScreen) +{ + PictureScreenPtr ps = GetPictureScreen (pScreen); + + if (ps->totalGlyphPrivateSize) + { + GlyphPtr glyph; + int fdepth, i; + + globalTotalGlyphPrivateSize += ps->totalGlyphPrivateSize; + + for (fdepth = 0; fdepth < GlyphFormatNum; fdepth++) + { + if (!globalGlyphs[fdepth].hashSet) + continue; + + for (i = 0; i < globalGlyphs[fdepth].hashSet->size; i++) + { + glyph = globalGlyphs[fdepth].table[i].glyph; + if (glyph && glyph != DeletedGlyph) + { + if (!ReallocGlobalGlyphPrivate (glyph)) + return FALSE; + } + } + } + + SetGlyphScreenPrivateOffsets (); + + for (fdepth = 0; fdepth < GlyphFormatNum; fdepth++) + { + if (!globalGlyphs[fdepth].hashSet) + continue; + + for (i = 0; i < globalGlyphs[fdepth].hashSet->size; i++) + { + glyph = globalGlyphs[fdepth].table[i].glyph; + if (glyph && glyph != DeletedGlyph) + { + SetGlyphPrivatePointers (glyph); + + if (!(*ps->RealizeGlyph) (pScreen, glyph)) + return FALSE; + } + } + } + } + else + ps->glyphPrivateOffset = 0; + + return TRUE; +} + +void +GlyphUninit (ScreenPtr pScreen) +{ + PictureScreenPtr ps = GetPictureScreen (pScreen); + GlyphPtr glyph; + int fdepth, i; + + globalTotalGlyphPrivateSize -= ps->totalGlyphPrivateSize; + + for (fdepth = 0; fdepth < GlyphFormatNum; fdepth++) + { + if (!globalGlyphs[fdepth].hashSet) + continue; + + for (i = 0; i < globalGlyphs[fdepth].hashSet->size; i++) + { + glyph = globalGlyphs[fdepth].table[i].glyph; + if (glyph && glyph != DeletedGlyph) + { + (*ps->UnrealizeGlyph) (pScreen, glyph); + + if (globalTotalGlyphPrivateSize) + { + if (!ReallocGlobalGlyphPrivate (glyph)) + return; + } + else + { + if (glyph->devPrivates) + free (glyph->devPrivates); + glyph->devPrivates = NULL; + } + } + } + } + + if (globalTotalGlyphPrivateSize) + SetGlyphScreenPrivateOffsets (); + + for (fdepth = 0; fdepth < GlyphFormatNum; fdepth++) + { + if (!globalGlyphs[fdepth].hashSet) + continue; + + for (i = 0; i < globalGlyphs[fdepth].hashSet->size; i++) + { + glyph = globalGlyphs[fdepth].table[i].glyph; + if (glyph && glyph != DeletedGlyph) + { + if (globalTotalGlyphPrivateSize) + SetGlyphPrivatePointers (glyph); + } + } + } + + if (ps->glyphPrivateSizes) + free (ps->glyphPrivateSizes); +} GlyphHashSetPtr FindGlyphHashSet (CARD32 filled) @@ -111,17 +389,17 @@ ResetGlyphSetPrivateIndex (void) Bool _GlyphSetSetNewPrivate (GlyphSetPtr glyphSet, int n, void * ptr) { - void **new; + void * *new; if (n > glyphSet->maxPrivate) { if (glyphSet->devPrivates && glyphSet->devPrivates != (void *)(&glyphSet[1])) { - new = (void **) realloc (glyphSet->devPrivates, + new = (void * *) realloc (glyphSet->devPrivates, (n + 1) * sizeof (void *)); if (!new) return FALSE; } else { - new = (void **) malloc ((n + 1) * sizeof (void *)); + new = (void * *) malloc ((n + 1) * sizeof (void *)); if (!new) return FALSE; if (glyphSet->devPrivates) @@ -138,12 +416,6 @@ _GlyphSetSetNewPrivate (GlyphSetPtr glyphSet, int n, void * ptr) return TRUE; } -Bool -GlyphInit (ScreenPtr pScreen) -{ - return TRUE; -} - #ifndef NXAGENT_SERVER GlyphRefPtr FindGlyphRef (GlyphHashPtr hash, CARD32 signature, Bool match, GlyphPtr compare) @@ -242,9 +514,10 @@ FreeGlyph (GlyphPtr glyph, int format) CheckDuplicates (&globalGlyphs[format], "FreeGlyph"); if (--glyph->refcnt == 0) { - GlyphRefPtr gr; - int i; - int first; + PictureScreenPtr ps; + GlyphRefPtr gr; + int i; + int first; first = -1; for (i = 0; i < globalGlyphs[format].hashSet->size; i++) @@ -265,6 +538,16 @@ FreeGlyph (GlyphPtr glyph, int format) gr->signature = 0; globalGlyphs[format].tableEntries--; } + + for (i = 0; i < screenInfo.numScreens; i++) + { + ps = GetPictureScreenIfSet (screenInfo.screens[i]); + if (ps) + (*ps->UnrealizeGlyph) (screenInfo.screens[i], glyph); + } + + if (glyph->devPrivates) + free (glyph->devPrivates); free (glyph); } } @@ -282,6 +565,17 @@ AddGlyph (GlyphSetPtr glyphSet, GlyphPtr glyph, Glyph id) gr = FindGlyphRef (&globalGlyphs[glyphSet->fdepth], hash, TRUE, glyph); if (gr->glyph && gr->glyph != DeletedGlyph) { + PictureScreenPtr ps; + int i; + + for (i = 0; i < screenInfo.numScreens; i++) + { + ps = GetPictureScreenIfSet (screenInfo.screens[i]); + if (ps) + (*ps->UnrealizeGlyph) (screenInfo.screens[i], glyph); + } + if (glyph->devPrivates) + free (glyph->devPrivates); free (glyph); glyph = gr->glyph; } @@ -339,8 +633,10 @@ FindGlyph (GlyphSetPtr glyphSet, Glyph id) GlyphPtr AllocateGlyph (xGlyphInfo *gi, int fdepth) { - int size; - GlyphPtr glyph; + PictureScreenPtr ps; + int size; + GlyphPtr glyph; + int i; size_t padded_width; padded_width = PixmapBytePad (gi->width, glyphDepths[fdepth]); @@ -353,6 +649,39 @@ AllocateGlyph (xGlyphInfo *gi, int fdepth) glyph->refcnt = 0; glyph->size = size + sizeof (xGlyphInfo); glyph->info = *gi; + + if (globalTotalGlyphPrivateSize) + { + glyph->devPrivates = malloc (globalTotalGlyphPrivateSize); + if (!glyph->devPrivates) + return 0; + + SetGlyphPrivatePointers (glyph); + } else + glyph->devPrivates = NULL; + + for (i = 0; i < screenInfo.numScreens; i++) + { + ps = GetPictureScreenIfSet (screenInfo.screens[i]); + if (ps) + { + if (!(*ps->RealizeGlyph) (screenInfo.screens[i], glyph)) + { + while (i--) + { + ps = GetPictureScreenIfSet (screenInfo.screens[i]); + if (ps) + (*ps->UnrealizeGlyph) (screenInfo.screens[i], glyph); + } + + if (glyph->devPrivates) + free (glyph->devPrivates); + free (glyph); + return 0; + } + } + } + return glyph; } @@ -455,7 +784,7 @@ AllocateGlyphSet (int fdepth, PictFormatPtr format) } int -FreeGlyphSet (void *value, +FreeGlyphSet (void * value, XID gid) { GlyphSetPtr glyphSet = (GlyphSetPtr) value; @@ -490,210 +819,3 @@ FreeGlyphSet (void *value, } return Success; } - -void -GlyphExtents(int nlist, GlyphListPtr list, GlyphPtr * glyphs, BoxPtr extents) -{ - int x1, x2, y1, y2; - int n; - GlyphPtr glyph; - int x, y; - - x = 0; - y = 0; - extents->x1 = MAXSHORT; - extents->x2 = MINSHORT; - extents->y1 = MAXSHORT; - extents->y2 = MINSHORT; - while (nlist--) { - x += list->xOff; - y += list->yOff; - n = list->len; - list++; - while (n--) { - glyph = *glyphs++; - x1 = x - glyph->info.x; - if (x1 < MINSHORT) - x1 = MINSHORT; - y1 = y - glyph->info.y; - if (y1 < MINSHORT) - y1 = MINSHORT; - x2 = x1 + glyph->info.width; - if (x2 > MAXSHORT) - x2 = MAXSHORT; - y2 = y1 + glyph->info.height; - if (y2 > MAXSHORT) - y2 = MAXSHORT; - if (x1 < extents->x1) - extents->x1 = x1; - if (x2 > extents->x2) - extents->x2 = x2; - if (y1 < extents->y1) - extents->y1 = y1; - if (y2 > extents->y2) - extents->y2 = y2; - x += glyph->info.xOff; - y += glyph->info.yOff; - } - } -} - -#define NeedsComponent(f) (PICT_FORMAT_A(f) != 0 && PICT_FORMAT_RGB(f) != 0) - -void -CompositeGlyphs(CARD8 op, - PicturePtr pSrc, - PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, - INT16 ySrc, int nlist, GlyphListPtr lists, GlyphPtr * glyphs) -{ - PictureScreenPtr ps = GetPictureScreen(pDst->pDrawable->pScreen); - - ValidatePicture(pSrc); - ValidatePicture(pDst); - (*ps->Glyphs) (op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, lists, - glyphs); -} - -#ifndef NXAGENT_SERVER -void -miGlyphs(CARD8 op, - PicturePtr pSrc, - PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, - INT16 ySrc, int nlist, GlyphListPtr list, GlyphPtr * glyphs) -{ - PixmapPtr pPixmap = 0; - PicturePtr pPicture; - PixmapPtr pMaskPixmap = 0; - PicturePtr pMask; - ScreenPtr pScreen = pDst->pDrawable->pScreen; - int width = 0, height = 0; - int x, y; - int xDst = list->xOff, yDst = list->yOff; - int n; - GlyphPtr glyph; - int error; - BoxRec extents; - CARD32 component_alpha; - - if (maskFormat) { - GCPtr pGC; - xRectangle rect; - - GlyphExtents(nlist, list, glyphs, &extents); - - if (extents.x2 <= extents.x1 || extents.y2 <= extents.y1) - return; - width = extents.x2 - extents.x1; - height = extents.y2 - extents.y1; - pMaskPixmap = - (*pScreen->CreatePixmap) (pScreen, width, height, - maskFormat->depth, - CREATE_PIXMAP_USAGE_SCRATCH); - if (!pMaskPixmap) - return; - component_alpha = NeedsComponent(maskFormat->format); - pMask = CreatePicture(0, &pMaskPixmap->drawable, - maskFormat, CPComponentAlpha, &component_alpha, - serverClient, &error); - if (!pMask) { - (*pScreen->DestroyPixmap) (pMaskPixmap); - return; - } - pGC = GetScratchGC(pMaskPixmap->drawable.depth, pScreen); - ValidateGC(&pMaskPixmap->drawable, pGC); - rect.x = 0; - rect.y = 0; - rect.width = width; - rect.height = height; - (*pGC->ops->PolyFillRect) (&pMaskPixmap->drawable, pGC, 1, &rect); - FreeScratchGC(pGC); - x = -extents.x1; - y = -extents.y1; - } - else { - pMask = pDst; - x = 0; - y = 0; - } - pPicture = 0; - while (nlist--) { - x += list->xOff; - y += list->yOff; - n = list->len; - while (n--) { - glyph = *glyphs++; - if (!pPicture) { - pPixmap = - GetScratchPixmapHeader(pScreen, glyph->info.width, - glyph->info.height, - list->format->depth, - list->format->depth, 0, - (void *) (glyph + 1)); - if (!pPixmap) - return; - component_alpha = NeedsComponent(list->format->format); - pPicture = CreatePicture(0, &pPixmap->drawable, list->format, - CPComponentAlpha, &component_alpha, - serverClient, &error); - if (!pPicture) { - FreeScratchPixmapHeader(pPixmap); - return; - } - } - (*pScreen->ModifyPixmapHeader) (pPixmap, - glyph->info.width, - glyph->info.height, 0, 0, -1, - (void *) (glyph + 1)); - pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER; - if (maskFormat) { - CompositePicture(PictOpAdd, - pPicture, - None, - pMask, - 0, 0, - 0, 0, - x - glyph->info.x, - y - glyph->info.y, - glyph->info.width, glyph->info.height); - } - else { - CompositePicture(op, - pSrc, - pPicture, - pDst, - xSrc + (x - glyph->info.x) - xDst, - ySrc + (y - glyph->info.y) - yDst, - 0, 0, - x - glyph->info.x, - y - glyph->info.y, - glyph->info.width, glyph->info.height); - } - x += glyph->info.xOff; - y += glyph->info.yOff; - } - list++; - if (pPicture) { - FreeScratchPixmapHeader(pPixmap); - FreePicture((void *) pPicture, 0); - pPicture = 0; - pPixmap = 0; - } - } - if (maskFormat) { - x = extents.x1; - y = extents.y1; - CompositePicture(op, - pSrc, - pMask, - pDst, - xSrc + x - xDst, - ySrc + y - yDst, 0, 0, x, y, width, height); - FreePicture((void *) pMask, (XID) 0); - (*pScreen->DestroyPixmap) (pMaskPixmap); - } -} -#endif diff --git a/nx-X11/programs/Xserver/render/glyphstr.h b/nx-X11/programs/Xserver/render/glyphstr.h index 5c4ed4933b..adcc72b637 100644 --- a/nx-X11/programs/Xserver/render/glyphstr.h +++ b/nx-X11/programs/Xserver/render/glyphstr.h @@ -27,6 +27,8 @@ #include #include "picture.h" #include "screenint.h" +#include "regionstr.h" +#include "miscstruct.h" #define GlyphFormat1 0 #define GlyphFormat4 1 @@ -37,6 +39,7 @@ typedef struct _Glyph { CARD32 refcnt; + DevUnion *devPrivates; CARD32 size; /* info + bitmap */ xGlyphInfo info; /* bits follow */ @@ -95,8 +98,6 @@ typedef struct _GlyphList { PictFormatPtr format; } GlyphListRec, *GlyphListPtr; -extern GlyphHashRec globalGlyphs[GlyphFormatNum]; - GlyphHashSetPtr FindGlyphHashSet (CARD32 filled); @@ -109,9 +110,29 @@ ResetGlyphSetPrivateIndex (void); Bool _GlyphSetSetNewPrivate (GlyphSetPtr glyphSet, int n, void * ptr); +void +ResetGlyphPrivates (void); + +int +AllocateGlyphPrivateIndex (void); + +Bool +AllocateGlyphPrivate (ScreenPtr pScreen, + int index2, + unsigned amount); + Bool GlyphInit (ScreenPtr pScreen); +Bool +GlyphFinishInit (ScreenPtr pScreen); + +void +GlyphUninit (ScreenPtr pScreen); + +GlyphHashSetPtr +FindGlyphHashSet (CARD32 filled); + GlyphRefPtr FindGlyphRef (GlyphHashPtr hash, CARD32 signature, Bool match, GlyphPtr compare); diff --git a/nx-X11/programs/Xserver/render/miglyph.c b/nx-X11/programs/Xserver/render/miglyph.c new file mode 100644 index 0000000000..a6711c18ae --- /dev/null +++ b/nx-X11/programs/Xserver/render/miglyph.c @@ -0,0 +1,257 @@ +/* + * + * Copyright © 2000 SuSE, Inc. + * + * 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 SuSE not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. SuSE makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE + * 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. + * + * Author: Keith Packard, SuSE, Inc. + */ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include "scrnintstr.h" +#include "gcstruct.h" +#include "pixmapstr.h" +#include "windowstr.h" +#include "mi.h" +#include "picturestr.h" +#include "mipict.h" + +Bool +miRealizeGlyph (ScreenPtr pScreen, + GlyphPtr glyph) +{ + return TRUE; +} + +void +miUnrealizeGlyph (ScreenPtr pScreen, + GlyphPtr glyph) +{ +} + +void +miGlyphExtents (int nlist, + GlyphListPtr list, + GlyphPtr *glyphs, + BoxPtr extents) +{ + int x1, x2, y1, y2; + int n; + GlyphPtr glyph; + int x, y; + + x = 0; + y = 0; + extents->x1 = MAXSHORT; + extents->x2 = MINSHORT; + extents->y1 = MAXSHORT; + extents->y2 = MINSHORT; + while (nlist--) + { + x += list->xOff; + y += list->yOff; + n = list->len; + list++; + while (n--) + { + glyph = *glyphs++; + x1 = x - glyph->info.x; + if (x1 < MINSHORT) + x1 = MINSHORT; + y1 = y - glyph->info.y; + if (y1 < MINSHORT) + y1 = MINSHORT; + x2 = x1 + glyph->info.width; + if (x2 > MAXSHORT) + x2 = MAXSHORT; + y2 = y1 + glyph->info.height; + if (y2 > MAXSHORT) + y2 = MAXSHORT; + if (x1 < extents->x1) + extents->x1 = x1; + if (x2 > extents->x2) + extents->x2 = x2; + if (y1 < extents->y1) + extents->y1 = y1; + if (y2 > extents->y2) + extents->y2 = y2; + x += glyph->info.xOff; + y += glyph->info.yOff; + } + } +} + +#define NeedsComponent(f) (PICT_FORMAT_A(f) != 0 && PICT_FORMAT_RGB(f) != 0) + +#ifndef NXAGENT_SERVER +void +miGlyphs (CARD8 op, + PicturePtr pSrc, + PicturePtr pDst, + PictFormatPtr maskFormat, + INT16 xSrc, + INT16 ySrc, + int nlist, + GlyphListPtr list, + GlyphPtr *glyphs) +{ + PixmapPtr pPixmap = 0; + PicturePtr pPicture; + PixmapPtr pMaskPixmap = 0; + PicturePtr pMask; + ScreenPtr pScreen = pDst->pDrawable->pScreen; + int width = 0, height = 0; + int x, y; + int xDst = list->xOff, yDst = list->yOff; + int n; + GlyphPtr glyph; + int error; + BoxRec extents; + CARD32 component_alpha; + + if (maskFormat) + { + GCPtr pGC; + xRectangle rect; + + miGlyphExtents (nlist, list, glyphs, &extents); + + if (extents.x2 <= extents.x1 || extents.y2 <= extents.y1) + return; + width = extents.x2 - extents.x1; + height = extents.y2 - extents.y1; + pMaskPixmap = (*pScreen->CreatePixmap) (pScreen, width, height, maskFormat->depth, 0); + if (!pMaskPixmap) + return; + component_alpha = NeedsComponent(maskFormat->format); + pMask = CreatePicture (0, &pMaskPixmap->drawable, + maskFormat, CPComponentAlpha, &component_alpha, + serverClient, &error); + if (!pMask) + { + (*pScreen->DestroyPixmap) (pMaskPixmap); + return; + } + pGC = GetScratchGC (pMaskPixmap->drawable.depth, pScreen); + ValidateGC (&pMaskPixmap->drawable, pGC); + rect.x = 0; + rect.y = 0; + rect.width = width; + rect.height = height; + (*pGC->ops->PolyFillRect) (&pMaskPixmap->drawable, pGC, 1, &rect); + FreeScratchGC (pGC); + x = -extents.x1; + y = -extents.y1; + } + else + { + pMask = pDst; + x = 0; + y = 0; + } + pPicture = 0; + while (nlist--) + { + x += list->xOff; + y += list->yOff; + n = list->len; + while (n--) + { + glyph = *glyphs++; + if (!pPicture) + { + pPixmap = GetScratchPixmapHeader (pScreen, glyph->info.width, glyph->info.height, + list->format->depth, + list->format->depth, + 0, (void *) (glyph + 1)); + if (!pPixmap) + return; + component_alpha = NeedsComponent(list->format->format); + pPicture = CreatePicture (0, &pPixmap->drawable, list->format, + CPComponentAlpha, &component_alpha, + serverClient, &error); + if (!pPicture) + { + FreeScratchPixmapHeader (pPixmap); + return; + } + } + (*pScreen->ModifyPixmapHeader) (pPixmap, + glyph->info.width, glyph->info.height, + 0, 0, -1, (void *) (glyph + 1)); + pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER; + if (maskFormat) + { + CompositePicture (PictOpAdd, + pPicture, + None, + pMask, + 0, 0, + 0, 0, + x - glyph->info.x, + y - glyph->info.y, + glyph->info.width, + glyph->info.height); + } + else + { + CompositePicture (op, + pSrc, + pPicture, + pDst, + xSrc + (x - glyph->info.x) - xDst, + ySrc + (y - glyph->info.y) - yDst, + 0, 0, + x - glyph->info.x, + y - glyph->info.y, + glyph->info.width, + glyph->info.height); + } + x += glyph->info.xOff; + y += glyph->info.yOff; + } + list++; + if (pPicture) + { + FreeScratchPixmapHeader (pPixmap); + FreePicture ((void *) pPicture, 0); + pPicture = 0; + pPixmap = 0; + } + } + if (maskFormat) + { + x = extents.x1; + y = extents.y1; + CompositePicture (op, + pSrc, + pMask, + pDst, + xSrc + x - xDst, + ySrc + y - yDst, + 0, 0, + x, y, + width, height); + FreePicture ((void *) pMask, (XID) 0); + (*pScreen->DestroyPixmap) (pMaskPixmap); + } +} +#endif diff --git a/nx-X11/programs/Xserver/render/miindex.c b/nx-X11/programs/Xserver/render/miindex.c index 5b5f35b199..91ec3da44b 100644 --- a/nx-X11/programs/Xserver/render/miindex.c +++ b/nx-X11/programs/Xserver/render/miindex.c @@ -1,4 +1,5 @@ /* + * * Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its diff --git a/nx-X11/programs/Xserver/render/mipict.c b/nx-X11/programs/Xserver/render/mipict.c index 9b8f0cfdaa..bfcea97c69 100644 --- a/nx-X11/programs/Xserver/render/mipict.c +++ b/nx-X11/programs/Xserver/render/mipict.c @@ -1,4 +1,5 @@ /* + * * Copyright © 1999 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its @@ -265,19 +266,19 @@ miChangePictureFilter (PicturePtr pPicture, #define BOUND(v) (INT16) ((v) < MINSHORT ? MINSHORT : (v) > MAXSHORT ? MAXSHORT : (v)) -static __inline Bool -miClipPictureReg (RegionPtr pRegion, - RegionPtr pClip, +static inline pixman_bool_t +miClipPictureReg (pixman_region16_t * pRegion, + pixman_region16_t * pClip, int dx, int dy) { - if (RegionNumRects(pRegion) == 1 && - RegionNumRects(pClip) == 1) + if (pixman_region_n_rects(pRegion) == 1 && + pixman_region_n_rects(pClip) == 1) { - BoxPtr pRbox = RegionRects(pRegion); - BoxPtr pCbox = RegionRects(pClip); + pixman_box16_t * pRbox = pixman_region_rectangles(pRegion, NULL); + pixman_box16_t * pCbox = pixman_region_rectangles(pClip, NULL); int v; - + if (pRbox->x1 < (v = pCbox->x1 + dx)) pRbox->x1 = BOUND(v); if (pRbox->x2 > (v = pCbox->x2 + dx)) @@ -289,23 +290,23 @@ miClipPictureReg (RegionPtr pRegion, if (pRbox->x1 >= pRbox->x2 || pRbox->y1 >= pRbox->y2) { - RegionEmpty(pRegion); + pixman_region_init (pRegion); } } - else if (!RegionNotEmpty(pClip)) + else if (!pixman_region_not_empty (pClip)) return FALSE; else { if (dx || dy) - RegionTranslate(pRegion, -dx, -dy); - if (!RegionIntersect(pRegion, pRegion, pClip)) + pixman_region_translate (pRegion, -dx, -dy); + if (!pixman_region_intersect (pRegion, pRegion, pClip)) return FALSE; if (dx || dy) - RegionTranslate(pRegion, dx, dy); + pixman_region_translate(pRegion, dx, dy); } - return RegionNotEmpty(pRegion); + return pixman_region_not_empty(pRegion); } - + static __inline Bool miClipPictureSrc (RegionPtr pRegion, PicturePtr pPicture, @@ -319,13 +320,13 @@ miClipPictureSrc (RegionPtr pRegion, { if (pPicture->clientClipType != CT_NONE) { - RegionTranslate(pRegion, + pixman_region_translate ( pRegion, dx - pPicture->clipOrigin.x, dy - pPicture->clipOrigin.y); - if (!RegionIntersect(pRegion, pRegion, - (RegionPtr) pPicture->clientClip)) + if (!RegionIntersect(pRegion, pRegion, + (RegionPtr) pPicture->pCompositeClip)) // clientClip)) return FALSE; - RegionTranslate(pRegion, + pixman_region_translate ( pRegion, - (dx - pPicture->clipOrigin.x), - (dy - pPicture->clipOrigin.y)); } @@ -340,7 +341,7 @@ miClipPictureSrc (RegionPtr pRegion, } } -static void +void miCompositeSourceValidate (PicturePtr pPicture, INT16 x, INT16 y, @@ -416,6 +417,7 @@ miComputeCompositeRegion (RegionPtr pRegion, CARD16 width, CARD16 height) { + int v; pRegion->extents.x1 = xDst; @@ -429,13 +431,13 @@ miComputeCompositeRegion (RegionPtr pRegion, if (pRegion->extents.x1 >= pRegion->extents.x2 || pRegion->extents.y1 >= pRegion->extents.y2) { - RegionEmpty(pRegion); + pixman_region_init (pRegion); return FALSE; } /* clip against dst */ if (!miClipPictureReg (pRegion, pDst->pCompositeClip, 0, 0)) { - RegionUninit(pRegion); + pixman_region_fini (pRegion); return FALSE; } if (pDst->alphaMap) @@ -444,14 +446,14 @@ miComputeCompositeRegion (RegionPtr pRegion, -pDst->alphaOrigin.x, -pDst->alphaOrigin.y)) { - RegionUninit(pRegion); + pixman_region_fini (pRegion); return FALSE; } } /* clip against src */ if (!miClipPictureSrc (pRegion, pSrc, xDst - xSrc, yDst - ySrc)) { - RegionUninit(pRegion); + pixman_region_fini (pRegion); return FALSE; } if (pSrc->alphaMap) @@ -460,7 +462,7 @@ miComputeCompositeRegion (RegionPtr pRegion, xDst - (xSrc + pSrc->alphaOrigin.x), yDst - (ySrc + pSrc->alphaOrigin.y))) { - RegionUninit(pRegion); + pixman_region_fini (pRegion); return FALSE; } } @@ -469,7 +471,7 @@ miComputeCompositeRegion (RegionPtr pRegion, { if (!miClipPictureSrc (pRegion, pMask, xDst - xMask, yDst - yMask)) { - RegionUninit(pRegion); + pixman_region_fini (pRegion); return FALSE; } if (pMask->alphaMap) @@ -478,14 +480,17 @@ miComputeCompositeRegion (RegionPtr pRegion, xDst - (xMask + pMask->alphaOrigin.x), yDst - (yMask + pMask->alphaOrigin.y))) { - RegionUninit(pRegion); + pixman_region_fini (pRegion); return FALSE; } } } + + miCompositeSourceValidate (pSrc, xSrc, ySrc, width, height); if (pMask) miCompositeSourceValidate (pMask, xMask, yMask, width, height); + return TRUE; } @@ -626,6 +631,8 @@ miPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats) ps->UpdateIndexed = miUpdateIndexed; ps->ChangePictureTransform = miChangePictureTransform; ps->ChangePictureFilter = miChangePictureFilter; + ps->RealizeGlyph = miRealizeGlyph; + ps->UnrealizeGlyph = miUnrealizeGlyph; /* MI rendering routines */ ps->Composite = 0; /* requires DDX support */ diff --git a/nx-X11/programs/Xserver/render/mipict.h b/nx-X11/programs/Xserver/render/mipict.h index 6a6554033e..d8b4f84114 100644 --- a/nx-X11/programs/Xserver/render/mipict.h +++ b/nx-X11/programs/Xserver/render/mipict.h @@ -1,4 +1,5 @@ /* + * * Copyright © 2000 SuSE, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its @@ -87,6 +88,12 @@ miClipPicture (RegionPtr pRegion, INT16 xPict, INT16 yPict); +void +miCompositeSourceValidate (PicturePtr pPicture, + INT16 x, + INT16 y, + CARD16 width, + CARD16 height); Bool miComputeCompositeRegion (RegionPtr pRegion, PicturePtr pSrc, @@ -104,6 +111,20 @@ miComputeCompositeRegion (RegionPtr pRegion, Bool miPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats); +Bool +miRealizeGlyph (ScreenPtr pScreen, + GlyphPtr glyph); + +void +miUnrealizeGlyph (ScreenPtr pScreen, + GlyphPtr glyph); + +void +miGlyphExtents (int nlist, + GlyphListPtr list, + GlyphPtr *glyphs, + BoxPtr extents); + void miGlyphs (CARD8 op, PicturePtr pSrc, diff --git a/nx-X11/programs/Xserver/render/mirect.c b/nx-X11/programs/Xserver/render/mirect.c index 49da8d4f87..10305a367c 100644 --- a/nx-X11/programs/Xserver/render/mirect.c +++ b/nx-X11/programs/Xserver/render/mirect.c @@ -1,4 +1,5 @@ /* + * * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its diff --git a/nx-X11/programs/Xserver/render/mitrap.c b/nx-X11/programs/Xserver/render/mitrap.c index 2155641cee..d0e02bc1cf 100644 --- a/nx-X11/programs/Xserver/render/mitrap.c +++ b/nx-X11/programs/Xserver/render/mitrap.c @@ -1,4 +1,5 @@ /* + * * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its diff --git a/nx-X11/programs/Xserver/render/mitri.c b/nx-X11/programs/Xserver/render/mitri.c index a39e236232..526cb250a5 100644 --- a/nx-X11/programs/Xserver/render/mitri.c +++ b/nx-X11/programs/Xserver/render/mitri.c @@ -1,4 +1,5 @@ /* + * * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its diff --git a/nx-X11/programs/Xserver/render/picture.c b/nx-X11/programs/Xserver/render/picture.c index c06ac35509..92ed145200 100644 --- a/nx-X11/programs/Xserver/render/picture.c +++ b/nx-X11/programs/Xserver/render/picture.c @@ -1,4 +1,5 @@ /* + * * Copyright © 2000 SuSE, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its @@ -43,9 +44,9 @@ #include "picturestr.h" #endif -int PictureScreenPrivateIndex = -1; +int PictureScreenPrivateIndex = -1; int PictureWindowPrivateIndex; -int PictureGeneration; +static int PictureGeneration; RESTYPE PictureType; RESTYPE PictFormatType; RESTYPE GlyphSetType; @@ -137,6 +138,7 @@ PictureCloseScreen (ScreenPtr pScreen) for (n = 0; n < ps->nformats; n++) if (ps->formats[n].type == PictTypeIndexed) (*ps->CloseIndexed) (pScreen, &ps->formats[n]); + GlyphUninit (pScreen); SetPictureScreen(pScreen, 0); if (ps->PicturePrivateSizes) free (ps->PicturePrivateSizes); @@ -235,10 +237,14 @@ PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp) formats[nformats].format = PICT_a1; formats[nformats].depth = 1; nformats++; - formats[nformats].format = PICT_a8; + formats[nformats].format = PICT_FORMAT(BitsPerPixel(8), + PICT_TYPE_A, + 8, 0, 0, 0); formats[nformats].depth = 8; nformats++; - formats[nformats].format = PICT_a4; + formats[nformats].format = PICT_FORMAT(BitsPerPixel(4), + PICT_TYPE_A, + 4, 0, 0, 0); formats[nformats].depth = 4; nformats++; formats[nformats].format = PICT_a8r8g8b8; @@ -496,6 +502,8 @@ PictureFinishInit (void) for (s = 0; s < screenInfo.numScreens; s++) { + if (!GlyphFinishInit (screenInfo.screens[s])) + return FALSE; if (!PictureInitIndexedFormats (screenInfo.screens[s])) return FALSE; (void) AnimCurInit (screenInfo.screens[s]); @@ -865,12 +873,12 @@ static CARD32 xRenderColorToCard32(xRenderColor c) static unsigned int premultiply(unsigned int x) { unsigned int a = x >> 24; - unsigned int t = (x & 0xff00ff) * a; - t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8; + unsigned int t = (x & 0xff00ff) * a + 0x800080; + t = (t + ((t >> 8) & 0xff00ff)) >> 8; t &= 0xff00ff; - x = ((x >> 8) & 0xff) * a; - x = (x + ((x >> 8) & 0xff) + 0x80); + x = ((x >> 8) & 0xff) * a + 0x80; + x = (x + ((x >> 8) & 0xff)); x &= 0xff00; x |= t | (a << 24); return x; @@ -889,54 +897,22 @@ static unsigned int INTERPOLATE_PIXEL_256(unsigned int x, unsigned int a, return x; } -static void initGradientColorTable(SourcePictPtr pGradient, int *error) +CARD32 +PictureGradientColor (PictGradientStopPtr stop1, + PictGradientStopPtr stop2, + CARD32 x) { - int begin_pos, end_pos; - xFixed incr, dpos; - int pos, current_stop; - PictGradientStopPtr stops = pGradient->linear.stops; - int nstops = pGradient->linear.nstops; - - /* The position where the gradient begins and ends */ - begin_pos = (stops[0].x * PICT_GRADIENT_STOPTABLE_SIZE) >> 16; - end_pos = (stops[nstops - 1].x * PICT_GRADIENT_STOPTABLE_SIZE) >> 16; - - pos = 0; /* The position in the color table. */ - - /* Up to first point */ - while (pos <= begin_pos) { - pGradient->linear.colorTable[pos] = xRenderColorToCard32(stops[0].color); - ++pos; - } - - incr = (1<<16)/ PICT_GRADIENT_STOPTABLE_SIZE; /* the double increment. */ - dpos = incr * pos; /* The position in terms of 0-1. */ - - current_stop = 0; /* We always interpolate between current and current + 1. */ - - /* Gradient area */ - while (pos < end_pos) { - unsigned int current_color = xRenderColorToCard32(stops[current_stop].color); - unsigned int next_color = xRenderColorToCard32(stops[current_stop + 1].color); - - int dist = (int)(256*(dpos - stops[current_stop].x) - / (stops[current_stop+1].x - stops[current_stop].x)); - int idist = 256 - dist; + CARD32 current_color, next_color; + int dist, idist; - pGradient->linear.colorTable[pos] = premultiply(INTERPOLATE_PIXEL_256(current_color, idist, next_color, dist)); + current_color = xRenderColorToCard32 (stop1->color); + next_color = xRenderColorToCard32 (stop2->color); - ++pos; - dpos += incr; + dist = (int) (256 * (x - stop1->x) / (stop2->x - stop1->x)); + idist = 256 - dist; - if (dpos > stops[current_stop + 1].x) - ++current_stop; - } - - /* After last point */ - while (pos < PICT_GRADIENT_STOPTABLE_SIZE) { - pGradient->linear.colorTable[pos] = xRenderColorToCard32(stops[nstops - 1].color); - ++pos; - } + return premultiply (INTERPOLATE_PIXEL_256 (current_color, idist, + next_color, dist)); } static void initGradient(SourcePictPtr pGradient, int stopCount, @@ -952,26 +928,30 @@ static void initGradient(SourcePictPtr pGradient, int stopCount, dpos = -1; for (i = 0; i < stopCount; ++i) { - if (stopPoints[i] <= dpos || stopPoints[i] > (1<<16)) { + if (stopPoints[i] < dpos || stopPoints[i] > (1<<16)) { *error = BadValue; return; } dpos = stopPoints[i]; } - pGradient->linear.stops = malloc(stopCount*sizeof(PictGradientStop)); - if (!pGradient->linear.stops) { + pGradient->gradient.stops = malloc(stopCount*sizeof(PictGradientStop)); + if (!pGradient->gradient.stops) { *error = BadAlloc; return; } - pGradient->linear.nstops = stopCount; + pGradient->gradient.nstops = stopCount; for (i = 0; i < stopCount; ++i) { - pGradient->linear.stops[i].x = stopPoints[i]; - pGradient->linear.stops[i].color = stopColors[i]; + pGradient->gradient.stops[i].x = stopPoints[i]; + pGradient->gradient.stops[i].color = stopColors[i]; } - initGradientColorTable(pGradient, error); + + pGradient->gradient.class = SourcePictClassUnknown; + pGradient->gradient.stopRange = 0xffff; + pGradient->gradient.colorTable = NULL; + pGradient->gradient.colorTableSize = 0; } #ifndef NXAGENT_SERVER @@ -984,6 +964,7 @@ static PicturePtr createSourcePicture(void) pPicture->pDrawable = 0; pPicture->pFormat = 0; pPicture->pNext = 0; + pPicture->format = PICT_a8r8g8b8; pPicture->devPrivates = 0; SetPictureToDefaults(pPicture); @@ -1029,10 +1010,6 @@ CreateLinearGradientPicture (Picture pid, xPointFixed *p1, xPointFixed *p2, *error = BadAlloc; return 0; } - if (p1->x == p2->x && p1->y == p2->y) { - *error = BadValue; - return 0; - } pPicture->id = pid; pPicture->pSourcePict = (SourcePictPtr) malloc(sizeof(PictLinearGradient)); @@ -1074,14 +1051,6 @@ CreateRadialGradientPicture (Picture pid, xPointFixed *inner, xPointFixed *outer *error = BadAlloc; return 0; } - { - double dx = (double)(inner->x - outer->x); - double dy = (double)(inner->y - outer->y); - if (sqrt(dx*dx + dy*dy) + (double)(innerRadius) > (double)(outerRadius)) { - *error = BadValue; - return 0; - } - } pPicture->id = pid; pPicture->pSourcePict = (SourcePictPtr) malloc(sizeof(PictRadialGradient)); @@ -1093,22 +1062,19 @@ CreateRadialGradientPicture (Picture pid, xPointFixed *inner, xPointFixed *outer radial = &pPicture->pSourcePict->radial; radial->type = SourcePictTypeRadial; - { - double x = (double)innerRadius / (double)outerRadius; - radial->dx = (outer->x - inner->x); - radial->dy = (outer->y - inner->y); - radial->fx = (inner->x) - x*radial->dx; - radial->fy = (inner->y) - x*radial->dy; - radial->m = 1./(1+x); - radial->b = -x*radial->m; - radial->dx /= 65536.; - radial->dy /= 65536.; - radial->fx /= 65536.; - radial->fy /= 65536.; - x = outerRadius/65536.; - radial->a = x*x - radial->dx*radial->dx - radial->dy*radial->dy; - } - + radial->c1.x = inner->x; + radial->c1.y = inner->y; + radial->c1.radius = innerRadius; + radial->c2.x = outer->x; + radial->c2.y = outer->y; + radial->c2.radius = outerRadius; + radial->cdx = (radial->c2.x - radial->c1.x) / 65536.; + radial->cdy = (radial->c2.y - radial->c1.y) / 65536.; + radial->dr = (radial->c2.radius - radial->c1.radius) / 65536.; + radial->A = ( radial->cdx * radial->cdx + + radial->cdy * radial->cdy + - radial->dr * radial->dr); + initGradient(pPicture->pSourcePict, nStops, stops, colors, error); if (*error) { free(pPicture); @@ -1218,7 +1184,8 @@ ChangePicture (PicturePtr pPicture, error = BadPixmap; break; } - if (pAlpha->pDrawable->type != DRAWABLE_PIXMAP) + if (pAlpha->pDrawable == NULL || + pAlpha->pDrawable->type != DRAWABLE_PIXMAP) { client->errorValue = pid; error = BadMatch; @@ -1460,18 +1427,25 @@ SetPictureClipRegion (PicturePtr pPicture, return result; } +static Bool +transformIsIdentity(PictTransform *t) +{ + return ((t->matrix[0][0] == t->matrix[1][1]) && + (t->matrix[0][0] == t->matrix[2][2]) && + (t->matrix[0][0] != 0) && + (t->matrix[0][1] == 0) && + (t->matrix[0][2] == 0) && + (t->matrix[1][0] == 0) && + (t->matrix[1][2] == 0) && + (t->matrix[2][0] == 0) && + (t->matrix[2][1] == 0)); +} int SetPictureTransform (PicturePtr pPicture, PictTransform *transform) { - static const PictTransform identity = { { - { xFixed1, 0x00000, 0x00000 }, - { 0x00000, xFixed1, 0x00000 }, - { 0x00000, 0x00000, xFixed1 }, - } }; - - if (transform && memcmp (transform, &identity, sizeof (PictTransform)) == 0) + if (transform && transformIsIdentity (transform)) transform = 0; if (transform) @@ -1494,6 +1468,15 @@ SetPictureTransform (PicturePtr pPicture, } pPicture->serialNumber |= GC_CHANGE_SERIAL_BIT; + if (pPicture->pDrawable != NULL) { + int result; + PictureScreenPtr ps = GetPictureScreen(pPicture->pDrawable->pScreen); + + result = (*ps->ChangePictureTransform) (pPicture, transform); + + return result; + } + return Success; } @@ -1613,13 +1596,17 @@ FreePicture (void * value, { if (pPicture->transform) free (pPicture->transform); - if (!pPicture->pDrawable) { - if (pPicture->pSourcePict) { - if (pPicture->pSourcePict->type != SourcePictTypeSolidFill) - free(pPicture->pSourcePict->linear.stops); - free(pPicture->pSourcePict); - } - } else { + + if (pPicture->pSourcePict) + { + if (pPicture->pSourcePict->type != SourcePictTypeSolidFill) + free(pPicture->pSourcePict->linear.stops); + + free(pPicture->pSourcePict); + } + + if (pPicture->pDrawable) + { ScreenPtr pScreen = pPicture->pDrawable->pScreen; PictureScreenPtr ps = GetPictureScreen(pScreen); @@ -1794,9 +1781,29 @@ CompositePicture (CARD8 op, } void -CompositeRects(CARD8 op, - PicturePtr pDst, - xRenderColor * color, int nRect, xRectangle *rects) +CompositeGlyphs (CARD8 op, + PicturePtr pSrc, + PicturePtr pDst, + PictFormatPtr maskFormat, + INT16 xSrc, + INT16 ySrc, + int nlist, + GlyphListPtr lists, + GlyphPtr *glyphs) +{ + PictureScreenPtr ps = GetPictureScreen(pDst->pDrawable->pScreen); + + ValidatePicture (pSrc); + ValidatePicture (pDst); + (*ps->Glyphs) (op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, lists, glyphs); +} + +void +CompositeRects (CARD8 op, + PicturePtr pDst, + xRenderColor *color, + int nRect, + xRectangle *rects) { PictureScreenPtr ps = GetPictureScreen(pDst->pDrawable->pScreen); @@ -1884,3 +1891,4 @@ AddTraps (PicturePtr pPicture, ValidatePicture (pPicture); (*ps->AddTraps) (pPicture, xOff, yOff, ntrap, traps); } + diff --git a/nx-X11/programs/Xserver/render/picture.h b/nx-X11/programs/Xserver/render/picture.h index 518e9fbb02..563a81b430 100644 --- a/nx-X11/programs/Xserver/render/picture.h +++ b/nx-X11/programs/Xserver/render/picture.h @@ -25,6 +25,8 @@ #ifndef _PICTURE_H_ #define _PICTURE_H_ +#include + typedef struct _DirectFormat *DirectFormatPtr; typedef struct _PictFormat *PictFormatPtr; typedef struct _Picture *PicturePtr; @@ -34,12 +36,7 @@ typedef struct _Picture *PicturePtr; * sample implementation allows only packed RGB and GBR * representations for data to simplify software rendering, */ -#define PICT_FORMAT(bpp,type,a,r,g,b) (((bpp) << 24) | \ - ((type) << 16) | \ - ((a) << 12) | \ - ((r) << 8) | \ - ((g) << 4) | \ - ((b))) +#define PICT_FORMAT(bpp,type,a,r,g,b) PIXMAN_FORMAT(bpp, type, a, r, g, b) /* * gray/color formats use a visual index instead of argb @@ -48,80 +45,78 @@ typedef struct _Picture *PicturePtr; ((type) << 16) | \ ((vi))) -#define PICT_FORMAT_BPP(f) (((f) >> 24) ) -#define PICT_FORMAT_TYPE(f) (((f) >> 16) & 0xff) -#define PICT_FORMAT_A(f) (((f) >> 12) & 0x0f) -#define PICT_FORMAT_R(f) (((f) >> 8) & 0x0f) -#define PICT_FORMAT_G(f) (((f) >> 4) & 0x0f) -#define PICT_FORMAT_B(f) (((f) ) & 0x0f) -#define PICT_FORMAT_RGB(f) (((f) ) & 0xfff) -#define PICT_FORMAT_VIS(f) (((f) ) & 0xffff) +#define PICT_FORMAT_BPP(f) PIXMAN_FORMAT_BPP(f) +#define PICT_FORMAT_TYPE(f) PIXMAN_FORMAT_TYPE(f) +#define PICT_FORMAT_A(f) PIXMAN_FORMAT_A(f) +#define PICT_FORMAT_R(f) PIXMAN_FORMAT_R(f) +#define PICT_FORMAT_G(f) PIXMAN_FORMAT_G(f) +#define PICT_FORMAT_B(f) PIXMAN_FORMAT_B(f) +#define PICT_FORMAT_RGB(f) PIXMAN_FORMAT_RGB(f) +#define PICT_FORMAT_VIS(f) PIXMAN_FORMAT_VIS(f) -#define PICT_TYPE_OTHER 0 -#define PICT_TYPE_A 1 -#define PICT_TYPE_ARGB 2 -#define PICT_TYPE_ABGR 3 -#define PICT_TYPE_COLOR 4 -#define PICT_TYPE_GRAY 5 +#define PICT_TYPE_OTHER PIXMAN_TYPE_OTHER +#define PICT_TYPE_A PIXMAN_TYPE_A +#define PICT_TYPE_ARGB PIXMAN_TYPE_ARGB +#define PICT_TYPE_ABGR PIXMAN_TYPE_ABGR +#define PICT_TYPE_COLOR PIXMAN_TYPE_COLOR +#define PICT_TYPE_GRAY PIXMAN_TYPE_GRAY -#define PICT_FORMAT_COLOR(f) (PICT_FORMAT_TYPE(f) & 2) +#define PICT_FORMAT_COLOR(f) PIXMAN_FORMAT_COLOR(f) /* 32bpp formats */ -#define PICT_a8r8g8b8 PICT_FORMAT(32,PICT_TYPE_ARGB,8,8,8,8) -#define PICT_x8r8g8b8 PICT_FORMAT(32,PICT_TYPE_ARGB,0,8,8,8) -#define PICT_a8b8g8r8 PICT_FORMAT(32,PICT_TYPE_ABGR,8,8,8,8) -#define PICT_x8b8g8r8 PICT_FORMAT(32,PICT_TYPE_ABGR,0,8,8,8) +typedef enum _PictFormatShort { + PICT_a8r8g8b8 = PIXMAN_a8r8g8b8, + PICT_x8r8g8b8 = PIXMAN_x8r8g8b8, + PICT_a8b8g8r8 = PIXMAN_a8b8g8r8, + PICT_x8b8g8r8 = PIXMAN_x8b8g8r8, /* 24bpp formats */ -#define PICT_r8g8b8 PICT_FORMAT(24,PICT_TYPE_ARGB,0,8,8,8) -#define PICT_b8g8r8 PICT_FORMAT(24,PICT_TYPE_ABGR,0,8,8,8) + PICT_r8g8b8 = PIXMAN_r8g8b8, + PICT_b8g8r8 = PIXMAN_b8g8r8, /* 16bpp formats */ -#define PICT_r5g6b5 PICT_FORMAT(16,PICT_TYPE_ARGB,0,5,6,5) -#define PICT_b5g6r5 PICT_FORMAT(16,PICT_TYPE_ABGR,0,5,6,5) - -#define PICT_a1r5g5b5 PICT_FORMAT(16,PICT_TYPE_ARGB,1,5,5,5) -#define PICT_x1r5g5b5 PICT_FORMAT(16,PICT_TYPE_ARGB,0,5,5,5) -#define PICT_a1b5g5r5 PICT_FORMAT(16,PICT_TYPE_ABGR,1,5,5,5) -#define PICT_x1b5g5r5 PICT_FORMAT(16,PICT_TYPE_ABGR,0,5,5,5) -#define PICT_a4r4g4b4 PICT_FORMAT(16,PICT_TYPE_ARGB,4,4,4,4) -#define PICT_x4r4g4b4 PICT_FORMAT(16,PICT_TYPE_ARGB,0,4,4,4) -#define PICT_a4b4g4r4 PICT_FORMAT(16,PICT_TYPE_ABGR,4,4,4,4) -#define PICT_x4b4g4r4 PICT_FORMAT(16,PICT_TYPE_ABGR,0,4,4,4) + PICT_r5g6b5 = PIXMAN_r5g6b5, + PICT_b5g6r5 = PIXMAN_b5g6r5, + + PICT_a1r5g5b5 = PIXMAN_a1r5g5b5, + PICT_x1r5g5b5 = PIXMAN_x1r5g5b5, + PICT_a1b5g5r5 = PIXMAN_a1b5g5r5, + PICT_x1b5g5r5 = PIXMAN_x1b5g5r5, + PICT_a4r4g4b4 = PIXMAN_a4r4g4b4, + PICT_x4r4g4b4 = PIXMAN_x4r4g4b4, + PICT_a4b4g4r4 = PIXMAN_a4b4g4r4, + PICT_x4b4g4r4 = PIXMAN_x4b4g4r4, /* 8bpp formats */ -#define PICT_a8 PICT_FORMAT(8,PICT_TYPE_A,8,0,0,0) -#define PICT_r3g3b2 PICT_FORMAT(8,PICT_TYPE_ARGB,0,3,3,2) -#define PICT_b2g3r3 PICT_FORMAT(8,PICT_TYPE_ABGR,0,3,3,2) -#define PICT_a2r2g2b2 PICT_FORMAT(8,PICT_TYPE_ARGB,2,2,2,2) -#define PICT_a2b2g2r2 PICT_FORMAT(8,PICT_TYPE_ABGR,2,2,2,2) + PICT_a8 = PIXMAN_a8, + PICT_r3g3b2 = PIXMAN_r3g3b2, + PICT_b2g3r3 = PIXMAN_b2g3r3, + PICT_a2r2g2b2 = PIXMAN_a2r2g2b2, + PICT_a2b2g2r2 = PIXMAN_a2b2g2r2, -#define PICT_c8 PICT_FORMAT(8,PICT_TYPE_COLOR,0,0,0,0) -#define PICT_g8 PICT_FORMAT(8,PICT_TYPE_GRAY,0,0,0,0) + PICT_c8 = PIXMAN_c8, + PICT_g8 = PIXMAN_g8, -#define PICT_x4a4 PICT_FORMAT(8,PICT_TYPE_A,4,0,0,0) -#define PICT_x4r1g2b1 PICT_FORMAT(8,PICT_TYPE_ARGB,0,1,2,1) -#define PICT_x4b1g2r1 PICT_FORMAT(8,PICT_TYPE_ABGR,0,1,2,1) -#define PICT_x4a1r1g1b1 PICT_FORMAT(8,PICT_TYPE_ARGB,1,1,1,1) -#define PICT_x4a1b1g1r1 PICT_FORMAT(8,PICT_TYPE_ABGR,1,1,1,1) - -#define PICT_x4c4 PICT_FORMAT(8,PICT_TYPE_COLOR,0,0,0,0) -#define PICT_x4g4 PICT_FORMAT(8,PICT_TYPE_GRAY,0,0,0,0) + PICT_x4a4 = PIXMAN_x4a4, + + PICT_x4c4 = PIXMAN_x4c4, + PICT_x4g4 = PIXMAN_x4g4, /* 4bpp formats */ -#define PICT_a4 PICT_FORMAT(4,PICT_TYPE_A,4,0,0,0) -#define PICT_r1g2b1 PICT_FORMAT(4,PICT_TYPE_ARGB,0,1,2,1) -#define PICT_b1g2r1 PICT_FORMAT(4,PICT_TYPE_ABGR,0,1,2,1) -#define PICT_a1r1g1b1 PICT_FORMAT(4,PICT_TYPE_ARGB,1,1,1,1) -#define PICT_a1b1g1r1 PICT_FORMAT(4,PICT_TYPE_ABGR,1,1,1,1) + PICT_a4 = PIXMAN_a4, + PICT_r1g2b1 = PIXMAN_r1g2b1, + PICT_b1g2r1 = PIXMAN_b1g2r1, + PICT_a1r1g1b1 = PIXMAN_a1r1g1b1, + PICT_a1b1g1r1 = PIXMAN_a1b1g1r1, -#define PICT_c4 PICT_FORMAT(4,PICT_TYPE_COLOR,0,0,0,0) -#define PICT_g4 PICT_FORMAT(4,PICT_TYPE_GRAY,0,0,0,0) + PICT_c4 = PIXMAN_c4, + PICT_g4 = PIXMAN_g4, /* 1bpp formats */ -#define PICT_a1 PICT_FORMAT(1,PICT_TYPE_A,1,0,0,0) + PICT_a1 = PIXMAN_a1, -#define PICT_g1 PICT_FORMAT(1,PICT_TYPE_GRAY,0,0,0,0) + PICT_g1 = PIXMAN_g1, +} PictFormatShort; /* * For dynamic indexed visuals (GrayScale and PseudoColor), these control the @@ -173,53 +168,35 @@ extern int RenderClientPrivateIndex; /* Fixed point updates from Carl Worth, USC, Information Sciences Institute */ -#if defined(WIN32) && !defined(__GNUC__) -typedef __int64 xFixed_32_32; -#else -# if defined (_LP64) || \ - defined(__alpha__) || defined(__alpha) || \ - defined(ia64) || defined(__ia64__) || \ - defined(__sparc64__) || \ - defined(__s390x__) || \ - defined(amd64) || defined (__amd64__) -typedef long xFixed_32_32; -# else -# if defined(__GNUC__) && \ - ((__GNUC__ > 2) || \ - ((__GNUC__ == 2) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ > 7))) -__extension__ -# endif -typedef long long int xFixed_32_32; -# endif -#endif - -typedef xFixed_32_32 xFixed_48_16; - -#define MAX_FIXED_48_16 ((xFixed_48_16) 0x7fffffff) -#define MIN_FIXED_48_16 (-((xFixed_48_16) 1 << 31)) - -typedef CARD32 xFixed_1_31; -typedef CARD32 xFixed_1_16; -typedef INT32 xFixed_16_16; +typedef pixman_fixed_32_32_t xFixed_32_32; + +typedef pixman_fixed_48_16_t xFixed_48_16; + +#define MAX_FIXED_48_16 pixman_max_fixed_48_16 +#define MIN_FIXED_48_16 pixman_min_fixed_48_16 + +typedef pixman_fixed_1_31_t xFixed_1_31; +typedef pixman_fixed_1_16_t xFixed_1_16; +typedef pixman_fixed_16_16_t xFixed_16_16; /* * An unadorned "xFixed" is the same as xFixed_16_16, * (since it's quite common in the code) */ -typedef xFixed_16_16 xFixed; +typedef pixman_fixed_t xFixed; #define XFIXED_BITS 16 -#define xFixedToInt(f) (int) ((f) >> XFIXED_BITS) -#define IntToxFixed(i) ((xFixed) (i) << XFIXED_BITS) -#define xFixedE ((xFixed) 1) -#define xFixed1 (IntToxFixed(1)) -#define xFixed1MinusE (xFixed1 - xFixedE) -#define xFixedFrac(f) ((f) & xFixed1MinusE) -#define xFixedFloor(f) ((f) & ~xFixed1MinusE) -#define xFixedCeil(f) xFixedFloor((f) + xFixed1MinusE) - -#define xFixedFraction(f) ((f) & xFixed1MinusE) -#define xFixedMod2(f) ((f) & (xFixed1 | xFixed1MinusE)) +#define xFixedToInt(f) pixman_fixed_to_int(f) +#define IntToxFixed(i) pixman_int_to_fixed(i) +#define xFixedE pixman_fixed_e +#define xFixed1 pixman_fixed_1 +#define xFixed1MinusE pixman_fixed_1_minus_e +#define xFixedFrac(f) pixman_fixed_frac(f) +#define xFixedFloor(f) pixman_fixed_floor(f) +#define xFixedCeil(f) pixman_fixed_ceil(f) + +#define xFixedFraction(f) pixman_fixed_fraction(f) +#define xFixedMod2(f) pixman_fixed_mod2(f) /* whether 't' is a well defined not obviously empty trapezoid */ #define xTrapezoidValid(t) ((t)->left.p1.y != (t)->left.p2.y && \ diff --git a/nx-X11/programs/Xserver/render/picturestr.h b/nx-X11/programs/Xserver/render/picturestr.h index f5c367bb42..0696c2511f 100644 --- a/nx-X11/programs/Xserver/render/picturestr.h +++ b/nx-X11/programs/Xserver/render/picturestr.h @@ -1,6 +1,4 @@ /* - * $Id: picturestr.h,v 1.15 2005/12/09 18:35:21 ajax Exp $ - * * Copyright © 2000 SuSE, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its @@ -26,8 +24,8 @@ #ifndef _PICTURESTR_H_ #define _PICTURESTR_H_ -#include "glyphstr.h" #include "scrnintstr.h" +#include "glyphstr.h" #include "resource.h" typedef struct _DirectFormat { @@ -65,11 +63,16 @@ typedef struct pixman_transform PictTransform, *PictTransformPtr; #define SourcePictTypeRadial 2 #define SourcePictTypeConical 3 +#define SourcePictClassUnknown 0 +#define SourcePictClassHorizontal 1 +#define SourcePictClassVertical 2 + #ifdef NXAGENT_SERVER #include "../hw/nxagent/NXpicturestr_PictSolidFill.h" #else typedef struct _PictSolidFill { unsigned int type; + unsigned int class; CARD32 color; } PictSolidFill, *PictSolidFillPtr; #endif /* NXAGENT_SERVER */ @@ -81,39 +84,56 @@ typedef struct _PictGradientStop { typedef struct _PictGradient { unsigned int type; + unsigned int class; int nstops; PictGradientStopPtr stops; - CARD32 colorTable[PICT_GRADIENT_STOPTABLE_SIZE]; + int stopRange; + CARD32 *colorTable; + int colorTableSize; } PictGradient, *PictGradientPtr; typedef struct _PictLinearGradient { unsigned int type; + unsigned int class; int nstops; PictGradientStopPtr stops; - CARD32 colorTable[PICT_GRADIENT_STOPTABLE_SIZE]; + int stopRange; + CARD32 *colorTable; + int colorTableSize; xPointFixed p1; xPointFixed p2; } PictLinearGradient, *PictLinearGradientPtr; +typedef struct _PictCircle { + xFixed x; + xFixed y; + xFixed radius; +} PictCircle, *PictCirclePtr; + typedef struct _PictRadialGradient { unsigned int type; + unsigned int class; int nstops; PictGradientStopPtr stops; - CARD32 colorTable[PICT_GRADIENT_STOPTABLE_SIZE]; - double fx; - double fy; - double dx; - double dy; - double a; - double m; - double b; + int stopRange; + CARD32 *colorTable; + int colorTableSize; + PictCircle c1; + PictCircle c2; + double cdx; + double cdy; + double dr; + double A; } PictRadialGradient, *PictRadialGradientPtr; typedef struct _PictConicalGradient { unsigned int type; + unsigned int class; int nstops; PictGradientStopPtr stops; - CARD32 colorTable[PICT_GRADIENT_STOPTABLE_SIZE]; + int stopRange; + CARD32 *colorTable; + int colorTableSize; xPointFixed center; xFixed angle; } PictConicalGradient, *PictConicalGradientPtr; @@ -130,7 +150,7 @@ typedef union _SourcePict { typedef struct _Picture { DrawablePtr pDrawable; PictFormatPtr pFormat; - CARD32 format; /* PICT_FORMAT */ + PictFormatShort format; /* PICT_FORMAT */ int refcnt; CARD32 id; PicturePtr pNext; /* chain on same drawable */ @@ -309,6 +329,12 @@ typedef void (*AddTrianglesProcPtr) (PicturePtr pPicture, int ntri, xTriangle *tris); +typedef Bool (*RealizeGlyphProcPtr) (ScreenPtr pScreen, + GlyphPtr glyph); + +typedef void (*UnrealizeGlyphProcPtr) (ScreenPtr pScreen, + GlyphPtr glyph); + typedef struct _PictureScreen { int totalPictureSize; unsigned int *PicturePrivateSizes; @@ -346,6 +372,10 @@ typedef struct _PictureScreen { PictFilterAliasPtr filterAliases; int nfilterAliases; + /** + * Called immediately after a picture's transform is changed through the + * SetPictureTransform request. Not called for source-only pictures. + */ ChangePictureTransformProcPtr ChangePictureTransform; /** @@ -367,6 +397,14 @@ typedef struct _PictureScreen { AddTrapsProcPtr AddTraps; + int totalGlyphPrivateSize; + unsigned int *glyphPrivateSizes; + int glyphPrivateLen; + int glyphPrivateOffset; + + RealizeGlyphProcPtr RealizeGlyph; + UnrealizeGlyphProcPtr UnrealizeGlyph; + } PictureScreenRec, *PictureScreenPtr; extern int PictureScreenPrivateIndex; @@ -381,6 +419,9 @@ extern RESTYPE GlyphSetType; #define GetPictureWindow(w) ((PicturePtr) ((w)->devPrivates[PictureWindowPrivateIndex].ptr)) #define SetPictureWindow(w,p) ((w)->devPrivates[PictureWindowPrivateIndex].ptr = (void *) (p)) +#define GetGlyphPrivatesForScreen(glyph, s) \ + ((glyph)->devPrivates + (GetPictureScreen (s))->glyphPrivateOffset) + #define VERIFY_PICTURE(pPicture, pid, client, mode, err) {\ pPicture = SecurityLookupIDByType(client, pid, PictureType, mode);\ if (!pPicture) { \ @@ -611,6 +652,11 @@ Bool PictureTransformPoint3d (PictTransformPtr transform, PictVectorPtr vector); +CARD32 +PictureGradientColor (PictGradientStopPtr stop1, + PictGradientStopPtr stop2, + CARD32 x); + void RenderExtensionInit (void); Bool @@ -626,6 +672,10 @@ AddTraps (PicturePtr pPicture, int ntraps, xTrap *traps); +pixman_image_t * +PixmanImageFromPicture (PicturePtr pPict, + Bool hasClip); + PicturePtr CreateSolidPicture (Picture pid, xRenderColor *color, diff --git a/nx-X11/programs/Xserver/render/render.c b/nx-X11/programs/Xserver/render/render.c index 3dcbac0e62..6e923eb9fc 100644 --- a/nx-X11/programs/Xserver/render/render.c +++ b/nx-X11/programs/Xserver/render/render.c @@ -1,4 +1,5 @@ /* + * * Copyright © 2000 SuSE, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its @@ -289,14 +290,12 @@ ProcRenderQueryVersion (ClientPtr client) REQUEST(xRenderQueryVersionReq); - REQUEST_SIZE_MATCH(xRenderQueryVersionReq); - pRenderClient->major_version = stuff->majorVersion; pRenderClient->minor_version = stuff->minorVersion; if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); + swaps(&rep.sequenceNumber); + swapl(&rep.length); swapl(&rep.majorVersion); swapl(&rep.minorVersion); } @@ -639,7 +638,10 @@ ProcRenderCreatePicture (ClientPtr client) LEGAL_NEW_RESOURCE(stuff->pid, client); SECURITY_VERIFY_DRAWABLE(pDrawable, stuff->drawable, client, - DixWriteAccess); + DixWriteAccess); + if (rc != Success) + return rc; + pFormat = (PictFormatPtr) SecurityLookupIDByType (client, stuff->format, PictFormatType, @@ -759,12 +761,12 @@ ProcRenderComposite (ClientPtr client) RenderErrBase + BadPicture); if (!pDst->pDrawable) return BadDrawable; - VERIFY_PICTURE (pSrc, stuff->src, client, DixReadAccess, + VERIFY_PICTURE (pSrc, stuff->src, client, DixReadAccess, RenderErrBase + BadPicture); - VERIFY_ALPHA (pMask, stuff->mask, client, DixReadAccess, + VERIFY_ALPHA (pMask, stuff->mask, client, DixReadAccess, RenderErrBase + BadPicture); if ((pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen) || - (pMask && pMask->pDrawable && pSrc->pDrawable->pScreen != pMask->pDrawable->pScreen)) + (pMask && pMask->pDrawable && pDst->pDrawable->pScreen != pMask->pDrawable->pScreen)) return BadMatch; CompositePicture (stuff->op, pSrc, @@ -803,9 +805,9 @@ ProcRenderTrapezoids (ClientPtr client) client->errorValue = stuff->op; return BadValue; } - VERIFY_PICTURE (pSrc, stuff->src, client, DixReadAccess, + VERIFY_PICTURE (pSrc, stuff->src, client, DixReadAccess, RenderErrBase + BadPicture); - VERIFY_PICTURE (pDst, stuff->dst, client, DixWriteAccess, + VERIFY_PICTURE (pDst, stuff->dst, client, DixWriteAccess, RenderErrBase + BadPicture); if (!pDst->pDrawable) return BadDrawable; @@ -851,9 +853,9 @@ ProcRenderTriangles (ClientPtr client) client->errorValue = stuff->op; return BadValue; } - VERIFY_PICTURE (pSrc, stuff->src, client, DixReadAccess, + VERIFY_PICTURE (pSrc, stuff->src, client, DixReadAccess, RenderErrBase + BadPicture); - VERIFY_PICTURE (pDst, stuff->dst, client, DixWriteAccess, + VERIFY_PICTURE (pDst, stuff->dst, client, DixWriteAccess, RenderErrBase + BadPicture); if (!pDst->pDrawable) return BadDrawable; @@ -898,9 +900,9 @@ ProcRenderTriStrip (ClientPtr client) client->errorValue = stuff->op; return BadValue; } - VERIFY_PICTURE (pSrc, stuff->src, client, DixReadAccess, + VERIFY_PICTURE (pSrc, stuff->src, client, DixReadAccess, RenderErrBase + BadPicture); - VERIFY_PICTURE (pDst, stuff->dst, client, DixWriteAccess, + VERIFY_PICTURE (pDst, stuff->dst, client, DixWriteAccess, RenderErrBase + BadPicture); if (!pDst->pDrawable) return BadDrawable; @@ -945,9 +947,9 @@ ProcRenderTriFan (ClientPtr client) client->errorValue = stuff->op; return BadValue; } - VERIFY_PICTURE (pSrc, stuff->src, client, DixReadAccess, + VERIFY_PICTURE (pSrc, stuff->src, client, DixReadAccess, RenderErrBase + BadPicture); - VERIFY_PICTURE (pDst, stuff->dst, client, DixWriteAccess, + VERIFY_PICTURE (pDst, stuff->dst, client, DixWriteAccess, RenderErrBase + BadPicture); if (!pDst->pDrawable) return BadDrawable; @@ -1355,7 +1357,7 @@ ProcRenderCompositeGlyphs (ClientPtr client) if (glyphsBase != glyphsLocal) free(glyphsBase); return BadAlloc; - } + } } buffer = (CARD8 *) (stuff + 1); glyphs = glyphsBase; @@ -1459,7 +1461,7 @@ ProcRenderFillRectangles (ClientPtr client) client->errorValue = stuff->op; return BadValue; } - VERIFY_PICTURE (pDst, stuff->dst, client, DixWriteAccess, + VERIFY_PICTURE (pDst, stuff->dst, client, DixWriteAccess, RenderErrBase + BadPicture); if (!pDst->pDrawable) return BadDrawable; @@ -1527,7 +1529,7 @@ ProcRenderCreateCursor (ClientPtr client) REQUEST_SIZE_MATCH (xRenderCreateCursorReq); LEGAL_NEW_RESOURCE(stuff->cid, client); - VERIFY_PICTURE (pSrc, stuff->src, client, DixReadAccess, + VERIFY_PICTURE (pSrc, stuff->src, client, DixReadAccess, RenderErrBase + BadPicture); if (!pSrc->pDrawable) return BadDrawable; @@ -1818,8 +1820,8 @@ ProcRenderQueryFilters (ClientPtr client) { swaps (&aliases[i]); } - swaps(&reply->sequenceNumber); - swapl(&reply->length); + swaps(&reply->sequenceNumber); + swapl(&reply->length); swapl(&reply->numAliases); swapl(&reply->numFilters); } @@ -1904,7 +1906,7 @@ ProcRenderAddTraps (ClientPtr client) REQUEST(xRenderAddTrapsReq); REQUEST_AT_LEAST_SIZE(xRenderAddTrapsReq); - VERIFY_PICTURE (pPicture, stuff->picture, client, DixWriteAccess, + VERIFY_PICTURE (pPicture, stuff->picture, client, DixWriteAccess, RenderErrBase + BadPicture); if (!pPicture->pDrawable) return BadDrawable; @@ -2115,6 +2117,8 @@ SProcRenderSetPictureClipRectangles (ClientPtr client) REQUEST_AT_LEAST_SIZE(xRenderSetPictureClipRectanglesReq); swaps(&stuff->length); swapl(&stuff->picture); + swaps(&stuff->xOrigin); + swaps(&stuff->yOrigin); SwapRestS(stuff); return (*ProcRenderVector[stuff->renderReqType]) (client); } @@ -2345,7 +2349,7 @@ SProcRenderCompositeGlyphs (ClientPtr client) REQUEST(xRenderCompositeGlyphsReq); REQUEST_AT_LEAST_SIZE(xRenderCompositeGlyphsReq); - + switch (stuff->renderReqType) { default: size = 1; break; case X_RenderCompositeGlyphs16: size = 2; break; @@ -2817,11 +2821,11 @@ PanoramiXRenderComposite (ClientPtr client) REQUEST_SIZE_MATCH(xRenderCompositeReq); - VERIFY_XIN_PICTURE (src, stuff->src, client, DixReadAccess, + VERIFY_XIN_PICTURE (src, stuff->src, client, DixReadAccess, RenderErrBase + BadPicture); - VERIFY_XIN_ALPHA (msk, stuff->mask, client, DixReadAccess, + VERIFY_XIN_ALPHA (msk, stuff->mask, client, DixReadAccess, RenderErrBase + BadPicture); - VERIFY_XIN_PICTURE (dst, stuff->dst, client, DixWriteAccess, + VERIFY_XIN_PICTURE (dst, stuff->dst, client, DixWriteAccess, RenderErrBase + BadPicture); orig = *stuff; @@ -2908,7 +2912,7 @@ PanoramiXRenderFillRectangles (ClientPtr client) int extra_len; REQUEST_AT_LEAST_SIZE (xRenderFillRectanglesReq); - VERIFY_XIN_PICTURE (dst, stuff->dst, client, DixWriteAccess, + VERIFY_XIN_PICTURE (dst, stuff->dst, client, DixWriteAccess, RenderErrBase + BadPicture); extra_len = (client->req_len << 2) - sizeof (xRenderFillRectanglesReq); if (extra_len && @@ -2938,9 +2942,9 @@ PanoramiXRenderFillRectangles (ClientPtr client) result = (*PanoramiXSaveRenderVector[X_RenderFillRectangles]) (client); if(result != Success) break; } - free(extra); } + return result; } @@ -2999,8 +3003,8 @@ PanoramiXRenderTrapezoids(ClientPtr client) if(result != Success) break; } - - free(extra); + + free(extra); } return result; @@ -3057,8 +3061,8 @@ PanoramiXRenderTriangles(ClientPtr client) if(result != Success) break; } - - free(extra); + + free(extra); } return result; @@ -3111,8 +3115,8 @@ PanoramiXRenderTriStrip(ClientPtr client) if(result != Success) break; } - - free(extra); + + free(extra); } return result; @@ -3165,8 +3169,8 @@ PanoramiXRenderTriFan(ClientPtr client) if(result != Success) break; } - - free(extra); + + free(extra); } return result; @@ -3275,7 +3279,7 @@ PanoramiXRenderAddTraps (ClientPtr client) INT16 x_off, y_off; REQUEST_AT_LEAST_SIZE (xRenderAddTrapsReq); - VERIFY_XIN_PICTURE (picture, stuff->picture, client, DixWriteAccess, + VERIFY_XIN_PICTURE (picture, stuff->picture, client, DixWriteAccess, RenderErrBase + BadPicture); extra_len = (client->req_len << 2) - sizeof (xRenderAddTrapsReq); if (extra_len && @@ -3296,7 +3300,6 @@ PanoramiXRenderAddTraps (ClientPtr client) result = (*PanoramiXSaveRenderVector[X_RenderAddTraps]) (client); if(result != Success) break; } - free(extra); } diff --git a/nx-X11/programs/Xserver/render/renderedge.c b/nx-X11/programs/Xserver/render/renderedge.c index f095038e56..8771fe164d 100644 --- a/nx-X11/programs/Xserver/render/renderedge.c +++ b/nx-X11/programs/Xserver/render/renderedge.c @@ -1,6 +1,4 @@ /* - * $Id: renderedge.c,v 1.4 2005/07/03 07:02:08 daniels Exp $ - * * Copyright © 2004 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its @@ -36,16 +34,7 @@ xFixed RenderSampleCeilY (xFixed y, int n) { - xFixed f = xFixedFrac(y); - xFixed i = xFixedFloor(y); - - f = ((f + Y_FRAC_FIRST(n)) / STEP_Y_SMALL(n)) * STEP_Y_SMALL(n) + Y_FRAC_FIRST(n); - if (f > Y_FRAC_LAST(n)) - { - f = Y_FRAC_FIRST(n); - i += xFixed1; - } - return (i | f); + return pixman_sample_ceil_y (y, n); } #define _div(a,b) ((a) >= 0 ? (a) / (b) : -((-(a) + (b) - 1) / (b))) @@ -57,16 +46,7 @@ RenderSampleCeilY (xFixed y, int n) xFixed RenderSampleFloorY (xFixed y, int n) { - xFixed f = xFixedFrac(y); - xFixed i = xFixedFloor (y); - - f = _div(f - Y_FRAC_FIRST(n), STEP_Y_SMALL(n)) * STEP_Y_SMALL(n) + Y_FRAC_FIRST(n); - if (f < Y_FRAC_FIRST(n)) - { - f = Y_FRAC_LAST(n); - i -= xFixed1; - } - return (i | f); + return pixman_sample_floor_y (y, n); } /* @@ -75,52 +55,7 @@ RenderSampleFloorY (xFixed y, int n) void RenderEdgeStep (RenderEdge *e, int n) { - xFixed_48_16 ne; - - e->x += n * e->stepx; - - ne = e->e + n * (xFixed_48_16) e->dx; - - if (n >= 0) - { - if (ne > 0) - { - int nx = (ne + e->dy - 1) / e->dy; - e->e = ne - nx * (xFixed_48_16) e->dy; - e->x += nx * e->signdx; - } - } - else - { - if (ne <= -e->dy) - { - int nx = (-ne) / e->dy; - e->e = ne + nx * (xFixed_48_16) e->dy; - e->x -= nx * e->signdx; - } - } -} - -/* - * A private routine to initialize the multi-step - * elements of an edge structure - */ -static void -_RenderEdgeMultiInit (RenderEdge *e, int n, xFixed *stepx_p, xFixed *dx_p) -{ - xFixed stepx; - xFixed_48_16 ne; - - ne = n * (xFixed_48_16) e->dx; - stepx = n * e->stepx; - if (ne > 0) - { - int nx = ne / e->dy; - ne -= nx * e->dy; - stepx += nx * e->signdx; - } - *dx_p = ne; - *stepx_p = stepx; + pixman_edge_step (e, n); } /* @@ -136,35 +71,7 @@ RenderEdgeInit (RenderEdge *e, xFixed x_bot, xFixed y_bot) { - xFixed dx, dy; - - e->x = x_top; - e->e = 0; - dx = x_bot - x_top; - dy = y_bot - y_top; - e->dy = dy; - e->dx = 0; - if (dy) - { - if (dx >= 0) - { - e->signdx = 1; - e->stepx = dx / dy; - e->dx = dx % dy; - e->e = -dy; - } - else - { - e->signdx = -1; - e->stepx = -(-dx / dy); - e->dx = -dx % dy; - e->e = 0; - } - - _RenderEdgeMultiInit (e, STEP_Y_SMALL(n), &e->stepx_small, &e->dx_small); - _RenderEdgeMultiInit (e, STEP_Y_BIG(n), &e->stepx_big, &e->dx_big); - } - RenderEdgeStep (e, y_start - y_top); + pixman_edge_init (e, n, y_start, x_top, y_top, x_bot, y_bot); } /* @@ -179,24 +86,6 @@ RenderLineFixedEdgeInit (RenderEdge *e, int x_off, int y_off) { - xFixed x_off_fixed = IntToxFixed(x_off); - xFixed y_off_fixed = IntToxFixed(y_off); - xPointFixed *top, *bot; - - if (line->p1.y <= line->p2.y) - { - top = &line->p1; - bot = &line->p2; - } - else - { - top = &line->p2; - bot = &line->p1; - } - RenderEdgeInit (e, n, y, - top->x + x_off_fixed, - top->y + y_off_fixed, - bot->x + x_off_fixed, - bot->y + y_off_fixed); + pixman_line_fixed_edge_init (e, n, y, (pixman_line_fixed_t *)line, x_off, y_off); } diff --git a/nx-X11/programs/Xserver/render/renderedge.h b/nx-X11/programs/Xserver/render/renderedge.h index bfd19fa937..644d9d9e5b 100644 --- a/nx-X11/programs/Xserver/render/renderedge.h +++ b/nx-X11/programs/Xserver/render/renderedge.h @@ -1,6 +1,4 @@ /* - * $Id: renderedge.h,v 1.4 2005/08/24 11:18:33 daniels Exp $ - * * Copyright © 2004 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its @@ -50,20 +48,7 @@ * and can be quickly stepped across small or large gaps in the * sample grid */ - -typedef struct { - xFixed x; - xFixed e; - xFixed stepx; - xFixed signdx; - xFixed dy; - xFixed dx; - - xFixed stepx_small; - xFixed stepx_big; - xFixed dx_small; - xFixed dx_big; -} RenderEdge; +typedef pixman_edge_t RenderEdge; /* * Step across a small sample grid gap diff --git a/nx-X11/programs/Xserver/xkb/XKBAlloc.c b/nx-X11/programs/Xserver/xkb/XKBAlloc.c index b55918f88d..0fd00a0b12 100644 --- a/nx-X11/programs/Xserver/xkb/XKBAlloc.c +++ b/nx-X11/programs/Xserver/xkb/XKBAlloc.c @@ -322,8 +322,11 @@ XkbFreeKeyboard(XkbDescPtr xkb,unsigned which,Bool freeAll) XkbFreeIndicatorMaps(xkb); if (which&XkbNamesMask) XkbFreeNames(xkb,XkbAllNamesMask,True); - if ((which&XkbGeometryMask) && (xkb->geom!=NULL)) + if ((which&XkbGeometryMask) && (xkb->geom!=NULL)) { XkbFreeGeometry(xkb->geom,XkbGeomAllMask,True); + /* PERHAPS BONGHITS etc */ + xkb->geom = NULL; + } if (which&XkbControlsMask) XkbFreeControls(xkb,XkbAllControlsMask,True); if (freeAll) diff --git a/nx-X11/programs/Xserver/xkb/ddxBeep.c b/nx-X11/programs/Xserver/xkb/ddxBeep.c index cf5570b588..eb92b438e5 100644 --- a/nx-X11/programs/Xserver/xkb/ddxBeep.c +++ b/nx-X11/programs/Xserver/xkb/ddxBeep.c @@ -38,7 +38,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include - /*#define FALLING_TONE 1*/ /*#define RISING_TONE 1*/ #define FALLING_TONE 10 @@ -110,9 +109,6 @@ _XkbDDXBeepInitAtoms(void) stickyLock= MAKE_ATOM(STICKY_LOCK); stickyUnlock= MAKE_ATOM(STICKY_UNLOCK); bounceReject= MAKE_ATOM(BOUNCE_REJECT); -#if defined(sun) - doesPitch = 0; -#endif return; } diff --git a/nx-X11/programs/Xserver/xkb/ddxKillSrv.c b/nx-X11/programs/Xserver/xkb/ddxKillSrv.c index 3a8ffdd578..0f40938058 100644 --- a/nx-X11/programs/Xserver/xkb/ddxKillSrv.c +++ b/nx-X11/programs/Xserver/xkb/ddxKillSrv.c @@ -41,7 +41,8 @@ int XkbDDXTerminateServer(DeviceIntPtr dev,KeyCode key,XkbAction *act) { #ifndef NXAGENT_SERVER - GiveUp(1); + if (dev != inputInfo.keyboard) + GiveUp(1); #endif /* NXAGENT_SERVER */ return 0; } diff --git a/nx-X11/programs/Xserver/xkb/ddxLoad.c b/nx-X11/programs/Xserver/xkb/ddxLoad.c index bff69196f6..0683b11cf2 100644 --- a/nx-X11/programs/Xserver/xkb/ddxLoad.c +++ b/nx-X11/programs/Xserver/xkb/ddxLoad.c @@ -211,7 +211,6 @@ char *cmd = NULL,file[PATH_MAX],xkm_output_dir[PATH_MAX],*map,*outFile; OutputDirectory(xkm_output_dir, sizeof(xkm_output_dir)); if (XkbBaseDirectory!=NULL) { - char *xkbbasedir = XkbBaseDirectory; char *xkbbindir = XkbBinDirectory; @@ -370,7 +369,7 @@ char tmpname[PATH_MAX]; return True; } else - DebugF("Error compiling keymap (%s)\n",keymap); + LogMessage(X_ERROR, "Error compiling keymap (%s)\n", keymap); #ifdef WIN32 /* remove the temporary file */ unlink(tmpname); @@ -378,9 +377,9 @@ char tmpname[PATH_MAX]; } else { #ifndef WIN32 - DebugF("Could not invoke keymap compiler\n"); + LogMessage(X_ERROR, "XKB: Could not invoke xkbcomp\n"); #else - DebugF("Could not open file %s\n", tmpname); + LogMessage(X_ERROR, "Could not open file %s\n", tmpname); #endif } if (nameRtrn) @@ -458,13 +457,14 @@ unsigned missing; return 0; } else if (!XkbDDXCompileNamedKeymap(xkb,names,nameRtrn,nameRtrnLen)) { - DebugF("Couldn't compile keymap file\n"); + LogMessage(X_ERROR, "Couldn't compile keymap file %s\n", + names->keymap); return 0; } } else if (!XkbDDXCompileKeymapByNames(xkb,names,want,need, - nameRtrn,nameRtrnLen)){ - DebugF("Couldn't compile keymap file\n"); + nameRtrn,nameRtrnLen)){ + LogMessage(X_ERROR, "XKB: Couldn't compile keymap\n"); return 0; } file= XkbDDXOpenConfigFile(nameRtrn,fileName,PATH_MAX); @@ -479,8 +479,8 @@ unsigned missing; (void) unlink (fileName); return 0; } - else if (xkbDebugFlags) { - DebugF("Loaded %s, defined=0x%x\n",fileName,finfoRtrn->defined); + else { + DebugF("XKB: Loaded %s, defined=0x%x\n",fileName,finfoRtrn->defined); } fclose(file); (void) unlink (fileName); @@ -500,32 +500,40 @@ XkbRF_RulesPtr rules; if (!rules_name) return False; - if (XkbBaseDirectory==NULL) { - if (strlen(rules_name)+7 > PATH_MAX) - return False; - sprintf(buf,"rules/%s",rules_name); - } - else { - if (snprintf(buf, PATH_MAX, "%s/rules/%s", XkbBaseDirectory, rules_name) - >= PATH_MAX) - return False; + + if (strlen(XkbBaseDirectory) + strlen(rules_name) + 8 > PATH_MAX) { + LogMessage(X_ERROR, "XKB: Rules name is too long\n"); + return False; } - if ((file= fopen(buf,"r"))==NULL) + sprintf(buf,"%s/rules/%s", XkbBaseDirectory, rules_name); + + file = fopen(buf, "r"); + if (!file) { + LogMessage(X_ERROR, "XKB: Couldn't open rules file %s\n", buf); return False; - if ((rules= XkbRF_Create(0,0))==NULL) { + } + + rules = XkbRF_Create(0, 0); + if (!rules) { + LogMessage(X_ERROR, "XKB: Couldn't create rules struct\n"); fclose(file); return False; } - if (!XkbRF_LoadRules(file,rules)) { + + if (!XkbRF_LoadRules(file, rules)) { + LogMessage(X_ERROR, "XKB: Couldn't parse rules file %s\n", rules_name); fclose(file); XkbRF_Free(rules,True); return False; } - bzero((char *)names,sizeof(XkbComponentNamesRec)); - complete= XkbRF_GetComponents(rules,defs,names); + + memset(names, 0, sizeof(*names)); + complete = XkbRF_GetComponents(rules,defs,names); fclose(file); - XkbRF_Free(rules,True); - return complete; -} + XkbRF_Free(rules, True); + if (!complete) + LogMessage(X_ERROR, "XKB: Rules returned no components\n"); + return complete; +} diff --git a/nx-X11/programs/Xserver/xkb/xkb.c b/nx-X11/programs/Xserver/xkb/xkb.c index 238b0897e7..78be8a19d1 100644 --- a/nx-X11/programs/Xserver/xkb/xkb.c +++ b/nx-X11/programs/Xserver/xkb/xkb.c @@ -341,6 +341,7 @@ ProcXkbSelectEvents(ClientPtr client) /***====================================================================***/ +/* FIXME: Needs to ding on all core-sending devices. */ int ProcXkbBell(ClientPtr client) { @@ -526,56 +527,67 @@ int ProcXkbLatchLockState(ClientPtr client) { int status; - DeviceIntPtr dev; + DeviceIntPtr dev, tmpd; XkbStateRec oldState,*newState; CARD16 changed; + xkbStateNotify sn; + XkbEventCauseRec cause; REQUEST(xkbLatchLockStateReq); REQUEST_SIZE_MATCH(xkbLatchLockStateReq); - if (!(client->xkbClientFlags&_XkbClientInitialized)) + if (!(client->xkbClientFlags & _XkbClientInitialized)) return BadAccess; - CHK_KBD_DEVICE(dev,stuff->deviceSpec); - CHK_MASK_MATCH(0x01,stuff->affectModLocks,stuff->modLocks); - CHK_MASK_MATCH(0x01,stuff->affectModLatches,stuff->modLatches); + CHK_KBD_DEVICE(dev, stuff->deviceSpec); + CHK_MASK_MATCH(0x01, stuff->affectModLocks, stuff->modLocks); + CHK_MASK_MATCH(0x01, stuff->affectModLatches, stuff->modLatches); status = Success; - oldState= dev->key->xkbInfo->state; - newState= &dev->key->xkbInfo->state; - if ( stuff->affectModLocks ) { - newState->locked_mods&= ~stuff->affectModLocks; - newState->locked_mods|= (stuff->affectModLocks&stuff->modLocks); - } - if (( status == Success ) && stuff->lockGroup ) - newState->locked_group = stuff->groupLock; - if (( status == Success ) && stuff->affectModLatches ) - status=XkbLatchModifiers(dev,stuff->affectModLatches,stuff->modLatches); - if (( status == Success ) && stuff->latchGroup ) - status=XkbLatchGroup(dev,stuff->groupLatch); - - if ( status != Success ) - return status; - XkbComputeDerivedState(dev->key->xkbInfo); - dev->key->state= XkbStateFieldFromRec(newState); - - changed = XkbStateChangedFlags(&oldState,newState); - if (changed) { - xkbStateNotify sn; - sn.keycode= 0; - sn.eventType= 0; - sn.requestMajor = XkbReqCode; - sn.requestMinor = X_kbLatchLockState; - sn.changed= changed; - XkbSendStateNotify(dev,&sn); - changed= XkbIndicatorsToUpdate(dev,changed,False); - if (changed) { - XkbEventCauseRec cause; - XkbSetCauseXkbReq(&cause,X_kbLatchLockState,client); - XkbUpdateIndicators(dev,changed,True,NULL,&cause); - } + for (tmpd = inputInfo.devices; tmpd; tmpd = tmpd->next) { + if ((dev == inputInfo.keyboard && tmpd->key && tmpd->coreEvents) || + tmpd == dev) { + if (!tmpd->key->xkbInfo) + continue; + + oldState = tmpd->key->xkbInfo->state; + newState = &tmpd->key->xkbInfo->state; + if (stuff->affectModLocks) { + newState->locked_mods &= ~stuff->affectModLocks; + newState->locked_mods |= (stuff->affectModLocks & stuff->modLocks); + } + if (status == Success && stuff->lockGroup) + newState->locked_group = stuff->groupLock; + if (status == Success && stuff->affectModLatches) + status = XkbLatchModifiers(tmpd, stuff->affectModLatches, + stuff->modLatches); + if (status == Success && stuff->latchGroup) + status = XkbLatchGroup(tmpd, stuff->groupLatch); + + if (status != Success) + return status; + + XkbComputeDerivedState(tmpd->key->xkbInfo); + tmpd->key->state = XkbStateFieldFromRec(newState); + + changed = XkbStateChangedFlags(&oldState, newState); + if (changed) { + sn.keycode = 0; + sn.eventType = 0; + sn.requestMajor = XkbReqCode; + sn.requestMinor = X_kbLatchLockState; + sn.changed = changed; + XkbSendStateNotify(tmpd, &sn); + changed = XkbIndicatorsToUpdate(tmpd, changed, False); + if (changed) { + XkbSetCauseXkbReq(&cause, X_kbLatchLockState, client); + XkbUpdateIndicators(tmpd, changed, True, NULL, &cause); + } + } + } } + return client->noClientException; } @@ -657,7 +669,7 @@ ProcXkbGetControls(ClientPtr client) int ProcXkbSetControls(ClientPtr client) { - DeviceIntPtr dev; + DeviceIntPtr dev, tmpd; XkbSrvInfoPtr xkbi; XkbControlsPtr ctrl; XkbControlsRec new,old; @@ -668,158 +680,209 @@ ProcXkbSetControls(ClientPtr client) REQUEST(xkbSetControlsReq); REQUEST_SIZE_MATCH(xkbSetControlsReq); - if (!(client->xkbClientFlags&_XkbClientInitialized)) + if (!(client->xkbClientFlags & _XkbClientInitialized)) return BadAccess; - CHK_KBD_DEVICE(dev,stuff->deviceSpec); - CHK_MASK_LEGAL(0x01,stuff->changeCtrls,XkbAllControlsMask); + CHK_KBD_DEVICE(dev, stuff->deviceSpec); + CHK_MASK_LEGAL(0x01, stuff->changeCtrls, XkbAllControlsMask); + + for (tmpd = inputInfo.keyboard; tmpd; tmpd = tmpd->next) { + if ((dev == inputInfo.keyboard && tmpd->key && tmpd->coreEvents) || + tmpd == dev) { + + xkbi = tmpd->key->xkbInfo; + ctrl = xkbi->desc->ctrls; + new = *ctrl; + XkbSetCauseXkbReq(&cause, X_kbSetControls, client); + + if (stuff->changeCtrls & XkbInternalModsMask) { + CHK_MASK_MATCH(0x02, stuff->affectInternalMods, + stuff->internalMods); + CHK_MASK_MATCH(0x03, stuff->affectInternalVMods, + stuff->internalVMods); + + new.internal.real_mods &= ~(stuff->affectInternalMods); + new.internal.real_mods |= (stuff->affectInternalMods & + stuff->internalMods); + new.internal.vmods &= ~(stuff->affectInternalVMods); + new.internal.vmods |= (stuff->affectInternalVMods & + stuff->internalVMods); + new.internal.mask = new.internal.real_mods | + XkbMaskForVMask(xkbi->desc, + new.internal.vmods); + } - xkbi = dev->key->xkbInfo; - ctrl = xkbi->desc->ctrls; - new = *ctrl; - XkbSetCauseXkbReq(&cause,X_kbSetControls,client); - if (stuff->changeCtrls&XkbInternalModsMask) { - CHK_MASK_MATCH(0x02,stuff->affectInternalMods,stuff->internalMods); - CHK_MASK_MATCH(0x03,stuff->affectInternalVMods,stuff->internalVMods); - new.internal.real_mods&=~stuff->affectInternalMods; - new.internal.real_mods|=(stuff->affectInternalMods&stuff->internalMods); - new.internal.vmods&=~stuff->affectInternalVMods; - new.internal.vmods|= (stuff->affectInternalVMods&stuff->internalVMods); - new.internal.mask= new.internal.real_mods| - XkbMaskForVMask(xkbi->desc,new.internal.vmods); - } - if (stuff->changeCtrls&XkbIgnoreLockModsMask) { - CHK_MASK_MATCH(0x4,stuff->affectIgnoreLockMods,stuff->ignoreLockMods); - CHK_MASK_MATCH(0x5,stuff->affectIgnoreLockVMods,stuff->ignoreLockVMods); - new.ignore_lock.real_mods&=~stuff->affectIgnoreLockMods; - new.ignore_lock.real_mods|= - (stuff->affectIgnoreLockMods&stuff->ignoreLockMods); - new.ignore_lock.vmods&= ~stuff->affectIgnoreLockVMods; - new.ignore_lock.vmods|= - (stuff->affectIgnoreLockVMods&stuff->ignoreLockVMods); - new.ignore_lock.mask= new.ignore_lock.real_mods| - XkbMaskForVMask(xkbi->desc,new.ignore_lock.vmods); - } - CHK_MASK_MATCH(0x06,stuff->affectEnabledCtrls,stuff->enabledCtrls); - if (stuff->affectEnabledCtrls) { - CHK_MASK_LEGAL(0x07,stuff->affectEnabledCtrls,XkbAllBooleanCtrlsMask); - new.enabled_ctrls&= ~stuff->affectEnabledCtrls; - new.enabled_ctrls|= (stuff->affectEnabledCtrls&stuff->enabledCtrls); - } - if (stuff->changeCtrls&XkbRepeatKeysMask) { - if ((stuff->repeatDelay<1)||(stuff->repeatInterval<1)) { - client->errorValue = _XkbErrCode3(0x08,stuff->repeatDelay, - stuff->repeatInterval); - return BadValue; - } - new.repeat_delay = stuff->repeatDelay; - new.repeat_interval = stuff->repeatInterval; - } - if (stuff->changeCtrls&XkbSlowKeysMask) { - if (stuff->slowKeysDelay<1) { - client->errorValue = _XkbErrCode2(0x09,stuff->slowKeysDelay); - return BadValue; - } - new.slow_keys_delay = stuff->slowKeysDelay; - } - if (stuff->changeCtrls&XkbBounceKeysMask) { - if (stuff->debounceDelay<1) { - client->errorValue = _XkbErrCode2(0x0A,stuff->debounceDelay); - return BadValue; - } - new.debounce_delay = stuff->debounceDelay; - } - if (stuff->changeCtrls&XkbMouseKeysMask) { - if (stuff->mkDfltBtn>XkbMaxMouseKeysBtn) { - client->errorValue = _XkbErrCode2(0x0B,stuff->mkDfltBtn); - return BadValue; - } - new.mk_dflt_btn = stuff->mkDfltBtn; - } - if (stuff->changeCtrls&XkbMouseKeysAccelMask) { - if ((stuff->mkDelay<1) || (stuff->mkInterval<1) || - (stuff->mkTimeToMax<1) || (stuff->mkMaxSpeed<1)|| - (stuff->mkCurve<-1000)) { - client->errorValue = _XkbErrCode2(0x0C,0); - return BadValue; - } - new.mk_delay = stuff->mkDelay; - new.mk_interval = stuff->mkInterval; - new.mk_time_to_max = stuff->mkTimeToMax; - new.mk_max_speed = stuff->mkMaxSpeed; - new.mk_curve = stuff->mkCurve; - AccessXComputeCurveFactor(xkbi,&new); - } - if (stuff->changeCtrls&XkbGroupsWrapMask) { - unsigned act,num; - act= XkbOutOfRangeGroupAction(stuff->groupsWrap); - switch (act) { - case XkbRedirectIntoRange: - num= XkbOutOfRangeGroupNumber(stuff->groupsWrap); - if (num>=new.num_groups) { - client->errorValue= _XkbErrCode3(0x0D,new.num_groups,num); - return BadValue; - } - case XkbWrapIntoRange: - case XkbClampIntoRange: - break; - default: - client->errorValue= _XkbErrCode2(0x0E,act); - return BadValue; - } - new.groups_wrap= stuff->groupsWrap; - } - CHK_MASK_LEGAL(0x0F,stuff->axOptions,XkbAX_AllOptionsMask); - if (stuff->changeCtrls&XkbAccessXKeysMask) - new.ax_options = stuff->axOptions&XkbAX_AllOptionsMask; - else { - if (stuff->changeCtrls&XkbStickyKeysMask) { - new.ax_options&= ~XkbAX_SKOptionsMask; - new.ax_options|= stuff->axOptions&XkbAX_SKOptionsMask; - } - if (stuff->changeCtrls&XkbAccessXFeedbackMask) { - new.ax_options&= ~XkbAX_FBOptionsMask; - new.ax_options|= stuff->axOptions&XkbAX_FBOptionsMask; - } - } + if (stuff->changeCtrls & XkbIgnoreLockModsMask) { + CHK_MASK_MATCH(0x4, stuff->affectIgnoreLockMods, + stuff->ignoreLockMods); + CHK_MASK_MATCH(0x5, stuff->affectIgnoreLockVMods, + stuff->ignoreLockVMods); + + new.ignore_lock.real_mods &= ~(stuff->affectIgnoreLockMods); + new.ignore_lock.real_mods |= (stuff->affectIgnoreLockMods & + stuff->ignoreLockMods); + new.ignore_lock.vmods &= ~(stuff->affectIgnoreLockVMods); + new.ignore_lock.vmods |= (stuff->affectIgnoreLockVMods & + stuff->ignoreLockVMods); + new.ignore_lock.mask = new.ignore_lock.real_mods | + XkbMaskForVMask(xkbi->desc, + new.ignore_lock.vmods); + } - if (stuff->changeCtrls&XkbAccessXTimeoutMask) { - if (stuff->axTimeout<1) { - client->errorValue = _XkbErrCode2(0x10,stuff->axTimeout); - return BadValue; - } - CHK_MASK_MATCH(0x11,stuff->axtCtrlsMask,stuff->axtCtrlsValues); - CHK_MASK_LEGAL(0x12,stuff->axtCtrlsMask,XkbAllBooleanCtrlsMask); - CHK_MASK_MATCH(0x13,stuff->axtOptsMask,stuff->axtOptsValues); - CHK_MASK_LEGAL(0x14,stuff->axtOptsMask,XkbAX_AllOptionsMask); - new.ax_timeout = stuff->axTimeout; - new.axt_ctrls_mask = stuff->axtCtrlsMask; - new.axt_ctrls_values = (stuff->axtCtrlsValues&stuff->axtCtrlsMask); - new.axt_opts_mask = stuff->axtOptsMask; - new.axt_opts_values= (stuff->axtOptsValues&stuff->axtOptsMask); - } - if (stuff->changeCtrls&XkbPerKeyRepeatMask) { - memcpy(new.per_key_repeat,stuff->perKeyRepeat,XkbPerKeyBitArraySize); - } - old= *ctrl; - *ctrl= new; - XkbDDXChangeControls(dev,&old,ctrl); - if (XkbComputeControlsNotify(dev,&old,ctrl,&cn,False)) { - cn.keycode= 0; - cn.eventType = 0; - cn.requestMajor = XkbReqCode; - cn.requestMinor = X_kbSetControls; - XkbSendControlsNotify(dev,&cn); - } - if ((sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0))!=NULL) - XkbUpdateIndicators(dev,sli->usesControls,True,NULL,&cause); -#ifndef NO_CLEAR_LATCHES_FOR_STICKY_KEYS_OFF - /* If sticky keys were disabled, clear all locks and latches */ - if ((old.enabled_ctrls&XkbStickyKeysMask)&& - (!(ctrl->enabled_ctrls&XkbStickyKeysMask))) { - XkbClearAllLatchesAndLocks(dev,xkbi,True,&cause); + CHK_MASK_MATCH(0x06, stuff->affectEnabledCtrls, + stuff->enabledCtrls); + if (stuff->affectEnabledCtrls) { + CHK_MASK_LEGAL(0x07, stuff->affectEnabledCtrls, + XkbAllBooleanCtrlsMask); + + new.enabled_ctrls &= ~(stuff->affectEnabledCtrls); + new.enabled_ctrls |= (stuff->affectEnabledCtrls & + stuff->enabledCtrls); + } + + if (stuff->changeCtrls & XkbRepeatKeysMask) { + if (stuff->repeatDelay < 1 || stuff->repeatInterval < 1) { + client->errorValue = _XkbErrCode3(0x08, stuff->repeatDelay, + stuff->repeatInterval); + return BadValue; + } + + new.repeat_delay = stuff->repeatDelay; + new.repeat_interval = stuff->repeatInterval; + } + + if (stuff->changeCtrls & XkbSlowKeysMask) { + if (stuff->slowKeysDelay < 1) { + client->errorValue = _XkbErrCode2(0x09, + stuff->slowKeysDelay); + return BadValue; + } + + new.slow_keys_delay = stuff->slowKeysDelay; + } + + if (stuff->changeCtrls & XkbBounceKeysMask) { + if (stuff->debounceDelay < 1) { + client->errorValue = _XkbErrCode2(0x0A, + stuff->debounceDelay); + return BadValue; + } + + new.debounce_delay = stuff->debounceDelay; + } + + if (stuff->changeCtrls & XkbMouseKeysMask) { + if (stuff->mkDfltBtn > XkbMaxMouseKeysBtn) { + client->errorValue = _XkbErrCode2(0x0B, stuff->mkDfltBtn); + return BadValue; + } + + new.mk_dflt_btn = stuff->mkDfltBtn; + } + + if (stuff->changeCtrls & XkbMouseKeysAccelMask) { + if (stuff->mkDelay < 1 || stuff->mkInterval < 1 || + stuff->mkTimeToMax < 1 || stuff->mkMaxSpeed < 1 || + stuff->mkCurve < -1000) { + client->errorValue = _XkbErrCode2(0x0C,0); + return BadValue; + } + + new.mk_delay = stuff->mkDelay; + new.mk_interval = stuff->mkInterval; + new.mk_time_to_max = stuff->mkTimeToMax; + new.mk_max_speed = stuff->mkMaxSpeed; + new.mk_curve = stuff->mkCurve; + AccessXComputeCurveFactor(xkbi, &new); + } + + if (stuff->changeCtrls & XkbGroupsWrapMask) { + unsigned act, num; + + act = XkbOutOfRangeGroupAction(stuff->groupsWrap); + switch (act) { + case XkbRedirectIntoRange: + num = XkbOutOfRangeGroupNumber(stuff->groupsWrap); + if (num >= new.num_groups) { + client->errorValue = _XkbErrCode3(0x0D, new.num_groups, + num); + return BadValue; + } + case XkbWrapIntoRange: + case XkbClampIntoRange: + break; + default: + client->errorValue = _XkbErrCode2(0x0E, act); + return BadValue; + } + + new.groups_wrap= stuff->groupsWrap; + } + + CHK_MASK_LEGAL(0x0F, stuff->axOptions, XkbAX_AllOptionsMask); + if (stuff->changeCtrls & XkbAccessXKeysMask) { + new.ax_options = stuff->axOptions & XkbAX_AllOptionsMask; + } + else { + if (stuff->changeCtrls & XkbStickyKeysMask) { + new.ax_options &= ~(XkbAX_SKOptionsMask); + new.ax_options |= (stuff->axOptions & XkbAX_SKOptionsMask); + } + + if (stuff->changeCtrls & XkbAccessXFeedbackMask) { + new.ax_options &= ~(XkbAX_FBOptionsMask); + new.ax_options |= (stuff->axOptions & XkbAX_FBOptionsMask); + } + } + + if (stuff->changeCtrls & XkbAccessXTimeoutMask) { + if (stuff->axTimeout < 1) { + client->errorValue = _XkbErrCode2(0x10, stuff->axTimeout); + return BadValue; + } + CHK_MASK_MATCH(0x11, stuff->axtCtrlsMask, + stuff->axtCtrlsValues); + CHK_MASK_LEGAL(0x12, stuff->axtCtrlsMask, + XkbAllBooleanCtrlsMask); + CHK_MASK_MATCH(0x13, stuff->axtOptsMask, stuff->axtOptsValues); + CHK_MASK_LEGAL(0x14, stuff->axtOptsMask, XkbAX_AllOptionsMask); + new.ax_timeout = stuff->axTimeout; + new.axt_ctrls_mask = stuff->axtCtrlsMask; + new.axt_ctrls_values = (stuff->axtCtrlsValues & + stuff->axtCtrlsMask); + new.axt_opts_mask = stuff->axtOptsMask; + new.axt_opts_values = (stuff->axtOptsValues & + stuff->axtOptsMask); + } + + if (stuff->changeCtrls & XkbPerKeyRepeatMask) + memcpy(new.per_key_repeat, stuff->perKeyRepeat, + XkbPerKeyBitArraySize); + + old= *ctrl; + *ctrl= new; + XkbDDXChangeControls(tmpd, &old, ctrl); + + if (XkbComputeControlsNotify(tmpd, &old, ctrl, &cn, False)) { + cn.keycode = 0; + cn.eventType = 0; + cn.requestMajor = XkbReqCode; + cn.requestMinor = X_kbSetControls; + XkbSendControlsNotify(tmpd, &cn); + } + + sli = XkbFindSrvLedInfo(tmpd, XkbDfltXIClass, XkbDfltXIId, 0); + if (sli) + XkbUpdateIndicators(tmpd, sli->usesControls, True, NULL, + &cause); + + /* If sticky keys were disabled, clear all locks and latches */ + if ((old.enabled_ctrls & XkbStickyKeysMask) && + !(ctrl->enabled_ctrls & XkbStickyKeysMask)) + XkbClearAllLatchesAndLocks(tmpd, xkbi, True, &cause); + } } -#endif + return client->noClientException; } @@ -1204,7 +1267,7 @@ unsigned short * pMap; wire= (xkbVModMapWireDesc *)buf; pMap= &xkb->server->vmodmap[rep->firstVModMapKey]; - for (i=0;inVModMapKeys;i++,pMap++) { + for (i=0;inVModMapKeys-1;i++,pMap++) { if (*pMap!=0) { wire->key= i+rep->firstVModMapKey; wire->vmods= *pMap; @@ -2202,6 +2265,7 @@ XkbServerMapPtr srv = xkbi->desc->server; return (char *)wire; } +/* FIXME: Needs to set map on all core-sending devices. */ int ProcXkbSetMap(ClientPtr client) { @@ -2517,6 +2581,7 @@ ProcXkbGetCompatMap(ClientPtr client) return XkbSendCompatMap(client,compat,&rep); } +/* FIXME: Needs to set compat map on all core-sending devices. */ int ProcXkbSetCompatMap(ClientPtr client) { @@ -2790,6 +2855,7 @@ XkbIndicatorPtr leds; return XkbSendIndicatorMap(client,leds,&rep); } +/* FIXME: Needs to set indicator map on all core-sending devices. */ int ProcXkbSetIndicatorMap(ClientPtr client) { @@ -2951,6 +3017,7 @@ ProcXkbGetNamedIndicator(ClientPtr client) return client->noClientException; } +/* FIXME: Needs to set indicator on all core-sending devices. */ int ProcXkbSetNamedIndicator(ClientPtr client) { @@ -3435,6 +3502,7 @@ const char * str; return True; } +/* FIXME: Needs to set names on all core-sending devices. */ int ProcXkbSetNames(ClientPtr client) { @@ -4739,6 +4807,7 @@ char * wire; return Success; } +/* FIXME: Needs to set geom on all core-sending devices. */ int ProcXkbSetGeometry(ClientPtr client) { @@ -5017,6 +5086,7 @@ int ProcXkbGetKbdByName(ClientPtr client) { DeviceIntPtr dev; + DeviceIntPtr tmpd; XkbFileInfo finfo; xkbGetKbdByNameReply rep = {0}; xkbGetMapReply mrep = {0}; @@ -5032,6 +5102,8 @@ ProcXkbGetKbdByName(ClientPtr client) unsigned fwant,fneed,reported; int status; Bool geom_changed; + XkbSrvLedInfoPtr old_sli; + XkbSrvLedInfoPtr sli; REQUEST(xkbGetKbdByNameReq); REQUEST_AT_LEAST_SIZE(xkbGetKbdByNameReq); @@ -5102,8 +5174,10 @@ ProcXkbGetKbdByName(ClientPtr client) fneed|= XkmKeyNamesIndex|XkmTypesIndex; fwant|= XkmIndicatorsIndex; } + + /* We pass dev in here so we can get the old names out if needed. */ rep.found = XkbDDXLoadKeymapByNames(dev,&names,fwant,fneed,&finfo, - mapFile,PATH_MAX); + mapFile,PATH_MAX); rep.newKeyboard= False; rep.pad1= rep.pad2= rep.pad3= rep.pad4= 0; @@ -5299,23 +5373,34 @@ ProcXkbGetKbdByName(ClientPtr client) } xkb->ctrls->num_groups= nTG; - memcpy(dev->key->modifierMap,xkb->map->modmap,xkb->max_key_code+1); - XkbUpdateCoreDescription(dev,True); - - if (dev->kbdfeed && dev->kbdfeed->xkb_sli) { - XkbSrvLedInfoPtr old_sli; - XkbSrvLedInfoPtr sli; - old_sli = dev->kbdfeed->xkb_sli; - dev->kbdfeed->xkb_sli = NULL; - sli = XkbAllocSrvLedInfo(dev,dev->kbdfeed,NULL,0); - if (sli) { - sli->explicitState = old_sli->explicitState; - sli->effectiveState = old_sli->effectiveState; + for (tmpd = inputInfo.devices; tmpd; tmpd = tmpd->next) { + if (tmpd == dev || + (dev->id == inputInfo.keyboard->id && tmpd->key && + tmpd->coreEvents)) { + + memcpy(tmpd->key->modifierMap, xkb->map->modmap, + xkb->max_key_code + 1); + if (tmpd != dev) + XkbCopyKeymap(dev->key->xkbInfo->desc, + tmpd->key->xkbInfo->desc, True); + XkbUpdateCoreDescription(tmpd, True); + + if (tmpd->kbdfeed && tmpd->kbdfeed->xkb_sli) { + old_sli = tmpd->kbdfeed->xkb_sli; + tmpd->kbdfeed->xkb_sli = NULL; + sli = XkbAllocSrvLedInfo(tmpd, tmpd->kbdfeed, NULL, 0); + if (sli) { + sli->explicitState = old_sli->explicitState; + sli->effectiveState = old_sli->effectiveState; + } + tmpd->kbdfeed->xkb_sli = sli; + XkbFreeSrvLedInfo(old_sli); + } } - dev->kbdfeed->xkb_sli = sli; - XkbFreeSrvLedInfo(old_sli); - } + } + /* this should be either a MN or an NKN, depending on whether or not + * the keycode range changed? */ memset(&nkn, 0, sizeof(xkbNewKeyboardNotify)); nkn.deviceID= nkn.oldDeviceID= dev->id; nkn.minKeyCode= finfo.xkb->min_key_code; @@ -5566,7 +5651,6 @@ char * str; wanted&= ~XkbXI_ButtonActionsMask; if ((!dev->kbdfeed)&&(!dev->leds)) wanted&= ~XkbXI_IndicatorsMask; - wanted&= ~XkbXI_KeyboardsMask; nameLen= XkbSizeCountedString(dev->name); rep.type = X_Reply; @@ -5574,8 +5658,8 @@ char * str; rep.sequenceNumber = client->sequence; rep.length = nameLen/4; rep.present = wanted; - rep.supported = XkbXI_AllDeviceFeaturesMask&(~XkbXI_KeyboardsMask); - rep.unsupported = XkbXI_KeyboardsMask; + rep.supported = XkbXI_AllDeviceFeaturesMask; + rep.unsupported = 0; rep.firstBtnWanted = rep.nBtnsWanted = 0; rep.firstBtnRtrn = rep.nBtnsRtrn = 0; if (dev->button) @@ -5868,6 +5952,7 @@ DeviceIntPtr kbd; return (char *)ledWire; } +/* FIXME: Needs to set info on all core-sending devices. */ int ProcXkbSetDeviceInfo(ClientPtr client) { @@ -5885,7 +5970,7 @@ xkbExtensionDeviceNotify ed; change= stuff->change; CHK_ANY_DEVICE(dev,stuff->deviceSpec); - CHK_MASK_LEGAL(0x01,change,(XkbXI_AllFeaturesMask&(~XkbXI_KeyboardsMask))); + CHK_MASK_LEGAL(0x01,change,XkbXI_AllFeaturesMask); wire= (char *)&stuff[1]; if (change&XkbXI_ButtonActionsMask) { diff --git a/nx-X11/programs/Xserver/xkb/xkb.h b/nx-X11/programs/Xserver/xkb/xkb.h index 19a93b20ec..a3d3962f10 100644 --- a/nx-X11/programs/Xserver/xkb/xkb.h +++ b/nx-X11/programs/Xserver/xkb/xkb.h @@ -25,7 +25,11 @@ extern int ProcXkbGetDeviceInfo(ClientPtr client); extern int ProcXkbSetDeviceInfo(ClientPtr client); extern int ProcXkbSetDebuggingFlags(ClientPtr client); - extern void XkbExtensionInit(void); extern Bool XkbFilterEvents(ClientPtr pClient, int nEvents, xEvent *xE); + +extern Bool XkbCopyKeymap( + XkbDescPtr src, + XkbDescPtr dst, + Bool sendNotifies); \ No newline at end of file diff --git a/nx-X11/programs/Xserver/xkb/xkbAccessX.c b/nx-X11/programs/Xserver/xkb/xkbAccessX.c index 3eafaa5b76..a9019ccf10 100644 --- a/nx-X11/programs/Xserver/xkb/xkbAccessX.c +++ b/nx-X11/programs/Xserver/xkb/xkbAccessX.c @@ -48,9 +48,9 @@ void * XkbLastRepeatEvent= NULL; unsigned short XkbDfltAccessXTimeout= 120; unsigned int XkbDfltAccessXTimeoutMask= DFLT_TIMEOUT_CTRLS; -static unsigned int XkbDfltAccessXTimeoutValues= 0; -static unsigned int XkbDfltAccessXTimeoutOptionsMask= DFLT_TIMEOUT_OPTS; -static unsigned int XkbDfltAccessXTimeoutOptionsValues= 0; +static unsigned int XkbDfltAccessXTimeoutValues= 0; +static unsigned int XkbDfltAccessXTimeoutOptionsMask= DFLT_TIMEOUT_OPTS; +static unsigned int XkbDfltAccessXTimeoutOptionsValues= 0; unsigned int XkbDfltAccessXFeedback= XkbAccessXFeedbackMask; unsigned short XkbDfltAccessXOptions= XkbAX_AllOptionsMask & ~(XkbAX_IndicatorFBMask|XkbAX_SKReleaseFBMask|XkbAX_SKRejectFBMask); @@ -300,14 +300,19 @@ xkbControlsNotify cn; static CARD32 AccessXRepeatKeyExpire(OsTimerPtr timer,CARD32 now,void * arg) { -XkbSrvInfoPtr xkbi= ((DeviceIntPtr)arg)->key->xkbInfo; +DeviceIntPtr dev = (DeviceIntPtr) arg; +XkbSrvInfoPtr xkbi = dev->key->xkbInfo; KeyCode key; +BOOL is_core; - if (xkbi->repeatKey==0) + if (xkbi->repeatKey == 0) return 0; - key= xkbi->repeatKey; - AccessXKeyboardEvent((DeviceIntPtr)arg,KeyRelease,key,True); - AccessXKeyboardEvent((DeviceIntPtr)arg,KeyPress,key,True); + + is_core = (dev == inputInfo.keyboard); + key = xkbi->repeatKey; + AccessXKeyboardEvent(dev, is_core ? KeyRelease : DeviceKeyRelease, key, + True); + AccessXKeyboardEvent(dev, is_core ? KeyPress : DeviceKeyPress, key, True); return xkbi->desc->ctrls->repeat_interval; } @@ -353,8 +358,7 @@ XkbControlsPtr ctrls; if (keybd->kbdfeed->ctrl.autoRepeat && ((xkbi->slowKey != xkbi->mouseKey) || (!xkbi->mouseKeysAccel)) && (ctrls->enabled_ctrls&XkbRepeatKeysMask)) { - if (BitIsOn(keybd->kbdfeed->ctrl.autoRepeats,xkbi->slowKey)) - { + if (BitIsOn(keybd->kbdfeed->ctrl.autoRepeats,xkbi->slowKey)) { xkbi->repeatKey = xkbi->slowKey; xkbi->repeatKeyTimer= TimerSet(xkbi->repeatKeyTimer, 0, ctrls->repeat_delay, @@ -520,6 +524,7 @@ KeySym * sym = XkbKeySymsPtr(xkbi->desc,key); if ((keybd->kbdfeed->ctrl.autoRepeat) && ((ctrls->enabled_ctrls&(XkbSlowKeysMask|XkbRepeatKeysMask))== XkbRepeatKeysMask)) { + if (BitIsOn(keybd->kbdfeed->ctrl.autoRepeats,key)) { if (xkbDebugFlags&0x10) @@ -684,6 +689,8 @@ ProcessPointerEvent( register xEvent * xE, DeviceIntPtr dev = (DeviceIntPtr)LookupKeyboardDevice(); XkbSrvInfoPtr xkbi = dev->key->xkbInfo; unsigned changed = 0; +ProcessInputProc backupproc; +xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(mouse); xkbi->shiftKeyCount = 0; xkbi->lastPtrEventTime= xE->u.keyButtonPointer.time; @@ -695,7 +702,26 @@ unsigned changed = 0; xkbi->lockedPtrButtons&= ~(1<<(xE->u.u.detail&0x7)); changed |= XkbPointerButtonMask; } - CoreProcessPointerEvent(xE,mouse,count); + + /* Guesswork. mostly. + * xkb actuall goes through some effort to transparently wrap the + * processInputProcs (see XkbSetExtension). But we all love fun, so the + * previous XKB implementation just hardcoded the CPPE call here instead + * of unwrapping like anybody with any sense of decency would do. + * I got no clue what the correct thing to do is, but my guess is that + * it's not hardcoding. I may be wrong. whatever it is, don't come whining + * to me. I just work here. + * + * Anyway. here's the old call, if you don't like the wrapping, revert it. + * + * CoreProcessPointerEvent(xE,mouse,count); + * + * see. it's still steaming. told you. (whot) + */ + UNWRAP_PROCESS_INPUT_PROC(mouse, xkbPrivPtr, backupproc); + mouse->public.processInputProc(xE, mouse, count); + COND_WRAP_PROCESS_INPUT_PROC(mouse, xkbPrivPtr, + backupproc, xkbUnwrapProc); xkbi->state.ptr_buttons = mouse->button->state; diff --git a/nx-X11/programs/Xserver/xkb/xkbActions.c b/nx-X11/programs/Xserver/xkb/xkbActions.c index eadef3beee..b918f21628 100644 --- a/nx-X11/programs/Xserver/xkb/xkbActions.c +++ b/nx-X11/programs/Xserver/xkb/xkbActions.c @@ -35,26 +35,28 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include "misc.h" #include "inputstr.h" +#include "exevents.h" #include #include "xkb.h" #include +#define EXTENSION_EVENT_BASE 64 static unsigned int _xkbServerGeneration; -static int xkbDevicePrivateIndex = -1; +int xkbDevicePrivateIndex = -1; -static void +void xkbUnwrapProc(DeviceIntPtr device, DeviceHandleProc proc, void * data) { xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(device); - ProcessInputProc tmp = device->public.processInputProc; + ProcessInputProc backupproc; if(xkbPrivPtr->unwrapProc) xkbPrivPtr->unwrapProc = NULL; - UNWRAP_PROCESS_INPUT_PROC(device,xkbPrivPtr); + UNWRAP_PROCESS_INPUT_PROC(device,xkbPrivPtr, backupproc); proc(device,data); - WRAP_PROCESS_INPUT_PROC(device,xkbPrivPtr, - tmp,xkbUnwrapProc); + COND_WRAP_PROCESS_INPUT_PROC(device,xkbPrivPtr, + backupproc,xkbUnwrapProc); } @@ -71,14 +73,13 @@ XkbSetExtension(DeviceIntPtr device, ProcessInputProc proc) if (!AllocateDevicePrivate(device, xkbDevicePrivateIndex)) return; - xkbPrivPtr = (xkbDeviceInfoPtr) malloc(sizeof(xkbDeviceInfoRec)); + xkbPrivPtr = (xkbDeviceInfoPtr) calloc(1, sizeof(xkbDeviceInfoRec)); if (!xkbPrivPtr) return; xkbPrivPtr->unwrapProc = NULL; device->devPrivates[xkbDevicePrivateIndex].ptr = xkbPrivPtr; - WRAP_PROCESS_INPUT_PROC(device,xkbPrivPtr, - proc,xkbUnwrapProc); + WRAP_PROCESS_INPUT_PROC(device, xkbPrivPtr, proc, xkbUnwrapProc); } void @@ -249,22 +250,6 @@ XkbAction fake; #define SYNTHETIC_KEYCODE 1 #define BTN_ACT_FLAG 0x100 -typedef struct _XkbFilter { - CARD16 keycode; - CARD8 what; - CARD8 active; - CARD8 filterOthers; - CARD32 priv; - XkbAction upAction; - int (*filter)( - XkbSrvInfoPtr /* xkbi */, - struct _XkbFilter * /* filter */, - unsigned /* keycode */, - XkbAction * /* action */ - ); - struct _XkbFilter *next; -} XkbFilterRec,*XkbFilterPtr; - static int _XkbFilterSetState( XkbSrvInfoPtr xkbi, XkbFilterPtr filter, @@ -429,7 +414,6 @@ _XkbFilterLockState( XkbSrvInfoPtr xkbi, unsigned keycode, XkbAction * pAction) { - if (pAction&&(pAction->type==XkbSA_LockGroup)) { if (pAction->group.flags&XkbSA_GroupAbsolute) xkbi->state.locked_group= XkbSAGroup(&pAction->group); @@ -591,6 +575,9 @@ _XkbFilterPointerMove( XkbSrvInfoPtr xkbi, int x,y; Bool accel; + if (xkbi->device == inputInfo.keyboard) + return 0; + if (filter->keycode==0) { /* initial press */ filter->keycode = keycode; filter->active = 1; @@ -631,6 +618,9 @@ _XkbFilterPointerBtn( XkbSrvInfoPtr xkbi, unsigned keycode, XkbAction * pAction) { + if (xkbi->device == inputInfo.keyboard) + return 0; + if (filter->keycode==0) { /* initial press */ int button= pAction->btn.button; @@ -701,6 +691,7 @@ _XkbFilterPointerBtn( XkbSrvInfoPtr xkbi, &old,xkbi->desc->ctrls, &cn,False)) { cn.keycode = keycode; + /* XXX: what about DeviceKeyPress? */ cn.eventType = KeyPress; cn.requestMajor = 0; cn.requestMinor = 0; @@ -765,6 +756,7 @@ XkbEventCauseRec cause; ctrls->enabled_ctrls|= change; if (XkbComputeControlsNotify(kbd,&old,ctrls,&cn,False)) { cn.keycode = keycode; + /* XXX: what about DeviceKeyPress? */ cn.eventType = KeyPress; cn.requestMajor = 0; cn.requestMinor = 0; @@ -880,6 +872,11 @@ int x,y; XkbStateRec old; unsigned mods,mask,oldCoreState = 0,oldCorePrevState = 0; xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(xkbi->device); +ProcessInputProc backupproc; + + /* never actually used uninitialised, but gcc isn't smart enough + * to work that out. */ + memset(&old, 0, sizeof(old)); if ((filter->keycode!=0)&&(filter->keycode!=keycode)) return 1; @@ -901,6 +898,7 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(xkbi->device); filter->filter = _XkbFilterRedirectKey; filter->upAction = *pAction; + /* XXX: what about DeviceKeyPress */ ev.u.u.type = KeyPress; ev.u.u.detail = pAction->redirect.new_key; @@ -928,10 +926,14 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(xkbi->device); realMods = xkbi->device->key->modifierMap[ev.u.u.detail]; xkbi->device->key->modifierMap[ev.u.u.detail] = 0; - UNWRAP_PROCESS_INPUT_PROC(xkbi->device,xkbPrivPtr); + /* XXX: Bad! Since the switch to XI devices xkbi->device will be the + * XI device. Sending a core event through ProcessOtherEvent will + * cause trouble. Somebody should fix this. + */ + UNWRAP_PROCESS_INPUT_PROC(xkbi->device,xkbPrivPtr, backupproc); xkbi->device->public.processInputProc(&ev,xkbi->device,1); COND_WRAP_PROCESS_INPUT_PROC(xkbi->device, xkbPrivPtr, - ProcessKeyboardEvent,xkbUnwrapProc); + backupproc,xkbUnwrapProc); xkbi->device->key->modifierMap[ev.u.u.detail] = realMods; if ( mask || mods ) { @@ -942,6 +944,7 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(xkbi->device); } else if (filter->keycode==keycode) { + /* XXX: what about DeviceKeyRelease */ ev.u.u.type = KeyRelease; ev.u.u.detail = filter->upAction.redirect.new_key; @@ -969,10 +972,14 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(xkbi->device); realMods = xkbi->device->key->modifierMap[ev.u.u.detail]; xkbi->device->key->modifierMap[ev.u.u.detail] = 0; - UNWRAP_PROCESS_INPUT_PROC(xkbi->device,xkbPrivPtr); + /* XXX: Bad! Since the switch to XI devices xkbi->device will be the + * XI device. Sending a core event through ProcessOtherEvent will + * cause trouble. Somebody should fix this. + */ + UNWRAP_PROCESS_INPUT_PROC(xkbi->device,xkbPrivPtr, backupproc); xkbi->device->public.processInputProc(&ev,xkbi->device,1); COND_WRAP_PROCESS_INPUT_PROC(xkbi->device, xkbPrivPtr, - ProcessKeyboardEvent,xkbUnwrapProc); + backupproc,xkbUnwrapProc); xkbi->device->key->modifierMap[ev.u.u.detail] = realMods; if ( mask || mods ) { @@ -993,8 +1000,11 @@ _XkbFilterSwitchScreen( XkbSrvInfoPtr xkbi, unsigned keycode, XkbAction * pAction) { + DeviceIntPtr dev = xkbi->device; + if (dev == inputInfo.keyboard) + return 0; + if (filter->keycode==0) { /* initial press */ - DeviceIntPtr dev = xkbi->device; filter->keycode = keycode; filter->active = 1; filter->filterOthers = 0; @@ -1016,8 +1026,11 @@ _XkbFilterXF86Private( XkbSrvInfoPtr xkbi, unsigned keycode, XkbAction * pAction) { + DeviceIntPtr dev = xkbi->device; + if (dev == inputInfo.keyboard) + return 0; + if (filter->keycode==0) { /* initial press */ - DeviceIntPtr dev = xkbi->device; filter->keycode = keycode; filter->active = 1; filter->filterOthers = 0; @@ -1032,7 +1045,6 @@ _XkbFilterXF86Private( XkbSrvInfoPtr xkbi, return 1; } -#ifdef XINPUT static int _XkbFilterDeviceBtn( XkbSrvInfoPtr xkbi, @@ -1043,6 +1055,9 @@ _XkbFilterDeviceBtn( XkbSrvInfoPtr xkbi, DeviceIntPtr dev; int button; + if (xkbi->device == inputInfo.keyboard) + return 0; + if (filter->keycode==0) { /* initial press */ dev= _XkbLookupButtonDevice(pAction->devbtn.device,NULL); if ((!dev)||(!dev->public.on)||(&dev->public==LookupPointerDevice())) @@ -1104,34 +1119,33 @@ int button; } return 0; } -#endif - -static int szFilters = 0; -static XkbFilterPtr filters = NULL; static XkbFilterPtr _XkbNextFreeFilter( - void + XkbSrvInfoPtr xkbi ) { register int i; - if (szFilters==0) { - szFilters = 4; - filters = _XkbTypedCalloc(szFilters,XkbFilterRec); + if (xkbi->szFilters==0) { + xkbi->szFilters = 4; + xkbi->filters = _XkbTypedCalloc(xkbi->szFilters,XkbFilterRec); /* 6/21/93 (ef) -- XXX! deal with allocation failure */ } - for (i=0;iszFilters;i++) { + if (!xkbi->filters[i].active) { + xkbi->filters[i].keycode = 0; + return &xkbi->filters[i]; } } - szFilters*=2; - filters= _XkbTypedRealloc(filters,szFilters,XkbFilterRec); + xkbi->szFilters*=2; + xkbi->filters= _XkbTypedRealloc(xkbi->filters, + xkbi->szFilters, + XkbFilterRec); /* 6/21/93 (ef) -- XXX! deal with allocation failure */ - bzero(&filters[szFilters/2],(szFilters/2)*sizeof(XkbFilterRec)); - return &filters[szFilters/2]; + bzero(&xkbi->filters[xkbi->szFilters/2], + (xkbi->szFilters/2)*sizeof(XkbFilterRec)); + return &xkbi->filters[xkbi->szFilters/2]; } static int @@ -1140,9 +1154,10 @@ _XkbApplyFilters(XkbSrvInfoPtr xkbi,unsigned kc,XkbAction *pAction) register int i,send; send= 1; - for (i=0;iszFilters;i++) { + if ((xkbi->filters[i].active)&&(xkbi->filters[i].filter)) + send= ((*xkbi->filters[i].filter)(xkbi,&xkbi->filters[i],kc,pAction) + && send); } return send; } @@ -1160,15 +1175,15 @@ XkbAction act; XkbFilterPtr filter; Bool keyEvent; Bool pressEvent; -#ifdef XINPUT -Bool xiEvent; -#endif +ProcessInputProc backupproc; xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev); keyc= kbd->key; xkbi= keyc->xkbInfo; key= xE->u.u.detail; + /* The state may change, so if we're not in the middle of sending a state + * notify, prepare for it */ if ((xkbi->flags&_XkbStateNotifyInProgress)==0) { xkbi->prev_state = xkbi->state; xkbi->flags|= _XkbStateNotifyInProgress; @@ -1180,18 +1195,10 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev); xkbi->groupChange = 0; sendEvent = 1; -#ifdef XINPUT keyEvent= ((xE->u.u.type==KeyPress)||(xE->u.u.type==DeviceKeyPress)|| (xE->u.u.type==KeyRelease)||(xE->u.u.type==DeviceKeyRelease)); pressEvent= (xE->u.u.type==KeyPress)||(xE->u.u.type==DeviceKeyPress)|| (xE->u.u.type==ButtonPress)||(xE->u.u.type==DeviceButtonPress); - xiEvent= (xE->u.u.type==DeviceKeyPress)||(xE->u.u.type==DeviceKeyRelease)|| - (xE->u.u.type==DeviceButtonPress)|| - (xE->u.u.type==DeviceButtonRelease); -#else - keyEvent= (xE->u.u.type==KeyPress)||(xE->u.u.type==KeyRelease); - pressEvent= (xE->u.u.type==KeyPress)||(xE->u.u.type==ButtonPress); -#endif if (pressEvent) { if (keyEvent) @@ -1205,62 +1212,60 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev); switch (act.type) { case XkbSA_SetMods: case XkbSA_SetGroup: - filter = _XkbNextFreeFilter(); + filter = _XkbNextFreeFilter(xkbi); sendEvent = _XkbFilterSetState(xkbi,filter,key,&act); break; case XkbSA_LatchMods: case XkbSA_LatchGroup: - filter = _XkbNextFreeFilter(); + filter = _XkbNextFreeFilter(xkbi); sendEvent=_XkbFilterLatchState(xkbi,filter,key,&act); break; case XkbSA_LockMods: case XkbSA_LockGroup: - filter = _XkbNextFreeFilter(); + filter = _XkbNextFreeFilter(xkbi); sendEvent=_XkbFilterLockState(xkbi,filter,key,&act); break; case XkbSA_ISOLock: - filter = _XkbNextFreeFilter(); + filter = _XkbNextFreeFilter(xkbi); sendEvent=_XkbFilterISOLock(xkbi,filter,key,&act); break; case XkbSA_MovePtr: - filter = _XkbNextFreeFilter(); + filter = _XkbNextFreeFilter(xkbi); sendEvent= _XkbFilterPointerMove(xkbi,filter,key,&act); break; case XkbSA_PtrBtn: case XkbSA_LockPtrBtn: case XkbSA_SetPtrDflt: - filter = _XkbNextFreeFilter(); + filter = _XkbNextFreeFilter(xkbi); sendEvent= _XkbFilterPointerBtn(xkbi,filter,key,&act); break; case XkbSA_Terminate: sendEvent= XkbDDXTerminateServer(dev,key,&act); break; case XkbSA_SwitchScreen: - filter = _XkbNextFreeFilter(); + filter = _XkbNextFreeFilter(xkbi); sendEvent=_XkbFilterSwitchScreen(xkbi,filter,key,&act); break; case XkbSA_SetControls: case XkbSA_LockControls: - filter = _XkbNextFreeFilter(); + filter = _XkbNextFreeFilter(xkbi); sendEvent=_XkbFilterControls(xkbi,filter,key,&act); break; case XkbSA_ActionMessage: - filter = _XkbNextFreeFilter(); + filter = _XkbNextFreeFilter(xkbi); sendEvent=_XkbFilterActionMessage(xkbi,filter,key,&act); break; case XkbSA_RedirectKey: - filter = _XkbNextFreeFilter(); + filter = _XkbNextFreeFilter(xkbi); sendEvent= _XkbFilterRedirectKey(xkbi,filter,key,&act); break; -#ifdef XINPUT case XkbSA_DeviceBtn: case XkbSA_LockDeviceBtn: - filter = _XkbNextFreeFilter(); + filter = _XkbNextFreeFilter(xkbi); sendEvent= _XkbFilterDeviceBtn(xkbi,filter,key,&act); break; -#endif case XkbSA_XFree86Private: - filter = _XkbNextFreeFilter(); + filter = _XkbNextFreeFilter(xkbi); sendEvent= _XkbFilterXF86Private(xkbi,filter,key,&act); break; } @@ -1297,24 +1302,21 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev); } if (sendEvent) { -#ifdef XINPUT - if (xiEvent) - ProcessOtherEvent(xE,dev,count); - else -#endif if (keyEvent) { realMods = keyc->modifierMap[key]; keyc->modifierMap[key] = 0; - UNWRAP_PROCESS_INPUT_PROC(dev,xkbPrivPtr); - dev->public.processInputProc(xE,dev,count); - COND_WRAP_PROCESS_INPUT_PROC(dev, xkbPrivPtr, - ProcessKeyboardEvent,xkbUnwrapProc); + } + + UNWRAP_PROCESS_INPUT_PROC(dev,xkbPrivPtr, backupproc); + dev->public.processInputProc(xE,dev,count); + COND_WRAP_PROCESS_INPUT_PROC(dev, xkbPrivPtr, + backupproc,xkbUnwrapProc); + if (keyEvent) keyc->modifierMap[key] = realMods; - } - else CoreProcessPointerEvent(xE,dev,count); } - else if (keyEvent) + else if (keyEvent) { FixKeyState(xE,dev); + } XkbComputeDerivedState(xkbi); keyc->prev_state= keyc->state; @@ -1335,7 +1337,7 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev); if (changed) { XkbEventCauseRec cause; XkbSetCauseKey(&cause,key,xE->u.u.type); - XkbUpdateIndicators(dev,changed,True,NULL,&cause); + XkbUpdateIndicators(dev,changed,False,NULL,&cause); } return; } @@ -1359,7 +1361,7 @@ unsigned clear; act.type = XkbSA_LatchMods; act.mods.flags = 0; act.mods.mask = mask&latches; - filter = _XkbNextFreeFilter(); + filter = _XkbNextFreeFilter(xkbi); _XkbFilterLatchState(xkbi,filter,SYNTHETIC_KEYCODE,&act); _XkbFilterLatchState(xkbi,filter,SYNTHETIC_KEYCODE,(XkbAction *)NULL); return Success; @@ -1379,7 +1381,7 @@ XkbAction act; act.type = XkbSA_LatchGroup; act.group.flags = 0; XkbSASetGroup(&act.group,group); - filter = _XkbNextFreeFilter(); + filter = _XkbNextFreeFilter(xkbi); _XkbFilterLatchState(xkbi,filter,SYNTHETIC_KEYCODE,&act); _XkbFilterLatchState(xkbi,filter,SYNTHETIC_KEYCODE,(XkbAction *)NULL); return Success; diff --git a/nx-X11/programs/Xserver/xkb/xkbEvents.c b/nx-X11/programs/Xserver/xkb/xkbEvents.c index 7916737534..b12bd1c412 100644 --- a/nx-X11/programs/Xserver/xkb/xkbEvents.c +++ b/nx-X11/programs/Xserver/xkb/xkbEvents.c @@ -33,6 +33,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include +#include #include "inputstr.h" #include "windowstr.h" #include @@ -397,7 +398,8 @@ XID winID = 0; if ((force||(xkbi->desc->ctrls->enabled_ctrls&XkbAudibleBellMask))&& (!eventOnly)) { - (*kbd->kbdfeed->BellProc)(percent,kbd,(void *)pCtrl,class); + if (kbd->kbdfeed->BellProc) + (*kbd->kbdfeed->BellProc)(percent,kbd,(void *)pCtrl,class); } interest = kbd->xkb_interest; if ((!interest)||(force)) @@ -805,10 +807,12 @@ XkbSrvInfoPtr xkbi; xkbi= pXDev->key->xkbInfo; if ( pClient->xkbClientFlags & _XkbClientInitialized ) { if ((xkbDebugFlags&0x10)&& - ((xE[0].u.u.type==KeyPress)||(xE[0].u.u.type==KeyRelease))) { + ((xE[0].u.u.type==KeyPress)||(xE[0].u.u.type==KeyRelease)|| + (xE[0].u.u.type==DeviceKeyPress)|| + (xE[0].u.u.type == DeviceKeyRelease))) { DebugF("XKbFilterWriteEvents:\n"); DebugF(" Event state= 0x%04x\n",xE[0].u.keyButtonPointer.state); - DebugF(" XkbLastRepeatEvent!=xE (0x%x!=0x%x) %s\n", + DebugF(" XkbLastRepeatEvent!=xE (0x%p!=0x%p) %s\n", XkbLastRepeatEvent,xE, ((XkbLastRepeatEvent!=(void *)xE)?"True":"False")); DebugF(" (xkbClientEventsFlags&XWDA)==0 (0x%x) %s\n", @@ -823,7 +827,9 @@ XkbSrvInfoPtr xkbi; return False; } if ((pXDev->grab != NullGrab) && pXDev->fromPassiveGrab && - ((xE[0].u.u.type==KeyPress)||(xE[0].u.u.type==KeyRelease))) { + ((xE[0].u.u.type==KeyPress)||(xE[0].u.u.type==KeyRelease)|| + (xE[0].u.u.type==DeviceKeyPress)|| + (xE[0].u.u.type == DeviceKeyRelease))) { register unsigned state,flags; flags= pClient->xkbClientFlags; @@ -865,7 +871,9 @@ XkbSrvInfoPtr xkbi; for (i=0;istate.lookup_mods, @@ -886,16 +894,32 @@ XkbSrvInfoPtr xkbi; xE[i].u.keyButtonPointer.state= new; } else if ((type==EnterNotify)||(type==LeaveNotify)) { - xE->u.enterLeave.state&= 0x1F00; - xE->u.enterLeave.state|= xkbi->state.compat_grab_mods; - } + xE[i].u.enterLeave.state&= 0x1F00; + xE[i].u.enterLeave.state|= xkbi->state.compat_grab_mods; + } else if ((type>=DeviceKeyPress)&&(type<=DeviceMotionNotify)) { + CARD16 old, new; + deviceKeyButtonPointer *kbp = (deviceKeyButtonPointer*)&xE[i]; + old= kbp->state&(~0x1F00); + new= kbp->state&0x1F00; + if (old==XkbStateFieldFromRec(&xkbi->state)) + new|= xkbi->state.compat_lookup_mods; + else new|= xkbi->state.compat_grab_mods; + kbp->state= new; + } button_mask = 1 << xE[i].u.u.detail; if (type == ButtonPress && ((xE[i].u.keyButtonPointer.state >> 7) & button_mask) == button_mask && (xkbi->lockedPtrButtons & button_mask) == button_mask) { DebugF("Faking release of button %d\n", xE[i].u.u.detail); XkbDDXFakePointerButton(ButtonRelease, xE[i].u.u.detail); - } + } else if (type == DeviceButtonPress && + ((((deviceKeyButtonPointer*)&xE[i])->state >> 7) & button_mask) == button_mask && + (xkbi->lockedPtrButtons & button_mask) == button_mask) { +#ifdef DEBUG + ErrorF("Faking release of button %d\n", ((deviceKeyButtonPointer*)&xE[i])->state); +#endif + XkbDDXFakePointerButton(DeviceButtonRelease, ((deviceKeyButtonPointer*)&xE[i])->state); + } } } return True; diff --git a/nx-X11/programs/Xserver/xkb/xkbInit.c b/nx-X11/programs/Xserver/xkb/xkbInit.c index f37e202d86..4125978e6b 100644 --- a/nx-X11/programs/Xserver/xkb/xkbInit.c +++ b/nx-X11/programs/Xserver/xkb/xkbInit.c @@ -107,8 +107,7 @@ typedef struct _SrvXkmInfo { char * XkbBaseDirectory= XKB_BASE_DIRECTORY; char * XkbBinDirectory= XKB_BIN_DIRECTORY; - -static int XkbWantAccessX= 0; +static int XkbWantAccessX= 0; static XkbFileInfo * _XkbInitFileInfo= NULL; static Bool rulesDefined= False; @@ -118,12 +117,12 @@ static char * XkbLayoutDflt= NULL; static char * XkbVariantDflt= NULL; static char * XkbOptionsDflt= NULL; -static char * XkbModelUsed= NULL; -static char * XkbLayoutUsed= NULL; -static char * XkbVariantUsed= NULL; -static char * XkbOptionsUsed= NULL; +static char * XkbModelUsed= NULL; +static char * XkbLayoutUsed= NULL; +static char * XkbVariantUsed= NULL; +static char * XkbOptionsUsed= NULL; -Bool noXkbExtension= XKB_DFLT_DISABLED; +Bool noXkbExtension= XKB_DFLT_DISABLED; static Bool XkbWantRulesProp= XKB_DFLT_RULES_PROP; /***====================================================================***/ diff --git a/nx-X11/programs/Xserver/xkb/xkbLEDs.c b/nx-X11/programs/Xserver/xkb/xkbLEDs.c index 0fccd0913f..2854b9833f 100644 --- a/nx-X11/programs/Xserver/xkb/xkbLEDs.c +++ b/nx-X11/programs/Xserver/xkb/xkbLEDs.c @@ -62,6 +62,9 @@ XkbSrvLedInfoPtr sli; sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0); + if (!sli) + return update; + if (state_changes&(XkbModifierStateMask|XkbGroupStateMask)) update|= sli->usesEffective; if (state_changes&(XkbModifierBaseMask|XkbGroupBaseMask)) @@ -81,7 +84,7 @@ XkbSrvLedInfoPtr sli; /* * Bool - * XkbApplyLEDChangeToKeyboard(xkbi,map,on,change) + *XkbApplyLEDChangeToKeyboard(xkbi,map,on,change) * * Some indicators "drive" the keyboard when their state is explicitly * changed, as described in section 9.2.1 of the XKB protocol spec. @@ -165,7 +168,7 @@ XkbStatePtr state; } return (stateChange || ctrlChange); } - + /* * Bool * ComputeAutoState(map,state,ctrls) @@ -215,6 +218,7 @@ CARD8 mods,group; return on; } + static void XkbUpdateLedAutoState( DeviceIntPtr dev, XkbSrvLedInfoPtr sli, @@ -274,13 +278,13 @@ unsigned oldState; changes->indicators.state_changes|= affected; } - ed->reason|= (XkbXI_IndicatorStateMask&(~XkbXI_KeyboardsMask)); + ed->reason|= XkbXI_IndicatorStateMask; ed->ledClass= sli->class; ed->ledID= sli->id; ed->ledsDefined= sli->namesPresent|sli->mapsPresent; ed->ledState= sli->effectiveState; - ed->unsupported|= XkbXI_KeyboardsMask&XkbXI_IndicatorStateMask; - ed->supported= XkbXI_AllFeaturesMask&(~XkbXI_KeyboardsMask); + ed->unsupported|= XkbXI_IndicatorStateMask; + ed->supported= XkbXI_AllFeaturesMask; if (changes!=&my_changes) changes= NULL; if (ed!=&my_ed) ed= NULL; @@ -304,6 +308,7 @@ XkbSrvLedInfoPtr sli; sli= kf->xkb_sli; XkbUpdateLedAutoState(edev,sli,sli->mapsPresent,NULL, changes,cause); + } } if (edev->leds) { @@ -314,6 +319,7 @@ XkbSrvLedInfoPtr sli; sli= lf->xkb_sli; XkbUpdateLedAutoState(edev,sli,sli->mapsPresent,NULL, changes,cause); + } } } @@ -380,6 +386,8 @@ unsigned side_affected; return; } +/***====================================================================***/ + /***====================================================================***/ /* @@ -745,13 +753,13 @@ xkbExtensionDeviceNotify my_ed; changes->names.changed_indicators|= changed_names; } - ed->reason|= (XkbXI_IndicatorNamesMask&(~XkbXI_KeyboardsMask)); + ed->reason|= XkbXI_IndicatorNamesMask; ed->ledClass= sli->class; ed->ledID= sli->id; ed->ledsDefined= sli->namesPresent|sli->mapsPresent; ed->ledState= sli->effectiveState; - ed->unsupported= XkbXI_KeyboardsMask; - ed->supported= XkbXI_AllFeaturesMask&(~XkbXI_KeyboardsMask); + ed->unsupported= 0; + ed->supported= XkbXI_AllFeaturesMask; if (changes!=&my_changes) changes= NULL; if (ed!=&my_ed) ed= NULL; @@ -823,13 +831,13 @@ xkbExtensionDeviceNotify my_ed; XkbCheckIndicatorMaps(dev,sli,changed_maps); - ed->reason|= (XkbXI_IndicatorMapsMask&(~XkbXI_KeyboardsMask)); + ed->reason|= XkbXI_IndicatorMapsMask; ed->ledClass= sli->class; ed->ledID= sli->id; ed->ledsDefined= sli->namesPresent|sli->mapsPresent; ed->ledState= sli->effectiveState; - ed->unsupported|= XkbXI_KeyboardsMask&XkbXI_IndicatorMapsMask; - ed->supported= XkbXI_AllFeaturesMask&(~XkbXI_KeyboardsMask); + ed->unsupported|= XkbXI_IndicatorMapsMask; + ed->supported= XkbXI_AllFeaturesMask; XkbUpdateLedAutoState(dev,sli,changed_maps,ed,changes,cause); @@ -904,13 +912,13 @@ Bool kb_changed; if ((kbd==dev)&&(sli->flags&XkbSLI_IsDefault)) changes->indicators.state_changes|= affected; if (affected) { - ed->reason|= (XkbXI_IndicatorStateMask&(~XkbXI_KeyboardsMask)); + ed->reason|= XkbXI_IndicatorStateMask; ed->ledClass= sli->class; ed->ledID= sli->id; ed->ledsDefined= sli->namesPresent|sli->mapsPresent; ed->ledState= sli->effectiveState; - ed->unsupported|= XkbXI_KeyboardsMask&XkbXI_IndicatorStateMask; - ed->supported= XkbXI_AllFeaturesMask&(~XkbXI_KeyboardsMask); + ed->unsupported|= XkbXI_IndicatorStateMask; + ed->supported= XkbXI_AllFeaturesMask; } if (kb_changed) { @@ -926,5 +934,3 @@ Bool kb_changed; XkbUpdateAllDeviceIndicators(NULL,cause); return; } - -/***====================================================================***/ diff --git a/nx-X11/programs/Xserver/xkb/xkbPrKeyEv.c b/nx-X11/programs/Xserver/xkb/xkbPrKeyEv.c index 253b4654eb..7a8ba90e0a 100644 --- a/nx-X11/programs/Xserver/xkb/xkbPrKeyEv.c +++ b/nx-X11/programs/Xserver/xkb/xkbPrKeyEv.c @@ -35,9 +35,10 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include "misc.h" #include "inputstr.h" +#include "exevents.h" #include #include - +#define EXTENSION_EVENT_BASE 64 /***====================================================================***/ @@ -49,9 +50,11 @@ XkbSrvInfoPtr xkbi; int key; XkbBehavior behavior; unsigned ndx; +int xiEvent; xkbi= keyc->xkbInfo; key= xE->u.u.detail; + xiEvent= (xE->u.u.type & EXTENSION_EVENT_BASE); if (xkbDebugFlags&0x8) { DebugF("XkbPKE: Key %d %s\n",key,(xE->u.u.type==KeyPress?"down":"up")); } @@ -66,45 +69,69 @@ unsigned ndx; /* below XKB, such as a key that physically locks. XKB does not */ /* do anything to implement the behavior, but it *does* report that */ /* key is hardwired */ + if ((behavior.type&XkbKB_Permanent)==0) { switch (behavior.type) { case XkbKB_Default: - if (( xE->u.u.type == KeyPress ) && + if (( xE->u.u.type == KeyPress || + xE->u.u.type == DeviceKeyPress) && (keyc->down[key>>3] & (1<<(key&7)))) { XkbLastRepeatEvent= (void *)xE; - xE->u.u.type = KeyRelease; + + if (xiEvent) + xE->u.u.type = DeviceKeyRelease; + else + xE->u.u.type = KeyRelease; XkbHandleActions(keybd,keybd,xE,count); - xE->u.u.type = KeyPress; + + if (xiEvent) + xE->u.u.type = DeviceKeyPress; + else + xE->u.u.type = KeyPress; XkbHandleActions(keybd,keybd,xE,count); XkbLastRepeatEvent= NULL; return; } - else if ((xE->u.u.type==KeyRelease) && + else if ((xE->u.u.type==KeyRelease || + xE->u.u.type == DeviceKeyRelease) && (!(keyc->down[key>>3]&(1<<(key&7))))) { XkbLastRepeatEvent= (void *)&xE; - xE->u.u.type = KeyPress; + if (xiEvent) + xE->u.u.type = DeviceKeyPress; + else + xE->u.u.type = KeyPress; XkbHandleActions(keybd,keybd,xE,count); - xE->u.u.type = KeyRelease; + if (xiEvent) + xE->u.u.type = DeviceKeyRelease; + else + xE->u.u.type = KeyRelease; XkbHandleActions(keybd,keybd,xE,count); XkbLastRepeatEvent= NULL; return; } break; case XkbKB_Lock: - if ( xE->u.u.type == KeyRelease ) + if ( xE->u.u.type == KeyRelease || + xE->u.u.type == DeviceKeyRelease) { return; + } else { int bit= 1<<(key&7); - if ( keyc->down[key>>3]&bit ) - xE->u.u.type= KeyRelease; - } + if ( keyc->down[key>>3]&bit ) { + if (xiEvent) + xE->u.u.type = DeviceKeyRelease; + else + xE->u.u.type= KeyRelease; + } + } break; case XkbKB_RadioGroup: ndx= (behavior.data&(~XkbKB_RGAllowNone)); if ( ndxnRadioGroups ) { XkbRadioGroupPtr rg; - if ( xE->u.u.type == KeyRelease ) + if ( xE->u.u.type == KeyRelease || + xE->u.u.type == DeviceKeyRelease) return; rg = &xkbi->radioGroups[ndx]; @@ -118,10 +145,16 @@ unsigned ndx; } if ( rg->currentDown!=0 ) { int key = xE->u.u.detail; - xE->u.u.type= KeyRelease; + if (xiEvent) + xE->u.u.type = DeviceKeyRelease; + else + xE->u.u.type= KeyRelease; xE->u.u.detail= rg->currentDown; XkbHandleActions(keybd,keybd,xE,count); - xE->u.u.type= KeyPress; + if (xiEvent) + xE->u.u.type = DeviceKeyPress; + else + xE->u.u.type= KeyPress; xE->u.u.detail= key; } rg->currentDown= key; @@ -157,23 +190,42 @@ unsigned ndx; void ProcessKeyboardEvent(xEvent *xE,DeviceIntPtr keybd,int count) { -KeyClassPtr keyc = keybd->key; -XkbSrvInfoPtr xkbi; - xkbi= keyc->xkbInfo; + KeyClassPtr keyc = keybd->key; + XkbSrvInfoPtr xkbi = NULL; + ProcessInputProc backup_proc; + xkbDeviceInfoPtr xkb_priv = XKBDEVICEINFO(keybd); + int is_press = (xE->u.u.type == KeyPress || xE->u.u.type == DeviceKeyPress); + int is_release = (xE->u.u.type == KeyRelease || + xE->u.u.type == DeviceKeyRelease); + + if (keyc) + xkbi = keyc->xkbInfo; + + /* We're only interested in key events. */ + if (!is_press && !is_release) { + UNWRAP_PROCESS_INPUT_PROC(keybd, xkb_priv, backup_proc); + keybd->public.processInputProc(xE, keybd, count); + COND_WRAP_PROCESS_INPUT_PROC(keybd, xkb_priv, backup_proc, + xkbUnwrapProc); + return; + } -#ifdef DEBUG - if (xkbDebugFlags&0x8) { - int key= xE->u.u.detail; - ErrorF("PKE: Key %d %s\n",key,(xE->u.u.type==KeyPress?"down":"up")); + /* If AccessX filters are active, then pass it through to + * AccessXFilter{Press,Release}Event; else, punt to + * XkbProcessKeyboardEvent. + * + * If AXF[PK]E don't intercept anything (which they probably won't), + * they'll punt through XPKE anyway. */ + if ((xkbi->desc->ctrls->enabled_ctrls & XkbAllFilteredEventsMask)) { + if (is_press) + AccessXFilterPressEvent(xE, keybd, count); + else if (is_release) + AccessXFilterReleaseEvent(xE, keybd, count); } -#endif - if ((xkbi->desc->ctrls->enabled_ctrls&XkbAllFilteredEventsMask)==0) - XkbProcessKeyboardEvent(xE,keybd,count); - else if (xE->u.u.type==KeyPress) - AccessXFilterPressEvent(xE,keybd,count); - else if (xE->u.u.type==KeyRelease) - AccessXFilterReleaseEvent(xE,keybd,count); + else { + XkbProcessKeyboardEvent(xE, keybd, count); + } + return; } - diff --git a/nx-X11/programs/Xserver/xkb/xkbUtils.c b/nx-X11/programs/Xserver/xkb/xkbUtils.c index 941bb40388..2468d94db2 100644 --- a/nx-X11/programs/Xserver/xkb/xkbUtils.c +++ b/nx-X11/programs/Xserver/xkb/xkbUtils.c @@ -28,6 +28,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #endif +#include "os.h" #include #include #include @@ -42,20 +43,10 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "xkbgeom.h" #include "xkb.h" -#ifdef MODE_SWITCH -extern Bool noKME; /* defined in os/utils.c */ -#endif - int XkbDisableLockActions = 0; /***====================================================================***/ -#ifndef RETURN_SHOULD_REPEAT -#define RETURN_SHOULD_REPEAT 0 -#endif - -/***====================================================================***/ - DeviceIntPtr _XkbLookupAnyDevice(int id,int *why_rtrn) { @@ -85,6 +76,8 @@ _XkbLookupKeyboard(int id,int *why_rtrn) { DeviceIntPtr dev = NULL; + if (id == XkbDfltXIId) + id = XkbUseCoreKbd; if ((dev= _XkbLookupAnyDevice(id,why_rtrn))==NULL) return NULL; else if ((!dev->key)||(!dev->key->xkbInfo)) { @@ -115,6 +108,8 @@ _XkbLookupLedDevice(int id,int *why_rtrn) { DeviceIntPtr dev = NULL; + if (id == XkbDfltXIId) + id = XkbUseCorePtr; if ((dev= _XkbLookupAnyDevice(id,why_rtrn))==NULL) return NULL; else if ((!dev->kbdfeed)&&(!dev->leds)) { @@ -505,12 +500,6 @@ CARD8 keysPerMod[XkbNumModifiers]; } } } -#ifdef MODE_SWITCH - /* Fix up any of the KME stuff if we changed the core description. - */ - if (!noKME) - HandleKeyBinding(keyc, &keyc->curKeySyms); -#endif return; } @@ -619,7 +608,7 @@ int changed; return changed; } -void +static void XkbComputeCompatState(XkbSrvInfoPtr xkbi) { CARD16 grp_mask; @@ -904,3 +893,1169 @@ XkbConvertCase(register KeySym sym, KeySym *lower, KeySym *upper) break; } } + + +/** + * Copy an XKB map from src to dst, reallocating when necessary: if some + * map components are present in one, but not in the other, the destination + * components will be allocated or freed as necessary. + * + * Basic map consistency is assumed on both sides, so maps with random + * uninitialised data (e.g. names->radio_grous == NULL, names->num_rg == 19) + * _will_ cause failures. You've been warned. + * + * Returns TRUE on success, or FALSE on failure. If this function fails, + * dst may be in an inconsistent state: all its pointers are guaranteed + * to remain valid, but part of the map may be from src and part from dst. + * + * FIXME: This function wants to be broken up into multiple functions. + */ +Bool +XkbCopyKeymap(XkbDescPtr src, XkbDescPtr dst, Bool sendNotifies) +{ + int i = 0, j = 0, k = 0; + void *tmp = NULL; + XkbColorPtr scolor = NULL, dcolor = NULL; + XkbDoodadPtr sdoodad = NULL, ddoodad = NULL; + XkbKeyTypePtr stype = NULL, dtype = NULL; + XkbOutlinePtr soutline = NULL, doutline = NULL; + XkbPropertyPtr sprop = NULL, dprop = NULL; + XkbRowPtr srow = NULL, drow = NULL; + XkbSectionPtr ssection = NULL, dsection = NULL; + XkbShapePtr sshape = NULL, dshape = NULL; + DeviceIntPtr pDev = NULL, tmpDev = NULL; + xkbMapNotify mn; + xkbNewKeyboardNotify nkn; + + if (!src || !dst || src == dst) + return FALSE; + + /* client map */ + if (src->map) { + if (!dst->map) { + tmp = calloc(1, sizeof(XkbClientMapRec)); + if (!tmp) + return FALSE; + dst->map = tmp; + } + + if (src->map->syms) { + if (src->map->size_syms != dst->map->size_syms) { + if (dst->map->syms) + tmp = realloc(dst->map->syms, + src->map->size_syms * sizeof(KeySym)); + else + tmp = malloc(src->map->size_syms * sizeof(KeySym)); + if (!tmp) + return FALSE; + dst->map->syms = tmp; + + } + memcpy(dst->map->syms, src->map->syms, + src->map->size_syms * sizeof(KeySym)); + } + else { + if (dst->map->syms) { + free(dst->map->syms); + dst->map->syms = NULL; + } + } + dst->map->num_syms = src->map->num_syms; + dst->map->size_syms = src->map->size_syms; + + if (src->map->key_sym_map) { + if (src->max_key_code != dst->max_key_code) { + if (dst->map->key_sym_map) + tmp = realloc(dst->map->key_sym_map, + (src->max_key_code + 1) * + sizeof(XkbSymMapRec)); + else + tmp = malloc((src->max_key_code + 1) * + sizeof(XkbSymMapRec)); + if (!tmp) + return FALSE; + dst->map->key_sym_map = tmp; + } + memcpy(dst->map->key_sym_map, src->map->key_sym_map, + (src->max_key_code + 1) * sizeof(XkbSymMapRec)); + } + else { + if (dst->map->key_sym_map) { + free(dst->map->key_sym_map); + dst->map->key_sym_map = NULL; + } + } + + if (src->map->types && src->map->num_types) { + if (src->map->num_types > dst->map->size_types || + !dst->map->types || !dst->map->size_types) { + if (dst->map->types && dst->map->size_types) { + tmp = realloc(dst->map->types, + src->map->num_types * sizeof(XkbKeyTypeRec)); + if (!tmp) + return FALSE; + dst->map->types = tmp; + bzero(dst->map->types + dst->map->num_types, + (src->map->num_types - dst->map->num_types) * + sizeof(XkbKeyTypeRec)); + } + else { + tmp = calloc(src->map->num_types, sizeof(XkbKeyTypeRec)); + if (!tmp) + return FALSE; + dst->map->types = tmp; + } + } + else if (src->map->num_types < dst->map->num_types && + dst->map->types) { + for (i = src->map->num_types, dtype = (dst->map->types + i); + i < dst->map->num_types; i++, dtype++) { + if (dtype->level_names) + free(dtype->level_names); + dtype->level_names = NULL; + dtype->num_levels = 0; + if (dtype->map_count) { + if (dtype->map) + free(dtype->map); + if (dtype->preserve) + free(dtype->preserve); + } + } + } + + stype = src->map->types; + dtype = dst->map->types; + for (i = 0; i < src->map->num_types; i++, dtype++, stype++) { + if (stype->num_levels && stype->level_names) { + if (stype->num_levels != dtype->num_levels && + dtype->num_levels && dtype->level_names && + i < dst->map->num_types) { + tmp = realloc(dtype->level_names, + stype->num_levels * sizeof(Atom)); + if (!tmp) + continue; + dtype->level_names = tmp; + } + else if (!dtype->num_levels || !dtype->level_names || + i >= dst->map->num_types) { + tmp = malloc(stype->num_levels * sizeof(Atom)); + if (!tmp) + continue; + dtype->level_names = tmp; + } + dtype->num_levels = stype->num_levels; + memcpy(dtype->level_names, stype->level_names, + stype->num_levels * sizeof(Atom)); + } + else { + if (dtype->num_levels && dtype->level_names && + i < dst->map->num_types) + free(dtype->level_names); + dtype->num_levels = 0; + dtype->level_names = NULL; + } + + dtype->name = stype->name; + memcpy(&dtype->mods, &stype->mods, sizeof(XkbModsRec)); + + if (stype->map_count) { + if (stype->map) { + if (stype->map_count != dtype->map_count && + dtype->map_count && dtype->map && + i < dst->map->num_types) { + tmp = realloc(dtype->map, + stype->map_count * + sizeof(XkbKTMapEntryRec)); + if (!tmp) + return FALSE; + dtype->map = tmp; + } + else if (!dtype->map_count || !dtype->map || + i >= dst->map->num_types) { + tmp = malloc(stype->map_count * + sizeof(XkbKTMapEntryRec)); + if (!tmp) + return FALSE; + dtype->map = tmp; + } + + memcpy(dtype->map, stype->map, + stype->map_count * sizeof(XkbKTMapEntryRec)); + } + else { + if (dtype->map && i < dst->map->num_types) + free(dtype->map); + dtype->map = NULL; + } + + if (stype->preserve) { + if (stype->map_count != dtype->map_count && + dtype->map_count && dtype->preserve && + i < dst->map->num_types) { + tmp = realloc(dtype->preserve, + stype->map_count * + sizeof(XkbModsRec)); + if (!tmp) + return FALSE; + dtype->preserve = tmp; + } + else if (!dtype->preserve || !dtype->map_count || + i >= dst->map->num_types) { + tmp = malloc(stype->map_count * + sizeof(XkbModsRec)); + if (!tmp) + return FALSE; + dtype->preserve = tmp; + } + + memcpy(dtype->preserve, stype->preserve, + stype->map_count * sizeof(XkbModsRec)); + } + else { + if (dtype->preserve && i < dst->map->num_types) + free(dtype->preserve); + dtype->preserve = NULL; + } + + dtype->map_count = stype->map_count; + } + else { + if (dtype->map_count && i < dst->map->num_types) { + if (dtype->map) + free(dtype->map); + if (dtype->preserve) + free(dtype->preserve); + } + dtype->map_count = 0; + dtype->map = NULL; + dtype->preserve = NULL; + } + } + + dst->map->size_types = src->map->num_types; + dst->map->num_types = src->map->num_types; + } + else { + if (dst->map->types) { + for (i = 0, dtype = dst->map->types; i < dst->map->num_types; + i++, dtype++) { + if (dtype->level_names) + free(dtype->level_names); + if (dtype->map && dtype->map_count) + free(dtype->map); + if (dtype->preserve && dtype->map_count) + free(dtype->preserve); + } + free(dst->map->types); + dst->map->types = NULL; + } + dst->map->num_types = 0; + dst->map->size_types = 0; + } + + if (src->map->modmap) { + if (src->max_key_code != dst->max_key_code) { + if (dst->map->modmap) + tmp = realloc(dst->map->modmap, src->max_key_code + 1); + else + tmp = malloc(src->max_key_code + 1); + if (!tmp) + return FALSE; + dst->map->modmap = tmp; + } + memcpy(dst->map->modmap, src->map->modmap, src->max_key_code + 1); + } + else { + if (dst->map->modmap) { + free(dst->map->modmap); + dst->map->modmap = NULL; + } + } + } + else { + if (dst->map) + XkbFreeClientMap(dst, XkbAllClientInfoMask, True); + } + + /* server map */ + if (src->server) { + if (!dst->server) { + tmp = calloc(1, sizeof(XkbServerMapRec)); + if (!tmp) + return FALSE; + dst->server = tmp; + } + + if (src->server->explicit) { + if (src->max_key_code != dst->max_key_code) { + if (dst->server->explicit) + tmp = realloc(dst->server->explicit, src->max_key_code + 1); + else + tmp = malloc(src->max_key_code + 1); + if (!tmp) + return FALSE; + dst->server->explicit = tmp; + } + memcpy(dst->server->explicit, src->server->explicit, + src->max_key_code + 1); + } + else { + if (dst->server->explicit) { + free(dst->server->explicit); + dst->server->explicit = NULL; + } + } + + if (src->server->acts) { + if (src->server->size_acts != dst->server->size_acts) { + if (dst->server->acts) + tmp = realloc(dst->server->acts, + src->server->size_acts * sizeof(XkbAction)); + else + tmp = malloc(src->server->size_acts * sizeof(XkbAction)); + if (!tmp) + return FALSE; + dst->server->acts = tmp; + } + memcpy(dst->server->acts, src->server->acts, + src->server->size_acts * sizeof(XkbAction)); + } + else { + if (dst->server->acts) { + free(dst->server->acts); + dst->server->acts = NULL; + } + } + dst->server->size_acts = src->server->size_acts; + dst->server->num_acts = src->server->num_acts; + + if (src->server->key_acts) { + if (src->max_key_code != dst->max_key_code) { + if (dst->server->key_acts) + tmp = realloc(dst->server->key_acts, + (src->max_key_code + 1) * + sizeof(unsigned short)); + else + tmp = malloc((src->max_key_code + 1) * + sizeof(unsigned short)); + if (!tmp) + return FALSE; + dst->server->key_acts = tmp; + } + memcpy(dst->server->key_acts, src->server->key_acts, + (src->max_key_code + 1) * sizeof(unsigned short)); + } + else { + if (dst->server->key_acts) { + free(dst->server->key_acts); + dst->server->key_acts = NULL; + } + } + + if (src->server->behaviors) { + if (src->max_key_code != dst->max_key_code) { + if (dst->server->behaviors) + tmp = realloc(dst->server->behaviors, + (src->max_key_code + 1) * + sizeof(XkbBehavior)); + else + tmp = malloc((src->max_key_code + 1) * + sizeof(XkbBehavior)); + if (!tmp) + return FALSE; + dst->server->behaviors = tmp; + } + memcpy(dst->server->behaviors, src->server->behaviors, + (src->max_key_code + 1) * sizeof(XkbBehavior)); + } + else { + if (dst->server->behaviors) { + free(dst->server->behaviors); + dst->server->behaviors = NULL; + } + } + + memcpy(dst->server->vmods, src->server->vmods, XkbNumVirtualMods); + + if (src->server->vmodmap) { + if (src->max_key_code != dst->max_key_code) { + if (dst->server->vmodmap) + tmp = realloc(dst->server->vmodmap, + (src->max_key_code + 1) * + sizeof(unsigned short)); + else + tmp = malloc((src->max_key_code + 1) * + sizeof(unsigned short)); + if (!tmp) + return FALSE; + dst->server->vmodmap = tmp; + } + memcpy(dst->server->vmodmap, src->server->vmodmap, + (src->max_key_code + 1) * sizeof(unsigned short)); + } + else { + if (dst->server->vmodmap) { + free(dst->server->vmodmap); + dst->server->vmodmap = NULL; + } + } + } + else { + if (dst->server) + XkbFreeServerMap(dst, XkbAllServerInfoMask, True); + } + + /* indicators */ + if (src->indicators) { + if (!dst->indicators) { + dst->indicators = malloc(sizeof(XkbIndicatorRec)); + if (!dst->indicators) + return FALSE; + } + memcpy(dst->indicators, src->indicators, sizeof(XkbIndicatorRec)); + } + else { + if (dst->indicators) { + free(dst->indicators); + dst->indicators = NULL; + } + } + + /* controls */ + if (src->ctrls) { + if (!dst->ctrls) { + dst->ctrls = malloc(sizeof(XkbControlsRec)); + if (!dst->ctrls) + return FALSE; + } + memcpy(dst->ctrls, src->ctrls, sizeof(XkbControlsRec)); + } + else { + if (dst->ctrls) { + free(dst->ctrls); + dst->ctrls = NULL; + } + } + + /* names */ + if (src->names) { + if (!dst->names) { + dst->names = calloc(1, sizeof(XkbNamesRec)); + if (!dst->names) + return FALSE; + } + + if (src->names->keys) { + if (src->max_key_code != dst->max_key_code) { + if (dst->names->keys) + tmp = realloc(dst->names->keys, (src->max_key_code + 1) * + sizeof(XkbKeyNameRec)); + else + tmp = malloc((src->max_key_code + 1) * + sizeof(XkbKeyNameRec)); + if (!tmp) + return FALSE; + dst->names->keys = tmp; + } + memcpy(dst->names->keys, src->names->keys, + (src->max_key_code + 1) * sizeof(XkbKeyNameRec)); + } + else { + if (dst->names->keys) { + free(dst->names->keys); + dst->names->keys = NULL; + } + } + + if (src->names->num_key_aliases) { + if (src->names->num_key_aliases != dst->names->num_key_aliases) { + if (dst->names->key_aliases) + tmp = realloc(dst->names->key_aliases, + src->names->num_key_aliases * + sizeof(XkbKeyAliasRec)); + else + tmp = malloc(src->names->num_key_aliases * + sizeof(XkbKeyAliasRec)); + if (!tmp) + return FALSE; + dst->names->key_aliases = tmp; + } + memcpy(dst->names->key_aliases, src->names->key_aliases, + src->names->num_key_aliases * sizeof(XkbKeyAliasRec)); + } + else { + if (dst->names->key_aliases) { + free(dst->names->key_aliases); + dst->names->key_aliases = NULL; + } + } + dst->names->num_key_aliases = src->names->num_key_aliases; + + if (src->names->num_rg) { + if (src->names->num_rg != dst->names->num_rg) { + if (dst->names->radio_groups) + tmp = realloc(dst->names->radio_groups, + src->names->num_rg * sizeof(Atom)); + else + tmp = malloc(src->names->num_rg * sizeof(Atom)); + if (!tmp) + return FALSE; + dst->names->radio_groups = tmp; + } + memcpy(dst->names->radio_groups, src->names->radio_groups, + src->names->num_rg * sizeof(Atom)); + } + else { + if (dst->names->radio_groups) + free(dst->names->radio_groups); + } + dst->names->num_rg = src->names->num_rg; + + dst->names->keycodes = src->names->keycodes; + dst->names->geometry = src->names->geometry; + dst->names->symbols = src->names->symbols; + dst->names->types = src->names->types; + dst->names->compat = src->names->compat; + dst->names->phys_symbols = src->names->phys_symbols; + + memcpy(dst->names->vmods, src->names->vmods, + XkbNumVirtualMods * sizeof(Atom)); + memcpy(dst->names->indicators, src->names->indicators, + XkbNumIndicators * sizeof(Atom)); + memcpy(dst->names->groups, src->names->groups, + XkbNumKbdGroups * sizeof(Atom)); + } + else { + if (dst->names) + XkbFreeNames(dst, XkbAllNamesMask, True); + } + + /* compat */ + if (src->compat) { + if (!dst->compat) { + dst->compat = calloc(1, sizeof(XkbCompatMapRec)); + if (!dst->compat) + return FALSE; + } + + if (src->compat->sym_interpret && src->compat->num_si) { + if (src->compat->num_si != dst->compat->size_si) { + if (dst->compat->sym_interpret) + tmp = realloc(dst->compat->sym_interpret, + src->compat->num_si * + sizeof(XkbSymInterpretRec)); + else + tmp = malloc(src->compat->num_si * + sizeof(XkbSymInterpretRec)); + if (!tmp) + return FALSE; + dst->compat->sym_interpret = tmp; + } + memcpy(dst->compat->sym_interpret, src->compat->sym_interpret, + src->compat->num_si * sizeof(XkbSymInterpretRec)); + + dst->compat->num_si = src->compat->num_si; + dst->compat->size_si = src->compat->num_si; + } + else { + if (dst->compat->sym_interpret && dst->compat->size_si) + free(dst->compat->sym_interpret); + + dst->compat->sym_interpret = NULL; + dst->compat->num_si = 0; + dst->compat->size_si = 0; + } + + memcpy(dst->compat->groups, src->compat->groups, + XkbNumKbdGroups * sizeof(XkbModsRec)); + } + else { + if (dst->compat) + XkbFreeCompatMap(dst, XkbAllCompatMask, True); + } + + /* geometry */ + if (src->geom) { + if (!dst->geom) { + dst->geom = calloc(sizeof(XkbGeometryRec), 1); + if (!dst->geom) + return FALSE; + } + + /* properties */ + if (src->geom->num_properties) { + if (src->geom->num_properties != dst->geom->sz_properties) { + if (src->geom->num_properties < dst->geom->sz_properties) { + for (i = src->geom->num_properties, + dprop = dst->geom->properties + + src->geom->num_properties; + i < dst->geom->num_properties; + i++, dprop++) { + free(dprop->name); + free(dprop->value); + } + } + + if (dst->geom->sz_properties) + tmp = realloc(dst->geom->properties, + src->geom->num_properties * + sizeof(XkbPropertyRec)); + else + tmp = malloc(src->geom->num_properties * + sizeof(XkbPropertyRec)); + if (!tmp) + return FALSE; + dst->geom->properties = tmp; + } + + dst->geom->sz_properties = src->geom->num_properties; + + if (dst->geom->sz_properties > dst->geom->num_properties) { + bzero(dst->geom->properties + dst->geom->num_properties, + (dst->geom->sz_properties - dst->geom->num_properties) * + sizeof(XkbPropertyRec)); + } + + for (i = 0, + sprop = src->geom->properties, + dprop = dst->geom->properties; + i < src->geom->num_properties; + i++, sprop++, dprop++) { + if (i < dst->geom->num_properties) { + if (strlen(sprop->name) != strlen(dprop->name)) { + tmp = realloc(dprop->name, strlen(sprop->name) + 1); + if (!tmp) + return FALSE; + dprop->name = tmp; + } + if (strlen(sprop->value) != strlen(dprop->value)) { + tmp = realloc(dprop->value, strlen(sprop->value) + 1); + if (!tmp) + return FALSE; + dprop->value = tmp; + } + strcpy(dprop->name, sprop->name); + strcpy(dprop->value, sprop->value); + } + else { + dprop->name = xstrdup(sprop->name); + dprop->value = xstrdup(sprop->value); + } + } + + dst->geom->num_properties = dst->geom->sz_properties; + } + else { + if (dst->geom->sz_properties) { + for (i = 0, dprop = dst->geom->properties; + i < dst->geom->num_properties; + i++, dprop++) { + free(dprop->name); + free(dprop->value); + } + free(dst->geom->properties); + dst->geom->properties = NULL; + } + + dst->geom->num_properties = 0; + dst->geom->sz_properties = 0; + } + + /* colors */ + if (src->geom->num_colors) { + if (src->geom->num_colors != dst->geom->sz_colors) { + if (src->geom->num_colors < dst->geom->sz_colors) { + for (i = src->geom->num_colors, + dcolor = dst->geom->colors + + src->geom->num_colors; + i < dst->geom->num_colors; + i++, dcolor++) { + free(dcolor->spec); + } + } + + if (dst->geom->sz_colors) + tmp = realloc(dst->geom->colors, + src->geom->num_colors * + sizeof(XkbColorRec)); + else + tmp = malloc(src->geom->num_colors * + sizeof(XkbColorRec)); + if (!tmp) + return FALSE; + dst->geom->colors = tmp; + } + + dst->geom->sz_colors = src->geom->num_colors; + + if (dst->geom->sz_colors > dst->geom->num_colors) { + bzero(dst->geom->colors + dst->geom->num_colors, + (dst->geom->sz_colors - dst->geom->num_colors) * + sizeof(XkbColorRec)); + } + + for (i = 0, + scolor = src->geom->colors, + dcolor = dst->geom->colors; + i < src->geom->num_colors; + i++, scolor++, dcolor++) { + if (i < dst->geom->num_colors) { + if (strlen(scolor->spec) != strlen(dcolor->spec)) { + tmp = realloc(dcolor->spec, strlen(scolor->spec) + 1); + if (!tmp) + return FALSE; + dcolor->spec = tmp; + } + strcpy(dcolor->spec, scolor->spec); + } + else { + dcolor->spec = xstrdup(scolor->spec); + } + } + + dst->geom->num_colors = dst->geom->sz_colors; + } + else { + if (dst->geom->sz_colors) { + for (i = 0, dcolor = dst->geom->colors; + i < dst->geom->num_colors; + i++, dcolor++) { + free(dcolor->spec); + } + free(dst->geom->colors); + dst->geom->colors = NULL; + } + + dst->geom->num_colors = 0; + dst->geom->sz_colors = 0; + } + + /* shapes */ + /* shapes break down into outlines, which break down into points. */ + if (dst->geom->num_shapes) { + for (i = 0, dshape = dst->geom->shapes; + i < dst->geom->num_shapes; + i++, dshape++) { + for (j = 0, doutline = dshape->outlines; + j < dshape->num_outlines; + j++, doutline++) { + if (doutline->sz_points) + free(doutline->points); + } + + if (dshape->sz_outlines) { + free(dshape->outlines); + dshape->outlines = NULL; + } + + dshape->num_outlines = 0; + dshape->sz_outlines = 0; + } + } + + if (src->geom->num_shapes) { + tmp = calloc(src->geom->num_shapes, sizeof(XkbShapeRec)); + if (!tmp) + return FALSE; + dst->geom->shapes = tmp; + + for (i = 0, sshape = src->geom->shapes, dshape = dst->geom->shapes; + i < src->geom->num_shapes; + i++, sshape++, dshape++) { + if (sshape->num_outlines) { + tmp = calloc(sshape->num_outlines, sizeof(XkbOutlineRec)); + if (!tmp) + return FALSE; + dshape->outlines = tmp; + + for (j = 0, + soutline = sshape->outlines, + doutline = dshape->outlines; + j < sshape->num_outlines; + j++, soutline++, doutline++) { + if (soutline->num_points) { + tmp = malloc(soutline->num_points * + sizeof(XkbPointRec)); + if (!tmp) + return FALSE; + doutline->points = tmp; + + memcpy(doutline->points, soutline->points, + soutline->num_points * sizeof(XkbPointRec)); + } + + doutline->num_points = soutline->num_points; + doutline->sz_points = soutline->sz_points; + } + } + + dshape->num_outlines = sshape->num_outlines; + dshape->sz_outlines = sshape->num_outlines; + } + + dst->geom->num_shapes = src->geom->num_shapes; + dst->geom->sz_shapes = src->geom->num_shapes; + } + else { + if (dst->geom->sz_shapes) { + free(dst->geom->shapes); + } + dst->geom->shapes = NULL; + dst->geom->num_shapes = 0; + dst->geom->sz_shapes = 0; + } + + /* sections */ + /* sections break down into doodads, and also into rows, which break + * down into keys. */ + if (dst->geom->num_sections) { + for (i = 0, dsection = dst->geom->sections; + i < dst->geom->num_sections; + i++, dsection++) { + for (j = 0, drow = dsection->rows; + j < dsection->num_rows; + j++, drow++) { + if (drow->num_keys) + free(drow->keys); + } + + if (dsection->num_rows) + free(dsection->rows); + + /* cut and waste from geom/doodad below. */ + for (j = 0, ddoodad = dsection->doodads; + j < dsection->num_doodads; + j++, ddoodad++) { + if (ddoodad->any.type == XkbTextDoodad) { + if (ddoodad->text.text) { + free(ddoodad->text.text); + ddoodad->text.text = NULL; + } + if (ddoodad->text.font) { + free(ddoodad->text.font); + ddoodad->text.font = NULL; + } + } + else if (ddoodad->any.type == XkbLogoDoodad) { + if (ddoodad->logo.logo_name) { + free(ddoodad->logo.logo_name); + ddoodad->logo.logo_name = NULL; + } + } + } + + if (dsection->num_doodads) + free(dsection->doodads); + } + + dst->geom->num_sections = 0; + dst->geom->sections = NULL; + } + + if (src->geom->num_sections) { + if (dst->geom->sz_sections) + tmp = realloc(dst->geom->sections, + src->geom->num_sections * + sizeof(XkbSectionRec)); + else + tmp = malloc(src->geom->num_sections * sizeof(XkbSectionRec)); + if (!tmp) + return FALSE; + memset(tmp, 0, src->geom->num_sections * sizeof(XkbSectionRec)); + dst->geom->sections = tmp; + dst->geom->num_sections = src->geom->num_sections; + + for (i = 0, + ssection = src->geom->sections, + dsection = dst->geom->sections; + i < src->geom->num_sections; + i++, ssection++, dsection++) { + if (ssection->num_rows) { + tmp = calloc(ssection->num_rows, sizeof(XkbRowRec)); + if (!tmp) + return FALSE; + dsection->rows = tmp; + } + for (j = 0, srow = ssection->rows, drow = dsection->rows; + j < ssection->num_rows; + j++, srow++, drow++) { + if (srow->num_keys) { + tmp = malloc(srow->num_keys * sizeof(XkbKeyRec)); + if (!tmp) + return FALSE; + drow->keys = tmp; + memcpy(drow->keys, srow->keys, + srow->num_keys * sizeof(XkbKeyRec)); + } + drow->num_keys = srow->num_keys; + drow->sz_keys = srow->num_keys; + } + + if (ssection->num_doodads) { + tmp = calloc(ssection->num_doodads, sizeof(XkbDoodadRec)); + if (!tmp) + return FALSE; + dsection->doodads = tmp; + } + else { + dsection->doodads = NULL; + } + + for (k = 0, + sdoodad = ssection->doodads, + ddoodad = dsection->doodads; + k < ssection->num_doodads; + k++, sdoodad++, ddoodad++) { + if (sdoodad->any.type == XkbTextDoodad) { + if (sdoodad->text.text) + ddoodad->text.text = + xstrdup(sdoodad->text.text); + if (sdoodad->text.font) + ddoodad->text.font = + xstrdup(sdoodad->text.font); + } + else if (sdoodad->any.type == XkbLogoDoodad) { + if (sdoodad->logo.logo_name) + ddoodad->logo.logo_name = + xstrdup(sdoodad->logo.logo_name); + } + ddoodad->any.type = sdoodad->any.type; + } + dsection->num_doodads = ssection->num_doodads; + dsection->sz_doodads = ssection->num_doodads; + } + } + else { + if (dst->geom->sz_sections) { + free(dst->geom->sections); + } + + dst->geom->sections = NULL; + dst->geom->num_sections = 0; + dst->geom->sz_sections = 0; + } + + /* doodads */ + if (dst->geom->num_doodads) { + for (i = src->geom->num_doodads, + ddoodad = dst->geom->doodads + + src->geom->num_doodads; + i < dst->geom->num_doodads; + i++, ddoodad++) { + if (ddoodad->any.type == XkbTextDoodad) { + if (ddoodad->text.text) { + free(ddoodad->text.text); + ddoodad->text.text = NULL; + } + if (ddoodad->text.font) { + free(ddoodad->text.font); + ddoodad->text.font = NULL; + } + } + else if (ddoodad->any.type == XkbLogoDoodad) { + if (ddoodad->logo.logo_name) { + free(ddoodad->logo.logo_name); + ddoodad->logo.logo_name = NULL; + } + } + } + dst->geom->num_doodads = 0; + dst->geom->doodads = NULL; + } + + if (src->geom->num_doodads) { + if (dst->geom->sz_doodads) + tmp = realloc(dst->geom->doodads, + src->geom->num_doodads * + sizeof(XkbDoodadRec)); + else + tmp = malloc(src->geom->num_doodads * + sizeof(XkbDoodadRec)); + if (!tmp) + return FALSE; + memset(tmp, 0, src->geom->num_doodads * sizeof(XkbDoodadRec)); + dst->geom->doodads = tmp; + + dst->geom->sz_doodads = src->geom->num_doodads; + + for (i = 0, + sdoodad = src->geom->doodads, + ddoodad = dst->geom->doodads; + i < src->geom->num_doodads; + i++, sdoodad++, ddoodad++) { + ddoodad->any.type = sdoodad->any.type; + if (sdoodad->any.type == XkbTextDoodad) { + if (sdoodad->text.text) + ddoodad->text.text = xstrdup(sdoodad->text.text); + if (sdoodad->text.font) + ddoodad->text.font = xstrdup(sdoodad->text.font); + } + else if (sdoodad->any.type == XkbLogoDoodad) { + if (sdoodad->logo.logo_name) + ddoodad->logo.logo_name = + xstrdup(sdoodad->logo.logo_name); + } + } + + dst->geom->num_doodads = dst->geom->sz_doodads; + } + else { + if (dst->geom->sz_doodads) { + free(dst->geom->doodads); + } + + dst->geom->doodads = NULL; + dst->geom->num_doodads = 0; + dst->geom->sz_doodads = 0; + } + + /* key aliases */ + if (src->geom->num_key_aliases) { + if (src->geom->num_key_aliases != dst->geom->sz_key_aliases) { + if (dst->geom->sz_key_aliases) + tmp = realloc(dst->geom->key_aliases, + src->geom->num_key_aliases * + 2 * XkbKeyNameLength); + else + tmp = malloc(src->geom->num_key_aliases * + 2 * XkbKeyNameLength); + if (!tmp) + return FALSE; + dst->geom->key_aliases = tmp; + + dst->geom->sz_key_aliases = src->geom->num_key_aliases; + } + + memcpy(dst->geom->key_aliases, src->geom->key_aliases, + src->geom->num_key_aliases * 2 * XkbKeyNameLength); + + dst->geom->num_key_aliases = dst->geom->sz_key_aliases; + } + else { + if (dst->geom->key_aliases) { + free(dst->geom->key_aliases); + } + dst->geom->key_aliases = NULL; + dst->geom->num_key_aliases = 0; + dst->geom->sz_key_aliases = 0; + } + + /* font */ + if (src->geom->label_font) { + if (!dst->geom->label_font) { + tmp = malloc(strlen(src->geom->label_font)); + if (!tmp) + return FALSE; + dst->geom->label_font = tmp; + } + else if (strlen(src->geom->label_font) != + strlen(dst->geom->label_font)) { + tmp = realloc(dst->geom->label_font, + strlen(src->geom->label_font)); + if (!tmp) + return FALSE; + dst->geom->label_font = tmp; + } + + strcpy(dst->geom->label_font, src->geom->label_font); + i = XkbGeomColorIndex(src->geom, src->geom->label_color); + dst->geom->label_color = &(src->geom->colors[i]); + i = XkbGeomColorIndex(src->geom, src->geom->base_color); + dst->geom->base_color = &(src->geom->colors[i]); + } + else { + if (dst->geom->label_font) { + free(dst->geom->label_font); + } + dst->geom->label_font = NULL; + dst->geom->label_color = NULL; + dst->geom->base_color = NULL; + } + + dst->geom->name = src->geom->name; + dst->geom->width_mm = src->geom->width_mm; + dst->geom->height_mm = src->geom->height_mm; + } + else + { + if (dst->geom) { + /* I LOVE THE DIFFERENT CALL SIGNATURE. REALLY, I DO. */ + XkbFreeGeometry(dst->geom, XkbGeomAllMask, True); + dst->geom = NULL; + } + } + + if (inputInfo.keyboard->key->xkbInfo && + inputInfo.keyboard->key->xkbInfo->desc == dst) { + pDev = inputInfo.keyboard; + } + else { + for (tmpDev = inputInfo.devices; tmpDev && !pDev; + tmpDev = tmpDev->next) { + if (tmpDev->key && tmpDev->key->xkbInfo && + tmpDev->key->xkbInfo->desc == dst) { + pDev = tmpDev; + break; + } + } + for (tmpDev = inputInfo.off_devices; tmpDev && !pDev; + tmpDev = tmpDev->next) { + if (tmpDev->key && tmpDev->key->xkbInfo && + tmpDev->key->xkbInfo->desc == dst) { + pDev = tmpDev; + break; + } + } + } + + if (sendNotifies) { + if (!pDev) { + ErrorF("XkbCopyKeymap: asked for notifies, but can't find device!\n"); + } + else { + /* send NewKeyboardNotify if the keycode range changed, else + * just MapNotify. we also need to send NKN if the geometry + * changed (obviously ...). */ + if ((src->min_key_code != dst->min_key_code || + src->max_key_code != dst->max_key_code) && sendNotifies) { + nkn.oldMinKeyCode = dst->min_key_code; + nkn.oldMaxKeyCode = dst->max_key_code; + nkn.deviceID = nkn.oldDeviceID = pDev->id; + nkn.minKeyCode = src->min_key_code; + nkn.maxKeyCode = src->max_key_code; + nkn.requestMajor = XkbReqCode; + nkn.requestMinor = X_kbSetMap; /* XXX bare-faced lie */ + nkn.changed = XkbAllNewKeyboardEventsMask; + XkbSendNewKeyboardNotify(pDev, &nkn); + } + else if (sendNotifies) { + mn.deviceID = pDev->id; + mn.minKeyCode = src->min_key_code; + mn.maxKeyCode = src->max_key_code; + mn.firstType = 0; + mn.nTypes = src->map->num_types; + mn.firstKeySym = src->min_key_code; + mn.nKeySyms = XkbNumKeys(src); + mn.firstKeyAct = src->min_key_code; + mn.nKeyActs = XkbNumKeys(src); + /* Cargo-culted from ProcXkbGetMap. */ + mn.firstKeyBehavior = src->min_key_code; + mn.nKeyBehaviors = XkbNumKeys(src); + mn.firstKeyExplicit = src->min_key_code; + mn.nKeyExplicit = XkbNumKeys(src); + mn.firstModMapKey = src->min_key_code; + mn.nModMapKeys = XkbNumKeys(src); + mn.firstVModMapKey = src->min_key_code; + mn.nVModMapKeys = XkbNumKeys(src); + mn.virtualMods = ~0; /* ??? */ + mn.changed = XkbAllMapComponentsMask; + XkbSendMapNotify(pDev, &mn); + } + } + } + + dst->min_key_code = src->min_key_code; + dst->max_key_code = src->max_key_code; + + return TRUE; +} diff --git a/nx-X11/programs/Xserver/xkb/xkbfmisc.c b/nx-X11/programs/Xserver/xkb/xkbfmisc.c index 823bb74790..2dea4510c8 100644 --- a/nx-X11/programs/Xserver/xkb/xkbfmisc.c +++ b/nx-X11/programs/Xserver/xkb/xkbfmisc.c @@ -131,76 +131,6 @@ unsigned set,rtrn; /***===================================================================***/ -Bool -XkbLookupGroupAndLevel( XkbDescPtr xkb, - int key, - int * mods_inout, - int * grp_inout, - int * lvl_rtrn) -{ -int nG,eG; - - if ((!xkb)||(!XkbKeycodeInRange(xkb,key))||(!grp_inout)) - return False; - - nG= XkbKeyNumGroups(xkb,key); - eG= *grp_inout; - - if ( nG==0 ) { - *grp_inout= 0; - if (lvl_rtrn!=NULL) - *lvl_rtrn= 0; - return False; - } - else if ( nG==1 ) { - eG= 0; - } - else if ( eG>=nG ) { - unsigned gI= XkbKeyGroupInfo(xkb,key); - switch (XkbOutOfRangeGroupAction(gI)) { - default: - eG %= nG; - break; - case XkbClampIntoRange: - eG = nG-1; - break; - case XkbRedirectIntoRange: - eG = XkbOutOfRangeGroupNumber(gI); - if (eG>=nG) - eG= 0; - break; - } - } - *grp_inout= eG; - if (mods_inout!=NULL) { - XkbKeyTypePtr type; - int preserve; - - type = XkbKeyKeyType(xkb,key,eG); - if (lvl_rtrn!=NULL) - *lvl_rtrn= 0; - preserve= 0; - if (type->map) { /* find the shift level */ - register int i; - register XkbKTMapEntryPtr entry; - for (i=0,entry=type->map;imap_count;i++,entry++) { - if ((entry->active)&& - (((*mods_inout)&type->mods.mask)==entry->mods.mask)){ - if (lvl_rtrn!=NULL) - *lvl_rtrn= entry->level; - if (type->preserve) - preserve= type->preserve[i].mask; - break; - } - } - } - (*mods_inout)&= ~(type->mods.mask&(~preserve)); - } - return True; -} - -/***===================================================================***/ - static Bool XkbWriteSectionFromName(FILE *file,char *sectionName,char *name) { @@ -415,15 +345,6 @@ XkbFileInfo finfo; /***====================================================================***/ -/*ARGSUSED*/ -Status -XkbMergeFile(XkbDescPtr xkb,XkbFileInfo finfo) -{ - return BadImplementation; -} - -/***====================================================================***/ - int XkbFindKeycodeByName(XkbDescPtr xkb,char *name,Bool use_aliases) { @@ -483,34 +404,6 @@ unsigned rtrn; return rtrn; } -unsigned -XkbConvertXkbComponents(Bool toXkm,unsigned orig) -{ -unsigned rtrn; - - rtrn= 0; - if (toXkm) { - if (orig&XkbClientMapMask) rtrn|= XkmTypesMask|XkmSymbolsMask; - if (orig&XkbServerMapMask) rtrn|= XkmTypesMask|XkmSymbolsMask; - if (orig&XkbCompatMapMask) rtrn|= XkmCompatMapMask; - if (orig&XkbIndicatorMapMask) rtrn|= XkmIndicatorsMask; - if (orig&XkbNamesMask) rtrn|= XkmKeyNamesMask; - if (orig&XkbGeometryMask) rtrn|= XkmGeometryMask; - } - else { - if (orig!=0) rtrn|= XkbNamesMask; - if (orig&XkmTypesMask) rtrn|= XkbClientMapMask; - if (orig&XkmCompatMapMask) - rtrn|= XkbCompatMapMask|XkbIndicatorMapMask; - if (orig&XkmSymbolsMask) rtrn|=XkbClientMapMask|XkbServerMapMask; - if (orig&XkmIndicatorsMask) rtrn|= XkbIndicatorMapMask; - if (orig&XkmKeyNamesMask) - rtrn|= XkbNamesMask|XkbIndicatorMapMask; - if (orig&XkmGeometryMask) rtrn|= XkbGeometryMask; - } - return rtrn; -} - Bool XkbDetermineFileType(XkbFileInfoPtr finfo,int format,int *opts_missing) { diff --git a/nx-X11/programs/Xserver/xkb/xkbout.c b/nx-X11/programs/Xserver/xkb/xkbout.c index ae821c9095..8efd4f6837 100644 --- a/nx-X11/programs/Xserver/xkb/xkbout.c +++ b/nx-X11/programs/Xserver/xkb/xkbout.c @@ -921,127 +921,3 @@ XkbGeometryPtr geom; fprintf(file,"};\n\n"); return True; } - -/*ARGSUSED*/ -Bool -XkbWriteXKBSemantics( FILE * file, - XkbFileInfo * result, - Bool topLevel, - Bool showImplicit, - XkbFileAddOnFunc addOn, - void * priv) -{ -Bool ok; - - fprintf(file,"xkb_semantics {\n"); - ok= XkbWriteXKBKeyTypes(file,result,False,False,addOn,priv); - ok= ok&&XkbWriteXKBCompatMap(file,result,False,False,addOn,priv); - fprintf(file,"};\n"); - return ok; -} - -/*ARGSUSED*/ -Bool -XkbWriteXKBLayout( FILE * file, - XkbFileInfo * result, - Bool topLevel, - Bool showImplicit, - XkbFileAddOnFunc addOn, - void * priv) -{ -Bool ok; -XkbDescPtr xkb; - - xkb= result->xkb; - fprintf(file,"xkb_layout {\n"); - ok= XkbWriteXKBKeycodes(file,result,False,showImplicit,addOn,priv); - ok= ok&&XkbWriteXKBKeyTypes(file,result,False,showImplicit,addOn,priv); - ok= ok&&XkbWriteXKBSymbols(file,result,False,showImplicit,addOn,priv); - if (xkb->geom) - ok= ok&&XkbWriteXKBGeometry(file,result,False,showImplicit,addOn,priv); - fprintf(file,"};\n"); - return ok; -} - -/*ARGSUSED*/ -Bool -XkbWriteXKBKeymap( FILE * file, - XkbFileInfo * result, - Bool topLevel, - Bool showImplicit, - XkbFileAddOnFunc addOn, - void * priv) -{ -Bool ok; -XkbDescPtr xkb; - - xkb= result->xkb; - fprintf(file,"xkb_keymap {\n"); - ok= XkbWriteXKBKeycodes(file,result,False,showImplicit,addOn,priv); - ok= ok&&XkbWriteXKBKeyTypes(file,result,False,showImplicit,addOn,priv); - ok= ok&&XkbWriteXKBCompatMap(file,result,False,showImplicit,addOn,priv); - ok= ok&&XkbWriteXKBSymbols(file,result,False,showImplicit,addOn,priv); - if (xkb->geom) - ok= ok&&XkbWriteXKBGeometry(file,result,False,showImplicit,addOn,priv); - fprintf(file,"};\n"); - return ok; -} - -Bool -XkbWriteXKBFile( FILE * out, - XkbFileInfo * result, - Bool showImplicit, - XkbFileAddOnFunc addOn, - void * priv) -{ -Bool ok = False; -Bool (*func)( - FILE * /* file */, - XkbFileInfo * /* result */, - Bool /* topLevel */, - Bool /* showImplicit */, - XkbFileAddOnFunc /* addOn */, - void * /* priv */ -) = NULL; - - switch (result->type) { - case XkmSemanticsFile: - func= XkbWriteXKBSemantics; - break; - case XkmLayoutFile: - func= XkbWriteXKBLayout; - break; - case XkmKeymapFile: - func= XkbWriteXKBKeymap; - break; - case XkmTypesIndex: - func= XkbWriteXKBKeyTypes; - break; - case XkmCompatMapIndex: - func= XkbWriteXKBCompatMap; - break; - case XkmSymbolsIndex: - func= XkbWriteXKBSymbols; - break; - case XkmKeyNamesIndex: - func= XkbWriteXKBKeycodes; - break; - case XkmGeometryFile: - case XkmGeometryIndex: - func= XkbWriteXKBGeometry; - break; - case XkmVirtualModsIndex: - case XkmIndicatorsIndex: - _XkbLibError(_XkbErrBadImplementation, - XkbConfigText(result->type,XkbMessage),0); - return False; - } - if (out==NULL) { - _XkbLibError(_XkbErrFileCannotOpen,"XkbWriteXkbFile",0); - ok= False; - } - else if (func) { - ok= (*func)(out,result,True,showImplicit,addOn,priv); - } - return ok; -} diff --git a/nx-X11/programs/Xserver/xkb/xkbtext.c b/nx-X11/programs/Xserver/xkb/xkbtext.c index dc1c712ae0..ca1186ac63 100644 --- a/nx-X11/programs/Xserver/xkb/xkbtext.c +++ b/nx-X11/programs/Xserver/xkb/xkbtext.c @@ -448,100 +448,6 @@ char * buf; return buf; } -char * -XkbAccessXDetailText(unsigned state,unsigned format) -{ -char *buf,*prefix; - - buf= tbGetBuffer(32); - if (format==XkbMessage) prefix= ""; - else prefix= "XkbAXN_"; - switch (state){ - case XkbAXN_SKPress: sprintf(buf,"%sSKPress",prefix); break; - case XkbAXN_SKAccept: sprintf(buf,"%sSKAccept",prefix); break; - case XkbAXN_SKRelease: sprintf(buf,"%sSKRelease",prefix); break; - case XkbAXN_SKReject: sprintf(buf,"%sSKReject",prefix); break; - case XkbAXN_BKAccept: sprintf(buf,"%sBKAccept",prefix); break; - case XkbAXN_BKReject: sprintf(buf,"%sBKReject",prefix); break; - case XkbAXN_AXKWarning: sprintf(buf,"%sAXKWarning",prefix); break; - default: sprintf(buf,"ILLEGAL"); break; - } - return buf; -} - -static char *nknNames[] = { - "keycodes", "geometry", "deviceID" -}; -#define NUM_NKN (sizeof(nknNames)/sizeof(char *)) - -char * -XkbNKNDetailMaskText(unsigned detail,unsigned format) -{ -char *buf,*prefix,*suffix; -register int i; -register unsigned bit; -int len,plen,slen; - - - if ((detail&XkbAllNewKeyboardEventsMask)==0) { - char *tmp = ""; - if (format==XkbCFile) tmp= "0"; - else if (format==XkbMessage) tmp= "none"; - buf= tbGetBuffer(strlen(tmp)+1); - strcpy(buf,tmp); - return buf; - } - else if ((detail&XkbAllNewKeyboardEventsMask)==XkbAllNewKeyboardEventsMask){ - char * tmp; - if (format==XkbCFile) tmp= "XkbAllNewKeyboardEventsMask"; - else tmp= "all"; - buf= tbGetBuffer(strlen(tmp)+1); - strcpy(buf,tmp); - return buf; - } - if (format==XkbMessage) { - prefix= ""; - suffix= ""; - slen= plen= 0; - } - else { - prefix= "XkbNKN_"; - plen= 7; - if (format==XkbCFile) - suffix= "Mask"; - else suffix= ""; - slen= strlen(suffix); - } - for (len=0,i=0,bit=1;i