From 08cbf3b50bfe713044f36b363c73768cd042f13c Mon Sep 17 00:00:00 2001 From: marha Date: Mon, 16 May 2011 08:06:12 +0000 Subject: xserver xkeyboar-config mesa git update 16 May 2011 --- xorg-server/include/dix.h | 4 +- xorg-server/include/eventstr.h | 4 - xorg-server/include/input.h | 50 ++-- xorg-server/include/inputstr.h | 10 + xorg-server/include/inpututils.h | 82 +++--- xorg-server/include/misc.h | 622 ++++++++++++++++++++------------------- 6 files changed, 403 insertions(+), 369 deletions(-) (limited to 'xorg-server/include') diff --git a/xorg-server/include/dix.h b/xorg-server/include/dix.h index c201e3ac1..9a111e8a7 100644 --- a/xorg-server/include/dix.h +++ b/xorg-server/include/dix.h @@ -375,7 +375,7 @@ extern void ReleaseActiveGrabs( extern GrabPtr CheckPassiveGrabsOnWindow( WindowPtr /* pWin */, DeviceIntPtr /* device */, - DeviceEvent * /* event */, + InternalEvent * /* event */, BOOL /* checkCore */, BOOL /* activate */); @@ -415,7 +415,7 @@ extern void DeliverFocusedEvent( InternalEvent* /* event */, WindowPtr /* window */); -extern void DeliverGrabbedEvent( +extern int DeliverGrabbedEvent( InternalEvent* /* event */, DeviceIntPtr /* thisDev */, Bool /* deactivateGrab */); diff --git a/xorg-server/include/eventstr.h b/xorg-server/include/eventstr.h index 673207ce3..049688ca0 100644 --- a/xorg-server/include/eventstr.h +++ b/xorg-server/include/eventstr.h @@ -68,10 +68,6 @@ enum EventType { ET_Internal = 0xFF /* First byte */ }; -#define CHECKEVENT(ev) if (ev && ((InternalEvent*)(ev))->any.header != 0xFF) \ - FatalError("Wrong event type %d.\n", \ - ((InternalEvent*)(ev))->any.header); - /** * Used for ALL input device events internal in the server until * copied into the matching protocol event. diff --git a/xorg-server/include/input.h b/xorg-server/include/input.h index 86078daee..4de4ff52c 100644 --- a/xorg-server/include/input.h +++ b/xorg-server/include/input.h @@ -109,19 +109,8 @@ typedef union _GrabMask GrabMask; typedef struct _ValuatorMask ValuatorMask; -typedef struct _EventList { - xEvent* event; - int evlen; /* length of allocated memory for event in bytes. This is not - the actual length of the event. The event's actual length is - 32 for standard events or 32 + - ((xGenericEvent*)event)->length * 4 for GenericEvents. - For events in the EQ, the length is - ((InternalEvent*)event)->u.any.length */ -} EventList, *EventListPtr; - /* The DIX stores incoming input events in this list */ -extern EventListPtr InputEventList; -extern int InputEventListLen; +extern InternalEvent* InputEventList; typedef int (*DeviceProc)( DeviceIntPtr /*device*/, @@ -439,22 +428,28 @@ extern _X_EXPORT void CloseInput(void); extern _X_EXPORT int GetMaximumEventsNum(void); -extern _X_EXPORT int GetEventList(EventListPtr* list); -extern _X_EXPORT EventListPtr InitEventList(int num_events); -extern _X_EXPORT void FreeEventList(EventListPtr list, int num_events); +extern _X_EXPORT InternalEvent *InitEventList(int num_events); +extern _X_EXPORT void FreeEventList(InternalEvent *list, int num_events); -extern void CreateClassesChangedEvent(EventListPtr event, +extern void CreateClassesChangedEvent(InternalEvent *event, DeviceIntPtr master, DeviceIntPtr slave, int type); -extern EventListPtr UpdateFromMaster( - EventListPtr events, +extern InternalEvent * UpdateFromMaster( + InternalEvent *events, DeviceIntPtr pDev, int type, int *num_events); extern _X_EXPORT int GetPointerEvents( - EventListPtr events, + InternalEvent *events, + DeviceIntPtr pDev, + int type, + int buttons, + int flags, + const ValuatorMask *mask); + +extern _X_EXPORT void QueuePointerEvents( DeviceIntPtr pDev, int type, int buttons, @@ -462,14 +457,25 @@ extern _X_EXPORT int GetPointerEvents( const ValuatorMask *mask); extern _X_EXPORT int GetKeyboardEvents( - EventListPtr events, + InternalEvent *events, + DeviceIntPtr pDev, + int type, + int key_code, + const ValuatorMask *mask); + +extern _X_EXPORT void QueueKeyboardEvents( DeviceIntPtr pDev, int type, int key_code, const ValuatorMask *mask); extern int GetProximityEvents( - EventListPtr events, + InternalEvent *events, + DeviceIntPtr pDev, + int type, + const ValuatorMask *mask); + +extern void QueueProximityEvents( DeviceIntPtr pDev, int type, const ValuatorMask *mask); @@ -495,6 +501,8 @@ extern _X_EXPORT int GetMotionHistory( ScreenPtr pScreen, BOOL core); +extern void ReleaseButtonsAndKeys(DeviceIntPtr dev); + extern int AttachDevice(ClientPtr client, DeviceIntPtr slave, DeviceIntPtr master); diff --git a/xorg-server/include/inputstr.h b/xorg-server/include/inputstr.h index bd7c78dec..bc0accc87 100644 --- a/xorg-server/include/inputstr.h +++ b/xorg-server/include/inputstr.h @@ -591,4 +591,14 @@ typedef struct _EventSyncInfo { extern EventSyncInfoRec syncEvents; +/** + * Given a sprite, returns the window at the bottom of the trace (i.e. the + * furthest window from the root). + */ +static inline WindowPtr DeepestSpriteWin(SpritePtr sprite) +{ + assert(sprite->spriteTraceGood > 0); + return sprite->spriteTrace[sprite->spriteTraceGood - 1]; +} + #endif /* INPUTSTRUCT_H */ diff --git a/xorg-server/include/inpututils.h b/xorg-server/include/inpututils.h index af07afeb0..92a754327 100644 --- a/xorg-server/include/inpututils.h +++ b/xorg-server/include/inpututils.h @@ -1,40 +1,42 @@ -/* - * Copyright © 2010 Red Hat, Inc. - * - * 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 "dix-config.h" -#endif - -#ifndef INPUTUTILS_H -#define INPUTUTILS_H - -#include "input.h" - -struct _ValuatorMask { - int8_t last_bit; /* highest bit set in mask */ - uint8_t mask[(MAX_VALUATORS + 7)/8]; - int valuators[MAX_VALUATORS]; /* valuator data */ -}; - -#endif +/* + * Copyright © 2010 Red Hat, Inc. + * + * 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 "dix-config.h" +#endif + +#ifndef INPUTUTILS_H +#define INPUTUTILS_H + +#include "input.h" + +struct _ValuatorMask { + int8_t last_bit; /* highest bit set in mask */ + uint8_t mask[(MAX_VALUATORS + 7)/8]; + int valuators[MAX_VALUATORS]; /* valuator data */ +}; + +extern void verify_internal_event(const InternalEvent *ev); + +#endif diff --git a/xorg-server/include/misc.h b/xorg-server/include/misc.h index 42f225b17..bdcc8cc1e 100644 --- a/xorg-server/include/misc.h +++ b/xorg-server/include/misc.h @@ -1,302 +1,320 @@ -/*********************************************************** - -Copyright 1987, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - - -Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Digital not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR -ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. - -Copyright 1992, 1993 Data General Corporation; -Copyright 1992, 1993 OMRON Corporation - -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 -neither the name OMRON or DATA GENERAL be used in advertising or publicity -pertaining to distribution of the software without specific, written prior -permission of the party whose name is to be used. Neither OMRON or -DATA GENERAL make any representation about the suitability of this software -for any purpose. It is provided "as is" without express or implied warranty. - -OMRON AND DATA GENERAL EACH DISCLAIM ALL WARRANTIES WITH REGARD TO THIS -SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, -IN NO EVENT SHALL OMRON OR DATA GENERAL 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. - -******************************************************************/ -#ifndef MISC_H -#define MISC_H 1 -/* - * X internal definitions - * - */ - -#include -#include -#include -#include -#include - -#include -#include - -#ifndef MAXSCREENS -#define MAXSCREENS 16 -#endif -#define MAXCLIENTS 256 -#define MAXEXTENSIONS 128 -#define MAXFORMATS 8 -#define MAXDEVICES 40 /* input devices */ - -#define EXTENSION_EVENT_BASE 64 -#define EXTENSION_BASE 128 - -typedef uint32_t ATOM; - -#ifndef TRUE -#define TRUE 1 -#define FALSE 0 -#endif - -#ifndef _XTYPEDEF_CALLBACKLISTPTR -typedef struct _CallbackList *CallbackListPtr; /* also in dix.h */ -#define _XTYPEDEF_CALLBACKLISTPTR -#endif - -typedef struct _xReq *xReqPtr; - -#include "os.h" /* for ALLOCATE_LOCAL and DEALLOCATE_LOCAL */ -#include /* for bcopy, bzero, and bcmp */ - -#define NullBox ((BoxPtr)0) -#define MILLI_PER_MIN (1000 * 60) -#define MILLI_PER_SECOND (1000) - - /* this next is used with None and ParentRelative to tell - PaintWin() what to use to paint the background. Also used - in the macro IS_VALID_PIXMAP */ - -#define USE_BACKGROUND_PIXEL 3 -#define USE_BORDER_PIXEL 3 - - -/* byte swap a 32-bit literal */ -#define lswapl(x) ((((x) & 0xff) << 24) |\ - (((x) & 0xff00) << 8) |\ - (((x) & 0xff0000) >> 8) |\ - (((x) >> 24) & 0xff)) - -/* byte swap a short literal */ -#define lswaps(x) ((((x) & 0xff) << 8) | (((x) >> 8) & 0xff)) - -#undef min -#undef max - -#define min(a, b) (((a) < (b)) ? (a) : (b)) -#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 */ -#endif -#define sign(x) ((x) < 0 ? -1 : ((x) > 0 ? 1 : 0)) -/* this assumes b > 0 */ -#define modulus(a, b, d) if (((d) = (a) % (b)) < 0) (d) += (b) -/* - * return the least significant bit in x which is set - * - * This works on 1's complement and 2's complement machines. - * If you care about the extra instruction on 2's complement - * machines, change to ((x) & (-(x))) - */ -#define lowbit(x) ((x) & (~(x) + 1)) - -/* XXX Not for modules */ -#include -#if !defined(MAXSHORT) || !defined(MINSHORT) || \ - !defined(MAXINT) || !defined(MININT) -/* - * Some implementations #define these through , so preclude - * #include'ing it later. - */ - -#include -#undef MAXSHORT -#define MAXSHORT SHRT_MAX -#undef MINSHORT -#define MINSHORT SHRT_MIN -#undef MAXINT -#define MAXINT INT_MAX -#undef MININT -#define MININT INT_MIN - -#include -#include -#include /* for fopen, etc... */ - -#endif - -#ifndef PATH_MAX -#include -#ifndef PATH_MAX -#ifdef MAXPATHLEN -#define PATH_MAX MAXPATHLEN -#else -#define PATH_MAX 1024 -#endif -#endif -#endif - -/** - * Calculate the number of bytes needed to hold bits. - * @param bits The minimum number of bits needed. - * @return The number of bytes needed to hold bits. - */ -static inline int -bits_to_bytes(const int bits) { - return ((bits + 7) >> 3); -} -/** - * Calculate the number of 4-byte units needed to hold the given number of - * bytes. - * @param bytes The minimum number of bytes needed. - * @return The number of 4-byte units needed to hold bytes. - */ -static inline int -bytes_to_int32(const int bytes) { - return (((bytes) + 3) >> 2); -} - -/** - * Calculate the number of bytes (in multiples of 4) needed to hold bytes. - * @param bytes The minimum number of bytes needed. - * @return The closest multiple of 4 that is equal or higher than bytes. - */ -static inline int -pad_to_int32(const int bytes) { - return (((bytes) + 3) & ~3); -} - -extern char** -xstrtokenize(const char *str, const char* separators); - -/* some macros to help swap requests, replies, and events */ - -#define LengthRestB(stuff) \ - ((client->req_len << 2) - sizeof(*stuff)) - -#define LengthRestS(stuff) \ - ((client->req_len << 1) - (sizeof(*stuff) >> 1)) - -#define LengthRestL(stuff) \ - (client->req_len - (sizeof(*stuff) >> 2)) - -#define SwapRestS(stuff) \ - SwapShorts((short *)(stuff + 1), LengthRestS(stuff)) - -#define SwapRestL(stuff) \ - SwapLongs((CARD32 *)(stuff + 1), LengthRestL(stuff)) - -/* byte swap a 32-bit value */ -#define swapl(x, n) { \ - n = ((char *) (x))[0];\ - ((char *) (x))[0] = ((char *) (x))[3];\ - ((char *) (x))[3] = n;\ - n = ((char *) (x))[1];\ - ((char *) (x))[1] = ((char *) (x))[2];\ - ((char *) (x))[2] = n; } - -/* byte swap a short */ -#define swaps(x, n) { \ - n = ((char *) (x))[0];\ - ((char *) (x))[0] = ((char *) (x))[1];\ - ((char *) (x))[1] = n; } - -/* copy 32-bit value from src to dst byteswapping on the way */ -#define cpswapl(src, dst) { \ - ((char *)&(dst))[0] = ((char *) &(src))[3];\ - ((char *)&(dst))[1] = ((char *) &(src))[2];\ - ((char *)&(dst))[2] = ((char *) &(src))[1];\ - ((char *)&(dst))[3] = ((char *) &(src))[0]; } - -/* copy short from src to dst byteswapping on the way */ -#define cpswaps(src, dst) { \ - ((char *) &(dst))[0] = ((char *) &(src))[1];\ - ((char *) &(dst))[1] = ((char *) &(src))[0]; } - -extern _X_EXPORT void SwapLongs( - CARD32 *list, - unsigned long count); - -extern _X_EXPORT void SwapShorts( - short *list, - unsigned long count); - -extern _X_EXPORT void MakePredeclaredAtoms(void); - -extern _X_EXPORT int Ones( - unsigned long /*mask*/); - -typedef struct _xPoint *DDXPointPtr; -typedef struct pixman_box16 *BoxPtr; -typedef struct _xEvent *xEventPtr; -typedef struct _xRectangle *xRectanglePtr; -typedef struct _GrabRec *GrabPtr; - -/* typedefs from other places - duplicated here to minimize the amount - * of unnecessary junk that one would normally have to include to get - * these symbols defined - */ - -#ifndef _XTYPEDEF_CHARINFOPTR -typedef struct _CharInfo *CharInfoPtr; /* also in fonts/include/font.h */ -#define _XTYPEDEF_CHARINFOPTR -#endif - -extern _X_EXPORT unsigned long globalSerialNumber; -extern _X_EXPORT unsigned long serverGeneration; - -#endif /* MISC_H */ +/*********************************************************** + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +Copyright 1992, 1993 Data General Corporation; +Copyright 1992, 1993 OMRON Corporation + +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 +neither the name OMRON or DATA GENERAL be used in advertising or publicity +pertaining to distribution of the software without specific, written prior +permission of the party whose name is to be used. Neither OMRON or +DATA GENERAL make any representation about the suitability of this software +for any purpose. It is provided "as is" without express or implied warranty. + +OMRON AND DATA GENERAL EACH DISCLAIM ALL WARRANTIES WITH REGARD TO THIS +SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, +IN NO EVENT SHALL OMRON OR DATA GENERAL 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. + +******************************************************************/ +#ifndef MISC_H +#define MISC_H 1 +/* + * X internal definitions + * + */ + +#include +#include +#include +#include +#include + +#include +#include + +#ifndef MAXSCREENS +#define MAXSCREENS 16 +#endif +#define MAXCLIENTS 256 +#define MAXEXTENSIONS 128 +#define MAXFORMATS 8 +#define MAXDEVICES 40 /* input devices */ + +#define EXTENSION_EVENT_BASE 64 +#define EXTENSION_BASE 128 + +typedef uint32_t ATOM; + +#ifndef TRUE +#define TRUE 1 +#define FALSE 0 +#endif + +#ifndef _XTYPEDEF_CALLBACKLISTPTR +typedef struct _CallbackList *CallbackListPtr; /* also in dix.h */ +#define _XTYPEDEF_CALLBACKLISTPTR +#endif + +typedef struct _xReq *xReqPtr; + +#include "os.h" /* for ALLOCATE_LOCAL and DEALLOCATE_LOCAL */ +#include /* for bcopy, bzero, and bcmp */ + +#define NullBox ((BoxPtr)0) +#define MILLI_PER_MIN (1000 * 60) +#define MILLI_PER_SECOND (1000) + + /* this next is used with None and ParentRelative to tell + PaintWin() what to use to paint the background. Also used + in the macro IS_VALID_PIXMAP */ + +#define USE_BACKGROUND_PIXEL 3 +#define USE_BORDER_PIXEL 3 + + +/* byte swap a 32-bit literal */ +#define lswapl(x) ((((x) & 0xff) << 24) |\ + (((x) & 0xff00) << 8) |\ + (((x) & 0xff0000) >> 8) |\ + (((x) >> 24) & 0xff)) + +/* byte swap a short literal */ +#define lswaps(x) ((((x) & 0xff) << 8) | (((x) >> 8) & 0xff)) + +#undef min +#undef max + +#define min(a, b) (((a) < (b)) ? (a) : (b)) +#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 */ +#endif +#define sign(x) ((x) < 0 ? -1 : ((x) > 0 ? 1 : 0)) +/* this assumes b > 0 */ +#define modulus(a, b, d) if (((d) = (a) % (b)) < 0) (d) += (b) +/* + * return the least significant bit in x which is set + * + * This works on 1's complement and 2's complement machines. + * If you care about the extra instruction on 2's complement + * machines, change to ((x) & (-(x))) + */ +#define lowbit(x) ((x) & (~(x) + 1)) + +/* XXX Not for modules */ +#include +#if !defined(MAXSHORT) || !defined(MINSHORT) || \ + !defined(MAXINT) || !defined(MININT) +/* + * Some implementations #define these through , so preclude + * #include'ing it later. + */ + +#include +#undef MAXSHORT +#define MAXSHORT SHRT_MAX +#undef MINSHORT +#define MINSHORT SHRT_MIN +#undef MAXINT +#define MAXINT INT_MAX +#undef MININT +#define MININT INT_MIN + +#include +#include +#include /* for fopen, etc... */ + +#endif + +#ifndef PATH_MAX +#include +#ifndef PATH_MAX +#ifdef MAXPATHLEN +#define PATH_MAX MAXPATHLEN +#else +#define PATH_MAX 1024 +#endif +#endif +#endif + +/** + * Calculate the number of bytes needed to hold bits. + * @param bits The minimum number of bits needed. + * @return The number of bytes needed to hold bits. + */ +static inline int +bits_to_bytes(const int bits) { + return ((bits + 7) >> 3); +} +/** + * Calculate the number of 4-byte units needed to hold the given number of + * bytes. + * @param bytes The minimum number of bytes needed. + * @return The number of 4-byte units needed to hold bytes. + */ +static inline int +bytes_to_int32(const int bytes) { + return (((bytes) + 3) >> 2); +} + +/** + * Calculate the number of bytes (in multiples of 4) needed to hold bytes. + * @param bytes The minimum number of bytes needed. + * @return The closest multiple of 4 that is equal or higher than bytes. + */ +static inline int +pad_to_int32(const int bytes) { + return (((bytes) + 3) & ~3); +} + +extern char** +xstrtokenize(const char *str, const char* separators); + +/** + * Compare the two version numbers comprising of major.minor. + * + * @return A value less than 0 if a is less than b, 0 if a is equal to b, + * or a value greater than 0 + */ +static inline int +version_compare(uint16_t a_major, uint16_t a_minor, + uint16_t b_major, uint16_t b_minor) +{ + int a, b; + + a = a_major << 16 | a_minor; + b = b_major << 16 | b_minor; + + return (a - b); +} + +/* some macros to help swap requests, replies, and events */ + +#define LengthRestB(stuff) \ + ((client->req_len << 2) - sizeof(*stuff)) + +#define LengthRestS(stuff) \ + ((client->req_len << 1) - (sizeof(*stuff) >> 1)) + +#define LengthRestL(stuff) \ + (client->req_len - (sizeof(*stuff) >> 2)) + +#define SwapRestS(stuff) \ + SwapShorts((short *)(stuff + 1), LengthRestS(stuff)) + +#define SwapRestL(stuff) \ + SwapLongs((CARD32 *)(stuff + 1), LengthRestL(stuff)) + +/* byte swap a 32-bit value */ +#define swapl(x, n) { \ + n = ((char *) (x))[0];\ + ((char *) (x))[0] = ((char *) (x))[3];\ + ((char *) (x))[3] = n;\ + n = ((char *) (x))[1];\ + ((char *) (x))[1] = ((char *) (x))[2];\ + ((char *) (x))[2] = n; } + +/* byte swap a short */ +#define swaps(x, n) { \ + n = ((char *) (x))[0];\ + ((char *) (x))[0] = ((char *) (x))[1];\ + ((char *) (x))[1] = n; } + +/* copy 32-bit value from src to dst byteswapping on the way */ +#define cpswapl(src, dst) { \ + ((char *)&(dst))[0] = ((char *) &(src))[3];\ + ((char *)&(dst))[1] = ((char *) &(src))[2];\ + ((char *)&(dst))[2] = ((char *) &(src))[1];\ + ((char *)&(dst))[3] = ((char *) &(src))[0]; } + +/* copy short from src to dst byteswapping on the way */ +#define cpswaps(src, dst) { \ + ((char *) &(dst))[0] = ((char *) &(src))[1];\ + ((char *) &(dst))[1] = ((char *) &(src))[0]; } + +extern _X_EXPORT void SwapLongs( + CARD32 *list, + unsigned long count); + +extern _X_EXPORT void SwapShorts( + short *list, + unsigned long count); + +extern _X_EXPORT void MakePredeclaredAtoms(void); + +extern _X_EXPORT int Ones( + unsigned long /*mask*/); + +typedef struct _xPoint *DDXPointPtr; +typedef struct pixman_box16 *BoxPtr; +typedef struct _xEvent *xEventPtr; +typedef struct _xRectangle *xRectanglePtr; +typedef struct _GrabRec *GrabPtr; + +/* typedefs from other places - duplicated here to minimize the amount + * of unnecessary junk that one would normally have to include to get + * these symbols defined + */ + +#ifndef _XTYPEDEF_CHARINFOPTR +typedef struct _CharInfo *CharInfoPtr; /* also in fonts/include/font.h */ +#define _XTYPEDEF_CHARINFOPTR +#endif + +extern _X_EXPORT unsigned long globalSerialNumber; +extern _X_EXPORT unsigned long serverGeneration; + +#endif /* MISC_H */ -- cgit v1.2.3