diff options
author | Keith Packard <keithp@keithp.com> | 2011-12-08 20:57:26 -0800 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2011-12-08 20:57:26 -0800 |
commit | 522f8bcc0360d6a117e929a004bc956ab92037e9 (patch) | |
tree | ccfb8458dd88dec2877026a5059eda2522f42de1 /include | |
parent | 6369b59668613e51131857fbaeaa393a65a73048 (diff) | |
parent | 2abe83df686ed64c4f4df711ac3c1fd12131c2e4 (diff) |
Merge remote-tracking branch 'whot/for-keith'
Diffstat (limited to 'include')
-rw-r--r-- | include/dix.h | 1 | ||||
-rw-r--r-- | include/dixgrabs.h | 4 | ||||
-rw-r--r-- | include/input.h | 1 | ||||
-rw-r--r-- | include/inputstr.h | 22 | ||||
-rw-r--r-- | include/inpututils.h | 12 | ||||
-rw-r--r-- | include/list.h | 81 | ||||
-rw-r--r-- | include/misc.h | 9 |
7 files changed, 97 insertions, 33 deletions
diff --git a/include/dix.h b/include/dix.h index f98c87b04..cfbfa1f41 100644 --- a/include/dix.h +++ b/include/dix.h @@ -339,6 +339,7 @@ extern _X_EXPORT void NoticeEventTime(InternalEvent *ev); extern void EnqueueEvent( InternalEvent * /* ev */, DeviceIntPtr /* device */); +extern void PlayReleasedEvents(void); extern void ActivatePointerGrab( DeviceIntPtr /* mouse */, diff --git a/include/dixgrabs.h b/include/dixgrabs.h index 229c8bb53..65ff45d1d 100644 --- a/include/dixgrabs.h +++ b/include/dixgrabs.h @@ -31,6 +31,10 @@ struct _GrabParameters; extern void PrintDeviceGrabInfo(DeviceIntPtr dev); extern void UngrabAllDevices(Bool kill_client); +extern GrabPtr AllocGrab(void); +extern void FreeGrab(GrabPtr grab); +extern Bool CopyGrab(GrabPtr dst, const GrabPtr src); + extern GrabPtr CreateGrab( int /* client */, DeviceIntPtr /* device */, diff --git a/include/input.h b/include/input.h index 8e7b47a4c..8b0c18e70 100644 --- a/include/input.h +++ b/include/input.h @@ -205,6 +205,7 @@ extern _X_EXPORT KeybdCtrl defaultKeyboardControl; extern _X_EXPORT PtrCtrl defaultPointerControl; typedef struct _InputOption InputOption; +typedef struct _XI2Mask XI2Mask; typedef struct _InputAttributes { char *product; diff --git a/include/inputstr.h b/include/inputstr.h index f482a2294..5634f3cfc 100644 --- a/include/inputstr.h +++ b/include/inputstr.h @@ -118,7 +118,7 @@ typedef struct _InputClients { XID resource; /**< id for putting into resource manager */ Mask mask[EMASKSIZE]; /**< Actual XI event mask, deviceid is index */ /** XI2 event masks. One per device, each bit is a mask of (1 << type) */ - unsigned char xi2mask[EMASKSIZE][XI2MASKSIZE]; + struct _XI2Mask *xi2mask; } InputClients; /** @@ -148,7 +148,7 @@ typedef struct _OtherInputMasks { /** The clients that selected for events */ InputClientsPtr inputClients; /* XI2 event masks. One per device, each bit is a mask of (1 << type) */ - unsigned char xi2mask[EMASKSIZE][XI2MASKSIZE]; + struct _XI2Mask *xi2mask; } OtherInputMasks; /* @@ -176,7 +176,7 @@ typedef enum { union _GrabMask { Mask core; Mask xi; - char xi2mask[EMASKSIZE][XI2MASKSIZE]; + struct _XI2Mask *xi2mask; }; /** @@ -210,7 +210,7 @@ typedef struct _GrabRec { Mask eventMask; Mask deviceMask; /* XI2 event masks. One per device, each bit is a mask of (1 << type) */ - unsigned char xi2mask[EMASKSIZE][XI2MASKSIZE]; + struct _XI2Mask *xi2mask; } GrabRec; /** @@ -451,7 +451,7 @@ typedef struct _GrabInfoRec { TimeStamp grabTime; Bool fromPassiveGrab; /* true if from passive grab */ Bool implicitGrab; /* implicit from ButtonPress */ - GrabRec activeGrab; + GrabPtr activeGrab; GrabPtr grab; CARD8 activatingKey; void (*ActivateGrab) ( @@ -575,7 +575,7 @@ extern _X_EXPORT InputInfo inputInfo; /* for keeping the events for devices grabbed synchronously */ typedef struct _QdEvent *QdEventPtr; typedef struct _QdEvent { - QdEventPtr next; + struct list next; DeviceIntPtr device; ScreenPtr pScreen; /* what screen the pointer was on */ unsigned long months; /* milliseconds is in the event */ @@ -591,8 +591,8 @@ typedef struct _QdEvent { * replayed and processed as if they would come from the device directly. */ typedef struct _EventSyncInfo { - QdEventPtr pending, /**< list of queued events */ - *pendtail; /**< last event in list */ + struct list pending; + /** The device to replay events for. Only set in AllowEvents(), in which * case it is set to the device specified in the request. */ DeviceIntPtr replayDev; /* kludgy rock to put flag for */ @@ -622,4 +622,10 @@ static inline WindowPtr DeepestSpriteWin(SpritePtr sprite) return sprite->spriteTrace[sprite->spriteTraceGood - 1]; } +struct _XI2Mask { + unsigned char **masks; /* event mask in masks[deviceid][event type byte] */ + size_t nmasks; /* number of masks */ + size_t mask_size; /* size of each mask in bytes */ +}; + #endif /* INPUTSTRUCT_H */ diff --git a/include/inpututils.h b/include/inpututils.h index 2832ed5b1..5f9dfecc3 100644 --- a/include/inpututils.h +++ b/include/inpututils.h @@ -46,4 +46,16 @@ FP1616 double_to_fp1616(double in); double fp1616_to_double(FP1616 in); double fp3232_to_double(FP3232 in); + +XI2Mask* xi2mask_new(void); +XI2Mask* xi2mask_new_with_size(size_t, size_t); /* don't use it */ +void xi2mask_free(XI2Mask** mask); +Bool xi2mask_isset(XI2Mask* mask, const DeviceIntPtr dev, int event_type); +void xi2mask_set(XI2Mask *mask, int deviceid, int event_type); +void xi2mask_zero(XI2Mask *mask, int deviceid); +void xi2mask_merge(XI2Mask *dest, const XI2Mask *source); +size_t xi2mask_num_masks(const XI2Mask *mask); +size_t xi2mask_mask_size(const XI2Mask *mask); +void xi2mask_set_one_mask(XI2Mask *xi2mask, int deviceid, const unsigned char *mask, size_t mask_size); +const unsigned char* xi2mask_get_one_mask(const XI2Mask *xi2mask, int deviceid); #endif diff --git a/include/list.h b/include/list.h index 4706e178b..6ec2bac53 100644 --- a/include/list.h +++ b/include/list.h @@ -28,6 +28,7 @@ /** * @file Classic doubly-link circular list implementation. + * For real usage examples of the linked list, see the file test/list.c * * Example: * We need to keep a list of struct foo in the parent struct bar, i.e. what @@ -35,16 +36,16 @@ * * struct bar { * ... - * struct foo *foos; -----> struct foo {}, struct foo {}, struct foo{} + * struct foo *list_of_foos; -----> struct foo {}, struct foo {}, struct foo{} * ... * } * - * We need one list head in bar and a list element in all foos (both are of + * We need one list head in bar and a list element in all list_of_foos (both are of * data type 'struct list'). * * struct bar { * ... - * struct list foos; + * struct list list_of_foos; * ... * } * @@ -58,27 +59,27 @@ * * struct bar bar; * ... - * list_init(&bar.foos); + * list_init(&bar.list_of_foos); * * Then we create the first element and add it to this list: * * struct foo *foo = malloc(...); * .... - * list_add(&foo->entry, &bar.foos); + * list_add(&foo->entry, &bar.list_of_foos); * * Repeat the above for each element you want to add to the list. Deleting * works with the element itself. * list_del(&foo->entry); * free(foo); * - * Note: calling list_del(&bar.foos) will set bar.foos to an empty + * Note: calling list_del(&bar.list_of_foos) will set bar.list_of_foos to an empty * list again. * * Looping through the list requires a 'struct foo' as iterator and the * name of the field the subnodes use. * * struct foo *iterator; - * list_for_each_entry(iterator, &bar.foos, entry) { + * list_for_each_entry(iterator, &bar.list_of_foos, entry) { * if (iterator->something == ...) * ... * } @@ -87,7 +88,7 @@ * loop. You need to run the safe for-each loop instead: * * struct foo *iterator, *next; - * list_for_each_entry_safe(iterator, next, &bar.foos, entry) { + * list_for_each_entry_safe(iterator, next, &bar.list_of_foos, entry) { * if (...) * list_del(&iterator->entry); * } @@ -96,14 +97,8 @@ /** * The linkage struct for list nodes. This struct must be part of your - * to-be-linked struct. - * - * Example: - * struct foo { - * int a; - * void *b; - * struct list *mylist; - * } + * to-be-linked struct. struct list is required for both the head of the + * list and for each list node. * * Position and name of the struct list field is irrelevant. * There are no requirements that elements of a list are of the same type. @@ -118,7 +113,7 @@ struct list { * Initialize the list as an empty list. * * Example: - * list_init(&foo->mylist); + * list_init(&bar->list_of_foos); * * @param The list to initialized. */ @@ -140,7 +135,8 @@ __list_add(struct list *entry, } /** - * Insert a new element after the given list head. + * Insert a new element after the given list head. The new element does not + * need to be initialised as empty list. * The list changes from: * head → some element → ... * to @@ -148,7 +144,7 @@ __list_add(struct list *entry, * * Example: * struct foo *newfoo = malloc(...); - * list_add(&newfoo->mylist, &foo->mylist); + * list_add(&newfoo->entry, &bar->list_of_foos); * * @param entry The new element to prepend to the list. * @param head The existing list. @@ -159,6 +155,28 @@ list_add(struct list *entry, struct list *head) __list_add(entry, head, head->next); } +/** + * Append a new element to the end of the list given with this list head. + * + * The list changes from: + * head → some element → ... → lastelement + * to + * head → some element → ... → lastelement → new element + * + * Example: + * struct foo *newfoo = malloc(...); + * list_append(&newfoo->entry, &bar->list_of_foos); + * + * @param entry The new element to prepend to the list. + * @param head The existing list. + */ +static inline void +list_append(struct list *entry, struct list *head) +{ + __list_add(entry, head->prev, head); +} + + static inline void __list_del(struct list *prev, struct list *next) { @@ -176,7 +194,7 @@ __list_del(struct list *prev, struct list *next) * the list but rather reset the list as empty list. * * Example: - * list_del(&newfoo->mylist); + * list_del(&foo->entry); * * @param entry The element to remove. */ @@ -191,7 +209,7 @@ list_del(struct list *entry) * Check if the list is empty. * * Example: - * list_is_empty(&foo->mylist); + * list_is_empty(&bar->list_of_foos); * * @return True if the list contains one or more elements or False otherwise. */ @@ -206,7 +224,7 @@ list_is_empty(struct list *head) * * Example: * struct foo* f; - * f = container_of(&foo->mylist, struct foo, mylist); + * f = container_of(&foo->entry, struct foo, entry); * assert(f == foo); * * @param ptr Pointer to the struct list. @@ -230,7 +248,7 @@ list_is_empty(struct list *head) * * Example: * struct foo *first; - * first = list_first_entry(&foo->mylist, struct foo, mylist); + * first = list_first_entry(&bar->list_of_foos, struct foo, list_of_foos); * * @param ptr The list head * @param type Data type of the list element to retrieve @@ -240,6 +258,21 @@ list_is_empty(struct list *head) #define list_first_entry(ptr, type, member) \ list_entry((ptr)->next, type, member) +/** + * Retrieve the last list entry for the given listpointer. + * + * Example: + * struct foo *first; + * first = list_last_entry(&bar->list_of_foos, struct foo, list_of_foos); + * + * @param ptr The list head + * @param type Data type of the list element to retrieve + * @param member Member name of the struct list field in the list element. + * @return A pointer to the last list element. + */ +#define list_last_entry(ptr, type, member) \ + list_entry((ptr)->prev, type, member) + #define __container_of(ptr, sample, member) \ (void *)((char *)(ptr) \ - ((char *)&(sample)->member - (char *)(sample))) @@ -248,7 +281,7 @@ list_is_empty(struct list *head) * * Example: * struct foo *iterator; - * list_for_each_entry(iterator, &foo->mylist, mylist) { + * list_for_each_entry(iterator, &bar->list_of_foos, entry) { * [modify iterator] * } * diff --git a/include/misc.h b/include/misc.h index ef86fa539..d9811ca60 100644 --- a/include/misc.h +++ b/include/misc.h @@ -359,11 +359,18 @@ typedef struct _CharInfo *CharInfoPtr; /* also in fonts/include/font.h */ extern _X_EXPORT unsigned long globalSerialNumber; extern _X_EXPORT unsigned long serverGeneration; -#define BUG_WARN(cond) \ +/* Don't use this directly, use BUG_WARN or BUG_WARN_MSG instead */ +#define __BUG_WARN_MSG(cond, with_msg, ...) \ do { if (cond) { \ ErrorF("BUG: triggered 'if (" #cond ")'\nBUG: %s:%d in %s()\n", \ __FILE__, __LINE__, __func__); \ + if (with_msg) ErrorF(__VA_ARGS__); \ xorg_backtrace(); \ } } while(0) +#define BUG_WARN_MSG(cond, msg, ...) \ + __BUG_WARN_MSG(cond, 1, msg, __VA_ARGS__) + +#define BUG_WARN(cond) __BUG_WARN_MSG(cond, 0, NULL) + #endif /* MISC_H */ |