xmacro-0.3pre-20000911.orig/0040700000076400007640000000000007604112552014404 5ustar inetprivatexmacro-0.3pre-20000911.orig/Makefile0100600000076400007640000000121307157221606016044 0ustar inetprivateVERSION=0.3 all: xmacroplay xmacrorec xmacrorec2 xmacroplay: xmacroplay.cpp chartbl.h g++ -O2 -I/usr/X11R6/include -Wall -pedantic -DVERSION=$(VERSION) xmacroplay.cpp -o xmacroplay -L/usr/X11R6/lib -lXtst -lX11 xmacrorec: xmacrorec.cpp g++ -O2 -I/usr/X11R6/include -Wall -pedantic -DVERSION=$(VERSION) xmacrorec.cpp -o xmacrorec -L/usr/X11R6/lib -lXtst -lX11 xmacrorec2: xmacrorec2.cpp g++ -O2 -I/usr/X11R6/include -Wall -pedantic -DVERSION=$(VERSION) xmacrorec2.cpp -o xmacrorec2 -L/usr/X11R6/lib -lXtst -lX11 clean: rm xmacrorec xmacroplay xmacrorec2 deb: umask 022 && epm -f deb -nsm xmacro rpm: umask 022 && epm -f rpm -nsm xmacro xmacro-0.3pre-20000911.orig/COPYING0100600000076400007640000004310507155252703015445 0ustar inetprivate GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. xmacro-0.3pre-20000911.orig/chartbl.h0100600000076400007640000002604707155252703016210 0ustar inetprivate/***************************************************************************** * * chartbl.h is a character table for the xmacroplay utility * Copyright (C) 2000 Gabor Keresztfalvi * * Contains character to keysym name conversion tables. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ****************************************************************************/ /* Version 0.1 (20000817) probably still incomplete... */ char *chartbl_lat1[] = { "", // 0 0 "", // 1 1 "", // 2 2 "", // 3 3 "", // 4 4 "", // 5 5 "", // 6 6 "", // 7 7 "BackSpace", // 8 8 "Tab", // 9 9 "", // 10 A "", // 11 B "", // 12 C "Return", // 13 D "", // 14 E "", // 15 F "", // 16 10 "", // 17 11 "", // 18 12 "", // 19 13 "", // 20 14 "", // 21 15 "", // 22 16 "", // 23 17 "", // 24 18 "", // 25 19 "", // 26 1A "Escape", // 27 1B "", // 28 1C "", // 29 1D "", // 30 1E "", // 31 1F "space", // 32 20 "exclam", // 33 21 "quotedbl", // 34 22 "numbersign", // 35 23 "dollar", // 36 24 "percent", // 37 25 "ampersand", // 38 26 "apostrophe", // 39 27 "parenleft", // 40 28 "parenright", // 41 29 "asterisk", // 42 2A "plus", // 43 2B "comma", // 44 2C "minus", // 45 2D "period", // 46 2E "slash", // 47 2F "0", // 48 30 "1", // 49 31 "2", // 50 32 "3", // 51 33 "4", // 52 34 "5", // 53 35 "6", // 54 36 "7", // 55 37 "8", // 56 38 "9", // 57 39 "colon", // 58 3A "semicolon", // 59 3B "less", // 60 3C "equal", // 61 3D "greater", // 62 3E "question", // 63 3F "at", // 64 40 "A", // 65 41 "B", // 66 42 "C", // 67 43 "D", // 68 44 "E", // 69 45 "F", // 70 46 "G", // 71 47 "H", // 72 48 "I", // 73 49 "J", // 74 4A "K", // 75 4B "L", // 76 4C "M", // 77 4D "N", // 78 4E "O", // 79 4F "P", // 80 50 "Q", // 81 51 "R", // 82 52 "S", // 83 53 "T", // 84 54 "U", // 85 55 "V", // 86 56 "W", // 87 57 "X", // 88 58 "Y", // 89 59 "Z", // 90 5A "bracketleft", // 91 5B "backslash", // 92 5C "bracketright", // 93 5D "asciicircum", // 94 5E "underscore", // 95 5F "grave", // 96 60 "a", // 97 61 "b", // 98 62 "c", // 99 63 "d", // 100 64 "e", // 101 65 "f", // 102 66 "g", // 103 67 "h", // 104 68 "i", // 105 69 "j", // 106 6A "k", // 107 6B "l", // 108 6C "m", // 109 6D "n", // 110 6E "o", // 111 6F "p", // 112 70 "q", // 113 71 "r", // 114 72 "s", // 115 73 "t", // 116 74 "u", // 117 75 "v", // 118 76 "w", // 119 77 "x", // 120 78 "y", // 121 79 "z", // 122 7A "braceleft", // 123 7B "bar", // 124 7C "braceright", // 125 7D "asciitilde", // 126 7E "Delete", // 127 7F "", // 128 80 "", // 129 81 "", // 130 82 "", // 131 83 "", // 132 84 "", // 133 85 "", // 134 86 "", // 135 87 "", // 136 88 "", // 137 89 "", // 138 8A "", // 139 8B "", // 140 8C "", // 141 8D "", // 142 8E "", // 143 8F "", // 144 90 "", // 145 91 "", // 146 92 "", // 147 93 "", // 148 94 "", // 149 95 "", // 150 96 "", // 151 97 "", // 152 98 "", // 153 99 "", // 154 9A "", // 155 9B "", // 156 9C "", // 157 9D "", // 158 9E "", // 159 9F "nobreakspace", // 160 A0 "exclamdown", // 161 A1 "cent", // 162 A2 "sterling", // 163 A3 "currency", // 164 A4 "yen", // 165 A5 "brokenbar", // 166 A6 "section", // 167 A7 "diaeresis", // 168 A8 "copyright", // 169 A9 "ordfeminine", // 170 AA "guillemotleft",// 171 AB "notsign", // 172 AC "hyphen", // 173 AD "registered", // 174 AE "macron", // 175 AF "degree", // 176 B0 "plusminus", // 177 B1 "twosuperior", // 178 B2 "threesuperior",// 179 B3 "acute", // 180 B4 "mu", // 181 B5 "paragraph", // 182 B6 "periodcentered",// 183 B7 "cedilla", // 184 B8 "onesuperior", // 185 B9 "masculine", // 186 BA "guillemotright",// 187 BB "onequarter", // 188 BC "onehalf", // 189 BD "threequarters",// 190 BE "questiondown", // 191 BF "Agrave", // 192 C0 "Aacute", // 193 C1 "Acircumflex", // 194 C2 "Atilde", // 195 C3 "Adiaeresis", // 196 C4 "Aring", // 197 C5 "AE", // 198 C6 "Ccedilla", // 199 C7 "Egrave", // 200 C8 "Eacute", // 201 C9 "Ecircumflex", // 202 CA "Ediaeresis", // 203 CB "Igrave", // 204 CC "Iacute", // 205 CD "Icircumflex", // 206 CE "Idiaeresis", // 207 CF "ETH", // 208 D0 "Ntilde", // 209 D1 "Ograve", // 210 D2 "Oacute", // 211 D3 "Ocircumflex", // 212 D4 "Otilde", // 213 D5 "Odiaeresis", // 214 D6 "multiply", // 215 D7 "Ooblique", // 216 D8 "Ugrave", // 217 D9 "Uacute", // 218 DA "Ucircumflex", // 219 DB "Udiaeresis", // 220 DC "Yacute", // 221 DD "THORN", // 222 DE "ssharp", // 223 DF "agrave", // 224 E0 "aacute", // 225 E1 "acircumflex", // 226 E2 "atilde", // 227 E3 "adiaeresis", // 228 E4 "aring", // 229 E5 "ae", // 230 E6 "ccedilla", // 231 E7 "egrave", // 232 E8 "eacute", // 233 E9 "ecircumflex", // 234 EA "ediaeresis", // 235 EB "igrave", // 236 EC "iacute", // 237 ED "icircumflex", // 238 EE "idiaeresis", // 239 EF "eth", // 240 F0 "ntilde", // 241 F1 "ograve", // 242 F2 "oacute", // 243 F3 "ocircumflex", // 244 F4 "otilde", // 245 F5 "odiaeresis", // 246 F6 "division", // 247 F7 "oslash", // 248 F8 "ugrave", // 249 F9 "uacute", // 250 FA "ucircumflex", // 251 FB "udiaeresis", // 252 FC "yacute", // 253 FD "thorn", // 254 FE "ydiaeresis", // 255 FF }; char *chartbl_lat2[] = { "", // 0 0 "", // 1 1 "", // 2 2 "", // 3 3 "", // 4 4 "", // 5 5 "", // 6 6 "", // 7 7 "BackSpace", // 8 8 "Tab", // 9 9 "", // 10 A "", // 11 B "", // 12 C "Return", // 13 D "", // 14 E "", // 15 F "", // 16 10 "", // 17 11 "", // 18 12 "", // 19 13 "", // 20 14 "", // 21 15 "", // 22 16 "", // 23 17 "", // 24 18 "", // 25 19 "", // 26 1A "Escape", // 27 1B "", // 28 1C "", // 29 1D "", // 30 1E "", // 31 1F "space", // 32 20 "exclam", // 33 21 "quotedbl", // 34 22 "numbersign", // 35 23 "dollar", // 36 24 "percent", // 37 25 "ampersand", // 38 26 "apostrophe", // 39 27 "parenleft", // 40 28 "parenright", // 41 29 "asterisk", // 42 2A "plus", // 43 2B "comma", // 44 2C "minus", // 45 2D "period", // 46 2E "slash", // 47 2F "0", // 48 30 "1", // 49 31 "2", // 50 32 "3", // 51 33 "4", // 52 34 "5", // 53 35 "6", // 54 36 "7", // 55 37 "8", // 56 38 "9", // 57 39 "colon", // 58 3A "semicolon", // 59 3B "less", // 60 3C "equal", // 61 3D "greater", // 62 3E "question", // 63 3F "at", // 64 40 "A", // 65 41 "B", // 66 42 "C", // 67 43 "D", // 68 44 "E", // 69 45 "F", // 70 46 "G", // 71 47 "H", // 72 48 "I", // 73 49 "J", // 74 4A "K", // 75 4B "L", // 76 4C "M", // 77 4D "N", // 78 4E "O", // 79 4F "P", // 80 50 "Q", // 81 51 "R", // 82 52 "S", // 83 53 "T", // 84 54 "U", // 85 55 "V", // 86 56 "W", // 87 57 "X", // 88 58 "Y", // 89 59 "Z", // 90 5A "bracketleft", // 91 5B "backslash", // 92 5C "bracketright", // 93 5D "asciicircum", // 94 5E "underscore", // 95 5F "grave", // 96 60 "a", // 97 61 "b", // 98 62 "c", // 99 63 "d", // 100 64 "e", // 101 65 "f", // 102 66 "g", // 103 67 "h", // 104 68 "i", // 105 69 "j", // 106 6A "k", // 107 6B "l", // 108 6C "m", // 109 6D "n", // 110 6E "o", // 111 6F "p", // 112 70 "q", // 113 71 "r", // 114 72 "s", // 115 73 "t", // 116 74 "u", // 117 75 "v", // 118 76 "w", // 119 77 "x", // 120 78 "y", // 121 79 "z", // 122 7A "braceleft", // 123 7B "bar", // 124 7C "braceright", // 125 7D "asciitilde", // 126 7E "Delete", // 127 7F "", // 128 80 "", // 129 81 "", // 130 82 "", // 131 83 "", // 132 84 "", // 133 85 "", // 134 86 "", // 135 87 "", // 136 88 "", // 137 89 "", // 138 8A "", // 139 8B "", // 140 8C "", // 141 8D "", // 142 8E "", // 143 8F "", // 144 90 "", // 145 91 "", // 146 92 "", // 147 93 "", // 148 94 "", // 149 95 "", // 150 96 "", // 151 97 "", // 152 98 "", // 153 99 "", // 154 9A "", // 155 9B "", // 156 9C "", // 157 9D "", // 158 9E "", // 159 9F "nobreakspace", // 160 A0 "Aogonek", // 161 A1 "breve", // 162 A2 "Lstroke", // 163 A3 "currency", // 164 A4 "Lcaron", // 165 A5 "Sacute", // 166 A6 "section", // 167 A7 "diaeresis", // 168 A8 "Scaron", // 169 A9 "Scedilla", // 170 AA "Tcaron", // 171 AB "Zacute", // 172 AC "hyphen", // 173 AD "Zcaron", // 174 AE "Zabovedot", // 175 AF "degree", // 176 B0 "aogonek", // 177 B1 "ogonek", // 178 B2 "lstroke", // 179 B3 "acute", // 180 B4 "lcaron", // 181 B5 "sacute", // 182 B6 "caron", // 183 B7 "cedilla", // 184 B8 "scaron", // 185 B9 "scedilla", // 186 BA "tcaron", // 187 BB "zacute", // 188 BC "doubleacute", // 189 BD "zcaron", // 190 BE "zabovedot", // 191 BF "Racute", // 192 C0 "Aacute", // 193 C1 "Acircumflex", // 194 C2 "Abreve", // 195 C3 "Adiaeresis", // 196 C4 "Lacute", // 197 C5 "Cacute", // 198 C6 "Ccedilla", // 199 C7 "Ccaron", // 200 C8 "Eacute", // 201 C9 "Eogonek", // 202 CA "Ediaeresis", // 203 CB "Ecaron", // 204 CC "Iacute", // 205 CD "Icircumflex", // 206 CE "Dacron", // 207 CF "Dstroke", // 208 D0 "Nacute", // 209 D1 "Ncaron", // 210 D2 "Oacute", // 211 D3 "Ocircumflex", // 212 D4 "Odoubleacute", // 213 D5 "Odiaeresis", // 214 D6 "multiply", // 215 D7 "Rcaron", // 216 D8 "Uring", // 217 D9 "Uacute", // 218 DA "Udoubleacute", // 219 DB "Udiaeresis", // 220 DC "Yacute", // 221 DD "Tcedilla", // 222 DE "ssharp", // 223 DF "racute", // 224 E0 "aacute", // 225 E1 "acircumflex", // 226 E2 "abreve", // 227 E3 "adiaeresis", // 228 E4 "lacute", // 229 E5 "cacute", // 230 E6 "ccedilla", // 231 E7 "ccaron", // 232 E8 "eacute", // 233 E9 "eogonek", // 234 EA "ediaeresis", // 235 EB "ecaron", // 236 EC "iacute", // 237 ED "icircumflex", // 238 EE "dcaron", // 239 EF "dstroke", // 240 F0 "nacute", // 241 F1 "ncaron", // 242 F2 "oacute", // 243 F3 "ocircumflex", // 244 F4 "odoubleacute", // 245 F5 "odiaeresis", // 246 F6 "division", // 247 F7 "rcaron", // 248 F8 "uring", // 249 F9 "uacute", // 250 FA "udoubleacute", // 251 FB "udiaeresis", // 252 FC "yacute", // 253 FD "tcedilla", // 254 FE "abovedot", // 255 FF }; char **chartbl[]={ chartbl_lat1, chartbl_lat2 }; xmacro-0.3pre-20000911.orig/README0100600000076400007640000000546007155252703015274 0ustar inetprivatexmacrorec: Grabs all the control over your local display and send the mouse and keyboard events to the remote display. In the meantime it emits KeyStrPress, KeyStrRelease, ButtonPress and ButtonRelease lines to the standard output. It emits MotionNotify lines only if the event struct of the above four events contains different coordinates than the previous event or a mouse button is pressed during the movement. Note: As xmacrorec doesn't save the timestamp of the event, you may need to insert Delay statements into the recorded file! xmacroplay: Reads lines from the standard input. It can understand the following lines: Delay - delays the program with secundums ButtonPress - sends a ButtonPress event with button this emulates the pressing of the mouse button ButtonRelease - sends a ButtonRelease event with button this emulates the releaseing of the mouse button MotionNotify - sends a MotionNotify event this emulates the movment of the mouse KeyCodePress - sends a KeyPress event with the keycode in this case you must know the keycodes of the remote server KeyCodeRelease - sends a KeyRelease event with the keycode in this case you must know the keycodes of the remote server KeySymPress - sends a KeyPress event with the keysym converted to the appropriate keycode on the remote server KeySymRelease - sends a KeyRelease event with the keysym converted to the appropriate keycode on the remote server KeySym - send both KeyPress and KeyRelease events with the keysym converted to the appropriate keycode on the remote server KeyStrPress - sends a KeyPress event with the keysym name converted to the appropriate keycode on the remote server; standard KeySym names are obtained from by removing the XK_ prefix from each name. KeyStrRelease - sends a KeyRelease event with the keysym name converted to the appropriate keycode on the remote server; standard KeySym names are obtained from by removing the XK_ prefix from each name. KeyStr - sends both KeyPress and KeyRelease events with the keysym name converted to the appropriate keycode on the remote server; standard KeySym names are obtained from by removing the XK_ prefix from each name. String - Sends the string as single characters converted to KeyPress and KeyRelease events based on a character table in chartbl.h (currently only Latin1 is used...) The 'run' script is provided as an example to use the xmacrorec and xmacroplay utilities in a virtual frame buffer X server. You may need to modify the script... xmacro-0.3pre-20000911.orig/example/0040700000076400007640000000000007155252773016052 5ustar inetprivatexmacro-0.3pre-20000911.orig/example/test.icewm0100600000076400007640000000062407155252703020051 0ustar inetprivateMotionNotify 32 581 ButtonPress 1 MotionNotify 31 581 ButtonRelease 1 MotionNotify 32 581 KeyStrPress r KeyStrRelease r KeyStrPress Return KeyStrRelease Return Delay 1 KeyStrPress l KeyStrRelease l KeyStrPress s KeyStrRelease s KeyStrPress space KeyStrRelease space KeyStrPress minus KeyStrRelease minus KeyStrPress a KeyStrRelease a KeyStrPress l KeyStrRelease l KeyStrPress Return KeyStrRelease Return xmacro-0.3pre-20000911.orig/run0100700000076400007640000000161107155252703015136 0ustar inetprivatemydisp=:5.0 if [ $# -lt 1 ] then echo 'Usage: run ' exit fi case $1 in startvfb) Xvfb $mydisp -fbdir /tmp -screen 0 800x600x8 & # Xvfb $mydisp -fbdir /tmp -screen 0 1024x768x8 & icewm -display $mydisp & # xmodmap -display $mydisp /usr/X11R6/lib/X11/xmodmap.std # /home/keresztg/X/swm-1.0a/usr/X11R6/bin/swm -display $mydisp & ;; stopvfb) killall Xvfb ;; rec) if [ $# != 2 ] then echo 'Usage: run rec ' exit fi (xv -geometry +0+0 -nodecor -wait 2 -wloop /tmp/Xvfb_screen0 &) ; ./xmacrorec -k 110 $mydisp > $2 ;; play) if [ $# != 2 ] then echo 'Usage: run play ' exit fi ./xmacroplay $mydisp < $2 ;; look) xv -geometry +0+0 -nodecor -wait 2 -wloop /tmp/Xvfb_screen0 ;; control) (xv -geometry +0+0 -nodecor -wait 2 -wloop /tmp/Xvfb_screen0 &) ; ./xmacrorec -k 110 $mydisp ;; esac xmacro-0.3pre-20000911.orig/xmacroplay.cpp0100600000076400007640000003551407157221607017303 0ustar inetprivate/***************************************************************************** * * xmacroplay - a utility for playing X mouse and key events. * Portions Copyright (C) 2000 Gabor Keresztfalvi * * The recorded events are read from the standard input. * * This program is heavily based on * xremote (http://infa.abo.fi/~chakie/xremote/) which is: * Copyright (C) 2000 Jan Ekholm * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ****************************************************************************/ /***************************************************************************** * Do we have config.h? ****************************************************************************/ #ifdef HAVE_CONFIG #include "config.h" #endif /***************************************************************************** * Includes ****************************************************************************/ #include #include #include #include #include #include #include #include #include #include #include #include "chartbl.h" /***************************************************************************** * What iostream do we have? ****************************************************************************/ #ifdef HAVE_IOSTREAM #include #include #else #include #include #endif #define PROG "xmacroplay" /***************************************************************************** * The delay in milliseconds when sending events to the remote display ****************************************************************************/ const int DefaultDelay = 10; /***************************************************************************** * The multiplier used fot scaling coordinates before sending them to the * remote display. By default we don't scale at all ****************************************************************************/ const float DefaultScale = 1.0; /***************************************************************************** * Globals... ****************************************************************************/ int Delay = DefaultDelay; float Scale = DefaultScale; char * Remote; /****************************************************************************/ /*! Prints the usage, i.e. how the program is used. Exits the application with the passed exit-code. \arg const int ExitCode - the exitcode to use for exiting. */ /****************************************************************************/ void usage (const int exitCode) { // print the usage cerr << PROG << " " << VERSION << endl; cerr << "Usage: " << PROG << " [options] remote_display" << endl; cerr << "Options: " << endl; cerr << " -d DELAY delay in milliseconds for events sent to remote display." << endl << " Default: 10ms." << endl << " -s FACTOR scalefactor for coordinates. Default: 1.0." << endl << " -v show version. " << endl << " -h this help. " << endl << endl; // we're done exit ( EXIT_SUCCESS ); } /****************************************************************************/ /*! Prints the version of the application and exits. */ /****************************************************************************/ void version () { // print the version cerr << PROG << " " << VERSION << endl; // we're done exit ( EXIT_SUCCESS ); } /****************************************************************************/ /*! Parses the commandline and stores all data in globals (shudder). Exits the application with a failed exitcode if a parameter is illegal. \arg int argc - number of commandline arguments. \arg char * argv[] - vector of the commandline argument strings. */ /****************************************************************************/ void parseCommandLine (int argc, char * argv[]) { int Index = 1; // check the number of arguments if ( argc < 2 ) { // oops, too few arguments, go away usage ( EXIT_FAILURE ); } // loop through all arguments except the last, which is assumed to be the // name of the display while ( Index < argc ) { // is this '-v'? if ( strcmp (argv[Index], "-v" ) == 0 ) { // yep, show version and exit version (); } // is this '-h'? if ( strcmp (argv[Index], "-h" ) == 0 ) { // yep, show usage and exit usage ( EXIT_SUCCESS ); } // is this '-d'? else if ( strcmp (argv[Index], "-d" ) == 0 && Index + 1 < argc ) { // yep, and there seems to be a parameter too, interpret it as a // number if ( sscanf ( argv[Index + 1], "%d", &Delay ) != 1 ) { // oops, not a valid intereger cerr << "Invalid parameter for '-d'." << endl; usage ( EXIT_FAILURE ); } Index++; } // is this '-s'? else if ( strcmp (argv[Index], "-s" ) == 0 && Index + 1 < argc ) { // yep, and there seems to be a parameter too, interpret it as a // floating point number if ( sscanf ( argv[Index + 1], "%f", &Scale ) != 1 ) { // oops, not a valid intereger cerr << "Invalid parameter for '-s'." << endl; usage ( EXIT_FAILURE ); } Index++; } // is this the last parameter? else if ( Index == argc - 1 ) { // yep, we assume it's the display, store it Remote = argv [ Index ]; } else { // we got this far, the parameter is no good... cerr << "Invalid parameter '" << argv[Index] << "'." << endl; usage ( EXIT_FAILURE ); } // next value Index++; } } /****************************************************************************/ /*! Connects to the desired display. Returns the \c Display or \c 0 if no display could be obtained. \arg const char * DisplayName - name of the remote display. */ /****************************************************************************/ Display * remoteDisplay (const char * DisplayName) { int Event, Error; int Major, Minor; // open the display Display * D = XOpenDisplay ( DisplayName ); // did we get it? if ( ! D ) { // nope, so show error and abort cerr << PROG << ": could not open display \"" << XDisplayName ( DisplayName ) << "\", aborting." << endl; exit ( EXIT_FAILURE ); } // does the remote display have the Xtest-extension? if ( ! XTestQueryExtension (D, &Event, &Error, &Major, &Minor ) ) { // nope, extension not supported cerr << PROG << ": XTest extension not supported on server \"" << DisplayString(D) << "\"" << endl; // close the display and go away XCloseDisplay ( D ); exit ( EXIT_FAILURE ); } // print some information cerr << "XTest for server \"" << DisplayString(D) << "\" is version " << Major << "." << Minor << "." << endl << endl;; // execute requests even if server is grabbed XTestGrabControl ( D, True ); // sync the server XSync ( D,True ); // return the display return D; } /****************************************************************************/ /*! Scales the passed coordinate with the given saling factor. the factor is either given as a commandline argument or it is 1.0. */ /****************************************************************************/ int scale (const int Coordinate) { // perform the scaling, all in one ugly line return (int)( (float)Coordinate * Scale ); } /****************************************************************************/ /*! Sends a \a character to the remote display \a RemoteDpy. The character is converted to a \c KeySym based on a character table and then reconverted to a \c KeyCode on the remote display. Seems to work quite ok, apart from something weird with the Alt key. \arg Display * RemoteDpy - used display. \arg char c - character to send. */ /****************************************************************************/ void sendChar(Display *RemoteDpy, char c) { KeySym ks, sks, *kss, ksl, ksu; KeyCode kc, skc; int syms; #ifdef DEBUG int i; #endif sks=XK_Shift_L; ks=XStringToKeysym(chartbl[0][(unsigned char)c]); if ( ( kc = XKeysymToKeycode ( RemoteDpy, ks ) ) == 0 ) { cerr << "No keycode on remote display found for char: " << c << endl; return; } if ( ( skc = XKeysymToKeycode ( RemoteDpy, sks ) ) == 0 ) { cerr << "No keycode on remote display found for XK_Shift_L!" << endl; return; } kss=XGetKeyboardMapping(RemoteDpy, kc, 1, &syms); if (!kss) { cerr << "XGetKeyboardMapping failed on the remote display (keycode: " << kc << ")" << endl; return; } for (; syms && (!kss[syms-1]); syms--); if (!syms) { cerr << "XGetKeyboardMapping failed on the remote display (no syms) (keycode: " << kc << ")" << endl; XFree(kss); return; } XConvertCase(ks,&ksl,&ksu); #ifdef DEBUG cout << "kss: "; for (i=0; i> ev; if (ev[0]=='#') { cout << "Comment: " << ev << endl; continue; } if (!strcasecmp("Delay",ev)) { cin >> b; cout << "Delay: " << b << endl; sleep ( b ); } else if (!strcasecmp("ButtonPress",ev)) { cin >> b; cout << "ButtonPress: " << b << endl; XTestFakeButtonEvent ( RemoteDpy, b, True, Delay ); } else if (!strcasecmp("ButtonRelease",ev)) { cin >> b; cout << "ButtonRelease: " << b << endl; XTestFakeButtonEvent ( RemoteDpy, b, False, Delay ); } else if (!strcasecmp("MotionNotify",ev)) { cin >> x >> y; cout << "MotionNotify: " << x << " " << y << endl; XTestFakeMotionEvent ( RemoteDpy, RemoteScreen , scale ( x ), scale ( y ), Delay ); } else if (!strcasecmp("KeyCodePress",ev)) { cin >> kc; cout << "KeyPress: " << kc << endl; XTestFakeKeyEvent ( RemoteDpy, kc, True, Delay ); } else if (!strcasecmp("KeyCodeRelease",ev)) { cin >> kc; cout << "KeyRelease: " << kc << endl; XTestFakeKeyEvent ( RemoteDpy, kc, False, Delay ); } else if (!strcasecmp("KeySym",ev)) { cin >> ks; cout << "KeySym: " << ks << endl; if ( ( kc = XKeysymToKeycode ( RemoteDpy, ks ) ) == 0 ) { cerr << "No keycode on remote display found for keysym: " << ks << endl; continue; } XTestFakeKeyEvent ( RemoteDpy, kc, True, Delay ); XFlush ( RemoteDpy ); XTestFakeKeyEvent ( RemoteDpy, kc, False, Delay ); } else if (!strcasecmp("KeySymPress",ev)) { cin >> ks; cout << "KeySymPress: " << ks << endl; if ( ( kc = XKeysymToKeycode ( RemoteDpy, ks ) ) == 0 ) { cerr << "No keycode on remote display found for keysym: " << ks << endl; continue; } XTestFakeKeyEvent ( RemoteDpy, kc, True, Delay ); } else if (!strcasecmp("KeySymRelease",ev)) { cin >> ks; cout << "KeySymRelease: " << ks << endl; if ( ( kc = XKeysymToKeycode ( RemoteDpy, ks ) ) == 0 ) { cerr << "No keycode on remote display found for keysym: " << ks << endl; continue; } XTestFakeKeyEvent ( RemoteDpy, kc, False, Delay ); } else if (!strcasecmp("KeyStr",ev)) { cin >> ev; cout << "KeyStr: " << ev << endl; ks=XStringToKeysym(ev); if ( ( kc = XKeysymToKeycode ( RemoteDpy, ks ) ) == 0 ) { cerr << "No keycode on remote display found for '" << ev << "': " << ks << endl; continue; } XTestFakeKeyEvent ( RemoteDpy, kc, True, Delay ); XFlush ( RemoteDpy ); XTestFakeKeyEvent ( RemoteDpy, kc, False, Delay ); } else if (!strcasecmp("KeyStrPress",ev)) { cin >> ev; cout << "KeyStrPress: " << ev << endl; ks=XStringToKeysym(ev); if ( ( kc = XKeysymToKeycode ( RemoteDpy, ks ) ) == 0 ) { cerr << "No keycode on remote display found for '" << ev << "': " << ks << endl; continue; } XTestFakeKeyEvent ( RemoteDpy, kc, True, Delay ); } else if (!strcasecmp("KeyStrRelease",ev)) { cin >> ev; cout << "KeyStrRelease: " << ev << endl; ks=XStringToKeysym(ev); if ( ( kc = XKeysymToKeycode ( RemoteDpy, ks ) ) == 0 ) { cerr << "No keycode on remote display found for '" << ev << "': " << ks << endl; continue; } XTestFakeKeyEvent ( RemoteDpy, kc, False, Delay ); } else if (!strcasecmp("String",ev)) { cin.ignore().get(str,1024); cout << "String: " << str << endl; b=0; while(str[b]) sendChar(RemoteDpy, str[b++]); } else if (ev[0]!=0) cout << "Unknown tag: " << ev << endl; // sync the remote server XFlush ( RemoteDpy ); } } /****************************************************************************/ /*! Main function of the application. It expects no commandline arguments. \arg int argc - number of commandline arguments. \arg char * argv[] - vector of the commandline argument strings. */ /****************************************************************************/ int main (int argc, char * argv[]) { // parse commandline arguments parseCommandLine ( argc, argv ); // open the remote display or abort Display * RemoteDpy = remoteDisplay ( Remote ); // get the screens too int RemoteScreen = DefaultScreen ( RemoteDpy ); XTestDiscard ( RemoteDpy ); // start the main event loop eventLoop ( RemoteDpy, RemoteScreen ); // discard and even flush all events on the remote display XTestDiscard ( RemoteDpy ); XFlush ( RemoteDpy ); // we're done with the display XCloseDisplay ( RemoteDpy ); cerr << PROG << ": pointer and keyboard released. " << endl; // go away exit ( EXIT_SUCCESS ); } xmacro-0.3pre-20000911.orig/xmacrorec.cpp0100600000076400007640000005542107155252703017105 0ustar inetprivate/***************************************************************************** * * xmacrorec - a utility for recording X mouse and key events. * Portions Copyright (C) 2000 Gabor Keresztfalvi * * The recorded events are emitted to the standard output and can be played * with the xmacroplay utility. * * This program is heavily based on * xremote (http://infa.abo.fi/~chakie/xremote/) which is: * Copyright (C) 2000 Jan Ekholm * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ****************************************************************************/ /***************************************************************************** * Do we have config.h? ****************************************************************************/ #ifdef HAVE_CONFIG #include "config.h" #endif /***************************************************************************** * Includes ****************************************************************************/ #include #include #include #include #include #include #include #include #include /***************************************************************************** * What iostream do we have? ****************************************************************************/ #ifdef HAVE_IOSTREAM #include #include #else #include #include #endif #define PROG "xmacrorec" /***************************************************************************** * The delay in milliseconds when sending events to the remote display ****************************************************************************/ const int DefaultDelay = 10; /***************************************************************************** * The multiplier used fot scaling coordinates before sending them to the * remote display. By default we don't scale at all ****************************************************************************/ const float DefaultScale = 1.0; /***************************************************************************** * Globals... ****************************************************************************/ int Delay = DefaultDelay; float Scale = DefaultScale; char * Remote; /***************************************************************************** * Key used for quitting the application. ****************************************************************************/ unsigned int QuitKey; bool HasQuitKey = false; /****************************************************************************/ /*! Prints the usage, i.e. how the program is used. Exits the application with the passed exit-code. \arg const int ExitCode - the exitcode to use for exiting. */ /****************************************************************************/ void usage (const int exitCode) { // print the usage cerr << PROG << " " << VERSION << endl; cerr << "Usage: " << PROG << " [options] remote_display" << endl; cerr << "Options: " << endl; cerr << " -d DELAY delay in milliseconds for events sent to remote display." << endl << " Default: 10ms." << endl << " -s FACTOR scalefactor for coordinates. Default: 1.0." << endl << " -k KEYCODE the keycode for the key used for quitting." << endl << " -v show version. " << endl << " -h this help. " << endl << endl; // we're done exit ( EXIT_SUCCESS ); } /****************************************************************************/ /*! Prints the version of the application and exits. */ /****************************************************************************/ void version () { // print the version cerr << PROG << " " << VERSION << endl; // we're done exit ( EXIT_SUCCESS ); } /****************************************************************************/ /*! Parses the commandline and stores all data in globals (shudder). Exits the application with a failed exitcode if a parameter is illegal. \arg int argc - number of commandline arguments. \arg char * argv[] - vector of the commandline argument strings. */ /****************************************************************************/ void parseCommandLine (int argc, char * argv[]) { int Index = 1; // check the number of arguments if ( argc < 2 ) { // oops, too few arguments, go away usage ( EXIT_FAILURE ); } // loop through all arguments except the last, which is assumed to be the // name of the display while ( Index < argc ) { // is this '-v'? if ( strcmp (argv[Index], "-v" ) == 0 ) { // yep, show version and exit version (); } // is this '-h'? if ( strcmp (argv[Index], "-h" ) == 0 ) { // yep, show usage and exit usage ( EXIT_SUCCESS ); } // is this '-d'? else if ( strcmp (argv[Index], "-d" ) == 0 && Index + 1 < argc ) { // yep, and there seems to be a parameter too, interpret it as a // number if ( sscanf ( argv[Index + 1], "%d", &Delay ) != 1 ) { // oops, not a valid intereger cerr << "Invalid parameter for '-d'." << endl; usage ( EXIT_FAILURE ); } Index++; } // is this '-s'? else if ( strcmp (argv[Index], "-s" ) == 0 && Index + 1 < argc ) { // yep, and there seems to be a parameter too, interpret it as a // floating point number if ( sscanf ( argv[Index + 1], "%f", &Scale ) != 1 ) { // oops, not a valid intereger cerr << "Invalid parameter for '-s'." << endl; usage ( EXIT_FAILURE ); } Index++; } // is this '-k'? else if ( strcmp (argv[Index], "-k" ) == 0 && Index + 1 < argc ) { // yep, and there seems to be a parameter too, interpret it as a // number if ( sscanf ( argv[Index + 1], "%d", &QuitKey ) != 1 ) { // oops, not a valid integer cerr << "Invalid parameter for '-k'." << QuitKey << endl; usage ( EXIT_FAILURE ); } // now we have a key for quitting HasQuitKey = true; Index++; } // is this the last parameter? else if ( Index == argc - 1 ) { // yep, we assume it's the display, store it Remote = argv [ Index ]; } else { // we got this far, the parameter is no good... cerr << "Invalid parameter '" << argv[Index] << "'." << endl; usage ( EXIT_FAILURE ); } // next value Index++; } } /****************************************************************************/ /*! Connects to the local display. Returns the \c Display or \c 0 if no display could be obtained. */ /****************************************************************************/ Display * localDisplay () { // open the display Display * D = XOpenDisplay ( 0 ); // did we get it? if ( ! D ) { // nope, so show error and abort cerr << PROG << ": could not open display \"" << XDisplayName ( 0 ) << "\", aborting." << endl; exit ( EXIT_FAILURE ); } // return the display return D; } /****************************************************************************/ /*! Connects to the desired display. Returns the \c Display or \c 0 if no display could be obtained. \arg const char * DisplayName - name of the remote display. */ /****************************************************************************/ Display * remoteDisplay (const char * DisplayName) { int Event, Error; int Major, Minor; // open the display Display * D = XOpenDisplay ( DisplayName ); // did we get it? if ( ! D ) { // nope, so show error and abort cerr << PROG << ": could not open display \"" << XDisplayName ( DisplayName ) << "\", aborting." << endl; exit ( EXIT_FAILURE ); } // does the remote display have the Xtest-extension? if ( ! XTestQueryExtension (D, &Event, &Error, &Major, &Minor ) ) { // nope, extension not supported cerr << PROG << ": XTest extension not supported on server \"" << DisplayString(D) << "\"" << endl; // close the display and go away XCloseDisplay ( D ); exit ( EXIT_FAILURE ); } // print some information cerr << "XTest for server \"" << DisplayString(D) << "\" is version " << Major << "." << Minor << "." << endl << endl;; // execute requests even if server is grabbed XTestGrabControl ( D, True ); // sync the server XSync ( D,True ); // return the display return D; } /****************************************************************************/ /*! Function that finds out the key the user wishes to use for quitting the application. This must be configurable, as a suitable key is not always possible to determine in advance. By letting the user pick a key one that does not interfere with the needed applications can be chosen. The function grabs the keyboard and waits for a key to be pressed. Returns the keycode of the pressed key. \arg Display * Dpy - used display. \arg int Screen - the used screen. */ /****************************************************************************/ int findQuitKey (Display * Dpy, int Screen) { XEvent Event; XKeyEvent EKey; Window Target, Root; bool Loop = true; int Error; // get the root window and set default target Root = RootWindow ( Dpy, Screen ); Target = None; // grab the keyboard Error = XGrabKeyboard ( Dpy, Root, False, GrabModeSync, GrabModeAsync, CurrentTime ); // did we succeed in grabbing the keyboard? if ( Error != GrabSuccess) { // nope, abort cerr << "Could not grab the keyboard, aborting." << endl; exit ( EXIT_FAILURE ); } // print a message to the user informing about what's going on cerr << endl << "Press the key you want to use to end the application. " << "This key can be any key, " << endl << "as long as you don't need it while working with the remote display." << endl << "A good choice is Escape." << endl << endl; // let the user select a window... while ( Loop ) { // allow one more event XAllowEvents ( Dpy, SyncPointer, CurrentTime); XWindowEvent ( Dpy, Root, KeyPressMask, &Event); // what did we get? if ( Event.type == KeyPress ) { // a key was pressed, don't loop more EKey = Event.xkey; Loop = false; } } // we're done with pointer and keyboard XUngrabPointer ( Dpy, CurrentTime ); XUngrabKeyboard ( Dpy, CurrentTime ); // show the user what was chosen cerr << "The chosen quit-key has the keycode: " << EKey.keycode << endl; // return the found key return EKey.keycode; } /****************************************************************************/ /*! Scales the passed coordinate with the given saling factor. the factor is either given as a commandline argument or it is 1.0. */ /****************************************************************************/ int scale (const int Coordinate) { // perform the scaling, all in one ugly line return (int)( (float)Coordinate * Scale ); } /****************************************************************************/ /*! Returns the KeySym of the key code in the XKeyEvent struct. \arg XKeyEvent * ev - The struct which contains the key code. */ /****************************************************************************/ KeySym getKeySym(XKeyEvent *ev) { KeySym KS; char Buffer [64]; XLookupString ( ev, Buffer, 64, &KS, 0 ); return(KS); } /****************************************************************************/ /*! Sends the key \a Code to the remote display \a RemoteDpy. The keycode is converted to a \c KeySym on the local display and then reconverted to a \c KeyCode on the remote display. Seems to work quite ok, apart from something weird with the Alt key. \arg Display * LocalDpy - used display. \arg Display * RemoteDpy - used display. \arg const unsigned int Code - keycode of pressed key. \arg bool Pressed - true if it is a keypress event, false if a keyrelease. */ /****************************************************************************/ void sendKey (XKeyEvent * Event, Display * LocalDpy, Display * RemoteDpy, const unsigned int Code, bool Pressed) { KeySym KS; char Buffer [64]; KeyCode RemoteKeyCode; // perform lookup of the keycode XLookupString ( Event, Buffer, 64, &KS, 0 ); // convert it to a keycode on the remote server if ( ( RemoteKeyCode = XKeysymToKeycode ( RemoteDpy, KS ) ) == 0 ) { // no keycode on the remote display for the keysym cerr << "No keycode on remote display found for keysym: " << KS << endl; return; } // send the event. Check if it's a release or press if ( Pressed ) { // keypress XTestFakeKeyEvent ( RemoteDpy, (unsigned int)RemoteKeyCode, True, Delay ); } else { // keyrelease XTestFakeKeyEvent ( RemoteDpy,(unsigned int) RemoteKeyCode, False, Delay ); } } /*void getParent(Display *d, Window w) { cerr << "XQueryTree }*/ /****************************************************************************/ /*! Main event-loop of the application. Loops until a key with the keycode \a QuitKey is pressed. Sends all mouse- and key-events to the remote display. \arg Display * LocalDpy - used display. \arg Display * RemoteDpy - used display. \arg int LocalScreen - the used screen. \arg int RemoteScreen - the used screen. \arg unsigned int QuitKey - the key when pressed that quits the eventloop. */ /****************************************************************************/ void eventLoop (Display * LocalDpy, int LocalScreen, Display * RemoteDpy, int RemoteScreen, unsigned int QuitKey) { int Status1, Status2, x=0, y=0; bool Loop = true; XEvent Event; Window Root; XButtonEvent EButton; XMotionEvent EMotion; XKeyEvent EKey; // get the root window and set default target Root = RootWindow ( LocalDpy, LocalScreen ); // grab the pointer Status1 = XGrabPointer ( LocalDpy, Root, False, PointerMotionMask|ButtonPressMask|ButtonReleaseMask, GrabModeSync, GrabModeAsync, Root, None, CurrentTime ); // grab the keyboard Status2 = XGrabKeyboard ( LocalDpy, Root, False, GrabModeSync, GrabModeAsync, CurrentTime ); // did we succeed in grabbing the pointer? if ( Status1 != GrabSuccess) { // nope, abort cerr << "Could not grab the local mouse, aborting." << endl; exit ( EXIT_FAILURE ); } // did we succeed in grabbing the keyboard? if ( Status2 != GrabSuccess) { // nope, abort cerr << "Could not grab the local keyboard, aborting." << endl; exit ( EXIT_FAILURE ); } Status2=0; Status1=2; while ( Loop ) { // allow one more event XAllowEvents ( LocalDpy, SyncPointer, CurrentTime); // get an event matching the specified mask XWindowEvent ( LocalDpy, Root, KeyPressMask|KeyReleaseMask|PointerMotionMask|ButtonPressMask|ButtonReleaseMask, &Event); if (Status1) { Status1--; if (Event.type==KeyRelease) { cerr << "Skipping stale KeyRelease event. " << Status1 << endl; continue; } else Status1=0; } // what did we get? switch (Event.type) { case ButtonPress: // button pressed, create event EButton = Event.xbutton; #ifdef DEBUG cerr << "type: " << Event.xbutton.type << " serial: " << Event.xbutton.serial << endl; cerr << "send_event: " << Event.xbutton.send_event << " display_name: " << Event.xbutton.display->display_name << endl; cerr << "window: " << hex << Event.xbutton.window << " root: " << Event.xbutton.root << endl; cerr << "subwindow: " << Event.xbutton.subwindow << " time: " << dec << Event.xbutton.time << endl; cerr << "x: " << Event.xbutton.x << " y: " << Event.xbutton.y << endl; cerr << "x_root: " << Event.xbutton.x_root << " y_root: " << Event.xbutton.y_root << endl; cerr << "state: " << Event.xbutton.state << " button: " << Event.xbutton.button << endl; cerr << "same_screen: " << Event.xbutton.same_screen << endl << "------" << endl; #endif if (EButton.x!=x || EButton.y!=y) { cout << "MotionNotify " << EButton.x << " " << EButton.y << endl; x=EButton.x; y=EButton.y; } if (Status2<0) Status2=0; Status2++; cout << "ButtonPress " << EButton.button << endl; XTestFakeButtonEvent ( RemoteDpy, EButton.button, True, Delay ); break; case ButtonRelease: // button released, create event EButton = Event.xbutton; #ifdef DEBUG cerr << "type: " << Event.xbutton.type << " serial: " << Event.xbutton.serial << endl; cerr << "send_event: " << Event.xbutton.send_event << " display_name: " << Event.xbutton.display->display_name << endl; cerr << "window: " << hex << Event.xbutton.window << " root: " << Event.xbutton.root << endl; cerr << "subwindow: " << Event.xbutton.subwindow << " time: " << dec << Event.xbutton.time << endl; cerr << "x: " << Event.xbutton.x << " y: " << Event.xbutton.y << endl; cerr << "x_root: " << Event.xbutton.x_root << " y_root: " << Event.xbutton.y_root << endl; cerr << "state: " << Event.xbutton.state << " button: " << Event.xbutton.button << endl; cerr << "same_screen: " << Event.xbutton.same_screen << endl << "------" << endl; #endif if (EButton.x!=x || EButton.y!=y) { cout << "MotionNotify " << EButton.x << " " << EButton.y << endl; x=EButton.x; y=EButton.y; } Status2--; if (Status2<0) Status2=0; cout << "ButtonRelease " << EButton.button << endl; XTestFakeButtonEvent ( RemoteDpy, EButton.button, False, Delay ); break; case MotionNotify: // motion-event, create event EMotion = Event.xmotion; #ifdef DEBUG cerr << "type: " << Event.xmotion.type << " serial: " << Event.xmotion.serial << endl; cerr << "send_event: " << Event.xmotion.send_event << " display_name: " << Event.xmotion.display->display_name << endl; cerr << "window: " << hex << Event.xmotion.window << " root: " << Event.xmotion.root << endl; cerr << "subwindow: " << Event.xmotion.subwindow << " time: " << dec << Event.xmotion.time << endl; cerr << "x: " << Event.xmotion.x << " y: " << Event.xmotion.y << endl; cerr << "x_root: " << Event.xmotion.x_root << " y_root: " << Event.xmotion.y_root << endl; cerr << "state: " << Event.xmotion.state << " is_hint: " << Event.xmotion.is_hint << endl; cerr << "same_screen: " << Event.xmotion.same_screen << endl << "------" << endl; #endif if (Status2>0) cout << "MotionNotify " << EMotion.x << " " << EMotion.y << endl; XTestFakeMotionEvent ( RemoteDpy, RemoteScreen , scale ( EMotion.x ), scale ( EMotion.y ), Delay ); break; case KeyPress: // a key was pressed, don't loop more EKey = Event.xkey; #ifdef DEBUG cerr << "type: " << Event.xkey.type << " serial: " << Event.xkey.serial << endl; cerr << "send_event: " << Event.xkey.send_event << " display_name: " << Event.xkey.display->display_name << endl; cerr << "window: " << hex << Event.xkey.window << " root: " << Event.xkey.root << endl; cerr << "subwindow: " << Event.xkey.subwindow << " time: " << dec << Event.xkey.time << endl; cerr << "x: " << Event.xkey.x << " y: " << Event.xkey.y << endl; cerr << "x_root: " << Event.xkey.x_root << " y_root: " << Event.xkey.y_root << endl; cerr << "state: " << Event.xkey.state << " keycode: " << Event.xkey.keycode << endl; cerr << "same_screen: " << Event.xkey.same_screen << endl << "------" << endl; #endif // should we stop looping, i.e. did the user press the quitkey? if ( EKey.keycode == QuitKey ) { // yep, no more loops Loop = false; } else { // send the keycode to the remote server if (EKey.x!=x || EKey.y!=y) { cout << "MotionNotify " << EKey.x << " " << EKey.y << endl; x=EKey.x; y=EKey.y; } cout << "KeyStrPress " << XKeysymToString(getKeySym(&EKey)) << endl; sendKey ( &EKey, LocalDpy, RemoteDpy, EKey.keycode, true ); } break; case KeyRelease: // a key was released EKey = Event.xkey; #ifdef DEBUG cerr << "type: " << Event.xkey.type << " serial: " << Event.xkey.serial << endl; cerr << "send_event: " << Event.xkey.send_event << " display_name: " << Event.xkey.display->display_name << endl; cerr << "window: " << hex << Event.xkey.window << " root: " << Event.xkey.root << endl; cerr << "subwindow: " << Event.xkey.subwindow << " time: " << dec << Event.xkey.time << endl; cerr << "x: " << Event.xkey.x << " y: " << Event.xkey.y << endl; cerr << "x_root: " << Event.xkey.x_root << " y_root: " << Event.xkey.y_root << endl; cerr << "state: " << Event.xkey.state << " keycode: " << Event.xkey.keycode << endl; cerr << "same_screen: " << Event.xkey.same_screen << endl << "------" << endl; #endif if (EKey.x!=x || EKey.y!=y) { cout << "MotionNotify " << EKey.x << " " << EKey.y << endl; x=EKey.x; y=EKey.y; } cout << "KeyStrRelease " << XKeysymToString(getKeySym(&EKey)) << endl; sendKey ( &EKey, LocalDpy, RemoteDpy, EKey.keycode, false ); break; } // sync the remote server XFlush ( RemoteDpy ); } // we're done with pointer and keyboard XUngrabPointer ( LocalDpy, CurrentTime ); XUngrabKeyboard ( LocalDpy, CurrentTime ); } /****************************************************************************/ /*! Main function of the application. It expects no commandline arguments. \arg int argc - number of commandline arguments. \arg char * argv[] - vector of the commandline argument strings. */ /****************************************************************************/ int main (int argc, char * argv[]) { // parse commandline arguments parseCommandLine ( argc, argv ); // open the local display Display * LocalDpy = localDisplay (); // get the screens too int LocalScreen = DefaultScreen ( LocalDpy ); // do we already have a quit key? If one was supplied as a commandline // argument we use that key if ( ! HasQuitKey ) { // nope, so find the key that quits the application QuitKey = findQuitKey ( LocalDpy, LocalScreen ); } else { // show the user which key will be used cerr << "The used quit-key has the keycode: " << QuitKey << endl; } // open the remote display or abort Display * RemoteDpy = remoteDisplay ( Remote ); // get the screens too int RemoteScreen = DefaultScreen ( RemoteDpy ); // start the main event loop eventLoop ( LocalDpy, LocalScreen, RemoteDpy, RemoteScreen, QuitKey ); // discard and even flush all events on the remote display XTestDiscard ( RemoteDpy ); XFlush ( RemoteDpy ); // we're done with the display XCloseDisplay ( RemoteDpy ); XCloseDisplay ( LocalDpy ); cerr << PROG << ": pointer and keyboard released. " << endl; // go away exit ( EXIT_SUCCESS ); } xmacro-0.3pre-20000911.orig/xmacro.list0100600000076400007640000000101107155301460016561 0ustar inetprivate%product Xmacro %copyright 2000 Gabor Keresztfalvi %vendor Gabor Keresztfalvi %license COPYING %readme README %description X event recorder and replayer utilities %version 0.3 # Executables %system all f 0555 root sys /usr/bin/xmacroplay xmacroplay f 0555 root sys /usr/bin/xmacrorec xmacrorec f 0555 root sys /usr/bin/xmacrorec2 xmacrorec2 # Man pages - not ready yet # Documentation and example script f 0444 root sys /usr/doc/xmacro/README README f 0444 root sys /usr/doc/xmacro/example/run run xmacro-0.3pre-20000911.orig/xmacrorec2.cpp0100600000076400007640000004223707155302707017170 0ustar inetprivate/***************************************************************************** * * xmacrorec2 - a utility for recording X mouse and key events. * Portions Copyright (C) 2000 Gabor Keresztfalvi * * The recorded events are emitted to the standard output and can be played * with the xmacroplay utility. Using the Record extension on the local * display. No XTest playing on remote display during recording in this * version! * * This program is heavily based on * xremote (http://infa.abo.fi/~chakie/xremote/) which is: * Copyright (C) 2000 Jan Ekholm * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ****************************************************************************/ //#define DEBUG /***************************************************************************** * Do we have config.h? ****************************************************************************/ #ifdef HAVE_CONFIG #include "config.h" #endif /***************************************************************************** * Includes ****************************************************************************/ #include #include #include #include #include #include #include #include #include /***************************************************************************** * What iostream do we have? ****************************************************************************/ #ifdef HAVE_IOSTREAM #include #include #else #include #include #endif #define PROG "xmacrorec2" /***************************************************************************** * The delay in milliseconds when sending events to the remote display ****************************************************************************/ const int DefaultDelay = 10; /***************************************************************************** * The multiplier used fot scaling coordinates before sending them to the * remote display. By default we don't scale at all ****************************************************************************/ const float DefaultScale = 1.0; /***************************************************************************** * Globals... ****************************************************************************/ int Delay = DefaultDelay; float Scale = DefaultScale; /***************************************************************************** * Key used for quitting the application. ****************************************************************************/ unsigned int QuitKey; bool HasQuitKey = false; /***************************************************************************** * Private data used in eventCallback. ****************************************************************************/ typedef struct { int Status1, Status2, x, y, mmoved, doit; unsigned int QuitKey; Display *LocalDpy, *RecDpy; XRecordContext rc; } Priv; /****************************************************************************/ /*! Prints the usage, i.e. how the program is used. Exits the application with the passed exit-code. \arg const int ExitCode - the exitcode to use for exiting. */ /****************************************************************************/ void usage (const int exitCode) { // print the usage cerr << PROG << " " << VERSION << endl; cerr << "Usage: " << PROG << " [options] " << endl; cerr << "Options: " << endl; cerr << " -s FACTOR scalefactor for coordinates. Default: 1.0." << endl << " -k KEYCODE the keycode for the key used for quitting." << endl << " -v show version. " << endl << " -h this help. " << endl << endl; // we're done exit ( EXIT_SUCCESS ); } /****************************************************************************/ /*! Prints the version of the application and exits. */ /****************************************************************************/ void version () { // print the version cerr << PROG << " " << VERSION << endl; // we're done exit ( EXIT_SUCCESS ); } /****************************************************************************/ /*! Parses the commandline and stores all data in globals (shudder). Exits the application with a failed exitcode if a parameter is illegal. \arg int argc - number of commandline arguments. \arg char * argv[] - vector of the commandline argument strings. */ /****************************************************************************/ void parseCommandLine (int argc, char * argv[]) { int Index = 1; // loop through all arguments except the last, which is assumed to be the // name of the display while ( Index < argc ) { // is this '-v'? if ( strcmp (argv[Index], "-v" ) == 0 ) { // yep, show version and exit version (); } // is this '-h'? if ( strcmp (argv[Index], "-h" ) == 0 ) { // yep, show usage and exit usage ( EXIT_SUCCESS ); } // is this '-s'? else if ( strcmp (argv[Index], "-s" ) == 0 && Index + 1 < argc ) { // yep, and there seems to be a parameter too, interpret it as a // floating point number if ( sscanf ( argv[Index + 1], "%f", &Scale ) != 1 ) { // oops, not a valid intereger cerr << "Invalid parameter for '-s'." << endl; usage ( EXIT_FAILURE ); } Index++; } // is this '-k'? else if ( strcmp (argv[Index], "-k" ) == 0 && Index + 1 < argc ) { // yep, and there seems to be a parameter too, interpret it as a // number if ( sscanf ( argv[Index + 1], "%d", &QuitKey ) != 1 ) { // oops, not a valid integer cerr << "Invalid parameter for '-k'." << QuitKey << endl; usage ( EXIT_FAILURE ); } // now we have a key for quitting HasQuitKey = true; Index++; } else { // we got this far, the parameter is no good... cerr << "Invalid parameter '" << argv[Index] << "'." << endl; usage ( EXIT_FAILURE ); } // next value Index++; } } /****************************************************************************/ /*! Connects to the local display. Returns the \c Display or \c 0 if no display could be obtained. */ /****************************************************************************/ Display * localDisplay () { // open the display Display * D = XOpenDisplay ( 0 ); // did we get it? if ( ! D ) { // nope, so show error and abort cerr << PROG << ": could not open display \"" << XDisplayName ( 0 ) << "\", aborting." << endl; exit ( EXIT_FAILURE ); } // return the display return D; } /****************************************************************************/ /*! Function that finds out the key the user wishes to use for quitting the application. This must be configurable, as a suitable key is not always possible to determine in advance. By letting the user pick a key one that does not interfere with the needed applications can be chosen. The function grabs the keyboard and waits for a key to be pressed. Returns the keycode of the pressed key. \arg Display * Dpy - used display. \arg int Screen - the used screen. */ /****************************************************************************/ int findQuitKey (Display * Dpy, int Screen) { XEvent Event; XKeyEvent EKey; Window Target, Root; bool Loop = true; int Error; // get the root window and set default target Root = RootWindow ( Dpy, Screen ); Target = None; // grab the keyboard Error = XGrabKeyboard ( Dpy, Root, False, GrabModeSync, GrabModeAsync, CurrentTime ); // did we succeed in grabbing the keyboard? if ( Error != GrabSuccess) { // nope, abort cerr << "Could not grab the keyboard, aborting." << endl; exit ( EXIT_FAILURE ); } // print a message to the user informing about what's going on cerr << endl << "Press the key you want to use to end the application. " << "This key can be any key, " << endl << "as long as you don't need it while working with the remote display." << endl << "A good choice is Escape." << endl << endl; // let the user select a window... while ( Loop ) { // allow one more event XAllowEvents ( Dpy, SyncPointer, CurrentTime); XWindowEvent ( Dpy, Root, KeyPressMask, &Event); // what did we get? if ( Event.type == KeyPress ) { // a key was pressed, don't loop more EKey = Event.xkey; Loop = false; } } // we're done with pointer and keyboard XUngrabPointer ( Dpy, CurrentTime ); XUngrabKeyboard ( Dpy, CurrentTime ); // show the user what was chosen cerr << "The chosen quit-key has the keycode: " << EKey.keycode << endl; // return the found key return EKey.keycode; } /****************************************************************************/ /*! Scales the passed coordinate with the given saling factor. the factor is either given as a commandline argument or it is 1.0. */ /****************************************************************************/ int scale (const int Coordinate) { // perform the scaling, all in one ugly line return (int)( (float)Coordinate * Scale ); } #ifdef DEBUG #define DBG cerr << "type: " << type << " serial: " << seq << endl; \ cerr << "send_event: " << (unsigned int)(ud1[0]>>8) << endl; \ cerr << "window: " << hex << wevent << " root: " << wroot << endl; \ cerr << "subwindow: " << wchild << " time: " << dec << tstamp << endl; \ cerr << "x: " << eventx << " y: " << eventy << endl; \ cerr << "x_root: " << rootx << " y_root: " << rooty << endl; \ cerr << "state: " << kstate << " detail: " << detail << endl; \ cerr << "same_screen: " << samescreen << endl << "------" << endl #else #define DBG #endif void eventCallback(XPointer priv, XRecordInterceptData *d) { Priv *p=(Priv *) priv; unsigned int *ud4, tstamp, wroot, wevent, wchild, type, detail; unsigned char *ud1, type1, detail1, samescreen; unsigned short *ud2, seq; short *d2, rootx, rooty, eventx, eventy, kstate; if (d->category==XRecordStartOfData) cerr << "Got Start Of Data" << endl; if (d->category==XRecordEndOfData) cerr << "Got End Of Data" << endl; if (d->category!=XRecordFromServer || p->doit==0) { cerr << "Skipping..." << endl; goto returning; } if (d->client_swapped==True) cerr << "Client is swapped!!!" << endl; ud1=(unsigned char *)d->data; ud2=(unsigned short *)d->data; d2=(short *)d->data; ud4=(unsigned int *)d->data; type1=ud1[0]&0x7F; type=type1; detail1=ud1[1]; detail=detail1; seq=ud2[1]; tstamp=ud4[1]; wroot=ud4[2]; wevent=ud4[3]; wchild=ud4[4]; rootx=d2[10]; rooty=d2[11]; eventx=d2[12]; eventy=d2[13]; kstate=d2[14]; samescreen=ud1[30]; if (p->Status1) { p->Status1--; if (type==KeyRelease) { cerr << "- Skipping stale KeyRelease event. " << p->Status1 << endl; goto returning; } else p->Status1=0; } if (p->x==-1 && p->y==-1 && p->mmoved==0 && type!=MotionNotify) { cerr << "- Please move the mouse before any other event to synchronize pointer" << endl; cerr << " coordinates! This event is now ignored!" << endl; goto returning; } // what did we get? switch (type) { case ButtonPress: // button pressed, create event DBG; if (p->mmoved) { cout << "MotionNotify " << p->x << " " << p->y << endl; p->mmoved=0; } if (p->Status2<0) p->Status2=0; p->Status2++; cout << "ButtonPress " << detail << endl; break; case ButtonRelease: // button released, create event DBG; if (p->mmoved) { cout << "MotionNotify " << p->x << " " << p->y << endl; p->mmoved=0; } p->Status2--; if (p->Status2<0) p->Status2=0; cout << "ButtonRelease " << detail << endl; break; case MotionNotify: // motion-event, create event DBG; if (p->Status2>0) { cout << "MotionNotify " << rootx << " " << rooty << endl; p->mmoved=0; } else p->mmoved=1; p->x=rootx; p->y=rooty; break; case KeyPress: // a key was pressed DBG; // should we stop looping, i.e. did the user press the quitkey? if ( detail == p->QuitKey ) { // yep, no more loops cerr << "Got QuitKey, so exiting..." << endl; p->doit=0; } else { // send the keycode to the remote server if (p->mmoved) { cout << "MotionNotify " << p->x << " " << p->y << endl; p->mmoved=0; } cout << "KeyStrPress " << XKeysymToString(XKeycodeToKeysym(p->LocalDpy,detail,0)) << endl; } break; case KeyRelease: // a key was released DBG; if (p->mmoved) { cout << "MotionNotify " << p->x << " " << p->y << endl; p->mmoved=0; } cout << "KeyStrRelease " << XKeysymToString(XKeycodeToKeysym(p->LocalDpy,detail,0)) << endl; break; } returning: XRecordFreeData(d); } /****************************************************************************/ /*! Main event-loop of the application. Loops until a key with the keycode \a QuitKey is pressed. Sends all mouse- and key-events to the remote display. \arg Display * LocalDpy - used display. \arg int LocalScreen - the used screen. \arg Display * RecDpy - used display. \arg unsigned int QuitKey - the key when pressed that quits the eventloop. */ /****************************************************************************/ void eventLoop (Display * LocalDpy, int LocalScreen, Display * RecDpy, unsigned int QuitKey) { Window Root, rRoot, rChild; XRecordContext rc; XRecordRange *rr; XRecordClientSpec rcs; Priv priv; int rootx, rooty, winx, winy; unsigned int mmask; Bool ret; Status sret; // get the root window and set default target Root = RootWindow ( LocalDpy, LocalScreen ); ret=XQueryPointer(LocalDpy, Root, &rRoot, &rChild, &rootx, &rooty, &winx, &winy, &mmask); cerr << "XQueryPointer returned: " << ret << endl; rr=XRecordAllocRange(); if (!rr) { cerr << "Could not alloc record range, aborting." << endl; exit(EXIT_FAILURE); } rr->device_events.first=KeyPress; rr->device_events.last=MotionNotify; rcs=XRecordAllClients; rc=XRecordCreateContext(RecDpy, 0, &rcs, 1, &rr, 1); if (!rc) { cerr << "Could not create a record context, aborting." << endl; exit(EXIT_FAILURE); } priv.x=rootx; priv.y=rooty; priv.mmoved=1; priv.Status2=0; priv.Status1=2; priv.doit=1; priv.QuitKey=QuitKey; priv.LocalDpy=LocalDpy; priv.RecDpy=RecDpy; priv.rc=rc; if (!XRecordEnableContextAsync(RecDpy, rc, eventCallback, (XPointer) &priv)) { cerr << "Could not enable the record context, aborting." << endl; exit(EXIT_FAILURE); } while (priv.doit) XRecordProcessReplies(RecDpy); sret=XRecordDisableContext(LocalDpy, rc); if (!sret) cerr << "XRecordDisableContext failed!" << endl; sret=XRecordFreeContext(LocalDpy, rc); if (!sret) cerr << "XRecordFreeContext failed!" << endl; XFree(rr); } /****************************************************************************/ /*! Main function of the application. It expects no commandline arguments. \arg int argc - number of commandline arguments. \arg char * argv[] - vector of the commandline argument strings. */ /****************************************************************************/ int main (int argc, char * argv[]) { int Major, Minor; // parse commandline arguments parseCommandLine ( argc, argv ); // open the local display twice Display * LocalDpy = localDisplay (); Display * RecDpy = localDisplay (); // get the screens too int LocalScreen = DefaultScreen ( LocalDpy ); cerr << "Server VendorRelease: " << VendorRelease(RecDpy) << endl; // does the remote display have the Xrecord-extension? if ( ! XRecordQueryVersion (RecDpy, &Major, &Minor ) ) { // nope, extension not supported cerr << PROG << ": XRecord extension not supported on server \"" << DisplayString(RecDpy) << "\"" << endl; // close the display and go away XCloseDisplay ( RecDpy ); exit ( EXIT_FAILURE ); } // print some information cerr << "XRecord for server \"" << DisplayString(RecDpy) << "\" is version " << Major << "." << Minor << "." << endl << endl;; // do we already have a quit key? If one was supplied as a commandline // argument we use that key if ( ! HasQuitKey ) { // nope, so find the key that quits the application QuitKey = findQuitKey ( LocalDpy, LocalScreen ); } else { // show the user which key will be used cerr << "The used quit-key has the keycode: " << QuitKey << endl; } // start the main event loop eventLoop ( LocalDpy, LocalScreen, RecDpy, QuitKey ); // we're done with the display // XCloseDisplay ( RecDpy ); XCloseDisplay ( LocalDpy ); cerr << PROG << ": Exiting. " << endl; // go away exit ( EXIT_SUCCESS ); }