1/************************************************************
2Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
3
4Permission to use, copy, modify, and distribute this
5software and its documentation for any purpose and without
6fee is hereby granted, provided that the above copyright
7notice appear in all copies and that both that copyright
8notice and this permission notice appear in supporting
9documentation, and that the name of Silicon Graphics not be
10used in advertising or publicity pertaining to distribution
11of the software without specific prior written permission.
12Silicon Graphics makes no representation about the suitability
13of this software for any purpose. It is provided "as is"
14without any express or implied warranty.
15
16SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
17SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
18AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
19GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
20DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
21DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
22OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
23THE USE OR PERFORMANCE OF THIS SOFTWARE.
24
25********************************************************/
26
27#ifndef _XKBSTR_H_
28#define	_XKBSTR_H_
29
30#include <X11/Xfuncproto.h>
31#include <X11/extensions/XKB.h>
32
33#define	XkbCharToInt(v)		((v)&0x80?(int)((v)|(~0xff)):(int)((v)&0x7f))
34#define	XkbIntTo2Chars(i,h,l)	(((h)=((i>>8)&0xff)),((l)=((i)&0xff)))
35#define	Xkb2CharsToInt(h,l)	((short)(((h)<<8)|(l)))
36
37/*
38 * The Xkb structs are full of implicit padding to properly align members.
39 * We can't clean that up without breaking ABI, so tell clang not to bother
40 * complaining about it.
41 */
42#ifdef __clang__
43#pragma clang diagnostic push
44#pragma clang diagnostic ignored "-Wpadded"
45#endif
46
47	/*
48	 * Common data structures and access macros
49	 */
50
51typedef struct _XkbStateRec {
52	unsigned char	group;
53	unsigned char   locked_group;
54	unsigned short	base_group;
55	unsigned short	latched_group;
56	unsigned char	mods;
57	unsigned char	base_mods;
58	unsigned char	latched_mods;
59	unsigned char	locked_mods;
60	unsigned char	compat_state;
61	unsigned char	grab_mods;
62	unsigned char	compat_grab_mods;
63	unsigned char	lookup_mods;
64	unsigned char	compat_lookup_mods;
65	unsigned short	ptr_buttons;
66} XkbStateRec,*XkbStatePtr;
67#define	XkbModLocks(s)	 ((s)->locked_mods)
68#define	XkbStateMods(s)	 ((s)->base_mods|(s)->latched_mods|XkbModLocks(s))
69#define	XkbGroupLock(s)	 ((s)->locked_group)
70#define	XkbStateGroup(s) ((s)->base_group+(s)->latched_group+XkbGroupLock(s))
71#define	XkbStateFieldFromRec(s)	XkbBuildCoreState((s)->lookup_mods,(s)->group)
72#define	XkbGrabStateFromRec(s)	XkbBuildCoreState((s)->grab_mods,(s)->group)
73
74typedef struct _XkbMods {
75	unsigned char	mask;	/* effective mods */
76	unsigned char	real_mods;
77	unsigned short	vmods;
78} XkbModsRec,*XkbModsPtr;
79
80typedef struct _XkbKTMapEntry {
81	Bool		active;
82	unsigned char	level;
83	XkbModsRec	mods;
84} XkbKTMapEntryRec,*XkbKTMapEntryPtr;
85
86typedef struct _XkbKeyType {
87	XkbModsRec		mods;
88	unsigned char	  	num_levels;
89	unsigned char	  	map_count;
90	/* map is an array of map_count XkbKTMapEntryRec structs */
91	XkbKTMapEntryPtr  	map;
92	/* preserve is an array of map_count XkbModsRec structs */
93	XkbModsPtr  		preserve;
94	Atom		  	name;
95	/* level_names is an array of num_levels Atoms */
96	Atom *			level_names;
97} XkbKeyTypeRec, *XkbKeyTypePtr;
98
99#define	XkbNumGroups(g)			((g)&0x0f)
100#define	XkbOutOfRangeGroupInfo(g)	((g)&0xf0)
101#define	XkbOutOfRangeGroupAction(g)	((g)&0xc0)
102#define	XkbOutOfRangeGroupNumber(g)	(((g)&0x30)>>4)
103#define	XkbSetGroupInfo(g,w,n)	(((w)&0xc0)|(((n)&3)<<4)|((g)&0x0f))
104#define	XkbSetNumGroups(g,n)	(((g)&0xf0)|((n)&0x0f))
105
106	/*
107	 * Structures and access macros used primarily by the server
108	 */
109
110typedef struct _XkbBehavior {
111	unsigned char	type;
112	unsigned char	data;
113} XkbBehavior;
114
115#define	XkbAnyActionDataSize 7
116typedef	struct _XkbAnyAction {
117	unsigned char	type;
118	unsigned char	data[XkbAnyActionDataSize];
119} XkbAnyAction;
120
121typedef struct _XkbModAction {
122	unsigned char	type;
123	unsigned char	flags;
124	unsigned char	mask;
125	unsigned char	real_mods;
126	unsigned char	vmods1;
127	unsigned char	vmods2;
128} XkbModAction;
129#define	XkbModActionVMods(a)      \
130	((short)(((a)->vmods1<<8)|((a)->vmods2)))
131#define	XkbSetModActionVMods(a,v) \
132	(((a)->vmods1=(((v)>>8)&0xff)),(a)->vmods2=((v)&0xff))
133
134typedef struct _XkbGroupAction {
135	unsigned char	type;
136	unsigned char	flags;
137	char		group_XXX;
138} XkbGroupAction;
139#define	XkbSAGroup(a)		(XkbCharToInt((a)->group_XXX))
140#define	XkbSASetGroup(a,g)	((a)->group_XXX=(g))
141
142typedef struct _XkbISOAction {
143	unsigned char	type;
144	unsigned char	flags;
145	unsigned char	mask;
146	unsigned char	real_mods;
147	char		group_XXX;
148	unsigned char	affect;
149	unsigned char	vmods1;
150	unsigned char	vmods2;
151} XkbISOAction;
152
153typedef struct _XkbPtrAction {
154	unsigned char	type;
155	unsigned char	flags;
156	unsigned char	high_XXX;
157	unsigned char	low_XXX;
158	unsigned char	high_YYY;
159	unsigned char	low_YYY;
160} XkbPtrAction;
161#define	XkbPtrActionX(a)      (Xkb2CharsToInt((a)->high_XXX,(a)->low_XXX))
162#define	XkbPtrActionY(a)      (Xkb2CharsToInt((a)->high_YYY,(a)->low_YYY))
163#define	XkbSetPtrActionX(a,x) (XkbIntTo2Chars(x,(a)->high_XXX,(a)->low_XXX))
164#define	XkbSetPtrActionY(a,y) (XkbIntTo2Chars(y,(a)->high_YYY,(a)->low_YYY))
165
166typedef struct _XkbPtrBtnAction {
167	unsigned char	type;
168	unsigned char	flags;
169	unsigned char	count;
170	unsigned char	button;
171} XkbPtrBtnAction;
172
173typedef struct _XkbPtrDfltAction {
174	unsigned char	type;
175	unsigned char	flags;
176	unsigned char	affect;
177	char		valueXXX;
178} XkbPtrDfltAction;
179#define	XkbSAPtrDfltValue(a)		(XkbCharToInt((a)->valueXXX))
180#define	XkbSASetPtrDfltValue(a,c)	((a)->valueXXX= ((c)&0xff))
181
182typedef struct _XkbSwitchScreenAction {
183	unsigned char	type;
184	unsigned char	flags;
185	char		screenXXX;
186} XkbSwitchScreenAction;
187#define	XkbSAScreen(a)			(XkbCharToInt((a)->screenXXX))
188#define	XkbSASetScreen(a,s)		((a)->screenXXX= ((s)&0xff))
189
190typedef struct _XkbCtrlsAction {
191	unsigned char	type;
192	unsigned char	flags;
193	unsigned char	ctrls3;
194	unsigned char	ctrls2;
195	unsigned char	ctrls1;
196	unsigned char	ctrls0;
197} XkbCtrlsAction;
198#define	XkbActionSetCtrls(a,c)	(((a)->ctrls3=(((c)>>24)&0xff)),\
199					((a)->ctrls2=(((c)>>16)&0xff)),\
200					((a)->ctrls1=(((c)>>8)&0xff)),\
201					((a)->ctrls0=((c)&0xff)))
202#define	XkbActionCtrls(a) ((((unsigned int)(a)->ctrls3)<<24)|\
203			   (((unsigned int)(a)->ctrls2)<<16)|\
204			   (((unsigned int)(a)->ctrls1)<<8)|\
205			   ((unsigned int)((a)->ctrls0)))
206
207typedef struct _XkbMessageAction {
208	unsigned char	type;
209	unsigned char	flags;
210	unsigned char	message[6];
211} XkbMessageAction;
212
213typedef struct	_XkbRedirectKeyAction {
214	unsigned char	type;
215	unsigned char	new_key;
216	unsigned char	mods_mask;
217	unsigned char	mods;
218	unsigned char	vmods_mask0;
219	unsigned char	vmods_mask1;
220	unsigned char	vmods0;
221	unsigned char	vmods1;
222} XkbRedirectKeyAction;
223
224#define	XkbSARedirectVMods(a)		((((unsigned int)(a)->vmods1)<<8)|\
225					((unsigned int)(a)->vmods0))
226#define	XkbSARedirectSetVMods(a,m)	(((a)->vmods1=(((m)>>8)&0xff)),\
227					 ((a)->vmods0=((m)&0xff)))
228#define	XkbSARedirectVModsMask(a)	((((unsigned int)(a)->vmods_mask1)<<8)|\
229					((unsigned int)(a)->vmods_mask0))
230#define	XkbSARedirectSetVModsMask(a,m)	(((a)->vmods_mask1=(((m)>>8)&0xff)),\
231					 ((a)->vmods_mask0=((m)&0xff)))
232
233typedef struct _XkbDeviceBtnAction {
234	unsigned char	type;
235	unsigned char	flags;
236	unsigned char	count;
237	unsigned char	button;
238	unsigned char	device;
239} XkbDeviceBtnAction;
240
241typedef struct _XkbDeviceValuatorAction {
242	unsigned char	type;
243	unsigned char	device;
244	unsigned char	v1_what;
245	unsigned char	v1_ndx;
246	unsigned char	v1_value;
247	unsigned char	v2_what;
248	unsigned char	v2_ndx;
249	unsigned char	v2_value;
250} XkbDeviceValuatorAction;
251
252typedef	union _XkbAction {
253	XkbAnyAction		any;
254	XkbModAction		mods;
255	XkbGroupAction		group;
256	XkbISOAction		iso;
257	XkbPtrAction		ptr;
258	XkbPtrBtnAction		btn;
259	XkbPtrDfltAction	dflt;
260	XkbSwitchScreenAction	screen;
261	XkbCtrlsAction		ctrls;
262	XkbMessageAction	msg;
263	XkbRedirectKeyAction	redirect;
264	XkbDeviceBtnAction	devbtn;
265	XkbDeviceValuatorAction	devval;
266	unsigned char 		type;
267} XkbAction;
268
269typedef	struct _XkbControls {
270	unsigned char	mk_dflt_btn;
271	unsigned char	num_groups;
272	unsigned char	groups_wrap;
273	XkbModsRec	internal;
274	XkbModsRec	ignore_lock;
275	unsigned int	enabled_ctrls;
276	unsigned short	repeat_delay;
277	unsigned short	repeat_interval;
278	unsigned short	slow_keys_delay;
279	unsigned short	debounce_delay;
280	unsigned short	mk_delay;
281	unsigned short	mk_interval;
282	unsigned short	mk_time_to_max;
283	unsigned short	mk_max_speed;
284		 short	mk_curve;
285	unsigned short	ax_options;
286	unsigned short	ax_timeout;
287	unsigned short	axt_opts_mask;
288	unsigned short	axt_opts_values;
289	unsigned int	axt_ctrls_mask;
290	unsigned int	axt_ctrls_values;
291	unsigned char	per_key_repeat[XkbPerKeyBitArraySize];
292} XkbControlsRec, *XkbControlsPtr;
293
294#define	XkbAX_AnyFeedback(c)	((c)->enabled_ctrls&XkbAccessXFeedbackMask)
295#define	XkbAX_NeedOption(c,w)	((c)->ax_options&(w))
296#define	XkbAX_NeedFeedback(c,w)	(XkbAX_AnyFeedback(c)&&XkbAX_NeedOption(c,w))
297
298typedef struct _XkbServerMapRec {
299	/* acts is an array of XkbActions structs, with size_acts entries
300	   allocated, and num_acts entries used. */
301	unsigned short		 num_acts;
302	unsigned short		 size_acts;
303	XkbAction		*acts;
304
305	/* behaviors, key_acts, explicit, & vmodmap are all arrays with
306	   (xkb->max_key_code + 1) entries allocated for each. */
307	XkbBehavior		*behaviors;
308	unsigned short		*key_acts;
309#if defined(__cplusplus) || defined(c_plusplus)
310	/* explicit is a C++ reserved word */
311	unsigned char		*c_explicit;
312#else
313	unsigned char		*explicit;
314#endif
315	unsigned char		 vmods[XkbNumVirtualMods];
316	unsigned short		*vmodmap;
317} XkbServerMapRec, *XkbServerMapPtr;
318
319#define	XkbSMKeyActionsPtr(m,k) (&(m)->acts[(m)->key_acts[k]])
320
321	/*
322	 * Structures and access macros used primarily by clients
323	 */
324
325typedef	struct _XkbSymMapRec {
326	unsigned char	 kt_index[XkbNumKbdGroups];
327	unsigned char	 group_info;
328	unsigned char	 width;
329	unsigned short	 offset;
330} XkbSymMapRec, *XkbSymMapPtr;
331
332typedef struct _XkbClientMapRec {
333	/* types is an array of XkbKeyTypeRec structs, with size_types entries
334	   allocated, and num_types entries used. */
335	unsigned char		 size_types;
336	unsigned char		 num_types;
337	XkbKeyTypePtr		 types;
338
339	/* syms is an array of size_syms KeySyms, in which num_syms are used */
340	unsigned short		 size_syms;
341	unsigned short		 num_syms;
342	KeySym			*syms;
343	/* key_sym_map is an array of (max_key_code + 1) XkbSymMapRec structs */
344	XkbSymMapPtr		 key_sym_map;
345
346	/* modmap is an array of (max_key_code + 1) unsigned chars */
347	unsigned char		*modmap;
348} XkbClientMapRec, *XkbClientMapPtr;
349
350#define	XkbCMKeyGroupInfo(m,k)  ((m)->key_sym_map[k].group_info)
351#define	XkbCMKeyNumGroups(m,k)	 (XkbNumGroups((m)->key_sym_map[k].group_info))
352#define	XkbCMKeyGroupWidth(m,k,g) (XkbCMKeyType(m,k,g)->num_levels)
353#define	XkbCMKeyGroupsWidth(m,k) ((m)->key_sym_map[k].width)
354#define	XkbCMKeyTypeIndex(m,k,g) ((m)->key_sym_map[k].kt_index[g&0x3])
355#define	XkbCMKeyType(m,k,g)	 (&(m)->types[XkbCMKeyTypeIndex(m,k,g)])
356#define	XkbCMKeyNumSyms(m,k) (XkbCMKeyGroupsWidth(m,k)*XkbCMKeyNumGroups(m,k))
357#define	XkbCMKeySymsOffset(m,k)	((m)->key_sym_map[k].offset)
358#define	XkbCMKeySymsPtr(m,k)	(&(m)->syms[XkbCMKeySymsOffset(m,k)])
359
360	/*
361	 * Compatibility structures and access macros
362	 */
363
364typedef struct _XkbSymInterpretRec {
365	KeySym		sym;
366	unsigned char	flags;
367	unsigned char	match;
368	unsigned char	mods;
369	unsigned char	virtual_mod;
370	XkbAnyAction	act;
371} XkbSymInterpretRec,*XkbSymInterpretPtr;
372
373typedef struct _XkbCompatMapRec {
374	/* sym_interpret is an array of XkbSymInterpretRec structs,
375	   in which size_si are allocated & num_si are used. */
376	XkbSymInterpretPtr	 sym_interpret;
377	XkbModsRec		 groups[XkbNumKbdGroups];
378	unsigned short		 num_si;
379	unsigned short		 size_si;
380} XkbCompatMapRec, *XkbCompatMapPtr;
381
382typedef struct _XkbIndicatorMapRec {
383	unsigned char	flags;
384	unsigned char	which_groups;
385	unsigned char	groups;
386	unsigned char	which_mods;
387	XkbModsRec	mods;
388	unsigned int	ctrls;
389} XkbIndicatorMapRec, *XkbIndicatorMapPtr;
390
391#define	XkbIM_IsAuto(i)	((((i)->flags&XkbIM_NoAutomatic)==0)&&\
392			    (((i)->which_groups&&(i)->groups)||\
393			     ((i)->which_mods&&(i)->mods.mask)||\
394			     ((i)->ctrls)))
395#define	XkbIM_InUse(i)	(((i)->flags)||((i)->which_groups)||\
396					((i)->which_mods)||((i)->ctrls))
397
398
399typedef struct _XkbIndicatorRec {
400	unsigned long	  	phys_indicators;
401	XkbIndicatorMapRec	maps[XkbNumIndicators];
402} XkbIndicatorRec,*XkbIndicatorPtr;
403
404typedef	struct _XkbKeyNameRec {
405	char	name[XkbKeyNameLength]	_X_NONSTRING;
406} XkbKeyNameRec,*XkbKeyNamePtr;
407
408typedef struct _XkbKeyAliasRec {
409	char	real[XkbKeyNameLength]	_X_NONSTRING;
410	char	alias[XkbKeyNameLength]	_X_NONSTRING;
411} XkbKeyAliasRec,*XkbKeyAliasPtr;
412
413	/*
414	 * Names for everything
415	 */
416typedef struct _XkbNamesRec {
417	Atom		  keycodes;
418	Atom		  geometry;
419	Atom		  symbols;
420	Atom              types;
421	Atom		  compat;
422	Atom		  vmods[XkbNumVirtualMods];
423	Atom		  indicators[XkbNumIndicators];
424	Atom		  groups[XkbNumKbdGroups];
425	/* keys is an array of (xkb->max_key_code + 1) XkbKeyNameRec entries */
426	XkbKeyNamePtr	  keys;
427	/* key_aliases is an array of num_key_aliases XkbKeyAliasRec entries */
428	XkbKeyAliasPtr	  key_aliases;
429	/* radio_groups is an array of num_rg Atoms */
430	Atom		 *radio_groups;
431	Atom		  phys_symbols;
432
433	/* num_keys seems to be unused in libX11 */
434	unsigned char	  num_keys;
435	unsigned char	  num_key_aliases;
436	unsigned short	  num_rg;
437} XkbNamesRec,*XkbNamesPtr;
438
439typedef	struct _XkbGeometry	*XkbGeometryPtr;
440	/*
441	 * Tie it all together into one big keyboard description
442	 */
443typedef	struct _XkbDesc {
444	struct _XDisplay *	dpy;
445	unsigned short	 	flags;
446	unsigned short		device_spec;
447	KeyCode			min_key_code;
448	KeyCode			max_key_code;
449
450	XkbControlsPtr		ctrls;
451	XkbServerMapPtr		server;
452	XkbClientMapPtr		map;
453	XkbIndicatorPtr		indicators;
454	XkbNamesPtr		names;
455	XkbCompatMapPtr		compat;
456	XkbGeometryPtr		geom;
457} XkbDescRec, *XkbDescPtr;
458#define	XkbKeyKeyTypeIndex(d,k,g)	(XkbCMKeyTypeIndex((d)->map,k,g))
459#define	XkbKeyKeyType(d,k,g)		(XkbCMKeyType((d)->map,k,g))
460#define	XkbKeyGroupWidth(d,k,g)		(XkbCMKeyGroupWidth((d)->map,k,g))
461#define	XkbKeyGroupsWidth(d,k)		(XkbCMKeyGroupsWidth((d)->map,k))
462#define	XkbKeyGroupInfo(d,k)		(XkbCMKeyGroupInfo((d)->map,(k)))
463#define	XkbKeyNumGroups(d,k)		(XkbCMKeyNumGroups((d)->map,(k)))
464#define	XkbKeyNumSyms(d,k)		(XkbCMKeyNumSyms((d)->map,(k)))
465#define	XkbKeySymsPtr(d,k)		(XkbCMKeySymsPtr((d)->map,(k)))
466#define	XkbKeySym(d,k,n)		(XkbKeySymsPtr(d,k)[n])
467#define	XkbKeySymEntry(d,k,sl,g) \
468	(XkbKeySym(d,k,((XkbKeyGroupsWidth(d,k)*(g))+(sl))))
469#define	XkbKeyAction(d,k,n) \
470	(XkbKeyHasActions(d,k)?&XkbKeyActionsPtr(d,k)[n]:NULL)
471#define	XkbKeyActionEntry(d,k,sl,g) \
472	(XkbKeyHasActions(d,k)?\
473		XkbKeyAction(d,k,((XkbKeyGroupsWidth(d,k)*(g))+(sl))):NULL)
474
475#define	XkbKeyHasActions(d,k)	((d)->server->key_acts[k]!=0)
476#define	XkbKeyNumActions(d,k)	(XkbKeyHasActions(d,k)?XkbKeyNumSyms(d,k):1)
477#define	XkbKeyActionsPtr(d,k)	(XkbSMKeyActionsPtr((d)->server,k))
478#define	XkbKeycodeInRange(d,k)	(((k)>=(d)->min_key_code)&&\
479				 ((k)<=(d)->max_key_code))
480#define	XkbNumKeys(d)		((d)->max_key_code-(d)->min_key_code+1)
481
482
483	/*
484	 * The following structures can be used to track changes
485	 * to a keyboard device
486	 */
487typedef struct _XkbMapChanges {
488	unsigned short		 changed;
489	KeyCode			 min_key_code;
490	KeyCode			 max_key_code;
491	unsigned char		 first_type;
492	unsigned char		 num_types;
493	KeyCode			 first_key_sym;
494	unsigned char		 num_key_syms;
495	KeyCode			 first_key_act;
496	unsigned char		 num_key_acts;
497	KeyCode			 first_key_behavior;
498	unsigned char		 num_key_behaviors;
499	KeyCode 		 first_key_explicit;
500	unsigned char		 num_key_explicit;
501	KeyCode			 first_modmap_key;
502	unsigned char		 num_modmap_keys;
503	KeyCode			 first_vmodmap_key;
504	unsigned char		 num_vmodmap_keys;
505	unsigned char		 pad;
506	unsigned short		 vmods;
507} XkbMapChangesRec,*XkbMapChangesPtr;
508
509typedef struct _XkbControlsChanges {
510	unsigned int 		 changed_ctrls;
511	unsigned int		 enabled_ctrls_changes;
512	Bool			 num_groups_changed;
513} XkbControlsChangesRec,*XkbControlsChangesPtr;
514
515typedef struct _XkbIndicatorChanges {
516	unsigned int		 state_changes;
517	unsigned int		 map_changes;
518} XkbIndicatorChangesRec,*XkbIndicatorChangesPtr;
519
520typedef struct _XkbNameChanges {
521	unsigned int 		changed;
522	unsigned char		first_type;
523	unsigned char		num_types;
524	unsigned char		first_lvl;
525	unsigned char		num_lvls;
526	unsigned char		num_aliases;
527	unsigned char		num_rg;
528	unsigned char		first_key;
529	unsigned char		num_keys;
530	unsigned short		changed_vmods;
531	unsigned long		changed_indicators;
532	unsigned char		changed_groups;
533} XkbNameChangesRec,*XkbNameChangesPtr;
534
535typedef struct _XkbCompatChanges {
536	unsigned char		changed_groups;
537	unsigned short		first_si;
538	unsigned short		num_si;
539} XkbCompatChangesRec,*XkbCompatChangesPtr;
540
541typedef struct _XkbChanges {
542	unsigned short		 device_spec;
543	unsigned short		 state_changes;
544	XkbMapChangesRec	 map;
545	XkbControlsChangesRec	 ctrls;
546	XkbIndicatorChangesRec	 indicators;
547	XkbNameChangesRec	 names;
548	XkbCompatChangesRec	 compat;
549} XkbChangesRec, *XkbChangesPtr;
550
551	/*
552	 * These data structures are used to construct a keymap from
553	 * a set of components or to list components in the server
554	 * database.
555	 */
556typedef struct _XkbComponentNames {
557	char *			 keymap;
558	char *			 keycodes;
559	char *			 types;
560	char *			 compat;
561	char *			 symbols;
562	char *			 geometry;
563} XkbComponentNamesRec, *XkbComponentNamesPtr;
564
565typedef struct _XkbComponentName {
566	unsigned short		flags;
567	char *			name;
568} XkbComponentNameRec,*XkbComponentNamePtr;
569
570typedef struct _XkbComponentList {
571	int			num_keymaps;
572	int			num_keycodes;
573	int			num_types;
574	int			num_compat;
575	int			num_symbols;
576	int			num_geometry;
577	XkbComponentNamePtr	keymaps;
578	XkbComponentNamePtr 	keycodes;
579	XkbComponentNamePtr	types;
580	XkbComponentNamePtr	compat;
581	XkbComponentNamePtr	symbols;
582	XkbComponentNamePtr	geometry;
583} XkbComponentListRec, *XkbComponentListPtr;
584
585	/*
586	 * The following data structures describe and track changes to a
587	 * non-keyboard extension device
588	 */
589typedef struct _XkbDeviceLedInfo {
590	unsigned short			led_class;
591	unsigned short			led_id;
592	unsigned int			phys_indicators;
593	unsigned int			maps_present;
594	unsigned int			names_present;
595	unsigned int			state;
596	Atom 				names[XkbNumIndicators];
597	XkbIndicatorMapRec		maps[XkbNumIndicators];
598} XkbDeviceLedInfoRec,*XkbDeviceLedInfoPtr;
599
600typedef struct _XkbDeviceInfo {
601	char *			name;
602	Atom			type;
603	unsigned short		device_spec;
604	Bool			has_own_state;
605	unsigned short		supported;
606	unsigned short		unsupported;
607
608	/* btn_acts is an array of num_btn XkbAction entries */
609	unsigned short		num_btns;
610	XkbAction *		btn_acts;
611
612	unsigned short		sz_leds;
613	unsigned short		num_leds;
614	unsigned short		dflt_kbd_fb;
615	unsigned short		dflt_led_fb;
616	/* leds is an array of XkbDeviceLedInfoRec in which
617	   sz_leds entries are allocated and num_leds entries are used */
618	XkbDeviceLedInfoPtr	leds;
619} XkbDeviceInfoRec,*XkbDeviceInfoPtr;
620
621#define	XkbXI_DevHasBtnActs(d)	(((d)->num_btns>0)&&((d)->btn_acts!=NULL))
622#define	XkbXI_LegalDevBtn(d,b)	(XkbXI_DevHasBtnActs(d)&&((b)<(d)->num_btns))
623#define	XkbXI_DevHasLeds(d)	(((d)->num_leds>0)&&((d)->leds!=NULL))
624
625typedef struct _XkbDeviceLedChanges {
626	unsigned short		led_class;
627	unsigned short		led_id;
628	unsigned int		defined; /* names or maps changed */
629	struct _XkbDeviceLedChanges *next;
630} XkbDeviceLedChangesRec,*XkbDeviceLedChangesPtr;
631
632typedef struct _XkbDeviceChanges {
633	unsigned int		changed;
634	unsigned short		first_btn;
635	unsigned short		num_btns;
636	XkbDeviceLedChangesRec 	leds;
637} XkbDeviceChangesRec,*XkbDeviceChangesPtr;
638
639#ifdef __clang__
640#pragma clang diagnostic pop
641#endif
642
643#endif /* _XKBSTR_H_ */
644