1/* 2 3Copyright 1988, 1998 The Open Group 4 5Permission to use, copy, modify, distribute, and sell this software and its 6documentation for any purpose is hereby granted without fee, provided that 7the above copyright notice appear in all copies and that both that 8copyright notice and this permission notice appear in supporting 9documentation. 10 11The above copyright notice and this permission notice shall be included 12in all copies or substantial portions of the Software. 13 14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR 18OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20OTHER DEALINGS IN THE SOFTWARE. 21 22Except as contained in this notice, the name of The Open Group shall 23not be used in advertising or otherwise to promote the sale, use or 24other dealings in this Software without prior written authorization 25from The Open Group. 26 27*/ 28 29#ifndef _WQ_H 30#define _WQ_H 31 32/* 33 * Input is parsed and a work queue is built that is executed later. This 34 * allows us to swap keys as well as ensure that we don't mess up the keyboard 35 * by doing a partial rebind. 36 */ 37 38enum opcode { doKeycode, doAddModifier, doRemoveModifier, doClearModifier, 39 doPointer }; 40 41struct op_generic { 42 enum opcode type; /* oneof enum opcode */ 43 union op *next; /* next element in list or NULL */ 44}; 45 46 47/* 48 * keycode KEYCODE = KEYSYM 49 * keysym OLDKEYSYM = NEWKEYSYM 50 * 51 * want to eval the OLDKEYSYM before executing the work list so that it isn't 52 * effected by any assignments. 53 */ 54 55struct op_keycode { 56 enum opcode type; /* doKeycode */ 57 union op *next; /* next element in list or NULL */ 58 KeyCode target_keycode; /* key to which we are assigning */ 59 int count; /* number of new keysyms */ 60 KeySym *keysyms; /* new values to insert */ 61}; 62 63 64/* 65 * add MODIFIER = KEYSYM ... 66 */ 67 68struct op_addmodifier { 69 enum opcode type; /* doAddModifier */ 70 union op *next; /* next element in list or NULL */ 71 int modifier; /* index into modifier list */ 72 int count; /* number of keysyms */ 73 KeySym *keysyms; /* new values to insert */ 74}; 75 76 77/* 78 * remove MODIFIER = OLDKEYSYM ... 79 * 80 * want to eval the OLDKEYSYM before executing the work list so that it isn't 81 * effected by any assignments. 82 */ 83 84struct op_removemodifier { 85 enum opcode type; /* doRemoveModifier */ 86 union op *next; /* next element in list or NULL */ 87 int modifier; /* index into modifier list */ 88 int count; /* number of keysyms */ 89 KeyCode *keycodes; /* old values to remove */ 90}; 91 92 93/* 94 * clear MODIFIER 95 */ 96 97struct op_clearmodifier { 98 enum opcode type; /* doClearModifier */ 99 union op *next; /* next element in list or NULL */ 100 int modifier; /* index into modifier list */ 101}; 102 103/* 104 * pointer = NUMBER ... 105 * 106 * set pointer map to the positive numbers given on the right hand side 107 */ 108 109#define MAXBUTTONCODES 256 /* there are eight bits of buttons */ 110 111struct op_pointer { 112 enum opcode type; /* doPointer */ 113 union op *next; /* next element in list or NULL */ 114 int count; /* number of new button codes */ 115 unsigned char button_codes[MAXBUTTONCODES]; 116}; 117 118 119/* 120 * all together now 121 */ 122union op { 123 struct op_generic generic; 124 struct op_keycode keycode; 125 struct op_addmodifier addmodifier; 126 struct op_removemodifier removemodifier; 127 struct op_clearmodifier clearmodifier; 128 struct op_pointer pointer; 129}; 130 131extern struct wq { 132 union op *head; 133 union op *tail; 134} work_queue; 135 136 137extern struct modtab { 138 const char *name; 139 int length; 140 int value; 141} modifier_table[]; 142 143#define AllocStruct(s) (malloc (sizeof (s))) 144 145#define MAXKEYSYMNAMESIZE 80 /* absurdly large */ 146 147#endif 148