├── .gitignore ├── AUTHORS ├── COPYING ├── ChangeLog ├── INSTALL ├── Makefile.am ├── NEWS ├── README ├── all.proto ├── atoms.c ├── authdata.c ├── autogen.sh ├── bigfont.proto ├── bigrequest.proto ├── composite.proto ├── configure.ac ├── copyauth.c ├── damage.proto ├── dga.proto ├── dpms.proto ├── dri2.proto ├── dri3.proto ├── errors.proto ├── events.proto ├── fixes.proto ├── genericevents.proto ├── glx.proto ├── main.c ├── mitshm.proto ├── parse.c ├── parse.h ├── present.proto ├── randr.proto ├── render.proto ├── requests.proto ├── saver.proto ├── setup.proto ├── shape.proto ├── stringlist.c ├── stringlist.h ├── sync.proto ├── translate.c ├── translate.h ├── vidmode.proto ├── x11client.c ├── x11common.c ├── x11server.c ├── xinerama.proto ├── xinput.proto ├── xkb.proto ├── xtrace.1 ├── xtrace.h └── xvideo.proto /.gitignore: -------------------------------------------------------------------------------- 1 | /Makefile.in 2 | /ac 3 | /aclocal.m4 4 | /autom4te.cache 5 | /config.h.in 6 | /configure 7 | /.deps 8 | /Makefile 9 | /config.h 10 | /config.log 11 | /config.status 12 | /stamp-h1 13 | /*.o 14 | /xtrace 15 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Bernhard R. Link 2 | Julien Cristau (jcristau%debian.org) 3 | 4 | Contributions by: 5 | Justin Pryzby (justinpryzby%users.sourceforge.net) 6 | manpage fixes 7 | Bruce Guenter (bruce%untroubled.org) 8 | starting a client given at the command line 9 | RALOVICH, Kristóf 10 | glx.inc 11 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | 2013-05-26 2 | * xinput: improve ValuatorClass (previously AxisClass), 3 | add ScrollClass, TouchClass 4 | * mark some font properties as atoms 5 | 2013-05-21 6 | * xkb: add partial support for GetMap, GetNames and GetNamedIndicator 7 | 2013-05-21 8 | * Add handling of GetAtomName 9 | 2012-06-01 10 | * fix parsing of unusual QueryExtension requests 11 | 2012-01-09 12 | * fix --timestamp description in manpage 13 | 2011-05-07 14 | * add support for XFree86-DGA 15 | 2011-05-06 16 | * add UFRACTION32_32 17 | 2011-02-12 18 | * configure.ac: change monotonic clock cache-id to make autoconf happy 19 | 2011-02-06 20 | * add a 'DIVIDE_COUNT' directive 21 | * enhance GLX support (GetVisualConfigs, GetFBConfigsSGIX, 22 | QueryServerString, ClientInfo) 23 | 2011-01-29 24 | * add a 'SIZE' directive to limit some structure to an explicit size 25 | (in VarStructs everything after that size is printed as unexpected 26 | data and otherwise ignored, also all field output or list length 27 | is automatically truncated to that value) 28 | * allow 'ELSEIF STORED ...' 29 | * use AC_PROG_CC_C99 to be sure to get C99 semantics 30 | 2011-01-28 31 | * allow to 'transfer' data from REQUEST to RESPONSE on the stack 32 | * allow 'IF STORED ...' to compare stored value 33 | * fix PUSH32 (was PUSH16 by mistake) 34 | * error out early in case of not yet supported min-length 0 35 | 2010-12-22 36 | * Add INT32_32 type for a 64 bit integer stored in two 32 bit integers 37 | * Add SYNC extension 38 | 2010-12-21 39 | * Add --monotonic-timestamps to print timestamps relative to system 40 | start (or whatever CLOCK_MONOTONIC returns on your system). 41 | 2010-10-26 42 | * Add Composite (Thanks to Adam Endrodi) 43 | 2010-10-20 44 | * fix size of do-not-propagate-mask in GetWindowAttributes results 45 | (Thanks to Pierre-Yves Baccou for noticing). 46 | 2010-06-20 47 | * Add XVideo (version 2.2) 48 | 2010-05-06 49 | * Add DRI2 (up to version 1.3) 50 | 2010-04-07 51 | * Add support for Generic Events (XGE) 52 | * Fix bug in error reporting when multiple STRUCTs have the same name 53 | * add --print-counts --print-offsets 54 | * add FIXED3232 (fixed point with 32 bits before and 32 after the dot) 55 | * add some of the generic events of XI2 56 | 2010-03-30 57 | * Add support for XInputExtension 1.5, and partial support for 58 | XInputExtension 2.0 59 | 2010-03-22 60 | * fix FRACTION16_16 on big-endian systems 61 | * add FRACTION32_32 62 | 2010-01-21 63 | * fix extension name output to not go to stdout unconditionaly 64 | (Thanks to Tommi Komulainen) 65 | * fix missing contants in shape kind and wrong kind in fixes 66 | extension (Thanks to Tommi Komulainen) 67 | 2010-01-05 68 | * fix parsing initial server response 69 | (old bug, but became obvious on big endian with the new code) 70 | 2010-01-02 71 | * fix SelectionNotify (thanks to Peter Collingbourne) 72 | * show more details of the initial X server response 73 | * fix segfault after some protocol description parsing errors 74 | * correctly identify core request NoOperation 75 | 2009-10-18 76 | * fix printing of column in protocoal description parser errors 77 | on 64 bit architectures. 78 | 2009-10-05 79 | * bugfix: the major/minor codes were transposed in 80 | print_server_error() (thanks to Chris Wilson) 81 | 2009-09-11 82 | * bugfix: fix LISTofTRAPEZOIDS offset in RenderTrapezoids (thanks to 83 | Chris Wilson) 84 | 2009-08-11 85 | * bugfix: when running xtrace with command, it was terminating 86 | when all connections were closed while the command still run 87 | (and this even when -k was specified). 88 | 2009-08-10 89 | * zero-pad fractial timestamp part 90 | 2009-07-02 91 | * print raw data of unsupported or unknown requests and of 92 | unexpected replies. 93 | 2009-06-29 94 | * remove unecessary output of spaces for ft_IF,... 95 | 2009-06-28 96 | * references to constants allowed in .proto files where 97 | numbers are expected. 98 | * add FLOAT32, LISTofFLOAT32, IF32, LISTofINT8, LISTofINT16, 99 | LISTofIN32, DECREMENT_COUNTER 100 | * some bugfixes in BE32 and LISTofUINT32 101 | 2009-06-27 102 | * add FRACTION16_16 103 | 2009-06-26 104 | * protocol specification is now read at run-time and no longer 105 | needs to be compiled in. Translated all the .inc files to the new 106 | .proto file format. 107 | 2009-06-15 108 | * add start of GLX support contributed by Kristof Ralovich 109 | 2009-06-01 110 | * complete XInputExtension support (if there is a price for worst 111 | documented extension, this would be my current candidate) 112 | 2009-05-19 113 | * omit "0x" when printing the sequence number for replies, to 114 | make the output more consistent with requests and events. 115 | 2009-04-18 116 | * start with XInputExtension support (only some opcodes yet) 117 | 2009-04-16 118 | * add --timestamps and --relative-timestamps options to print 119 | timestamps before each line. 120 | 2009-04-04 121 | * move start of output lines generation into common function 122 | (this makes some messages that until now got to stderr to go 123 | to the usual output, too. While that might hide them a bit, 124 | this also ensures they appear at the right place, which might 125 | be better). 126 | 2009-03-25 127 | * Properly set the address family when listening on a tcp socket 128 | 2009-02-19 129 | * fix decoding of GetAtomName reply 130 | * (cosmetic) use ft_RRCONFIGSTATUS for RRSetScreenConfig reply 131 | * fix decoding of RRGetOutputInfo reply 132 | * display FIXED as fixed-point numbers 133 | * RandR 1.3 support 134 | 2009-01-06 135 | * fix decoding of ConfigureWindow request 136 | (thanks to Yann Droneaud) 137 | * fix similar errors in RandrDeleteOutputProperty 138 | and XF86BigfontQueryVersion. 139 | 2008-08-02 140 | * add support for XFIXES and DAMAGE extensions 141 | 2008-08-01 142 | * add support for DPMS and MIT-SCREEN-SAVER extensions 143 | * print GetScreenSaver timeout and interval in decimal 144 | 2008-02-11 145 | * allow to give a program to start 146 | (based on patch supplied by Bruce Guenter) 147 | * actually use FAKEDISPLAY as manpage says 148 | (was INDISPLAY before) 149 | 2007-12-10 150 | * fix ROUND_32 (thanks to Julien Cristau) 151 | 2007-12-09 152 | * fix bug in RANDR 1.2 parsing (thanks to Julien Cristau) 153 | 2007-12-08 154 | * add support for XRANDR 1.2 155 | * add support for XINERAMA extension 156 | 2007-10-03 157 | * make some x and y UINT instead of CARD 158 | 2007-07-05 159 | * add support for XFree86-Bigfont extension 160 | * show extension names even in requests from unknown extensions 161 | * quiet some compiler warnings 162 | * fix typo to mismatch replies after 65535 requests 163 | * don't wait for replies for requests that got an error 164 | 2006-08-10 165 | * add --outfile and --buffered command line options 166 | 2006-07-24 167 | * add support for XFree86-VidModeExtension extension 168 | 2006-07-14 169 | * switch to stdint.h and uint* instead of u_int* 170 | * use getaddrinfo instead of gethostbyname2 171 | * implement fall-backs for strndup and asprintf 172 | 2006-07-12 173 | * print stringlists in ListFonts, SetFontPath, GetFontPath and 174 | ListExtensions 175 | 2006-06-10 176 | * fix ATOMs to be 32 bit 177 | * ChangeProperty pretty-prints types STRING and ATOM now 178 | 2006-06-09 179 | * remember atom names and print them when atoms are used 180 | * STRING8 fields now print \n and \t instead of \012 and \010 181 | * fix ft_IF8 processing, add ft_IFATOM 182 | * GetProperty pretty-prints type "STRING" now. 183 | 2006-06-08 184 | * fix QueryVersion of RANDR 185 | * implement MIT-SHM 186 | 2006-03-09 187 | * support RANDR extension 188 | 2006-03-08 189 | * manpage fixup. (Thanks to Justin Pryzby) 190 | 2006-02-28 191 | * work around copyauth problems with "localhost:" DISPLAYs 192 | (like ssh -X sets them) 193 | 2006-02-27 194 | * fix some problems with 16 bit ints shown as uints. 195 | 196 | 2006-02-24 197 | * support RENDER extension 198 | * fix handling of variable length structures 199 | (only those before the minimal length were shown) 200 | 201 | 2005-12-04 Bernhard R. Link 202 | * add --interactive option 203 | * make some widths and heights UINT instead of CARD 204 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | Basic Installation 2 | ================== 3 | 4 | These are generic installation instructions. 5 | 6 | The `configure' shell script attempts to guess correct values for 7 | various system-dependent variables used during compilation. It uses 8 | those values to create a `Makefile' in each directory of the package. 9 | It may also create one or more `.h' files containing system-dependent 10 | definitions. Finally, it creates a shell script `config.status' that 11 | you can run in the future to recreate the current configuration, a file 12 | `config.cache' that saves the results of its tests to speed up 13 | reconfiguring, and a file `config.log' containing compiler output 14 | (useful mainly for debugging `configure'). 15 | 16 | If you need to do unusual things to compile the package, please try 17 | to figure out how `configure' could check whether to do them, and mail 18 | diffs or instructions to the address given in the `README' so they can 19 | be considered for the next release. If at some point `config.cache' 20 | contains results you don't want to keep, you may remove or edit it. 21 | 22 | The file `configure.in' is used to create `configure' by a program 23 | called `autoconf'. You only need `configure.in' if you want to change 24 | it or regenerate `configure' using a newer version of `autoconf'. 25 | 26 | The simplest way to compile this package is: 27 | 28 | 1. `cd' to the directory containing the package's source code and type 29 | `./configure' to configure the package for your system. If you're 30 | using `csh' on an old version of System V, you might need to type 31 | `sh ./configure' instead to prevent `csh' from trying to execute 32 | `configure' itself. 33 | 34 | Running `configure' takes awhile. While running, it prints some 35 | messages telling which features it is checking for. 36 | 37 | 2. Type `make' to compile the package. 38 | 39 | 3. Optionally, type `make check' to run any self-tests that come with 40 | the package. 41 | 42 | 4. Type `make install' to install the programs and any data files and 43 | documentation. 44 | 45 | 5. You can remove the program binaries and object files from the 46 | source code directory by typing `make clean'. To also remove the 47 | files that `configure' created (so you can compile the package for 48 | a different kind of computer), type `make distclean'. There is 49 | also a `make maintainer-clean' target, but that is intended mainly 50 | for the package's developers. If you use it, you may have to get 51 | all sorts of other programs in order to regenerate files that came 52 | with the distribution. 53 | 54 | Compilers and Options 55 | ===================== 56 | 57 | Some systems require unusual options for compilation or linking that 58 | the `configure' script does not know about. You can give `configure' 59 | initial values for variables by setting them in the environment. Using 60 | a Bourne-compatible shell, you can do that on the command line like 61 | this: 62 | CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure 63 | 64 | Or on systems that have the `env' program, you can do it like this: 65 | env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure 66 | 67 | Compiling For Multiple Architectures 68 | ==================================== 69 | 70 | You can compile the package for more than one kind of computer at the 71 | same time, by placing the object files for each architecture in their 72 | own directory. To do this, you must use a version of `make' that 73 | supports the `VPATH' variable, such as GNU `make'. `cd' to the 74 | directory where you want the object files and executables to go and run 75 | the `configure' script. `configure' automatically checks for the 76 | source code in the directory that `configure' is in and in `..'. 77 | 78 | If you have to use a `make' that does not supports the `VPATH' 79 | variable, you have to compile the package for one architecture at a time 80 | in the source code directory. After you have installed the package for 81 | one architecture, use `make distclean' before reconfiguring for another 82 | architecture. 83 | 84 | Installation Names 85 | ================== 86 | 87 | By default, `make install' will install the package's files in 88 | `/usr/local/bin', `/usr/local/man', etc. You can specify an 89 | installation prefix other than `/usr/local' by giving `configure' the 90 | option `--prefix=PATH'. 91 | 92 | You can specify separate installation prefixes for 93 | architecture-specific files and architecture-independent files. If you 94 | give `configure' the option `--exec-prefix=PATH', the package will use 95 | PATH as the prefix for installing programs and libraries. 96 | Documentation and other data files will still use the regular prefix. 97 | 98 | In addition, if you use an unusual directory layout you can give 99 | options like `--bindir=PATH' to specify different values for particular 100 | kinds of files. Run `configure --help' for a list of the directories 101 | you can set and what kinds of files go in them. 102 | 103 | If the package supports it, you can cause programs to be installed 104 | with an extra prefix or suffix on their names by giving `configure' the 105 | option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. 106 | 107 | Optional Features 108 | ================= 109 | 110 | Some packages pay attention to `--enable-FEATURE' options to 111 | `configure', where FEATURE indicates an optional part of the package. 112 | They may also pay attention to `--with-PACKAGE' options, where PACKAGE 113 | is something like `gnu-as' or `x' (for the X Window System). The 114 | `README' should mention any `--enable-' and `--with-' options that the 115 | package recognizes. 116 | 117 | For packages that use the X Window System, `configure' can usually 118 | find the X include and library files automatically, but if it doesn't, 119 | you can use the `configure' options `--x-includes=DIR' and 120 | `--x-libraries=DIR' to specify their locations. 121 | 122 | Specifying the System Type 123 | ========================== 124 | 125 | There may be some features `configure' can not figure out 126 | automatically, but needs to determine by the type of host the package 127 | will run on. Usually `configure' can figure that out, but if it prints 128 | a message saying it can not guess the host type, give it the 129 | `--host=TYPE' option. TYPE can either be a short name for the system 130 | type, such as `sun4', or a canonical name with three fields: 131 | CPU-COMPANY-SYSTEM 132 | 133 | See the file `config.sub' for the possible values of each field. If 134 | `config.sub' isn't included in this package, then this package doesn't 135 | need to know the host type. 136 | 137 | If you are building compiler tools for cross-compiling, you can also 138 | use the `--target=TYPE' option to select the type of system they will 139 | produce code for and the `--build=TYPE' option to select the type of 140 | system on which you are compiling the package. 141 | 142 | Sharing Defaults 143 | ================ 144 | 145 | If you want to set default values for `configure' scripts to share, 146 | you can create a site shell script called `config.site' that gives 147 | default values for variables like `CC', `cache_file', and `prefix'. 148 | `configure' looks for `PREFIX/share/config.site' if it exists, then 149 | `PREFIX/etc/config.site' if it exists. Or, you can set the 150 | `CONFIG_SITE' environment variable to the location of the site script. 151 | A warning: not all `configure' scripts look for a site script. 152 | 153 | Operation Controls 154 | ================== 155 | 156 | `configure' recognizes the following options to control how it 157 | operates. 158 | 159 | `--cache-file=FILE' 160 | Use and save the results of the tests in FILE instead of 161 | `./config.cache'. Set FILE to `/dev/null' to disable caching, for 162 | debugging `configure'. 163 | 164 | `--help' 165 | Print a summary of the options to `configure', and exit. 166 | 167 | `--quiet' 168 | `--silent' 169 | `-q' 170 | Do not print messages saying which checks are being made. To 171 | suppress all normal output, redirect it to `/dev/null' (any error 172 | messages will still be shown). 173 | 174 | `--srcdir=DIR' 175 | Look for the package's source code in directory DIR. Usually 176 | `configure' can determine that directory automatically. 177 | 178 | `--version' 179 | Print the version of Autoconf used to generate the `configure' 180 | script, and exit. 181 | 182 | `configure' also accepts some other, not widely useful, options. 183 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = xtrace 2 | 3 | AM_CPPFLAGS = -DPKGDATADIR='"$(pkgdatadir)"' 4 | 5 | xtrace_SOURCES = main.c x11common.c x11client.c x11server.c parse.c copyauth.c atoms.c translate.c stringlist.c 6 | 7 | noinst_HEADERS = xtrace.h parse.h stringlist.h translate.h 8 | 9 | dist_man_MANS = xtrace.1 10 | 11 | MAINTAINERCLEANFILES = $(srcdir)/Makefile.in $(srcdir)/configure $(srcdir)/stamp-h.in $(srcdir)/aclocal.m4 $(srcdir)/config.h.in 12 | 13 | dist_pkgdata_DATA = all.proto bigfont.proto bigrequest.proto damage.proto dpms.proto dri2.proto errors.proto events.proto fixes.proto genericevents.proto glx.proto mitshm.proto randr.proto render.proto requests.proto saver.proto setup.proto shape.proto sync.proto vidmode.proto xinerama.proto xinput.proto xkb.proto xvideo.proto composite.proto dga.proto dri3.proto present.proto 14 | 15 | distclean-local: 16 | -rm -rf $(srcdir)/autom4te.cache 17 | maintainer-clean-local: 18 | -rm -rf $(srcdir)/ac 19 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | new after 1.3.1: 2 | - also remember atoms seen by GetAtomName 3 | - partial improvements to xkb, xinput, fontprops 4 | new after 1.3.0: 5 | - fix query extension parsing 6 | new after 1.2.0: 7 | - support XFree86-DGA 8 | - fix --timestamp description in manpage 9 | new after 1.1.0: 10 | - support XVideo, Composite, SYNC 11 | - bugfixes (GetWindowAttributes on big endian) 12 | - improved GLX support 13 | new after 1.0.2: 14 | - bugfixes 15 | - support Generic Events (XGE) 16 | - support XInputExtension 1.5, and partially XInputExtension 2.0 17 | - support DRI2 18 | new after 1.0.1: 19 | - bugfixes (SelectionNotify, NoOperation, initial server response) 20 | - show more details of the initial X server response 21 | new after 1.0.0: 22 | - bugfixes (RenderTrapezoids and server errors) 23 | new after 1.0.0~alpha1: 24 | - fix bug in when to terminate when run with a command 25 | new after 0.11.0: 26 | - add parser so that protocol descriptions are no longer compiled in but 27 | read from text files in a language for the virtual parsing machine of 28 | previous versions. 29 | - partial support for GLX extension 30 | - bugfix in BE32 and hex/non-hex fixes in different places 31 | new after 0.10.1: 32 | - bugfix: correct field length in GetAtomName, added missing field in 33 | RRGetOutputInfo reply. 34 | - output FIXED values as fixed point numbers instead of multiples of 1/65536 35 | - RANDR 1.3 support 36 | - bugfix: set the address family when listening on a tcp socket 37 | - new --timestamps and --relative-timestamps options 38 | - XInputExtension support 39 | new after 0.10.0: 40 | - bugfix: correct field offsets in ConfigureWindow, 41 | RandrDeleteOutputProperty and XF86BigfontQueryVersion. 42 | new after 0.9.1: 43 | - XFIXES, DAMAGE, DPMS and MIT-SCREEN-SAVER extension support 44 | - start program given at command line 45 | new after 0.9.0: 46 | - bugfix in new RANDR rules 47 | new after 0.8.1: 48 | - RANDR 1.2 support 49 | - XINERAMA extension supported 50 | new after 0.8: 51 | - minor beautifiers 52 | new after 0.7: 53 | - XFree86-Bigfont extension added 54 | - several cleanups and beautifiers 55 | new after 0.6: 56 | - --outfile and --buffered options 57 | new after 0.5: 58 | - pretty print ListFonts, SetFontPath, GetFontPath and ListExtensions 59 | - compiles on Solaris now 60 | - support for XFree86-VidModeExtension (used by xvidtune and sdl) 61 | new after 0.4: 62 | - fix ATOMs for big-endian (by making them 32bit properly) 63 | - pretty print for ATOMs and some properties of format STRING. 64 | new after 0.3: 65 | - RANDR extension supported 66 | new after 0.2.1: 67 | - added --interactive 68 | - RENDER extension supported 69 | new from 0.2 to 0.2.1: 70 | - --keeprunning should work now 71 | - better extension support for multiple clients 72 | new from 0.1 to 0.2: 73 | - some cleanup 74 | - SHAPE extension supported (and some little framework for extensions) 75 | - added --help option 76 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | XTRACE 1.1 2 | ---------- 3 | 4 | What strace is for system calls, xtrace is for X11 connections: 5 | you hook it between one or more X11 clients and an X server and 6 | it prints the requests going from client to server and the replies, 7 | events and errors going the other way. 8 | 9 | Short howto: 10 | Run xtrace, which defaults to listening at :9 and forwarding to 11 | your current $DISPLAY. 12 | 13 | Then simply start other clients after setting DISPLAY=:9 or 14 | giving them -display :9 and see all the data flowing in a far 15 | to verbose form. 16 | 17 | Things still to do (any volunteers?): 18 | - test, test, test 19 | (currently only what I needed is tested, and as I calculated 20 | offsets by hand and copy&pasted a lot, there might still be 21 | some errors). 22 | - implement the common extensions. 23 | (currently only implemented are the base protocol and 24 | a limted number of extensions) 25 | - make it less verbose or even better allow to control 26 | verbosity. 27 | - implement some filtering 28 | - implement life modification. (Currently only supported 29 | by changing the source, look for requestButtonGrab in 30 | parse.c for an example. Being able to do this via 31 | command line would be nice.) 32 | - more checking of protocol specifications, there are many 33 | easy to make errors that are still not tested for. 34 | - script to translate xorg's protocol xml files to .proto language 35 | - allow generic dictionaries (generalizing the hard-coded atom 36 | support) and giving symbolic names to things (like GC1, GC2,..., 37 | that would make some logs much easier to compare). 38 | -------------------------------------------------------------------------------- /all.proto: -------------------------------------------------------------------------------- 1 | NEEDS "requests.proto" 2 | NEEDS "events.proto" 3 | NEEDS "errors.proto" 4 | NEEDS "setup.proto" 5 | 6 | NEEDS "bigfont.proto" 7 | NEEDS "bigrequest.proto" 8 | NEEDS "damage.proto" 9 | NEEDS "dpms.proto" 10 | NEEDS "dri2.proto" 11 | NEEDS "fixes.proto" 12 | NEEDS "genericevents.proto" 13 | NEEDS "glx.proto" 14 | NEEDS "mitshm.proto" 15 | NEEDS "randr.proto" 16 | NEEDS "render.proto" 17 | NEEDS "saver.proto" 18 | NEEDS "shape.proto" 19 | NEEDS "sync.proto" 20 | NEEDS "vidmode.proto" 21 | NEEDS "xinerama.proto" 22 | NEEDS "xinput.proto" 23 | NEEDS "xkb.proto" 24 | NEEDS "xvideo.proto" 25 | NEEDS "composite.proto" 26 | NEEDS "dga.proto" 27 | NEEDS "dri3.proto" 28 | NEEDS "present.proto" 29 | EOF 30 | -------------------------------------------------------------------------------- /atoms.c: -------------------------------------------------------------------------------- 1 | /* This file is part of "xtrace" 2 | * Copyright (C) 2006 Bernhard R. Link 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License version 2 as 5 | * published by the Free Software Foundation. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program; if not, write to the Free Software 14 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | */ 16 | #include 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include "xtrace.h" 30 | 31 | #define CONSTANT_ATOMS 68 32 | static const char *constant_atoms[CONSTANT_ATOMS] = { 33 | "PRIMARY", "SECONDARY", "ARC", "ATOM", 34 | "BITMAP", "CARDINAL", "COLORMAP", "CURSOR", 35 | "CUT_BUFFER0", "CUT_BUFFER1", "CUT_BUFFER2", "CUT_BUFFER3", 36 | "CUT_BUFFER4", "CUT_BUFFER5", "CUT_BUFFER6", "CUT_BUFFER7", 37 | "DRAWABLE", "FONT", "INTEGER", "PIXMAP", 38 | "POINT", "RECTANGLE", "RESOURCE_MANAGER", "RGB_COLOR_MAP", 39 | "RGB_BEST_MAP", "RGB_BLUE_MAP", "RGB_DEFAULT_MAP", "RGB_GRAY_MAP", 40 | "RGB_GREEN_MAP", "RGB_RED_MAP", "STRING", "VISUALID", 41 | "WINDOW", "WM_COMMAND", "WM_HINTS", "WM_CLIENT_MACHINE", 42 | "WM_ICON_NAME", "WM_ICON_SIZE", "WM_NAME", "WM_NORMAL_HINTS", 43 | "WM_SIZE_HINTS", "WM_ZOOM_HINTS", "MIN_SPACE", "NORM_SPACE", 44 | "MAX_SPACE", "END_SPACE", "SUPERSCRIPT_X", "SUPERSCRIPT_Y", 45 | "SUBSCRIPT_X", "SUBSCRIPT_Y", "UNDERLINE_POSITION", "UNDERLINE_THICKNESS", 46 | "STRIKEOUT_ASCENT", "STRIKEOUT_DESCENT", "ITALIC_ANGLE", "X_HEIGHT", 47 | "QUAD_WIDTH", "WEIGHT", "POINT_SIZE", "RESOLUTION", 48 | "COPYRIGHT", "NOTICE", "FONT_NAME", "FAMILY_NAME", 49 | "FULL_NAME", "CAP_HEIGHT", "WM_CLASS", "WM_TRANSIENT_FOR" 50 | }; 51 | 52 | struct atom { 53 | struct atom *left,*right; 54 | uint32_t atom; 55 | char name[]; 56 | }; 57 | /* TODO: add connection specific values, too, to be activated on mismatch */ 58 | struct atom *atom_root = NULL; 59 | 60 | struct atom *newAtom(const char *name, size_t len) { 61 | struct atom *atom; 62 | atom = malloc(sizeof(struct atom)+len+1); 63 | if( atom == NULL ) 64 | abort(); 65 | memcpy(atom->name,name,len); 66 | atom->name[len] = '\0'; 67 | return atom; 68 | } 69 | 70 | const char *getAtom(struct connection *c UNUSED, uint32_t atom) { 71 | struct atom *p; 72 | if( atom <= 0 ) 73 | return NULL; 74 | if( atom <= CONSTANT_ATOMS ) 75 | return constant_atoms[atom-1]; 76 | atom -= CONSTANT_ATOMS; 77 | p = atom_root; 78 | while( p != NULL ) { 79 | if( p->atom == atom ) 80 | return p->name; 81 | if( p->atom > atom ) 82 | p = p->left; 83 | else 84 | p = p->right; 85 | } 86 | return NULL; 87 | } 88 | void internAtom(struct connection *c UNUSED, uint32_t atom, struct atom *data) { 89 | struct atom **p; 90 | 91 | if( atom <= CONSTANT_ATOMS ) { 92 | free(data); 93 | return; 94 | } 95 | assert( data != NULL ); 96 | atom -= CONSTANT_ATOMS; /* still always > 0 */ 97 | data->atom = atom; 98 | 99 | p = &atom_root; 100 | while( *p != NULL ) { 101 | uint32_t k; 102 | k = (*p)->atom; 103 | if( atom == k ) { 104 | if( strcmp((*p)->name, data->name) != 0 ) 105 | fprintf(stderr,"Mismatch in InternAtom: Got %x = '%s', but remember = '%s'!\n",(unsigned int)atom,data->name,(*p)->name); 106 | free(data); 107 | return; 108 | } else if( atom > k ) { 109 | p = &(*p)->right; 110 | } else { /* atom < k */ 111 | p = &(*p)->left; 112 | } 113 | } 114 | *p = data; 115 | data->left = NULL; 116 | data->right = NULL; 117 | } 118 | -------------------------------------------------------------------------------- /authdata.c: -------------------------------------------------------------------------------- 1 | /* This file is part of "xtrace" 2 | * Copyright (C) 2005 Bernhard R. Link 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License version 2 as 5 | * published by the Free Software Foundation. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program; if not, write to the Free Software 14 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | */ 16 | #include 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | #include "xtrace.h" 29 | 30 | char *authdata = NULL; 31 | size_t authdata_len = 0; 32 | char *authname = "MIT-MAGIC-COOKIE-1"; 33 | size_t authname_len = strlen("MIT-MAGIC-COOKIE-1"); 34 | 35 | /* The following code is heavily based on code from xauth's process.c 36 | * with the following notice and diclaimer: 37 | * 38 | * * Copyright 1989, 1998 The Open Group 39 | * * 40 | * * Permission to use, copy, modify, distribute, and sell this software and its 41 | * * documentation for any purpose is hereby granted without fee, provided that 42 | * * the above copyright notice appear in all copies and that both that 43 | * * copyright notice and this permission notice appear in supporting 44 | * * documentation. 45 | * * 46 | * * The above copyright notice and this permission notice shall be included 47 | * * in all copies or substantial portions of the Software. 48 | * * 49 | * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 50 | * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 51 | * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 52 | * * IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR 53 | * * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 54 | * * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 55 | * * OTHER DEALINGS IN THE SOFTWARE. 56 | * * 57 | * * Except as contained in this notice, the name of The Open Group shall 58 | * * not be used in advertising or otherwise to promote the sale, use or 59 | * * other dealings in this Software without prior written authorization 60 | * * from The Open Group. 61 | */ 62 | 63 | static int x_protocol_error; 64 | static int 65 | catch_x_protocol_error(Display *dpy, XErrorEvent *errevent) 66 | { 67 | char buf[80]; 68 | XGetErrorText(dpy, errevent->error_code, buf, sizeof (buf)); 69 | fprintf(stderr, "%s\n", buf); 70 | x_protocol_error = errevent->error_code; 71 | return 1; 72 | } 73 | 74 | bool generateAuthorisation(const char *displayname) { 75 | Display *dpy; 76 | int major_version, minor_version; 77 | XSecurityAuthorization id_return; 78 | XSecurityAuthorizationAttributes attributes; 79 | Xauth *auth_in, *auth_return; 80 | int status; 81 | bool successfull = true; 82 | 83 | dpy = XOpenDisplay (displayname); 84 | if (!dpy) { 85 | fprintf (stderr, "unable to open display \"%s\".\n", displayname); 86 | return false; 87 | } 88 | 89 | status = XSecurityQueryExtension(dpy, &major_version, &minor_version); 90 | if (!status) 91 | { 92 | fprintf (stderr, "couldn't query Security extension on display \"%s\"\n", 93 | displayname); 94 | return false; 95 | } 96 | /* TODO: make them configurable */ 97 | attributes.trust_level = XSecurityClientUntrusted; 98 | attributes.timeout = 1200; 99 | auth_in = XSecurityAllocXauth(); 100 | if( auth_in == NULL ) { 101 | XCloseDisplay(dpy); 102 | return false; 103 | } 104 | auth_in->name = authname; 105 | auth_in->name_length = authname_len; 106 | auth_in->data = NULL; 107 | auth_in->data_length = 0; 108 | x_protocol_error = 0; 109 | XSetErrorHandler(catch_x_protocol_error); 110 | auth_return = XSecurityGenerateAuthorization(dpy, auth_in, 111 | XSecurityTimeout|XSecurityTrustLevel, 112 | &attributes, &id_return); 113 | if( auth_return != NULL ) { 114 | authdata_len = auth_return->data_length; 115 | authdata = malloc(authdata_len+1); 116 | if( authdata == NULL ) 117 | successfull = false; 118 | else { 119 | memcpy(authdata,auth_return->data,authdata_len); 120 | authdata[authdata_len] = '\0'; 121 | } 122 | XSecurityFreeXauth(auth_return); 123 | } else 124 | successfull = false; 125 | XSecurityFreeXauth(auth_in); 126 | XCloseDisplay(dpy); 127 | return successfull; 128 | } 129 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | configindir="." 5 | if [ "x$1" = "x--chdir" ] ; then 6 | shift 7 | configindir="$1" 8 | shift 9 | fi 10 | 11 | autoreconf -i 12 | 13 | curdir="$(pwd)" 14 | mkdir -p -- "$configindir" 15 | cd "$configindir" || exit 1 16 | "$curdir"/configure --enable-maintainer-mode CFLAGS="-Wall -O2 -g -Wmissing-prototypes -Wstrict-prototypes -W -Wshadow -DSTUPIDCC=1" 17 | -------------------------------------------------------------------------------- /bigfont.proto: -------------------------------------------------------------------------------- 1 | # This file is part of "xtrace" 2 | # Copyright (C) 2007 Bernhard R. Link 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License version 2 as 5 | # published by the Free Software Foundation. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | # 12 | # You should have received a copy of the GNU General Public License 13 | # along with this program; if not, write to the Free Software 14 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | # 16 | # This file is based on /usr/include/X11/extensions/xf86bigf{ont,str}.h, which is: 17 | ## Copyright (c) 1999-2000 Bruno Haible 18 | ## Copyright (c) 1999-2000 The XFree86 Project, Inc. 19 | ## 20 | ## Permission is hereby granted, free of charge, to any person obtaining a copy 21 | ## of this software and associated documentation files (the "Software"), to deal 22 | ## in the Software without restriction, including without limitation the rights 23 | ## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 24 | ## copies of the Software, and to permit persons to whom the Software is 25 | ## furnished to do so, subject to the following conditions: 26 | ## 27 | ## The above copyright notice and this permission notice shall be included in all 28 | ## copies or substantial portions of the Software. 29 | ## 30 | ## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ## XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 34 | ## IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 35 | ## CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 36 | ## 37 | ## Except as contained in this notice, the name of the XFree86 Project shall not 38 | ## be used in advertising or otherwise to promote the sale, use or other dealings 39 | ## in this Software without prior written authorization from the XFree86 Project. 40 | 41 | EXTENSION "XFree86-Bigfont" bigfont 42 | USE core 43 | 44 | REQUESTS 45 | QueryVersion RESPONDS 46 | QueryFont RESPONDS 47 | END 48 | 49 | EVENTS 50 | END 51 | 52 | ERRORS 53 | END 54 | 55 | BITMASK xf86bigfont_capabilities 56 | 1 LocalShm 57 | END 58 | TYPE xf86bigfont_capabilities BITMASK32 xf86bigfont_capabilities 59 | 60 | BITMASK xf86bigfont_flags 61 | 1 Shm 62 | END 63 | TYPE xf86bigfont_flags BITMASK32 xf86bigfont_flags 64 | 65 | REQUEST QueryVersion 66 | END 67 | RESPONSE QueryVersion 68 | 8 major-version UINT16 69 | 10 minor-version UINT16 70 | 1 capabilities xf86bigfont_capabilities 71 | 12 uid UINT32 72 | 16 gid UINT32 73 | 20 signature UINT32 74 | END 75 | 76 | REQUEST QueryFont 77 | 4 id UINT32 78 | 8 flags xf86bigfont_flags 79 | END 80 | 81 | RESPONSE QueryFont 82 | 8 min-bounds CHARINFO 83 | 24 max-bounds CHARINFO 84 | 40 min-char-or-byte2 CARD16 85 | 42 max-char-or-byte2 CARD16 86 | 44 default-char CARD16 87 | 48 draw-direction ENUM8 direction 88 | 49 min-byte1 CARD8 89 | 50 max-byte1 CARD8 90 | 51 all-chars-exists BOOL 91 | 52 font-ascent INT16 92 | 54 font-descent INT16 93 | 64 shmid COUNT32 94 | 68 shmsegoffset COUNT32 95 | 96 | 46 nFontProps COUNT16 97 | 72 properties LISTofFONTPROP 98 | 60 nUniqCharInfos COUNT32 99 | LATER uniq-char-infos LISTofCHARINFO 100 | 56 nCharInfos COUNT32 101 | LATER char-info-offsets LISTofCARD16 102 | END 103 | 104 | EOF 105 | -------------------------------------------------------------------------------- /bigrequest.proto: -------------------------------------------------------------------------------- 1 | # This file is part of "xtrace" 2 | # Copyright (C) 2009 Bernhard R. Link 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License version 2 as 5 | # published by the Free Software Foundation. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | # 12 | # You should have received a copy of the GNU General Public License 13 | # along with this program; if not, write to the Free Software 14 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | EXTENSION "BIG-REQUESTS" BigRequest 17 | USE core 18 | 19 | REQUESTS 20 | Enable RESPONDS 21 | END 22 | 23 | EVENTS 24 | END 25 | 26 | ERRORS 27 | END 28 | 29 | REQUEST Enable ALIASES Empty 30 | RESPONSE Enable 31 | 8 maximum-request-length UINT32 32 | END 33 | 34 | EOF 35 | -------------------------------------------------------------------------------- /composite.proto: -------------------------------------------------------------------------------- 1 | NEEDS "requests.proto" 2 | NEEDS "fixes.proto" 3 | 4 | EXTENSION "Composite" Composite 5 | USE core 6 | 7 | REQUESTS 8 | QueryVersion RESPONDS 9 | RedirectWindow 10 | RedirectSubwindows 11 | UnredirectWindow 12 | UnredirectSubwindows 13 | CreateRegionFromBorderClip 14 | NameWindowPixmap 15 | GetOverlayWindow RESPONDS 16 | ReleaseOverlayWindow /*8*/ 17 | END 18 | 19 | CONSTANTS updateType 20 | 0 Automatic 21 | 1 Manual 22 | END 23 | TYPE UpdateType ENUM8 updateType 24 | 25 | REQUEST QueryVersion 26 | 4 majorVersion UINT32 27 | 8 minorVersion UINT32 28 | END 29 | RESPONSE QueryVersion 30 | 8 majorVersion UINT32 31 | 12 minorVersion UINT32 32 | END 33 | 34 | REQUEST RedirectWindow 35 | 4 window WINDOW 36 | 8 update UpdateType 37 | END 38 | 39 | REQUEST RedirectSubwindows 40 | 4 window WINDOW 41 | 8 update UpdateType 42 | END 43 | 44 | # UpdateType doesn't make sense, but it's transmitted through the wire 45 | REQUEST UnredirectWindow 46 | 4 window WINDOW 47 | 8 update UpdateType 48 | END 49 | 50 | # Likewise 51 | REQUEST UnredirectSubwindows 52 | 4 window WINDOW 53 | 8 update UpdateType 54 | END 55 | 56 | REQUEST CreateRegionFromBorderClip 57 | 4 region Fixes::REGION 58 | 8 window WINDOW 59 | END 60 | 61 | REQUEST NameWindowPixmap 62 | 4 window WINDOW 63 | 8 pixmap PIXMAP 64 | END 65 | 66 | REQUEST GetOverlayWindow 67 | 4 window WINDOW 68 | END 69 | RESPONSE GetOverlayWindow 70 | 4 overlayWin WINDOW 71 | END 72 | 73 | REQUEST ReleaseOverlayWindow 74 | 4 window WINDOW 75 | END 76 | 77 | EOF 78 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | dnl 2 | dnl Process this file with autoconf to produce a configure script 3 | dnl 4 | 5 | AC_INIT(xtrace, 1.3.1, brlink@debian.org) 6 | AC_CONFIG_SRCDIR(main.c) 7 | AC_CONFIG_AUX_DIR(ac) 8 | AM_CONFIG_HEADER(config.h) 9 | AM_INIT_AUTOMAKE([-Wall -Werror]) 10 | 11 | AM_MAINTAINER_MODE 12 | AC_GNU_SOURCE 13 | 14 | if test "${CFLAGS:+set}" != set ; then 15 | CFLAGS="-Wall -O2 -g -Wmissing-prototypes -Wstrict-prototypes -Wshadow" 16 | fi 17 | 18 | AC_LANG(C) 19 | AC_PROG_CC_C99 20 | AC_PROG_INSTALL 21 | 22 | AC_CACHE_CHECK([Checking for _POSIX_TIMERS and _POSIX_MONOTONIC_CLOCK],[ac_cv_monotonic_clock], 23 | [AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[ 24 | #include 25 | #include 26 | ]],[[ 27 | #ifdef _POSIX_TIMERS 28 | #if defined(_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK >= 0 29 | 1 30 | #else 31 | #error _POSIX_MONOTONIC_CLOCK not defined, or not positive, not using clock_gettime 32 | #endif 33 | #else 34 | #error _POSIX_TIMERS not defined, not using clock_gettime 35 | #endif 36 | ]])], [ac_cv_monotonic_clock=yes], [ac_cv_monotonic_clock=no])]) 37 | 38 | if test $ac_cv_monotonic_clock = yes ; then 39 | AC_DEFINE([HAVE_MONOTONIC_CLOCK], 1, [Define if clock_gettime(CLOCK_MONOTONIC) should work]) 40 | AC_CHECK_FUNC([clock_gettime],[],[ 41 | AC_CHECK_LIB(rt, clock_gettime, [], [AC_MSG_ERROR([_POSIX_TIMERS suggests clock_gettime should work but it seems not to work, though])]) 42 | ]) 43 | fi 44 | 45 | AC_CHECK_FUNCS([strndup asprintf socket tdestroy]) 46 | if test $ac_cv_func_socket = no; then 47 | AC_CHECK_LIB(socket, socket, [AC_DEFINE(HAVE_SOCKET) 48 | LIBS="$LIBS -lsocket -lnsl"; break],[AC_MSG_ERROR([Could not find socket library function])]) 49 | fi 50 | AC_CHECK_FUNC([getaddrinfo],,[AC_MSG_ERROR([Could not find getaddrinfo library function])]) 51 | 52 | AC_SEARCH_LIBS(sendmsg, socket, [have_sendmsg="yes"], [have_sendmsg="no"]) 53 | AC_CHECK_HEADER(sys/socket.h, [], [have_sendmsg="no"]) 54 | if test $have_sendmsg = yes ; then 55 | AC_DEFINE([HAVE_SENDMSG],1,[Define if your platform supports sendmsg]) 56 | fi 57 | 58 | dnl AC_CHECK_HEADER(X11/X.h,[],[AC_MSG_ERROR([Could not find X11/X.h])]) 59 | dnl AC_CHECK_HEADER(X11/Xlib.h,[],[AC_MSG_ERROR([Could not find X11/Xlib.h])]) 60 | dnl AC_CHECK_HEADER(X11/extensions/security.h,[],[AC_MSG_ERROR([Could not find X11/extensions/secruity.h])],[#include ]) 61 | 62 | AC_OUTPUT(Makefile) 63 | -------------------------------------------------------------------------------- /copyauth.c: -------------------------------------------------------------------------------- 1 | /* This file is part of "xtrace" 2 | * Copyright (C) 2005 Bernhard R. Link 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License version 2 as 5 | * published by the Free Software Foundation. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program; if not, write to the Free Software 14 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | */ 16 | #include 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include "xtrace.h" 32 | 33 | /* This file is responsible for getting the autorisation tokens of the 34 | * device we are connecting to and saving them for the fake device we 35 | * are creating. This is done by calling xauth. (This allows to 36 | * to set PATH to an alternative utility to do even more funny things, 37 | * and is simpler than reimplementing xauth by using libXau) */ 38 | 39 | static inline ssize_t readtoend(int fd, char *buffer, size_t len) { 40 | size_t bytesgottotal = 0; 41 | ssize_t bytesgotlast; 42 | 43 | do { 44 | bytesgotlast = read(fd,buffer+bytesgottotal,len-bytesgottotal); 45 | if( bytesgotlast < 0 ) { 46 | int e = errno; 47 | fprintf(stderr,"Error reading from xauth pipe: %d=%s\n",e,strerror(e)); 48 | return bytesgotlast; 49 | } else if( bytesgotlast > 0 ) { 50 | bytesgottotal += bytesgotlast; 51 | if( bytesgottotal >= len ) { 52 | fprintf(stderr,"Too much data from xauth command: more than %u\n",(unsigned int)len); 53 | return -1; 54 | } 55 | } 56 | } while( bytesgotlast != 0 ); 57 | return bytesgottotal; 58 | } 59 | static inline bool parseauthdata(char *buffer,const char **name,const char **data) { 60 | char *p; 61 | bool foundsomething = false; 62 | char *thisname; 63 | char *thisdata; 64 | 65 | p = buffer; 66 | do { 67 | while( *p != '\0' && *p != '\n' && *p != ' ' && *p != '\t') 68 | p++; 69 | while( *p != '\0' && *p != '\n' && (*p == ' ' || *p == '\t') ) 70 | p++; 71 | thisname = p; 72 | while( *p != '\0' && *p != '\n' && *p != ' ' && *p != '\t' ) 73 | p++; 74 | if( *p != '\0' && *p != '\n' ) { 75 | *p = '\0'; 76 | p++; 77 | } 78 | while( *p != '\0' && *p != '\n' && (*p == ' ' || *p == '\t') ) 79 | p++; 80 | thisdata = p; 81 | while( *p != '\0' && *p != '\n' && *p != ' ' && *p != '\t' ) 82 | p++; 83 | if( *p != '\0' && *p != '\n' ) { 84 | *p = '\0'; 85 | p++; 86 | } 87 | while( *p != '\0' && *p != '\n' && (*p == ' ' || *p == '\t') ) 88 | p++; 89 | if( *p == '\n' ) { 90 | *p = '\0'; 91 | } else if( *p != '\0' ) { 92 | fprintf(stderr,"Error parsing xauth list data: more than three things in a line!\n"); 93 | return false; 94 | } 95 | if( thisname[0] == '\0' || thisdata[0] == '\0' ) { 96 | fprintf(stderr,"Error parsing xauth list data: less than three things in a line!\n"); 97 | return false; 98 | } 99 | if( strcmp(thisname,"MIT-MAGIC-COOKIE-1") == 0) { 100 | *name = thisname; 101 | *data = thisdata; 102 | foundsomething = true; 103 | } 104 | } while( *p != '\0' ); 105 | return foundsomething; 106 | } 107 | 108 | bool copy_authentication(const char *fakedisplay,const char *display, const char *infile, const char *outfile) { 109 | int pipe_fds[2]; 110 | int r,e; 111 | pid_t pid,waitresult; 112 | /* if this is not enough, copy manually */ 113 | char buffer[4096]; 114 | ssize_t bytesgot; 115 | #ifdef STUPIDCC 116 | const char *name = NULL, *data = NULL; 117 | #else 118 | const char *name,*data; 119 | #endif 120 | int status; 121 | 122 | if( strncmp(display,"localhost:",10) == 0 ) { 123 | /* copy with remote X DISPLAYs */ 124 | display += 9; 125 | } 126 | 127 | pid = fork(); 128 | if( pid < 0 ) { 129 | e = errno; 130 | fprintf(stderr,"Error forking: %d=%s\n",e,strerror(e)); 131 | return false; 132 | } 133 | if( pid == 0 ) { 134 | int fd = open("/dev/null",O_RDONLY); 135 | if( fd >= 0 ) { 136 | (void)dup2(fd,0); 137 | (void)dup2(fd,1); 138 | if( fd > 2 ) 139 | (void)close(fd); 140 | } 141 | if( outfile != NULL ) 142 | r = execlp("xauth","xauth","-f",outfile,"remove",fakedisplay,(char*)NULL); 143 | else 144 | r = execlp("xauth","xauth","remove",fakedisplay,(char*)NULL); 145 | exit(EXIT_FAILURE); 146 | } 147 | do { 148 | waitresult = waitpid(pid,&status,0); 149 | } while( waitresult < 0 && errno == EINTR ); 150 | if( waitresult < 0 ) { 151 | e = errno; 152 | fprintf(stderr,"Error waiting for xauth remove: %d=%s\n",e,strerror(e)); 153 | return false; 154 | } 155 | if( !WIFEXITED(status) ) { 156 | fprintf(stderr,"Abnormal termination of xauth remove!\n"); 157 | return false; 158 | } 159 | if( WEXITSTATUS(status) != 0 ) { 160 | fprintf(stderr,"xauth remove terminated with exit code %d!\n",(int)(WEXITSTATUS(status))); 161 | return false; 162 | } 163 | r = pipe(pipe_fds); 164 | if( r != 0 ) { 165 | e = errno; 166 | fprintf(stderr,"Error creating pipe: %d=%s\n",e,strerror(e)); 167 | return false; 168 | } 169 | pid = fork(); 170 | if( pid < 0 ) { 171 | e = errno; 172 | fprintf(stderr,"Error forking: %d=%s\n",e,strerror(e)); 173 | return false; 174 | } 175 | if( pid == 0 ) { 176 | int fd = open("/dev/null",O_RDONLY); 177 | if( fd >= 0 ) { 178 | (void)dup2(fd,0); 179 | if( fd > 2 ) 180 | (void)close(fd); 181 | } 182 | (void)close(pipe_fds[0]); 183 | r = dup2(pipe_fds[1],1); 184 | if( r < 0 ) { 185 | e = errno; 186 | fprintf(stderr,"Error connecting pipe to stdin in child process: %d=%s\n",e,strerror(e)); 187 | exit(EXIT_FAILURE); 188 | } 189 | (void)close(pipe_fds[1]); 190 | if( infile != NULL ) 191 | r = execlp("xauth","xauth","-f",infile,"list",display,(char*)NULL); 192 | else 193 | r = execlp("xauth","xauth","list",display,(char*)NULL); 194 | exit(EXIT_FAILURE); 195 | } 196 | (void)close(pipe_fds[1]); 197 | bytesgot = readtoend(pipe_fds[0],buffer,sizeof(buffer)-1); 198 | if( bytesgot < 0 ) { 199 | return false; 200 | } 201 | r = close(pipe_fds[0]); 202 | if( r != 0 ) { 203 | e = errno; 204 | fprintf(stderr,"Error reading from pipe from xauth: %d=%s\n",e,strerror(e)); 205 | return false; 206 | } 207 | buffer[bytesgot-1] = '\0'; 208 | do { 209 | waitresult = waitpid(pid,&status,0); 210 | } while( waitresult < 0 && errno == EINTR ); 211 | if( waitresult < 0 ) { 212 | e = errno; 213 | fprintf(stderr,"Error waiting for xauth list: %d=%s\n",e,strerror(e)); 214 | return false; 215 | } 216 | if( !WIFEXITED(status) ) { 217 | fprintf(stderr,"Abnormal termination of xauth list!\n"); 218 | return false; 219 | } 220 | if( WEXITSTATUS(status) != 0 ) { 221 | fprintf(stderr,"xauth list terminated with exit code %d!\n",(int)(WEXITSTATUS(status))); 222 | return false; 223 | } 224 | if( !parseauthdata(buffer,&name,&data) ) { 225 | return false; 226 | } 227 | pid = fork(); 228 | if( pid < 0 ) { 229 | e = errno; 230 | fprintf(stderr,"Error forking: %d=%s\n",e,strerror(e)); 231 | return false; 232 | } 233 | if( pid == 0 ) { 234 | int fd = open("/dev/null",O_RDONLY); 235 | if( fd >= 0 ) { 236 | (void)dup2(fd,0); 237 | (void)dup2(fd,1); 238 | if( fd > 2 ) 239 | (void)close(fd); 240 | } 241 | if( outfile != NULL ) 242 | r = execlp("xauth","xauth","-f",outfile,"add",fakedisplay,name,data,(char*)NULL); 243 | else 244 | r = execlp("xauth","xauth","add",fakedisplay,name,data,(char*)NULL); 245 | exit(EXIT_FAILURE); 246 | } 247 | do { 248 | waitresult = waitpid(pid,&status,0); 249 | } while( waitresult < 0 && errno == EINTR ); 250 | if( waitresult < 0 ) { 251 | e = errno; 252 | fprintf(stderr,"Error waiting for xauth add: %d=%s\n",e,strerror(e)); 253 | return false; 254 | } 255 | if( !WIFEXITED(status) ) { 256 | fprintf(stderr,"Abnormal termination of xauth add!\n"); 257 | return false; 258 | } 259 | if( WEXITSTATUS(status) != 0 ) { 260 | fprintf(stderr,"xauth add terminated with exit code %d!\n",(int)(WEXITSTATUS(status))); 261 | return false; 262 | } 263 | return true; 264 | } 265 | -------------------------------------------------------------------------------- /damage.proto: -------------------------------------------------------------------------------- 1 | # This file is part of "xtrace" 2 | # Copyright (C) 2008 Bernhard R. Link 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License version 2 as 5 | # published by the Free Software Foundation. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | # 12 | # You should have received a copy of the GNU General Public License 13 | # along with this program; if not, write to the Free Software 14 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | EXTENSION "DAMAGE" Damage 17 | USE core 18 | 19 | REQUESTS 20 | QueryVersion RESPONDS 21 | Create 22 | Destroy 23 | Subtract 24 | END 25 | 26 | EVENTS 27 | Notify 28 | END 29 | 30 | ERRORS 31 | BadDamage 32 | END 33 | 34 | CONSTANTS damage_level 35 | 0 "report raw rectangles" 36 | 1 "report delta rectangles" 37 | 2 "report bounding box" 38 | 3 "report non-empty" 39 | END 40 | TYPE DAMAGE_LEVEL ENUM8 damage_level 41 | 42 | CONSTANTS damage_state 43 | 0 off 44 | 1 on 45 | 2 cycle 46 | 3 disable 47 | END 48 | TYPE DAMAGE_STATE ENUM8 damage_state 49 | CONSTANTS damage_kind 50 | 0 blanked 51 | 1 internal 52 | 2 external 53 | END 54 | TYPE DAMAGE_KIND ENUM8 damage_kind 55 | 56 | BITMASK damage_mask 57 | 0x00000001 notify 58 | 0x00000002 cycle 59 | END 60 | TYPE DAMAGE_MASK BITMASK32 damage_mask 61 | 62 | REQUEST QueryVersion 63 | 4 "major version" UINT32 64 | 8 "minor version" UINT32 65 | END 66 | RESPONSE QueryVersion 67 | 8 "major version" UINT32 68 | 12 "minor version" UINT32 69 | END 70 | 71 | REQUEST Create 72 | 4 damage CARD32 73 | 8 drawable DRAWABLE 74 | 12 level DAMAGE_LEVEL 75 | END 76 | 77 | REQUEST Destroy 78 | 4 damage CARD32 79 | END 80 | 81 | REQUEST Subtract 82 | 4 damage CARD32 83 | 8 repair-region CARD32 84 | 12 parts-region CARD32 85 | END 86 | 87 | EVENT Notify 88 | 1 level DAMAGE_LEVEL 89 | 4 drawable DRAWABLE 90 | 8 damage CARD32 91 | 12 timestamp TIMESTAMP 92 | 16 area RECTANGLE 93 | 24 geometry RECTANGLE 94 | END 95 | 96 | EOF 97 | -------------------------------------------------------------------------------- /dga.proto: -------------------------------------------------------------------------------- 1 | # This file is part of "xtrace" 2 | # Copyright (C) 2011 Ville Syrjala 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License version 2 as 5 | # published by the Free Software Foundation. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | # 12 | # You should have received a copy of the GNU General Public License 13 | # along with this program; if not, write to the Free Software 14 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | # 16 | # This file is based on /usr/include/X11/extensions/xf86dga1const.h, 17 | # /usr/include/X11/extensions/xf86dga1proto.h and 18 | # /usr/include/X11/extensions/xf86dgaproto.h which state: 19 | # 20 | # Copyright (c) 1995 Jon Tombs 21 | # Copyright (c) 1995 XFree86 Inc 22 | # 23 | # This file is based on /usr/include/X11/extensions/xf86dgaconst.h which states: 24 | # 25 | # Copyright (c) 1999 XFree86 Inc 26 | # 27 | # and those files it is based on are available under: 28 | # 29 | # Permission is hereby granted, free of charge, to any person obtaining a copy 30 | # of this software and associated documentation files (the "Software"), to deal 31 | # in the Software without restriction, including without limitation the rights 32 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 33 | # copies of the Software, and to permit persons to whom the Software is 34 | # furnished to do so, subject to the following conditions: 35 | # 36 | # The above copyright notice and this permission notice shall be included in all 37 | # copies or substantial portions of the Software. 38 | # 39 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 40 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 41 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 42 | # XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 43 | # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 44 | # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 45 | # 46 | # Except as contained in this notice, the name of the XFree86 Project shall not 47 | # be used in advertising or otherwise to promote the sale, use or other dealings 48 | # in this Software without prior written authorization from the XFree86 Project. 49 | 50 | EXTENSION "XFree86-DGA" DGA 51 | USE core 52 | 53 | REQUESTS 54 | DGAQueryVersion RESPONDS 55 | DGA1GetVideoLL RESPONDS 56 | DGA1DirectVideo 57 | DGA1GetViewPortSize RESPONDS 58 | DGA1SetViewPort 59 | DGA1GetVidPage RESPONDS 60 | DGA1SetVidPage 61 | DGA1InstallColormap 62 | DGA1QueryDirectVideo RESPONDS 63 | DGA1ViewPortChanged RESPONDS 64 | UNKNOWN 65 | UNKNOWN 66 | DGA2QueryModes RESPONDS 67 | DGA2SetMode RESPONDS 68 | DGA2SetViewport 69 | DGA2InstallColormap 70 | DGA2SelectInput 71 | DGA2FillRectangle 72 | DGA2CopyArea 73 | DGA2CopyTransparentArea 74 | DGA2GetViewportStatus RESPONDS 75 | DGA2Sync RESPONDS 76 | DGA2OpenFrameBuffer RESPONDS 77 | DGA2CloseFrameBuffer 78 | DGA2SetClientVersion 79 | DGA2ChangePixmapMode RESPONDS 80 | DGA2CreateColormap 81 | END 82 | 83 | EVENTS 84 | UNKNOWN 85 | UNKNOWN 86 | KeyPress 87 | KeyRelease 88 | ButtonPress 89 | ButtonRelease 90 | MotionNotify 91 | END 92 | 93 | ERRORS 94 | ClientNotLocal 95 | NoDirectVideoMode 96 | ScreenNotActive 97 | DirectNotActivated 98 | OperationNotSupported 99 | END 100 | 101 | BITMASK directvideoflags 102 | 0x0001 DirectPresent 103 | 0x0002 DirectGraphics 104 | 0x0004 DirectMouse 105 | 0x0008 DirectKeyb 106 | 0x0100 HasColormap 107 | 0x0200 DirectColormap 108 | END 109 | TYPE DIRECTVIDEOFLAGS16 BITMASK16 directvideoflags 110 | TYPE DIRECTVIDEOFLAGS32 BITMASK32 directvideoflags 111 | 112 | BITMASK viewportflags 113 | 0x00000001 FlipImmediate 114 | 0x00000002 FlipRetrace 115 | END 116 | TYPE VIEWPORTFLAGS BITMASK32 viewportflags 117 | 118 | BITMASK modeflags 119 | 0x00000001 ConcurrentAccess 120 | 0x00000002 SolidFillRect 121 | 0x00000004 BlitRect 122 | 0x00000008 BlitTransRect 123 | 0x00000010 Pixmap 124 | 0x00010000 Interlaced 125 | 0x00020000 Doublescan 126 | END 127 | TYPE MODEFLAGS BITMASK32 modeflags 128 | 129 | CONSTANTS pixmapmodeflags 130 | 0 PixmapModeLarge 131 | 1 PixmapModeSmall 132 | END 133 | TYPE PIXMAPMODEFLAGS CARD32 constants pixmapmodeflags 134 | 135 | BITMASK fbextraflags 136 | 0x00000001 NeedRoot 137 | END 138 | TYPE FBEXTRAFLAGS BITMASK32 fbextraflags 139 | 140 | REQUEST DGAQueryVersion 141 | END 142 | RESPONSE DGAQueryVersion 143 | 8 major-version UINT16 144 | 10 minor-version UINT16 145 | END 146 | 147 | REQUEST DGA1GetVideoLL 148 | 4 screen UINT16 149 | END 150 | RESPONSE DGA1GetVideoLL 151 | 8 offset UINT32 152 | 12 width UINT32 153 | 16 bank-size UINT32 154 | 20 ram-size UINT32 155 | END 156 | 157 | REQUEST DGA1InstallColormap 158 | 4 screen UINT16 159 | 8 id COLORMAP 160 | END 161 | 162 | REQUEST DGA1DirectVideo 163 | 4 screen UINT16 164 | 6 enable DIRECTVIDEOFLAGS16 165 | END 166 | 167 | REQUEST DGA1GetViewPortSize 168 | 4 screen UINT16 169 | END 170 | RESPONSE DGA1GetViewPortSize 171 | 8 width UINT32 172 | 12 height UINT32 173 | END 174 | 175 | REQUEST DGA1SetViewPort 176 | 4 screen UINT16 177 | 8 x UINT32 178 | 12 y UINT32 179 | END 180 | 181 | REQUEST DGA1GetVidPage 182 | 4 screen UINT16 183 | END 184 | RESPONSE DGA1GetVidPage 185 | 8 vpage UINT32 186 | END 187 | 188 | REQUEST DGA1SetVidPage 189 | 4 screen UINT16 190 | 6 vpage UINT16 191 | END 192 | 193 | REQUEST DGA1QueryDirectVideo 194 | 4 screen UINT16 195 | END 196 | RESPONSE DGA1QueryDirectVideo 197 | 8 flags DIRECTVIDEOFLAGS32 198 | END 199 | 200 | REQUEST DGA1ViewPortChanged 201 | 4 screen UINT16 202 | 6 num_pages UINT16 203 | END 204 | RESPONSE DGA1ViewPortChanged 205 | 8 result UINT32 206 | END 207 | 208 | LIST MODEINFO variable min-length 72 209 | 0 byte-order UINT8 210 | 1 depth UINT8 211 | 2 num UINT16 212 | 4 bpp UINT16 213 | 6 name-size COUNT16 214 | 8 vsync UFRACTION32_32 215 | 16 flags MODEFLAGS 216 | 20 image-width UINT16 217 | 22 image-height UINT16 218 | 24 pixmap-width UINT16 219 | 26 pixmap-height UINT16 220 | 28 bytes-per-scanline UINT32 221 | 32 red-mask CARD32 222 | 36 green-mask CARD32 223 | 40 blue-mask CARD32 224 | 44 visual-class UINT16 225 | 48 viewport-width UINT16 226 | 50 viewport-height UINT16 227 | 52 viewport-xstep UINT16 228 | 54 viewport-ystep UINT16 229 | 56 viewport-xmax UINT16 230 | 58 viewport-ymax UINT16 231 | 60 viewport-flags VIEWPORTFLAGS 232 | 64 reserved1 UINT32 233 | 68 reserved2 UINT32 234 | 72 name STRING8 235 | ROUND 236 | END 237 | 238 | REQUEST DGA2QueryModes 239 | 4 screen UINT32 240 | END 241 | RESPONSE DGA2QueryModes 242 | 8 number COUNT32 243 | 32 modes LISTofMODEINFO 244 | END 245 | 246 | REQUEST DGA2SetMode 247 | 4 screen UINT32 248 | 8 mode UINT32 249 | 12 pid PIXMAP 250 | END 251 | RESPONSE DGA2SetMode 252 | 8 flags MODEFLAGS 253 | 32 mode LISTofMODEINFO 254 | END 255 | 256 | REQUEST DGA2OpenFrameBuffer 257 | 4 screen UINT32 258 | END 259 | RESPONSE DGA2OpenFrameBuffer 260 | 8 mem1 CARD32 261 | 12 mem2 CARD32 262 | 16 size CARD32 263 | 20 offset UINT32 264 | 24 extra FBEXTRAFLAGS 265 | 32 device-name STRING8 266 | END 267 | 268 | REQUEST DGA2CloseFrameBuffer 269 | 4 screen UINT32 270 | END 271 | 272 | REQUEST DGA2SetViewport 273 | 4 screen UINT32 274 | 8 x UINT16 275 | 10 y UINT16 276 | 12 flags VIEWPORTFLAGS 277 | END 278 | 279 | REQUEST DGA2InstallColormap 280 | 4 screen UINT32 281 | 8 cmap COLORMAP 282 | END 283 | 284 | REQUEST DGA2SelectInput 285 | 4 screen UINT32 286 | 8 mask SETofDEVICEEVENT 287 | END 288 | 289 | REQUEST DGA2FillRectangle 290 | 4 screen UINT32 291 | 8 x UINT16 292 | 10 y UINT16 293 | 12 width UINT16 294 | 14 height UINT16 295 | 16 color CARD32 296 | END 297 | 298 | REQUEST DGA2CopyArea 299 | 4 screen UINT32 300 | 8 src-x UINT16 301 | 10 src-y UINT16 302 | 12 width UINT16 303 | 14 height UINT16 304 | 16 dst-x UINT16 305 | 18 dst-y UINT16 306 | END 307 | 308 | REQUEST DGA2CopyTransparentArea 309 | 4 screen UINT32 310 | 8 src-x UINT16 311 | 10 src-y UINT16 312 | 12 width UINT16 313 | 14 height UINT16 314 | 16 dst-x UINT16 315 | 18 dst-y UINT16 316 | 20 key UINT32 317 | END 318 | 319 | REQUEST DGA2GetViewportStatus 320 | 4 screen UINT32 321 | END 322 | RESPONSE DGA2GetViewportStatus 323 | 8 status CARD32 324 | END 325 | 326 | REQUEST DGA2Sync 327 | 4 screen UINT32 328 | END 329 | RESPONSE DGA2Sync 330 | END 331 | 332 | REQUEST DGA2SetClientVersion 333 | 4 major UINT16 334 | 6 minor UINT16 335 | END 336 | 337 | REQUEST DGA2ChangePixmapMode 338 | 4 screen UINT32 339 | 8 x UINT16 340 | 10 y UINT16 341 | 12 flags PIXMAPMODEFLAGS 342 | END 343 | RESPONSE DGA2ChangePixmapMode 344 | 8 screen UINT32 345 | 12 x UINT16 346 | 14 y UINT16 347 | END 348 | 349 | REQUEST DGA2CreateColormap 350 | 4 screen UINT32 351 | 8 id COLORMAP 352 | 12 mode UINT32 353 | 16 alloc ENUM8 alloc 354 | END 355 | 356 | templateEVENT Key 357 | 1 keycode KEYCODE 358 | 8 time TIMESTAMP 359 | 16 screen INT16 360 | 18 state SETofKEYBUTMASK 361 | END 362 | 363 | EVENT KeyPress ALIASES Key 364 | EVENT KeyRelease ALIASES Key 365 | 366 | templateEVENT Button 367 | 1 button BUTTON 368 | 8 time TIMESTAMP 369 | 16 screen INT16 370 | 18 state SETofKEYBUTMASK 371 | END 372 | 373 | EVENT ButtonPress ALIASES Button 374 | EVENT ButtonRelease ALIASES Button 375 | 376 | EVENT MotionNotify 377 | 8 time TIMESTAMP 378 | 12 dx INT16 379 | 14 dy INT16 380 | 16 screen INT16 381 | 18 state SETofKEYBUTMASK 382 | END 383 | 384 | EOF 385 | -------------------------------------------------------------------------------- /dpms.proto: -------------------------------------------------------------------------------- 1 | # This file is part of "xtrace" 2 | # Copyright (C) 2008 Bernhard R. Link 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License version 2 as 5 | # published by the Free Software Foundation. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | # 12 | # You should have received a copy of the GNU General Public License 13 | # along with this program; if not, write to the Free Software 14 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | EXTENSION "DPMS" Dpms 17 | USE core 18 | 19 | REQUESTS 20 | GetVersion RESPONDS 21 | Capable RESPONDS 22 | GetTimeouts RESPONDS 23 | SetTimeouts 24 | Enable 25 | Disable 26 | ForceLevel 27 | Info RESPONDS 28 | END 29 | 30 | EVENTS 31 | END 32 | ERRORS 33 | END 34 | 35 | CONSTANTS dpms_level 36 | 0 on 37 | 1 standby 38 | 2 suspend 39 | 3 off 40 | END 41 | TYPE DPMS_LEVEL ENUM16 dpms_level 42 | 43 | REQUEST GetVersion 44 | 4 "major version" UINT16 45 | 6 "minor version" UINT16 46 | END 47 | RESPONSE GetVersion 48 | 8 "major version" UINT16 49 | 10 "minor version" UINT16 50 | END 51 | 52 | REQUEST Capable ALIASES Empty 53 | RESPONSE Capable 54 | 8 capable BOOL 55 | END 56 | 57 | REQUEST GetTimeouts ALIASES Empty 58 | RESPONSE GetTimeouts 59 | 8 standby UINT16 60 | 10 suspend UINT16 61 | 12 off UINT16 62 | END 63 | 64 | REQUEST SetTimeouts 65 | 4 standby UINT16 66 | 6 suspend UINT16 67 | 8 off UINT16 68 | END 69 | 70 | REQUEST Enable ALIASES Empty 71 | 72 | REQUEST Disable ALIASES Empty 73 | 74 | REQUEST ForceLevel 75 | 4 level DPMS_LEVEL 76 | END 77 | 78 | REQUEST Info ALIASES Empty 79 | RESPONSE Info 80 | 8 power_level DPMS_LEVEL 81 | 10 state BOOL 82 | END 83 | 84 | EOF 85 | -------------------------------------------------------------------------------- /dri2.proto: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuq/xtrace/fd1e5a94628acc6277904c547992825aefa119c6/dri2.proto -------------------------------------------------------------------------------- /dri3.proto: -------------------------------------------------------------------------------- 1 | NEEDS "sync.proto" 2 | NEEDS "randr.proto" 3 | 4 | EXTENSION "DRI3" DRI3 5 | USE core 6 | 7 | REQUESTS 8 | QueryVersion RESPONDS 9 | Open RESPONDS 10 | PixmapFromBuffer 11 | BufferFromPixmap RESPONDS 12 | FenceFromFD 13 | FDFromFence RESPONDS 14 | END 15 | 16 | EVENTS 17 | END 18 | 19 | ERRORS 20 | END 21 | 22 | REQUEST QueryVersion 23 | 4 major_version UINT32 24 | 8 minor_version UINT32 25 | END 26 | RESPONSE QueryVersion 27 | 8 major-version UINT32 28 | 12 minor-version UINT32 29 | END 30 | 31 | REQUEST Open 32 | 4 drawable DRAWABLE 33 | 8 provider RandR::PROVIDER 34 | END 35 | RESPONSE Open 36 | 1 nfd UINT8 37 | END 38 | 39 | REQUEST PixmapFromBuffer 40 | 4 pixmap PIXMAP 41 | 8 drawable DRAWABLE 42 | 12 size UINT32 43 | 16 width UINT16 44 | 18 height UINT16 45 | 20 stride UINT16 46 | 22 depth UINT8 47 | 23 bpp UINT8 48 | END 49 | 50 | REQUEST BufferFromPixmap 51 | 4 pixmap PIXMAP 52 | END 53 | RESPONSE BufferFromPixmap 54 | 1 nfd UINT8 55 | 8 size UINT32 56 | 12 width UINT16 57 | 14 height UINT16 58 | 16 stride UINT16 59 | 18 depth UINT8 60 | 19 bpp UINT8 61 | END 62 | 63 | REQUEST FenceFromFD 64 | 4 drawable DRAWABLE 65 | 8 fence XSync::Fence 66 | 9 initially_triggered BOOL 67 | END 68 | 69 | REQUEST FDFromFence 70 | 4 drawable DRAWABLE 71 | 8 fence XSync::Fence 72 | END 73 | RESPONSE FDFromFence 74 | 1 nfd UINT8 75 | END 76 | 77 | EOF 78 | -------------------------------------------------------------------------------- /errors.proto: -------------------------------------------------------------------------------- 1 | NAMESPACE core 2 | 3 | ERRORS 4 | "no error" 5 | Request 6 | Value 7 | Window 8 | Pixmap 9 | Atom 10 | Cursor 11 | Font 12 | Match 13 | Drawable 14 | Access 15 | Alloc 16 | Colormap 17 | GContext 18 | IDChoice 19 | Name 20 | Length 21 | Implementation 22 | END 23 | 24 | EOF 25 | -------------------------------------------------------------------------------- /events.proto: -------------------------------------------------------------------------------- 1 | # This file is part of "xtrace" 2 | # Copyright (C) 2005 Bernhard R. Link 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License version 2 as 5 | # published by the Free Software Foundation. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | # 12 | # You should have received a copy of the GNU General Public License 13 | # along with this program; if not, write to the Free Software 14 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | # 16 | # This file is based on the 17 | # X Window System Protocol 18 | # X Consortium Standard 19 | # X Version 11, Release 6.4 20 | # 21 | # Robert W. Scheifler 22 | # X Consortium, Inc. 23 | # 24 | # with the following trademark and copyright notices and acknowlegdgments: 25 | ## 26 | ## X Window System is a trademark of X Consortium, Inc. 27 | ## 28 | ## Copyright (C) 1986, 1987, 1988, 1994 X Consortium 29 | ## 30 | ## Permission is hereby granted, free of charge, to any person 31 | ## obtaining a copy of this software and associated documenta- 32 | ## tion files (the ``Software''), to deal in the Software with- 33 | ## out restriction, including without limitation the rights to 34 | ## use, copy, modify, merge, publish, distribute, sublicense, 35 | ## and/or sell copies of the Software, and to permit persons to 36 | ## whom the Software is furnished to do so, subject to the fol- 37 | ## lowing conditions: 38 | ## 39 | ## The above copyright notice and this permission notice shall 40 | ## be included in all copies or substantial portions of the 41 | ## Software. 42 | ## 43 | ## THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY 44 | ## KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 45 | ## WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PUR- 46 | ## POSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE X CONSOR- 47 | ## TIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 48 | ## WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 49 | ## FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 50 | ## OR OTHER DEALINGS IN THE SOFTWARE. 51 | ## 52 | ## Except as contained in this notice, the name of the X Con- 53 | ## sortium shall not be used in advertising or otherwise to 54 | ## promote the sale, use or other dealings in this Software 55 | ## without prior written authorization from the X Consortium. 56 | ## 57 | ## Acknowledgments 58 | ## 59 | ## The primary contributers to the X11 protocol are: 60 | ## 61 | ## Dave Carver (Digital HPW) 62 | ## Branko Gerovac (Digital HPW) 63 | ## Jim Gettys (MIT/Project Athena, Digital) 64 | ## Phil Karlton (Digital WSL) 65 | ## Scott McGregor (Digital SSG) 66 | ## Ram Rao (Digital UEG) 67 | ## David Rosenthal (Sun) 68 | ## Dave Winchell (Digital UEG) 69 | ## 70 | ## The implementors of initial server who provided useful input 71 | ## are: 72 | ## 73 | ## Susan Angebranndt (Digital) 74 | ## Raymond Drewry (Digital) 75 | ## Todd Newman (Digital) 76 | ## 77 | ## The invited reviewers who provided useful input are: 78 | ## 79 | ## Andrew Cherenson (Berkeley) 80 | ## Burns Fisher (Digital) 81 | ## Dan Garfinkel (HP) 82 | ## Leo Hourvitz (Next) 83 | ## Brock Krizan (HP) 84 | ## David Laidlaw (Stellar) 85 | ## Dave Mellinger (Interleaf) 86 | ## Ron Newman (MIT) 87 | ## John Ousterhout (Berkeley) 88 | ## Andrew Palay (ITC CMU) 89 | ## Ralph Swick (MIT) 90 | ## Craig Taylor (Sun) 91 | ## Jeffery Vroom (Stellar) 92 | ## 93 | 94 | NEEDS "requests.proto" 95 | NAMESPACE core 96 | 97 | EVENTS 98 | UNKNOWN 99 | UNKNOWN 100 | KeyPress 101 | KeyRelease 102 | ButtonPress 103 | ButtonRelease 104 | MotionNotify 105 | EnterNotify 106 | LeaveNotify 107 | FocusIn 108 | FocusOut 109 | KeymapNotify 110 | Expose 111 | GraphicsExposure 112 | NoExposure 113 | VisibilityNotify 114 | CreateNotify 115 | DestroyNotify 116 | UnmapNotify 117 | MapNotify 118 | MapRequest 119 | ReparentNotify 120 | ConfigureNotify 121 | ConfigureRequest 122 | GravityNotify 123 | ResizeRequest 124 | CirculateNotify 125 | CirculateRequest 126 | PropertyNotify 127 | SelectionClear 128 | SelectionRequest 129 | SelectionNotify 130 | ColormapNotify 131 | ClientMessage 132 | MappingNotify 133 | Generic SPECIAL 134 | END 135 | 136 | templateEVENT Key 137 | 1 keycode KEYCODE 138 | 4 time TIMESTAMP 139 | 8 root WINDOW 140 | 12 event WINDOW 141 | 16 child WINDOW constants none 142 | 20 root-x INT16 143 | 22 root-y INT16 144 | 24 event-x INT16 145 | 26 event-y INT16 146 | 28 state SETofKEYBUTMASK 147 | 30 same-screen BOOL 148 | END 149 | 150 | EVENT KeyPress ALIASES Key 151 | EVENT KeyRelease ALIASES Key 152 | 153 | templateEVENT Button 154 | 1 button BUTTON 155 | 4 time TIMESTAMP 156 | 8 root WINDOW 157 | 12 event WINDOW 158 | 16 child WINDOW constants none 159 | 20 root-x INT16 160 | 22 root-y INT16 161 | 24 event-x INT16 162 | 26 event-y INT16 163 | 28 state SETofKEYBUTMASK 164 | 30 same-screen BOOL 165 | END 166 | 167 | EVENT ButtonPress ALIASES Button 168 | EVENT ButtonRelease ALIASES Button 169 | 170 | CONSTANTS normalhint 171 | 0 Normal 172 | 1 Hint 173 | END 174 | 175 | EVENT MotionNotify 176 | 1 detail ENUM8 normalhint 177 | 4 time TIMESTAMP 178 | 8 root WINDOW 179 | 12 event WINDOW 180 | 16 child WINDOW constants none 181 | 20 root-x INT16 182 | 22 root-y INT16 183 | 24 event-x INT16 184 | 26 event-y INT16 185 | 28 state SETofKEYBUTMASK 186 | 30 same-screen BOOL 187 | END 188 | 189 | CONSTANTS enterdetail 190 | 0 Ancestor 191 | 1 Virtual 192 | 2 Inferior 193 | 3 Nonlinear 194 | 4 NonlinearVirtual 195 | 5 Pointer 196 | 6 PointerRoot 197 | 7 None 198 | END 199 | CONSTANTS grabmode 200 | 0 Normal 201 | 1 Grab 202 | 2 Ungrab 203 | 3 WhileGrabbed 204 | END 205 | BITMASK focusscreen 206 | 0x01 focus 207 | 0x02 same-screen 208 | 0xFC unused 209 | END 210 | 211 | EVENT EnterNotify 212 | 1 detail ENUM8 enterdetail 213 | 30 mode ENUM8 grabmode 214 | 31 flags BITMASK8 focusscreen 215 | 4 time TIMESTAMP 216 | 8 root WINDOW 217 | 12 event WINDOW 218 | 16 child WINDOW constants none 219 | 20 root-x INT16 220 | 22 root-y INT16 221 | 24 event-x INT16 222 | 26 event-y INT16 223 | 28 state SETofKEYBUTMASK 224 | END 225 | EVENT LeaveNotify ALIASES EnterNotify 226 | 227 | EVENT FocusIn 228 | 1 detail ENUM8 enterdetail 229 | 4 event WINDOW 230 | 8 mode ENUM8 grabmode 231 | END 232 | EVENT FocusOut ALIASES FocusIn 233 | 234 | EVENT KeymapNotify 235 | 1 "keys(0-7 omitted)" LISTofCARD8 236 | END 237 | 238 | EVENT Expose 239 | 4 window WINDOW 240 | 8 x UINT16 241 | 10 y UINT16 242 | 12 width UINT16 243 | 14 height UINT16 244 | 16 count CARD16 245 | END 246 | 247 | EVENT GraphicsExposure 248 | 4 drawable DRAWABLE 249 | 8 x UINT16 250 | 10 y UINT16 251 | 12 width UINT16 252 | 13 height UINT16 253 | 14 minor-opcode CARD16 254 | 18 count CARD16 255 | 20 major-opcode CARD8 256 | END 257 | 258 | EVENT NoExposure 259 | 4 drawable DRAWABLE 260 | 8 minor-opcode CARD16 261 | 10 major-opcode CARD8 262 | END 263 | 264 | CONSTANTS obscure 265 | 0 Unobscured 266 | 1 PartiallyObscured 267 | 2 FullyObscured 268 | END 269 | 270 | EVENT VisibilityNotify 271 | 4 window WINDOW 272 | 8 state ENUM8 obscure 273 | END 274 | 275 | EVENT CreateNotify 276 | 4 parent WINDOW 277 | 8 window WINDOW 278 | 12 x INT16 279 | 14 y INT16 280 | 16 width UINT16 281 | 18 height UINT16 282 | 20 border-width UINT16 283 | 22 override-redirect BOOL 284 | END 285 | 286 | EVENT DestroyNotify 287 | 4 event WINDOW 288 | 8 window WINDOW 289 | END 290 | 291 | EVENT UnmapNotify 292 | 4 event WINDOW 293 | 8 window WINDOW 294 | 12 from-configure BOOL 295 | END 296 | 297 | EVENT MapNotify 298 | 4 event WINDOW 299 | 8 window WINDOW 300 | 12 override-redirect BOOL 301 | END 302 | 303 | EVENT MapRequest 304 | 4 parent WINDOW 305 | 8 window WINDOW 306 | END 307 | 308 | EVENT ReparentNotify 309 | 4 event WINDOW 310 | 8 window WINDOW 311 | 12 parent WINDOW 312 | 16 x INT16 313 | 18 y INT16 314 | 20 override-redirect BOOL 315 | END 316 | 317 | EVENT ConfigureNotify 318 | 4 event WINDOW 319 | 8 window WINDOW 320 | 12 above-sibling WINDOW constants none 321 | 16 x INT16 322 | 18 y INT16 323 | 20 width UINT16 324 | 22 height UINT16 325 | 24 border-width UINT16 326 | 26 override-redirect BOOL 327 | END 328 | 329 | BITMASK configure_mask 330 | 0x0001 x 331 | 0x0002 y 332 | 0x0004 width 333 | 0x0008 height 334 | 0x0010 border-width 335 | 0x0020 sibling 336 | 0x0040 stack-mode 337 | END 338 | 339 | EVENT ConfigureRequest 340 | 4 parent WINDOW 341 | 8 window WINDOW 342 | 26 value-mask BITMASK16 configure_mask 343 | 1 stack-mode ENUM8 stack_mode 344 | 12 sibling WINDOW constants none 345 | 16 x INT16 346 | 18 y INT16 347 | 20 width UINT16 348 | 22 height UINT16 349 | 24 border-width UINT16 350 | END 351 | 352 | EVENT GravityNotify 353 | 4 event WINDOW 354 | 8 window WINDOW 355 | 12 x INT16 356 | 14 y INT16 357 | END 358 | 359 | EVENT ResizeRequest 360 | 4 window WINDOW 361 | 8 width UINT16 362 | 10 height UINT16 363 | END 364 | 365 | CONSTANTS topbottom 366 | 0 Top 367 | 1 Bottom 368 | END 369 | 370 | EVENT CirculateNotify 371 | 4 event WINDOW 372 | 8 window WINDOW 373 | 16 place ENUM8 topbottom 374 | END 375 | EVENT CirculateRequest ALIASES CirculateNotify 376 | 377 | CONSTANTS newdeleted 378 | 0 NewValue 379 | 1 Deleted 380 | END 381 | 382 | EVENT PropertyNotify 383 | 4 window WINDOW 384 | 8 atom ATOM 385 | 12 time TIMESTAMP 386 | 16 state ENUM8 newdeleted 387 | END 388 | 389 | EVENT SelectionClear 390 | 4 time TIMESTAMP 391 | 8 owner WINDOW 392 | 12 selection ATOM 393 | END 394 | 395 | 396 | EVENT SelectionRequest 397 | 4 time TIMESTAMP constants curtime 398 | 8 owner WINDOW 399 | 12 requestor WINDOW 400 | 16 selection ATOM 401 | 20 target ATOM 402 | 24 property ATOM constants none 403 | END 404 | 405 | EVENT SelectionNotify 406 | 4 time TIMESTAMP constants curtime 407 | 8 requestor WINDOW 408 | 12 selection ATOM 409 | 16 target ATOM 410 | 20 property ATOM constants none 411 | END 412 | 413 | CONSTANTS uninstalledinstalled 414 | 0 Uninstalled 415 | 1 Installed 416 | END 417 | 418 | EVENT ColormapNotify 419 | 4 window WINDOW 420 | 8 colormap COLORMAP constants none 421 | 12 new BOOL 422 | 13 state ENUM8 uninstalledinstalled 423 | END 424 | 425 | EVENT ClientMessage 426 | 1 format CARD8 427 | 4 window WINDOW 428 | 8 type ATOM 429 | 12 data LISTofCARD8 430 | END 431 | 432 | CONSTANTS modkeypoi 433 | 0 Modifier 434 | 1 Keyboard 435 | 2 Pointer 436 | END 437 | 438 | EVENT MappingNotify 439 | 4 request ENUM8 modkeypoi 440 | 5 first-keycode KEYCODE 441 | 6 count CARD8 442 | END 443 | 444 | EVENT Generic 445 | 1 extension CARD8 446 | 4 length UINT32 447 | 8 evtype CARD16 448 | 10 data LISTofCARD8 449 | END 450 | 451 | EOF 452 | -------------------------------------------------------------------------------- /fixes.proto: -------------------------------------------------------------------------------- 1 | # This file is part of "xtrace" 2 | # Copyright (C) 2008 Bernhard R. Link 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License version 2 as 5 | # published by the Free Software Foundation. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | # 12 | # You should have received a copy of the GNU General Public License 13 | # along with this program; if not, write to the Free Software 14 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | NEEDS "render.proto" 17 | NEEDS "shape.proto" 18 | 19 | EXTENSION "XFIXES" Fixes 20 | USE core 21 | 22 | TYPE PICTURE Render::PICTURE 23 | 24 | REQUESTS 25 | QueryVersion RESPONDS 26 | ChangeSaveSet 27 | SelectSelectionInput 28 | SelectCursorInput 29 | GetCursorImage RESPONDS 30 | CreateRegion 31 | CreateRegionFromBitmap 32 | CreateRegionFromWindow 33 | CreateRegionFromGC 34 | CreateRegionFromPicture 35 | DestroyRegion 36 | SetRegion 37 | CopyRegion 38 | UnionRegion 39 | IntersectRegion 40 | SubtractRegion 41 | InvertRegion 42 | TranslateRegion 43 | RegionExtents 44 | FetchRegion RESPONDS 45 | SetGCClipRegion 46 | SetWindowShapeRegion 47 | SetPictureClipRegion 48 | SetCursorName 49 | GetCursorName RESPONDS 50 | GetCursorImageAndName RESPONDS 51 | ChangeCursor 52 | ChangeCursorByName 53 | ExpandRegion 54 | HideCursor 55 | ShowCursor 56 | END 57 | 58 | EVENTS 59 | SelectionNotify 60 | CursorNotify 61 | END 62 | 63 | ERRORS 64 | BadRegion 65 | END 66 | 67 | CONSTANTS fixes_mode 68 | 0 insert 69 | 1 delete 70 | END 71 | TYPE FIXES_MODE ENUM8 fixes_mode 72 | CONSTANTS fixes_target 73 | 0 nearest 74 | 1 root 75 | END 76 | TYPE FIXES_TARGET ENUM8 fixes_target 77 | CONSTANTS fixes_map 78 | 0 set 79 | 1 unset 80 | END 81 | TYPE FIXES_MAP ENUM8 fixes_map 82 | CONSTANTS fixes_region_kind 83 | 0 bounding 84 | 1 clip 85 | END 86 | TYPE FIXES_REGION_KIND ENUM8 fixes_region_kind 87 | TYPE REGION CARD32 88 | 89 | BITMASK fixes_mask 90 | 0x00000001 "owner notify" 91 | 0x00000002 "destroy notify" 92 | 0x00000004 "client close notify" 93 | END 94 | TYPE FIXES_MASK BITMASK32 fixes_mask 95 | 96 | CONSTANTS fixes_subtype 97 | 0 "set owner" 98 | 1 destroy 99 | 2 "client close" 100 | END 101 | TYPE FIXES_SUBTYPE ENUM8 fixes_subtype 102 | 103 | BITMASK fixes_cursor_mask 104 | 0x00000001 "display cursor notify" 105 | END 106 | TYPE FIXES_CURSOR_MASK BITMASK32 fixes_cursor_mask 107 | 108 | CONSTANTS fixes_cursor_subtype 109 | 0 "display cursor" 110 | END 111 | TYPE FIXES_CURSOR_SUBTYPE ENUM8 fixes_cursor_subtype 112 | 113 | REQUEST QueryVersion 114 | 4 "major version" UINT32 115 | 8 "minor version" UINT32 116 | END 117 | RESPONSE QueryVersion 118 | 8 "major version" UINT32 119 | 12 "minor version" UINT32 120 | END 121 | 122 | REQUEST ChangeSaveSet 123 | 4 mode FIXES_MODE 124 | 5 target FIXES_TARGET 125 | 6 map FIXES_MAP 126 | 8 window WINDOW 127 | END 128 | 129 | REQUEST SelectSelectionInput 130 | 4 window WINDOW 131 | 8 selection ATOM 132 | 12 eventMask FIXES_MASK 133 | END 134 | 135 | REQUEST SelectCursorInput 136 | 4 window WINDOW 137 | 8 eventMask FIXES_CURSOR_MASK 138 | END 139 | 140 | REQUEST GetCursorImage ALIASES Empty 141 | RESPONSE GetCursorImage 142 | 8 x INT16 143 | 10 y INT16 144 | 12 width UINT16 145 | 14 height UINT16 146 | 16 xhot UINT16 147 | 18 yhot UINT16 148 | 20 "cursor serial" CARD32 149 | END 150 | 151 | REQUEST CreateRegion 152 | 4 region REGION 153 | 8 rectangles LISTofRECTANGLE 154 | END 155 | 156 | REQUEST CreateRegionFromBitmap 157 | 4 region REGION 158 | 8 bitmap PIXMAP 159 | END 160 | 161 | REQUEST CreateRegionFromWindow 162 | 4 region REGION 163 | 8 window WINDOW 164 | 12 kind FIXES_REGION_KIND 165 | END 166 | 167 | REQUEST CreateRegionFromGC 168 | 4 region REGION 169 | 8 gc GCONTEXT 170 | END 171 | 172 | REQUEST CreateRegionFromPicture 173 | 4 region REGION 174 | 8 picture PICTURE 175 | END 176 | 177 | templateREQUEST Region 178 | 4 region REGION 179 | END 180 | 181 | REQUEST DestroyRegion ALIASES Region 182 | 183 | REQUEST SetRegion ALIASES Region 184 | 185 | REQUEST CopyRegion 186 | 4 src-region REGION 187 | 8 dst-region REGION 188 | END 189 | 190 | templateREQUEST CombineRegion 191 | 4 region1 REGION 192 | 8 region2 REGION 193 | 12 dst-region REGION 194 | END 195 | REQUEST UnionRegion ALIASES CombineRegion 196 | REQUEST IntersectRegion ALIASES CombineRegion 197 | REQUEST SubtractRegion ALIASES CombineRegion 198 | 199 | REQUEST InvertRegion 200 | 4 src-region REGION 201 | 8 x INT16 202 | 10 y INT16 203 | 12 width UINT16 204 | 14 height UINT16 205 | 16 dst-region REGION 206 | END 207 | 208 | REQUEST TranslateRegion 209 | 4 region REGION 210 | 8 delta-x INT16 211 | 10 delta-y INT16 212 | END 213 | 214 | REQUEST RegionExtents ALIASES CopyRegion 215 | REQUEST FetchRegion ALIASES Region 216 | 217 | RESPONSE FetchRegion 218 | 8 x INT16 219 | 10 y INT16 220 | 12 width UINT16 221 | 14 height UINT16 222 | 32 rects LISTofRECTANGLE 223 | END 224 | 225 | REQUEST SetGCClipRegion 226 | 4 gc GCONTEXT 227 | 8 region REGION 228 | 12 "x origin" INT16 229 | 14 "y origin" INT16 230 | END 231 | 232 | REQUEST SetWindowShapeRegion 233 | 4 window WINDOW 234 | 8 kind Shape::SHAPE_KIND 235 | 12 "x offset" INT16 236 | 14 "y offset" INT16 237 | 16 region REGION 238 | END 239 | 240 | REQUEST SetPictureClipRegion 241 | 4 picture PICTURE 242 | 8 region REGION 243 | 12 "x origin" INT16 244 | 14 "y origin" INT16 245 | END 246 | 247 | REQUEST SetCursorName 248 | 4 cursor CARD32 249 | 8 "" COUNT16 250 | 12 name STRING8 251 | END 252 | 253 | REQUEST GetCursorName 254 | 4 cursor CARD32 255 | END 256 | 257 | RESPONSE GetCursorName 258 | 8 atom ATOM 259 | 12 "" COUNT16 260 | 32 name STRING8 261 | END 262 | 263 | REQUEST GetCursorImageAndName ALIASES Empty 264 | RESPONSE GetCursorImageAndName 265 | 8 x INT16 266 | 10 y INT16 267 | 12 width UINT16 268 | 14 height UINT16 269 | 16 xhot UINT16 270 | 18 yhot UINT16 271 | 20 "cursor serial" CARD32 272 | 24 "cursor name" ATOM 273 | 28 "" COUNT16 274 | 32 name STRING8 275 | # cursor image?? 276 | END 277 | 278 | REQUEST ChangeCursor 279 | 4 src-cursor CARD32 280 | 8 dst-cursor CARD32 281 | END 282 | 283 | REQUEST ChangeCursorByName 284 | 4 src-cursor CARD32 285 | 8 "" COUNT16 286 | 12 name STRING8 287 | END 288 | 289 | REQUEST ExpandRegion 290 | 4 src-region REGION 291 | 8 dst-region REGION 292 | 12 left UINT16 293 | 14 right UINT16 294 | 16 top UINT16 295 | 18 bottom UINT16 296 | END 297 | 298 | REQUEST HideCursor ALIASES WINDOW 299 | 300 | REQUEST ShowCursor ALIASES WINDOW 301 | 302 | EVENT SelectionNotify 303 | 1 subtype FIXES_SUBTYPE 304 | 4 window WINDOW 305 | 8 owner WINDOW 306 | 12 selection ATOM 307 | 16 timestamp TIMESTAMP 308 | 20 selectionTimestamp TIMESTAMP 309 | END 310 | 311 | EVENT CursorNotify 312 | 1 subtype FIXES_CURSOR_SUBTYPE 313 | 4 window WINDOW 314 | 8 "cursor serial" CARD32 315 | 12 timestamp TIMESTAMP 316 | 16 name ATOM 317 | END 318 | 319 | EOF 320 | -------------------------------------------------------------------------------- /genericevents.proto: -------------------------------------------------------------------------------- 1 | # This file is part of "xtrace" 2 | # Copyright (C) 2008 Bernhard R. Link 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License version 2 as 5 | # published by the Free Software Foundation. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | # 12 | # You should have received a copy of the GNU General Public License 13 | # along with this program; if not, write to the Free Software 14 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | EXTENSION "Generic Event Extension" ge 17 | USE core 18 | 19 | REQUESTS 20 | QueryVersion RESPONDS 21 | END 22 | 23 | EVENTS 24 | Generic SPECIAL 25 | END 26 | 27 | ERRORS 28 | END 29 | 30 | REQUEST QueryVersion 31 | 4 "major version" UINT16 32 | 6 "minor version" UINT16 33 | END 34 | RESPONSE QueryVersion 35 | 8 "major version" UINT16 36 | 10 "minor version" UINT16 37 | END 38 | 39 | EVENT Generic 40 | 1 extension CARD8 41 | 4 length UINT32 42 | 8 evtype CARD16 43 | 10 data LISTofCARD8 44 | END 45 | 46 | EOF 47 | -------------------------------------------------------------------------------- /main.c: -------------------------------------------------------------------------------- 1 | /* This file is part of "xtrace" 2 | * Copyright (C) 2005, 2007, 2010 Bernhard R. Link 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License version 2 as 5 | * published by the Free Software Foundation. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program; if not, write to the Free Software 14 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1301 USA 15 | */ 16 | #include 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | #if HAVE_SENDMSG 35 | #include 36 | #endif 37 | 38 | #include "xtrace.h" 39 | #include "stringlist.h" 40 | #include "translate.h" 41 | 42 | FILE *out; 43 | 44 | bool readwritedebug = false; 45 | bool copyauth = true; 46 | bool stopwhennone = true; 47 | bool waitforclient = false; 48 | bool denyallextensions = false; 49 | bool interactive = false; 50 | bool print_timestamps = false; 51 | bool print_reltimestamps = false; 52 | bool print_uptimestamps = false; 53 | static bool buffered = false; 54 | size_t maxshownlistlen = SIZE_MAX; 55 | 56 | const char *out_displayname = NULL; 57 | char *out_protocol,*out_hostname; 58 | int out_family,out_display,out_screen; 59 | const char *in_displayname = NULL; 60 | char *in_protocol,*in_hostname; 61 | int in_family,in_display,in_screen; 62 | static volatile bool caught_child_signal = false; 63 | static pid_t child_pid = 0; 64 | 65 | struct connection *connections = NULL ; 66 | 67 | static void acceptConnection(int listener) { 68 | struct timeval tv; 69 | struct connection *c; 70 | static int id = 0; 71 | 72 | c = calloc(1,sizeof(struct connection)); 73 | if( c == NULL ) { 74 | fprintf(stderr,"Out of memory!\n"); 75 | exit(EXIT_FAILURE); 76 | } 77 | if( print_reltimestamps ) { 78 | if( gettimeofday(&tv, NULL) != 0 ) { 79 | int e = errno; 80 | fprintf(stderr, "gettimeofday error %d : %s!\n", 81 | e, strerror(e)); 82 | exit(EXIT_FAILURE); 83 | } 84 | c->starttime = tv.tv_sec*(unsigned long long)1000 + 85 | tv.tv_usec/1000; 86 | } 87 | c->next = connections; 88 | c->client_fd = acceptClient(in_family,listener, &c->from); 89 | if( c->client_fd < 0 ) { 90 | free(c); 91 | return; 92 | } 93 | waitforclient = false; 94 | fprintf(stderr,"Got connection from %s\n",c->from); 95 | c->server_fd = connectToServer(out_displayname,out_family,out_hostname,out_display); 96 | if( c->server_fd < 0 ) { 97 | close(c->client_fd); 98 | free(c->from); 99 | free(c); 100 | fprintf(stderr,"Error connecting to server %s\n",out_displayname); 101 | return; 102 | } 103 | c->id = id++; 104 | connections = c; 105 | } 106 | 107 | static ssize_t doread(int fd, void *buf, size_t n, struct fdqueue *fdq) 108 | { 109 | #if HAVE_SENDMSG 110 | struct iovec iov = { 111 | .iov_base = buf, 112 | .iov_len = n, 113 | }; 114 | union { 115 | struct cmsghdr cmsghdr; 116 | char buf[CMSG_SPACE(FDQUEUE_MAX_FD * sizeof(int))]; 117 | } cmsgbuf; 118 | struct msghdr msg = { 119 | .msg_name = NULL, 120 | .msg_namelen = 0, 121 | .msg_iov = &iov, 122 | .msg_iovlen = 1, 123 | .msg_control = cmsgbuf.buf, 124 | .msg_controllen = CMSG_SPACE(sizeof(int) * (FDQUEUE_MAX_FD - fdq->nfd)), 125 | }; 126 | int ret = recvmsg(fd, &msg, 0); 127 | 128 | /* Check for truncation errors. Only MSG_CTRUNC is 129 | * probably possible here, which would indicate that 130 | * the sender tried to transmit more than FDQUEUE_MAX_FD 131 | * file descriptors. 132 | */ 133 | if (msg.msg_flags & (MSG_TRUNC|MSG_CTRUNC)) 134 | return 0; 135 | 136 | struct cmsghdr *hdr; 137 | if (msg.msg_controllen >= sizeof (struct cmsghdr)) { 138 | for (hdr = CMSG_FIRSTHDR(&msg); hdr; hdr = CMSG_NXTHDR(&msg, hdr)) { 139 | if (hdr->cmsg_level == SOL_SOCKET && hdr->cmsg_type == SCM_RIGHTS) { 140 | int nfd = (hdr->cmsg_len - CMSG_LEN(0)) / sizeof (int); 141 | memcpy(fdq->fd + fdq->nfd, CMSG_DATA(hdr), nfd * sizeof (int)); 142 | fdq->nfd += nfd; 143 | } 144 | } 145 | } 146 | return ret; 147 | #else 148 | return read(fd, buf, n); 149 | #endif 150 | } 151 | 152 | static ssize_t dowrite(int fd, const void *buf, size_t n, struct fdqueue *fdq) 153 | { 154 | #if HAVE_SENDMSG 155 | if (fdq->nfd) { 156 | union { 157 | struct cmsghdr cmsghdr; 158 | char buf[CMSG_SPACE(FDQUEUE_MAX_FD * sizeof(int))]; 159 | } cmsgbuf; 160 | struct iovec iov = { 161 | .iov_base = buf, 162 | .iov_len = n, 163 | }; 164 | struct msghdr msg = { 165 | .msg_name = NULL, 166 | .msg_namelen = 0, 167 | .msg_iov = &iov, 168 | .msg_iovlen = 1, 169 | .msg_control = cmsgbuf.buf, 170 | .msg_controllen = CMSG_LEN(fdq->nfd * sizeof (int)), 171 | }; 172 | int i, ret; 173 | struct cmsghdr *hdr = CMSG_FIRSTHDR(&msg); 174 | 175 | hdr->cmsg_len = msg.msg_controllen; 176 | hdr->cmsg_level = SOL_SOCKET; 177 | hdr->cmsg_type = SCM_RIGHTS; 178 | memcpy(CMSG_DATA(hdr), fdq->fd, fdq->nfd * sizeof (int)); 179 | 180 | ret = sendmsg(fd, &msg, 0); 181 | if (ret < 0) 182 | return ret; 183 | for (i = 0; i < fdq->nfd; i++) 184 | close(fdq->fd[i]); 185 | fdq->nfd = 0; 186 | return ret; 187 | } else 188 | #endif 189 | { 190 | return write(fd, buf, n); 191 | } 192 | } 193 | 194 | static int mainqueue(int listener) { 195 | int n, r = 0; 196 | fd_set readfds,writefds,exceptfds; 197 | struct connection *c; 198 | unsigned int allowsent = 1; 199 | int status; 200 | 201 | while( 1 ) { 202 | n = listener+1; 203 | FD_ZERO(&readfds); 204 | FD_ZERO(&writefds); 205 | FD_ZERO(&exceptfds); 206 | FD_SET(listener,&readfds); 207 | 208 | c = connections; 209 | while( c != NULL ) { 210 | if( c->client_fd != -1 && c->server_fd == -1 && c->servercount == 0 && c->serverfdq.nfd == 0 ) { 211 | close(c->client_fd); 212 | c->client_fd = -1; 213 | if( readwritedebug ) 214 | fprintf(out,"%03d:>:sent EOF\n",c->id); 215 | } 216 | if( c->client_fd != -1 ) { 217 | if( sizeof(c->clientbuffer) > c->clientcount && FDQUEUE_MAX_FD > c->clientfdq.nfd ) 218 | FD_SET(c->client_fd,&readfds); 219 | FD_SET(c->client_fd,&exceptfds); 220 | if( c->client_fd >= n ) 221 | n = c->client_fd+1; 222 | if( c->serverignore > 0 && c->servercount > 0 || c->serverfdq.nfd > 0 ) 223 | FD_SET(c->client_fd,&writefds); 224 | } else if( c->server_fd != -1 && c->clientcount == 0 && c->clientfdq.nfd == 0 ) { 225 | close(c->server_fd); 226 | c->server_fd = -1; 227 | if( readwritedebug ) 228 | fprintf(out,"%03d:<:sent EOF\n",c->id); 229 | } 230 | if( c->server_fd != -1 ) { 231 | if( sizeof(c->serverbuffer) > c->servercount && FDQUEUE_MAX_FD > c->serverfdq.nfd ) 232 | FD_SET(c->server_fd,&readfds); 233 | FD_SET(c->server_fd,&exceptfds); 234 | if( c->server_fd >= n ) 235 | n = c->server_fd+1; 236 | if( (c->clientignore > 0 && c->clientcount > 0 || c->clientfdq.nfd > 0) 237 | && allowsent > 0) 238 | FD_SET(c->server_fd,&writefds); 239 | 240 | } 241 | if( c->client_fd == -1 && c->server_fd == -1 ) { 242 | if( c == connections ) { 243 | int i; 244 | for ( i = 0; i < c->clientfdq.nfd; i++ ) 245 | close(c->clientfdq.fd[i]); 246 | for ( i = 0; i < c->serverfdq.nfd; i++ ) 247 | close(c->serverfdq.fd[i]); 248 | free_usedextensions(c->usedextensions); 249 | free_unknownextensions(c->unknownextensions); 250 | free_unknownextensions(c->waiting); 251 | free(c->from); 252 | connections = c->next; 253 | free(c); 254 | c = connections; 255 | if( connections == NULL && 256 | stopwhennone && child_pid == 0 ) 257 | return EXIT_SUCCESS; 258 | continue; 259 | } 260 | } 261 | c = c->next; 262 | } 263 | if( interactive ) { 264 | FD_SET(0,&readfds); 265 | } 266 | 267 | if( child_pid != 0 && (r == -1 || caught_child_signal) ) { 268 | caught_child_signal = false; 269 | if( waitpid(child_pid,&status,WNOHANG) == child_pid ) { 270 | child_pid = 0; 271 | if( connections == NULL && !waitforclient ) { 272 | /* TODO: instead wait a bit before 273 | * terminating? */ 274 | if( WIFEXITED(status) ) 275 | return WEXITSTATUS(status); 276 | else 277 | return WTERMSIG(status) + 128; 278 | } 279 | } 280 | } 281 | r = select(n,&readfds,&writefds,&exceptfds,NULL); 282 | if( r == -1 ) { 283 | int e = errno; 284 | 285 | if( e != 0 && e != EINTR ) { 286 | fprintf(stderr,"Error %d in select: %s\n", 287 | e, strerror(e)); 288 | } 289 | continue; 290 | } 291 | for( c = connections ; c != NULL ; c = c->next ) { 292 | if( interactive && FD_ISSET(0,&readfds) ) { 293 | char buffer[201]; 294 | ssize_t isread; 295 | isread = read(0,buffer,200); 296 | if( isread == 0 ) 297 | exit(EXIT_SUCCESS); 298 | if( isread > 0 ) { 299 | buffer[isread]='\0'; 300 | int number = atoi(buffer); 301 | if( number <= 0 ) 302 | number = 1; 303 | allowsent += number; 304 | } 305 | } 306 | if( c->client_fd != -1 ) { 307 | if( FD_ISSET(c->client_fd,&exceptfds) ) { 308 | close(c->client_fd); 309 | c->client_fd = -1; 310 | fprintf(stdout,"%03d: exception in communication with client\n",c->id); 311 | continue; 312 | } 313 | if( FD_ISSET(c->client_fd,&writefds) ) { 314 | size_t towrite = c->servercount; 315 | ssize_t written; 316 | 317 | if( c->serverignore < towrite ) 318 | towrite = c->serverignore; 319 | written = dowrite(c->client_fd,c->serverbuffer,towrite,&c->serverfdq); 320 | if( written >= 0 ) { 321 | if( readwritedebug ) 322 | fprintf(stdout,"%03d:>:wrote %u bytes\n",c->id,(unsigned int)written); 323 | if( (size_t)written < c->servercount ) 324 | memmove(c->serverbuffer,c->serverbuffer+written,c->servercount-written); 325 | c->servercount -= written; 326 | c->serverignore -= written; 327 | if( c->servercount == 0 ) { 328 | if( c->server_fd == -1 ) { 329 | close(c->client_fd); 330 | c->client_fd = -1; 331 | if( readwritedebug ) 332 | fprintf(stdout,"%03d:>:send EOF\n",c->id); 333 | continue; 334 | } 335 | } else if( c->serverignore == 0 ) { 336 | parse_server(c); 337 | } 338 | } else { 339 | int e = errno; 340 | close(c->client_fd); 341 | c->client_fd = -1; 342 | if( readwritedebug ) 343 | fprintf(stdout,"%03d: error writing to client: %d=%s\n",c->id,e,strerror(e)); 344 | continue; 345 | } 346 | } 347 | if( FD_ISSET(c->client_fd,&readfds) ) { 348 | size_t toread = sizeof(c->clientbuffer)-c->clientcount; 349 | ssize_t wasread = doread(c->client_fd,c->clientbuffer+c->clientcount,toread,&c->clientfdq); 350 | assert( toread > 0 ); 351 | if( wasread > 0 ) { 352 | if( readwritedebug ) 353 | fprintf(stdout,"%03d:<:received %u bytes\n",c->id,(unsigned int)wasread); 354 | c->clientcount += wasread; 355 | } else { 356 | if( readwritedebug ) 357 | fprintf(stdout,"%03d:<:got EOF\n",c->id); 358 | close(c->client_fd); 359 | c->client_fd = -1; 360 | continue; 361 | } 362 | if( c->clientignore == 0 && c->clientcount > 0) { 363 | parse_client(c); 364 | } 365 | } 366 | } else if( c->servercount > 0 && c->serverignore > 0 ) { 367 | unsigned int min; 368 | /* discard additional events */ 369 | min = c->servercount; 370 | if( min > c->serverignore ) 371 | min = c->serverignore; 372 | fprintf(stdout,"%03d:s->?: discarded last answer of %u bytes\n",c->id,min); 373 | if( min < c->servercount ) 374 | memmove(c->serverbuffer,c->serverbuffer+min,c->servercount-min); 375 | c->servercount -= min; 376 | c->serverignore -= min; 377 | if( c->serverignore == 0 && c->servercount > 0 ) { 378 | parse_server(c); 379 | } 380 | } 381 | if( c->server_fd != -1 ) { 382 | if( FD_ISSET(c->server_fd,&exceptfds) ) { 383 | close(c->server_fd); 384 | c->server_fd = -1; 385 | fprintf(stdout,"%03d: exception in communication with server\n",c->id); 386 | continue; 387 | } 388 | if( FD_ISSET(c->server_fd,&writefds) ) { 389 | size_t towrite = c->clientcount; 390 | ssize_t written; 391 | 392 | if( c->clientignore < towrite ) 393 | towrite = c->clientignore; 394 | written = dowrite(c->server_fd,c->clientbuffer,towrite,&c->clientfdq); 395 | if( interactive && allowsent > 0 ) 396 | allowsent--; 397 | if( written >= 0 ) { 398 | if( readwritedebug ) 399 | fprintf(stdout,"%03d:<:wrote %u bytes\n",c->id,(unsigned int)written); 400 | if( (size_t)written < c->clientcount ) 401 | memmove(c->clientbuffer,c->clientbuffer+written,c->clientcount-written); 402 | c->clientcount -= written; 403 | c->clientignore -= written; 404 | if( c->clientcount != 0 && 405 | c->clientignore == 0 ) { 406 | parse_client(c); 407 | } 408 | } else { 409 | int e = errno; 410 | close(c->server_fd); 411 | c->server_fd = -1; 412 | if( readwritedebug ) 413 | fprintf(stdout,"%03d: error writing to server: %d=%s\n",c->id,e,strerror(e)); 414 | continue; 415 | } 416 | } 417 | if( FD_ISSET(c->server_fd,&readfds) ) { 418 | size_t toread = sizeof(c->serverbuffer)-c->servercount; 419 | ssize_t wasread = doread(c->server_fd,c->serverbuffer+c->servercount,toread,&c->serverfdq); 420 | assert( toread > 0 ); 421 | if( wasread > 0 ) { 422 | if( readwritedebug ) 423 | fprintf(stdout,"%03d:>:received %u bytes\n",c->id,(unsigned int)wasread); 424 | c->servercount += wasread; 425 | } else { 426 | if( readwritedebug ) 427 | fprintf(stdout,"%03d:>:got EOF\n",c->id); 428 | close(c->server_fd); 429 | c->server_fd = -1; 430 | } 431 | if( c->serverignore == 0 && c->servercount > 0 ) { 432 | parse_server(c); 433 | } 434 | } 435 | } else if( c->clientcount > 0 && c->clientignore > 0 ) { 436 | unsigned int min; 437 | /* discard additional events */ 438 | min = c->clientcount; 439 | if( min > c->clientignore ) 440 | min = c->clientignore; 441 | fprintf(stdout,"%03d:<: discarding last request of %u bytes\n",c->id,min); 442 | if( min < c->clientcount ) 443 | memmove(c->clientbuffer,c->clientbuffer+min,c->clientcount-min); 444 | c->clientcount -= min; 445 | c->clientignore -= min; 446 | if( c->clientignore == 0 && c->clientcount > 0 ) { 447 | parse_client(c); 448 | } 449 | } 450 | } 451 | if( FD_ISSET(listener,&readfds) ) { 452 | acceptConnection(listener); 453 | } 454 | 455 | } 456 | return EXIT_SUCCESS; 457 | } 458 | 459 | static void startClient(char *argv[]) { 460 | child_pid = fork(); 461 | if( child_pid == -1 ) { 462 | fprintf(stderr, "Error forking: %s\n", strerror(errno)); 463 | exit(EXIT_FAILURE); 464 | } 465 | if( child_pid == 0 ) { 466 | if (setenv("DISPLAY", in_displayname, 1) != 0) { 467 | fprintf(stderr,"Error setting $DISPLAY: %s\n", strerror(errno)); 468 | exit(EXIT_FAILURE); 469 | } 470 | execvp(argv[0], argv); 471 | fprintf(stderr, "Could not exec '%s': %s\n", argv[0], strerror(errno)); 472 | exit(EXIT_FAILURE); 473 | } 474 | } 475 | 476 | #ifndef HAVE_STRNDUP 477 | /* That's not the best possible strndup implementation, but it suffices for what 478 | * it is used here */ 479 | char *strndup(const char *str,size_t n) { 480 | char *r = malloc(n+1); 481 | if( r == NULL ) 482 | return r; 483 | memcpy(r,str,n); 484 | r[n] = '\0'; 485 | return r; 486 | } 487 | #endif 488 | 489 | enum {LO_DEFAULT=0, LO_TIMESTAMPS, LO_RELTIMESTAMPS, LO_UPTIMESTAMPS, LO_VERSION, LO_HELP, LO_PRINTCOUNTS, LO_PRINTOFFSETS}; 490 | static int long_only_option = 0; 491 | static const struct option longoptions[] = { 492 | {"display", required_argument, NULL, 'd'}, 493 | {"fakedisplay", required_argument, NULL, 'D'}, 494 | {"authfile", required_argument, NULL, 'f'}, 495 | {"newauthfile", required_argument, NULL, 'F'}, 496 | {"copyauthentication", no_argument, NULL, 'c'}, 497 | {"nocopyauthentication",no_argument, NULL, 'n'}, 498 | {"waitforclient", no_argument, NULL, 'w'}, 499 | {"stopwhendone", no_argument, NULL, 's'}, 500 | {"keeprunning", no_argument, NULL, 'k'}, 501 | {"denyextensions", no_argument, NULL, 'e'}, 502 | {"readwritedebug", no_argument, NULL, 'w'}, 503 | {"maxlistlength",required_argument, NULL, 'm'}, 504 | {"outfile", required_argument, NULL, 'o'}, 505 | {"buffered", no_argument, NULL, 'b'}, 506 | {"interactive", no_argument, NULL, 'i'}, 507 | {"help", no_argument, &long_only_option, LO_HELP}, 508 | {"version", no_argument, &long_only_option, LO_VERSION}, 509 | {"timestamps", no_argument, &long_only_option, LO_TIMESTAMPS}, 510 | {"relative-timestamps", no_argument, &long_only_option, LO_RELTIMESTAMPS}, 511 | {"monotonic-timestamps",no_argument, &long_only_option, LO_UPTIMESTAMPS}, 512 | {"print-counts", no_argument, &long_only_option, LO_PRINTCOUNTS}, 513 | {"print-offsets", no_argument, &long_only_option, LO_PRINTOFFSETS}, 514 | {NULL, 0, NULL, 0} 515 | }; 516 | 517 | static void catchsig(int signum UNUSED) 518 | { 519 | caught_child_signal = true; 520 | } 521 | 522 | extern bool print_counts; 523 | extern bool print_offsets; 524 | 525 | int main(int argc, char *argv[]) { 526 | int listener,r; 527 | const char *msg; 528 | int c; 529 | const char *out_authfile=NULL, *in_authfile = NULL; 530 | struct parser *parser; 531 | 532 | stringlist_init(); 533 | parser = parser_init(); 534 | if( parser == NULL ) 535 | return EXIT_FAILURE; 536 | 537 | out = stdout; 538 | while( (c=getopt_long(argc,argv,"+I:d:D:f:F:cnWskiewm:o:b",longoptions,NULL)) != -1 ) { 539 | switch( c ) { 540 | case 'I': 541 | add_searchpath(parser, optarg); 542 | break; 543 | case 'd': 544 | out_displayname = optarg; 545 | break; 546 | case 'D': 547 | in_displayname = optarg; 548 | break; 549 | case 'f': 550 | out_authfile = optarg; 551 | break; 552 | case 'F': 553 | in_authfile = optarg; 554 | break; 555 | case 'c': 556 | copyauth = true; 557 | break; 558 | case 'n': 559 | copyauth = false; 560 | break; 561 | case 'W': 562 | waitforclient = true; 563 | break; 564 | case 's': 565 | stopwhennone = true; 566 | break; 567 | case 'k': 568 | stopwhennone = false; 569 | break; 570 | case 'e': 571 | denyallextensions = true; 572 | break; 573 | case 'w': 574 | readwritedebug = true; 575 | break; 576 | case 'm': 577 | maxshownlistlen = strtoll(optarg,NULL,0); 578 | break; 579 | case 'i': 580 | interactive = true; 581 | break; 582 | case 'b': 583 | buffered = true; 584 | break; 585 | case 'o': 586 | if( out != stdout ) { 587 | fprintf(stderr, "Multiple -o options!\n"); 588 | exit(EXIT_FAILURE); 589 | } 590 | if( strcmp(optarg,"-") == 0 ) 591 | out = stdout; 592 | else 593 | out = fopen(optarg,"a"); 594 | if( out == NULL ) { 595 | fprintf(stderr, "Error opening %s: %s\n", 596 | optarg,strerror(errno)); 597 | exit(EXIT_FAILURE); 598 | } 599 | break; 600 | case '\0': 601 | switch( long_only_option ) { 602 | case LO_HELP: 603 | printf( 604 | "%s: Dump all X protocol data being tunneled from a fake X display to a real one.\n" 605 | "usage: xtrace [options] [[--] command args ...]\n" 606 | "--display, -d \n" 607 | "--fakedisplay, -D \n" 608 | "--copyauthentication, -c Copy credentials\n" 609 | "--nocopyauthentication, -n Do not copy credentials\n" 610 | "--authfile, -f \n" 611 | "--newauthfile, -F \n" 612 | "--waitforclient, -W wait for connection even if command terminates\n" 613 | "--stopwhendone, -s Return when last client disconnects\n" 614 | "--keeprunning, -k Keep running\n" 615 | "--denyextensions, -e Fake unavailability of all extensions\n" 616 | "--readwritedebug, -w Print amounts of data read/sent\n" 617 | "--maxlistlength, -m \n" 618 | "--outfile, -o Output to file instead of stdout\n" 619 | "--buffered, -b Do not output every line but only when buffer is full\n", 620 | argv[0]); 621 | exit(EXIT_SUCCESS); 622 | case LO_VERSION: 623 | puts(PACKAGE " version " VERSION); 624 | exit(EXIT_SUCCESS); 625 | case LO_TIMESTAMPS: 626 | print_timestamps = true; 627 | break; 628 | case LO_RELTIMESTAMPS: 629 | print_reltimestamps = true; 630 | break; 631 | case LO_UPTIMESTAMPS: 632 | #ifndef HAVE_MONOTONIC_CLOCK 633 | fprintf(stderr, "--monotonic-timestamps not supported as clock_gettime(MONOTONIC_CLOCK, ) was not available at compile time\n"); 634 | exit(EXIT_FAILURE); 635 | #else 636 | if (sysconf(_SC_MONOTONIC_CLOCK) < 0) { 637 | fprintf(stderr, "--monotonic-timestamps not supported on this system\n"); 638 | exit(EXIT_FAILURE); 639 | } 640 | print_uptimestamps = true; 641 | #endif 642 | break; 643 | case LO_PRINTCOUNTS: 644 | print_counts = true; 645 | break; 646 | case LO_PRINTOFFSETS: 647 | print_offsets = true; 648 | break; 649 | } 650 | break; 651 | case ':': 652 | case '?': 653 | default: 654 | exit(EXIT_FAILURE); 655 | } 656 | 657 | } 658 | add_searchpath(parser, PKGDATADIR); 659 | translate(parser, "all.proto"); 660 | finalize_everything(parser); 661 | if( !parser_free(parser) ) { 662 | return EXIT_FAILURE; 663 | } 664 | 665 | signal(SIGPIPE,SIG_IGN); 666 | if( out_displayname == NULL ) { 667 | out_displayname = getenv("DISPLAY"); 668 | if( out_displayname == NULL ) { 669 | fprintf(stderr,"No X server display to connect to specified\n"); 670 | exit(EXIT_FAILURE); 671 | } 672 | } 673 | if( in_displayname == NULL ) { 674 | in_displayname = getenv("FAKEDISPLAY"); 675 | if( in_displayname == NULL ) { 676 | fprintf(stderr,"No display name to create specified, trying :9\n"); 677 | in_displayname = ":9"; 678 | } 679 | } 680 | msg = parseDisplay(in_displayname,&in_protocol,&in_hostname,&in_display,&in_screen,&in_family); 681 | if( msg != NULL ) { 682 | fprintf(stderr,"Parsing '%s' failed: %s\n",in_displayname,msg); 683 | return -1; 684 | } 685 | msg = parseDisplay(out_displayname,&out_protocol,&out_hostname,&out_display,&out_screen,&out_family); 686 | if( msg != NULL ) { 687 | fprintf(stderr,"Parsing '%s' failed: %s\n",out_displayname,msg); 688 | return -1; 689 | } 690 | // generateAuthorisation(out_displayname); 691 | if( copyauth ) { 692 | /* TODO: normalize them? or keep them so the user has more 693 | * control? */ 694 | if( !copy_authentication(in_displayname,out_displayname,in_authfile,out_authfile) ) 695 | return -1; 696 | } 697 | setvbuf(out, NULL, buffered?_IOFBF:_IOLBF, BUFSIZ); 698 | listener = listenForClients(in_displayname,in_family,in_display); 699 | if( listener < 0 ) { 700 | exit(EXIT_FAILURE); 701 | } 702 | if( optind < argc && strcmp(argv[optind],"--") != 0 ) { 703 | signal(SIGCHLD, catchsig); 704 | startClient(argv + optind); 705 | } 706 | r = mainqueue(listener); 707 | close(listener); 708 | if( out != stdout ) { 709 | if( fclose(out) != 0 ) { 710 | fprintf(stderr, "Error writing to output file!\n"); 711 | return EXIT_FAILURE; 712 | } 713 | } 714 | stringlist_done(); 715 | return r; 716 | } 717 | -------------------------------------------------------------------------------- /mitshm.proto: -------------------------------------------------------------------------------- 1 | # This file is part of xtrace 2 | # Copyright (C) 2006 Bernhard R. Link 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License version 2 as 5 | # published by the Free Software Foundation. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | # 12 | # You should have received a copy of the GNU General Public License 13 | # along with this program; if not, write to the Free Software 14 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | # This file is based on /usr/include/X11/extensions/shmstr.h which states: 16 | #Copyright 1989, 1998 The Open Group 17 | # 18 | #Permission to use, copy, modify, distribute, and sell this software and its 19 | #documentation for any purpose is hereby granted without fee, provided that 20 | #the above copyright notice appear in all copies and that both that 21 | #copyright notice and this permission notice appear in supporting 22 | #documentation. 23 | # 24 | #The above copyright notice and this permission notice shall be included in 25 | #all copies or substantial portions of the Software. 26 | # 27 | #THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 28 | #IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 29 | #FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 30 | #OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 31 | #AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 32 | #CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 33 | # 34 | #Except as contained in this notice, the name of The Open Group shall not be 35 | #used in advertising or otherwise to promote the sale, use or other dealings 36 | #in this Software without prior written authorization from The Open Group. 37 | 38 | NEEDS "requests.proto" 39 | NEEDS "render.proto" 40 | 41 | EXTENSION "MIT-SHM" Shm 42 | USE core 43 | 44 | REQUESTS 45 | QueryVersion RESPONDS 46 | Attach 47 | Detach 48 | PutImage 49 | GetImage RESPONDS 50 | CreatePixmap 51 | END 52 | 53 | EVENTS 54 | Completion 55 | END 56 | 57 | ERRORS 58 | BadShmSeg 59 | END 60 | 61 | TYPE ShmSeg CARD32 62 | TYPE Drawable CARD32 63 | TYPE Visualid CARD32 64 | TYPE GContext CARD32 65 | TYPE Pixmap CARD32 66 | TYPE format CARD8 constants core::bitmap_format 67 | 68 | REQUEST QueryVersion ALIASES Empty 69 | 70 | RESPONSE QueryVersion 71 | 8 major-version UINT16 72 | 10 minor-version UINT16 73 | 12 uid UINT16 74 | 14 gid UINT16 75 | 16 pixmap-format format 76 | END 77 | 78 | REQUEST Attach 79 | 4 shmseg ShmSeg 80 | 8 shmid CARD32 81 | 12 readonly BOOL 82 | END 83 | 84 | REQUEST Detach 85 | 4 shmseg ShmSeg 86 | END 87 | 88 | REQUEST PutImage 89 | 4 drawable Drawable 90 | 8 gc GContext 91 | 12 total-width UINT16 92 | 14 total-height UINT16 93 | 16 src-x UINT16 94 | 18 src-y UINT16 95 | 20 src-width UINT16 96 | 22 src-height UINT16 97 | 24 dst-x INT16 98 | 26 dst-y INT16 99 | 28 depth UINT8 100 | 29 format format 101 | 30 send-event BOOL 102 | 32 shmseg ShmSeg 103 | 36 offset CARD32 104 | END 105 | 106 | REQUEST GetImage 107 | 4 drawable Drawable 108 | 8 x INT16 109 | 10 y INT16 110 | 12 width UINT16 111 | 14 height UINT16 112 | 16 planeMask UINT32 113 | 20 format format 114 | 24 shmseg ShmSeg 115 | 28 offset CARD32 116 | END 117 | 118 | RESPONSE GetImage 119 | 8 visual Render::VisualID 120 | 12 size UINT32 121 | END 122 | 123 | REQUEST CreatePixmap 124 | 4 pid Pixmap 125 | 8 drawable Drawable 126 | 12 width UINT16 127 | 14 height UINT16 128 | 16 depth UINT8 129 | 20 shmseg ShmSeg 130 | 24 offset CARD32 131 | END 132 | 133 | EVENT Completion 134 | 4 drawable Drawable 135 | 12 shmseg ShmSeg 136 | 16 offset CARD32 137 | END 138 | 139 | EOF 140 | -------------------------------------------------------------------------------- /parse.h: -------------------------------------------------------------------------------- 1 | #ifndef XTRACE_PARSE_H 2 | #define XTRACE_PARSE_H 3 | 4 | struct constant { 5 | unsigned long value; 6 | const char *name; 7 | }; 8 | struct event; 9 | 10 | typedef bool request_func(struct connection*, bool, bool, struct expectedreply *); 11 | typedef void reply_func(struct connection*, bool*, bool*, struct expectedreply *); 12 | typedef void event_func(struct connection *, const unsigned char *, const struct event *); 13 | 14 | struct request { 15 | const char *name; 16 | const struct parameter *parameters; 17 | const struct parameter *answers; 18 | 19 | request_func *request_func; 20 | reply_func *reply_func; 21 | /* stack values to be transfered to the reply code */ 22 | int record_variables; 23 | }; 24 | struct event { 25 | const char *name; 26 | const struct parameter *parameters; 27 | enum event_type { event_normal = 0, event_xge = 1} type; 28 | #define event_COUNT 2 29 | }; 30 | 31 | struct extension { 32 | const char *name; 33 | size_t namelen; 34 | const struct request *subrequests; 35 | unsigned char numsubrequests; 36 | const struct event *events; 37 | unsigned char numevents; 38 | const char * const *errors; 39 | unsigned char numerrors; 40 | unsigned short numxgevents; 41 | const struct event *xgevents; 42 | }; 43 | 44 | struct parameter { 45 | /* The offset within the event, request, reply or Struct this 46 | * applies to. If OFS_LATER it is after the last list item 47 | * in this parameter-list. */ 48 | size_t offse; 49 | /* NULL means end of list */ 50 | const char *name; 51 | enum fieldtype { 52 | /* signed endian specific: */ 53 | ft_INT8, ft_INT16, ft_INT32, 54 | /* unsigned decimal endian specific: */ 55 | ft_UINT8, ft_UINT16, ft_UINT32, 56 | /* unsigned hex endian specific: */ 57 | ft_CARD8, ft_CARD16, ft_CARD32, 58 | /* enums (not in constant list is error): */ 59 | ft_ENUM8, ft_ENUM16, ft_ENUM32, 60 | /* counts for following strings, lists, ... 61 | * value-mask for LISTofFormat */ 62 | ft_STORE8, ft_STORE16, ft_STORE32, 63 | /* to be ft_GET later into the store register */ 64 | ft_PUSH8, ft_PUSH16, ft_PUSH32, 65 | /* bitfields: multiple values are possible */ 66 | ft_BITMASK8, ft_BITMASK16, ft_BITMASK32, 67 | /* Different forms of lists: */ 68 | /* - boring ones */ 69 | ft_STRING8, ft_LISTofCARD32, ft_LISTofATOM, 70 | ft_LISTofCARD8, ft_LISTofCARD16, 71 | ft_LISTofUINT8, ft_LISTofUINT16, 72 | ft_LISTofUINT32, 73 | ft_LISTofINT8, ft_LISTofINT16, 74 | ft_LISTofINT32, 75 | /* - one of the above depening on last FORMAT */ 76 | ft_LISTofFormat, 77 | /* - iterate of list description in constants field */ 78 | ft_LISTofStruct, 79 | /* - same but length is mininum length and 80 | * actual length is taken from end of last list 81 | * or LASTMARKER, unless there is a SIZESET */ 82 | ft_LISTofVarStruct, 83 | /* - like ENUM for last STORE, but constants 84 | * are of type (struct value*) interpreteted at this 85 | * offset */ 86 | ft_LISTofVALUE, 87 | /* an LISTofStruct with count = 1 */ 88 | ft_Struct, 89 | /* specify bits per item for LISTofFormat */ 90 | ft_FORMAT8, 91 | /* an event 92 | * (would have also been possible with Struct and many IF)*/ 93 | ft_EVENT, 94 | /* jump to other parameter list if matches */ 95 | ft_IF8, 96 | ft_IF16, 97 | ft_IF32, 98 | /* jump to other parameter list if matches atom name */ 99 | ft_IFATOM, 100 | /* set end of last list manually, (for LISTofVarStruct) */ 101 | ft_LASTMARKER, 102 | /* set the end of the current context, also change length 103 | * of a VarStruct: */ 104 | ft_SET_SIZE, 105 | /* a ft_CARD32 looking into the ATOM list */ 106 | ft_ATOM, 107 | /* always big endian */ 108 | ft_BE32, 109 | /* get the #ofs value from the stack. (0 is the last pushed) */ 110 | ft_GET, 111 | /* a fixed-point number 16+16 bit */ 112 | ft_FIXED, 113 | /* a list of those */ 114 | ft_LISTofFIXED, 115 | /* a fixed-point number 32+32 bit */ 116 | ft_FIXED3232, 117 | /* a list of those */ 118 | ft_LISTofFIXED3232, 119 | /* a 32 bit floating pointer number */ 120 | ft_FLOAT32, 121 | /* a list of those */ 122 | ft_LISTofFLOAT32, 123 | /* fraction with nominator and denominator 16 bit */ 124 | ft_FRACTION16_16, 125 | /* dito 32 bit */ 126 | ft_FRACTION32_32, 127 | /* nominator is unsigned */ 128 | ft_UFRACTION32_32, 129 | /* a 64 bit number consisting of first the high 32 bit, then 130 | * the low 32 bti */ 131 | ft_INT32_32, 132 | /* decrement stored value by specific value */ 133 | ft_DECREMENT_STORED, 134 | ft_DIVIDE_STORED, 135 | /* set stored value to specific value */ 136 | ft_SET 137 | } type; 138 | union parameter_option { 139 | /* for integers and fields of integers */ 140 | const struct constant *constants; 141 | /* for IFs, Structs, ... */ 142 | const struct parameter *parameters; 143 | /* for LISTofVALUE */ 144 | const struct value *values; 145 | } o; 146 | }; 147 | struct value { 148 | unsigned long flag; 149 | /* NULL means EndOfValues */ 150 | const char *name; 151 | /* only elementary type (<= ft_BITMASK32 are allowed ), */ 152 | enum fieldtype type; 153 | const struct constant *constants; 154 | }; 155 | 156 | extern const struct request *requests; 157 | extern size_t num_requests; 158 | extern const struct event *events; 159 | extern size_t num_events; 160 | extern const const char * const *errors; 161 | extern size_t num_errors; 162 | extern const struct extension *extensions; 163 | extern size_t num_extensions; 164 | extern const struct parameter *unexpected_reply; 165 | extern const struct parameter *setup_parameters; 166 | 167 | /* special handlers, for the SPECIAL requests/events */ 168 | extern request_func requestQueryExtension; 169 | extern request_func requestInternAtom; 170 | extern request_func requestGetAtomName; 171 | extern reply_func replyListFontsWithInfo; 172 | extern reply_func replyQueryExtension; 173 | extern reply_func replyInternAtom; 174 | extern reply_func replyGetAtomName; 175 | 176 | #endif 177 | -------------------------------------------------------------------------------- /present.proto: -------------------------------------------------------------------------------- 1 | NEEDS "randr.proto" 2 | NEEDS "fixes.proto" 3 | NEEDS "sync.proto" 4 | 5 | EXTENSION "Present" Present 6 | USE core 7 | 8 | REQUESTS 9 | QueryVersion RESPONDS 10 | Pixmap 11 | NotifyMSC 12 | SelectInput 13 | QueryCapabilities RESPONDS 14 | END 15 | 16 | EVENTS 17 | END 18 | 19 | ERRORS 20 | END 21 | 22 | XGEVENTS 23 | ConfigureNotify 24 | CompleteNotify 25 | IdleNotify 26 | RedirectNotify 27 | END 28 | 29 | TYPE PRESENT_EVENT_ID CARD32 30 | 31 | BITMASK present_event_mask 32 | 1<<0 ConfigureNotify 33 | 1<<1 CompleteNotify 34 | 1<<2 IdleNotify 35 | 1<<3 RedirectNotify 36 | END 37 | TYPE PRESENT_EVENT_MASK BITMASK32 present_event_mask 38 | 39 | BITMASK present_option 40 | 1<<0 Async 41 | 1<<1 Copy 42 | 1<<2 UST 43 | END 44 | TYPE PRESENT_OPTION BITMASK32 present_option 45 | 46 | BITMASK present_capability 47 | 1<<0 Async 48 | 1<<1 Fence 49 | 1<<2 UST 50 | END 51 | TYPE PRESENT_CAPABILITY BITMASK32 present_capability 52 | 53 | CONSTANTS present_complete_kind 54 | 0 Pixmap 55 | 1 NotifyMSC 56 | END 57 | TYPE PRESENT_COMPLETE_KIND ENUM8 present_complete_kind 58 | 59 | CONSTANTS present_complete_mode 60 | 0 Copy 61 | 1 Flip 62 | 2 Skip 63 | END 64 | TYPE PRESENT_COMPLETE_MODE ENUM8 present_complete_mode 65 | 66 | LIST PRESENT_NOTIFY length 8 67 | 0 window WINDOW 68 | 4 serial UINT32 69 | END 70 | 71 | REQUEST QueryVersion 72 | 4 majorVersion UINT32 73 | 8 minorVersion UINT32 74 | END 75 | RESPONSE QueryVersion 76 | 8 majorVersion UINT32 77 | 12 minorVersion UINT32 78 | END 79 | 80 | REQUEST Pixmap 81 | 4 window WINDOW 82 | 8 pixmap PIXMAP 83 | 12 serial UINT32 84 | 16 valid Fixes::REGION 85 | 20 update Fixes::REGION 86 | 24 x_off INT16 87 | 26 y_off INT16 88 | 28 target_crtc RandR::CRTC 89 | 32 wait_fence XSync::Fence 90 | 36 idle_fence XSync::Fence 91 | 40 options PRESENT_OPTION 92 | 48 target_msc XSync::Value 93 | 56 divisor XSync::Value 94 | 64 remainder XSync::Value 95 | 72 notifies LISTofPRESENT_NOTIFY 96 | END 97 | 98 | REQUEST NotifyMSC 99 | 4 window WINDOW 100 | 8 serial UINT32 101 | 16 target_msc XSync::Value 102 | 24 divisor XSync::Value 103 | 32 remainder XSync::Value 104 | END 105 | 106 | REQUEST SelectInput 107 | 4 eid PRESENT_EVENT_ID 108 | 8 window WINDOW 109 | 12 event_mask PRESENT_EVENT_MASK 110 | END 111 | 112 | REQUEST QueryCapabilities 113 | 4 target UINT32 114 | END 115 | RESPONSE QueryCapabilities 116 | 8 capabilities PRESENT_CAPABILITY 117 | END 118 | 119 | XGEVENT ConfigureNotify 120 | 12 event PRESENT_EVENT_ID 121 | 16 window WINDOW 122 | 20 x INT16 123 | 22 y INT16 124 | 24 width UINT16 125 | 26 height UINT16 126 | 28 off_x INT16 127 | 30 off_y INT16 128 | 32 pixmap_width UINT16 129 | 34 pixmap_height UINT16 130 | 36 pixmap_flags CARD32 131 | END 132 | 133 | XGEVENT CompleteNotify 134 | 10 kind PRESENT_COMPLETE_KIND 135 | 11 mode PRESENT_COMPLETE_MODE 136 | 12 event PRESENT_EVENT_ID 137 | 16 window WINDOW 138 | 20 serial UINT32 139 | 24 ust XSync::Value 140 | 32 msc XSync::Value 141 | END 142 | 143 | XGEVENT IdleNotify 144 | 12 event PRESENT_EVENT_ID 145 | 16 window WINDOW 146 | 20 serial UINT32 147 | 24 pixmap PIXMAP 148 | 28 idle_fence XSync::Fence 149 | END 150 | 151 | XGEVENT RedirectNotify 152 | 10 update_window BOOL 153 | 12 event PRESENT_EVENT_ID 154 | 16 event_window WINDOW 155 | 20 window WINDOW 156 | 24 pixmap PIXMAP 157 | 28 serial UINT32 158 | 32 valid_region Fixes::REGION 159 | 36 update_region Fixes::REGION 160 | 40 valid_rect RECTANGLE 161 | 48 update_rect RECTANGLE 162 | 56 x_off INT16 163 | 58 y_off INT16 164 | 60 target_crtc RandR::CRTC 165 | 64 wait_fence XSync::Fence 166 | 68 idle_fence XSync::Fence 167 | 72 options PRESENT_OPTION 168 | 80 target_msc XSync::Value 169 | 88 divisor XSync::Value 170 | 96 remainder XSync::Value 171 | 104 notifies LISTofPRESENT_NOTIFY 172 | END 173 | 174 | EOF 175 | -------------------------------------------------------------------------------- /randr.proto: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuq/xtrace/fd1e5a94628acc6277904c547992825aefa119c6/randr.proto -------------------------------------------------------------------------------- /render.proto: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuq/xtrace/fd1e5a94628acc6277904c547992825aefa119c6/render.proto -------------------------------------------------------------------------------- /saver.proto: -------------------------------------------------------------------------------- 1 | # This file is part of "xtrace" 2 | # Copyright (C) 2008 Bernhard R. Link 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License version 2 as 5 | # published by the Free Software Foundation. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | # 12 | # You should have received a copy of the GNU General Public License 13 | # along with this program; if not, write to the Free Software 14 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | EXTENSION "MIT-SCREEN-SAVER" Saver 17 | USE core 18 | 19 | REQUESTS 20 | QueryVersion RESPONDS 21 | QueryInfo RESPONDS 22 | SelectInput 23 | SetAttributes 24 | UnsetAttributes 25 | Suspend 26 | END 27 | 28 | EVENTS 29 | SaverNotify 30 | END 31 | 32 | ERRORS 33 | END 34 | 35 | CONSTANTS saver_level 36 | 0 on 37 | 1 standby 38 | 2 suspend 39 | 3 off 40 | END 41 | TYPE Saver_LEVEL ENUM16 saver_level 42 | 43 | CONSTANTS saver_state 44 | 0 off 45 | 1 on 46 | 2 cycle 47 | 3 disable 48 | END 49 | TYPE Saver_STATE ENUM8 saver_state 50 | CONSTANTS saver_kind 51 | 0 blanked 52 | 1 internal 53 | 2 external 54 | END 55 | TYPE Saver_KIND ENUM8 saver_kind 56 | 57 | BITMASK saver_mask 58 | 0x00000001 notify 59 | 0x00000002 cycle 60 | END 61 | TYPE Saver_MASK BITMASK32 saver_mask 62 | 63 | REQUEST QueryVersion 64 | 4 "major version" UINT8 65 | 5 "minor version" UINT8 66 | END 67 | RESPONSE QueryVersion 68 | 8 "major version" UINT16 69 | 10 "minor version" UINT16 70 | END 71 | 72 | templateREQUEST DRAWABLE 73 | 4 drawable DRAWABLE 74 | END 75 | REQUEST QueryInfo ALIASES DRAWABLE 76 | 77 | #define parameterSaverQueryInfo parameterDRAWABLE 78 | 79 | RESPONSE QueryInfo 80 | 1 state Saver_STATE 81 | 8 window WINDOW 82 | 12 "til or since" UINT32 83 | 16 idle UINT32 84 | 20 "event mask" Saver_MASK 85 | 24 kind Saver_KIND 86 | END 87 | 88 | REQUEST SelectInput 89 | 4 drawable DRAWABLE 90 | 8 mask Saver_MASK 91 | END 92 | 93 | REQUEST SetAttributes 94 | 4 drawable DRAWABLE 95 | 8 x INT16 96 | 10 y INT16 97 | 12 width UINT16 98 | 14 height UINT16 99 | 16 border-height UINT16 100 | 18 c_class CARD8 101 | 19 depth UINT8 102 | 20 visual-id CARD32 103 | 24 mask Saver_MASK 104 | END 105 | REQUEST UnsetAttributes ALIASES DRAWABLE 106 | 107 | REQUEST Suspend 108 | 4 suspend BOOL 109 | END 110 | 111 | EVENT SaverNotify 112 | 1 state Saver_STATE 113 | 8 root WINDOW 114 | 12 window WINDOW 115 | 16 kind Saver_KIND 116 | 17 forced BOOL 117 | END 118 | 119 | EOF 120 | -------------------------------------------------------------------------------- /setup.proto: -------------------------------------------------------------------------------- 1 | # This file is part of xtrace 2 | # Copyright (C) 2010 Bernhard R. Link 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License version 2 as 5 | # published by the Free Software Foundation. 6 | # 7 | # This program is distributed in the hope that it will be useful 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | # 12 | # You should have received a copy of the GNU General Public License 13 | # along with this program; if not write to the Free Software 14 | # Foundation Inc. 51 Franklin St Fifth Floor Boston MA 02110-1301 USA 15 | 16 | NAMESPACE core 17 | 18 | CONSTANTS visualtypeclass 19 | 0 StaticGray 20 | 1 GrayScale 21 | 2 StaticColor 22 | 3 PseudoColor 23 | 4 TrueColor 24 | 5 DirectColor 25 | END 26 | 27 | LIST VISUALTYPE length 24 28 | 0 id CARD32 29 | 4 class ENUM8 visualtypeclass 30 | 5 bits/rgb-value UINT8 31 | 6 colormap-entries UINT16 32 | 8 red-mask CARD32 33 | 12 green-mask CARD32 34 | 16 blue-mask CARD32 35 | #20 pad CARD32 36 | END 37 | 38 | LIST DEPTH variable min-length 8 39 | 0 depth UINT8 40 | 2 "#types" COUNT16 41 | 8 visuals LISTofVISUALTYPE 42 | END 43 | 44 | CONSTANTS backingstore 45 | 0 Never 46 | 1 WhenMapped 47 | 2 Always 48 | END 49 | 50 | LIST SCREEN variable min-length 40 51 | 0 root WINDOW 52 | 4 default-colormap COLORMAP 53 | 8 white-pixel CARD32 54 | 12 black-pixel CARD32 55 | 16 input-mask SETofEVENT 56 | 20 width[pixel] UINT16 57 | 22 height[pixel] UINT16 58 | 24 width[mm] UINT16 59 | 26 height[mm] UINT16 60 | 28 min-installed-maps UINT16 61 | 30 max-installed-maps UINT16 62 | 32 root VISUALID 63 | 36 backing-stores ENUM8 backingstore 64 | 37 save-unders BOOL 65 | 38 root-depth UINT8 66 | 39 "#depths" COUNT8 67 | 40 "allowed depths" LISTofDEPTH 68 | END 69 | 70 | LIST FORMAT length 8 71 | 0 depth UINT8 72 | 1 bits/pixel UINT8 73 | 2 scanline-pad UINT8 74 | END 75 | 76 | CONSTANTS lsbmsb 77 | 0 LSBFirst 78 | 1 MSBFirst 79 | END 80 | CONSTANTS lsms 81 | 0 LeastSignificant 82 | 1 MostSignificant 83 | END 84 | 85 | SETUP 86 | 24 len(vendor) COUNT16 87 | 40 vendor STRING8 88 | ROUND 89 | 8 release UINT32 90 | 12 resource-id CARD32 91 | 16 resource-mask CARD32 92 | 20 motion-buffer-size UINT32 93 | 26 max-request-len UINT16 94 | 30 image-byte-order ENUM8 lsbmsb 95 | 31 bitmap-bit-order ENUM8 lsms 96 | 32 scanline-unit UINT8 97 | 33 scanline-pad UINT8 98 | 34 min-keycode KEYCODE 99 | 36 max-keycode KEYCODE 100 | 29 "#formats" COUNT8 101 | LATER pixmap-formats LISTofFORMAT 102 | 28 "#screens" COUNT8 103 | LATER roots LISTofSCREEN 104 | END 105 | 106 | EOF 107 | -------------------------------------------------------------------------------- /shape.proto: -------------------------------------------------------------------------------- 1 | # This file is part of "xtrace" 2 | # Copyright (C) 2005 Bernhard R. Link 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License version 2 as 5 | # published by the Free Software Foundation. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | # 12 | # You should have received a copy of the GNU General Public License 13 | # along with this program; if not, write to the Free Software 14 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | # This file is based on the 16 | ## X Nonrectangular Window 17 | ## Shape Extension Protocol 18 | ## Version 1.0 19 | ## X Consortium Standard 20 | ## X Version 11, Release 6.4 21 | ## Keith Packard 22 | ## MIT X Consortium 23 | ## Copyright (C) 1989 X Consortium 24 | ## 25 | ## Permission is hereby granted, free of charge, to any person 26 | ## obtaining a copy of this software and associated documenta- 27 | ## tion files (the ``Software''), to deal in the Software with- 28 | ## out restriction, including without limitation the rights to 29 | ## use, copy, modify, merge, publish, distribute, sublicense, 30 | ## and/or sell copies of the Software, and to permit persons to 31 | ## whom the Software is furnished to do so, subject to the fol- 32 | ## lowing conditions: 33 | ## 34 | ## The above copyright notice and this permission notice shall 35 | ## be included in all copies or substantial portions of the 36 | ## Software. 37 | ## 38 | ## THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY 39 | ## KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 40 | ## WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PUR- 41 | ## POSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE X 42 | ## CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABIL- 43 | ## ITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 44 | ## ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR 45 | ## THE USE OR OTHER DEALINGS IN THE SOFTWARE. 46 | ## 47 | ## Except as contained in this notice, the name of the X Con- 48 | ## sortium shall not be used in advertising or otherwise to 49 | ## promote the sale, use or other dealings in this Software 50 | ## without prior written authorization from the X Consortium. 51 | 52 | EXTENSION "SHAPE" Shape 53 | USE core 54 | 55 | REQUESTS 56 | QueryVersion RESPONDS 57 | Rectangles 58 | Mask 59 | Combine 60 | Offset 61 | QueryExtents RESPONDS 62 | SelectInput 63 | InputSelected RESPONDS 64 | GetRectangles RESPONDS 65 | END 66 | 67 | EVENTS 68 | ShapeNotify 69 | END 70 | 71 | ERRORS 72 | END 73 | 74 | CONSTANTS shape_kind 75 | 0 Bounding 76 | 1 Clip 77 | 2 Input 78 | END 79 | TYPE SHAPE_KIND ENUM8 shape_kind 80 | CONSTANTS shape_op 81 | 0 Set 82 | 1 Union 83 | 2 Intersect 84 | 3 Subtract 85 | 4 Invert 86 | END 87 | TYPE SHAPE_OP ENUM8 shape_op 88 | CONSTANTS shape_sort 89 | 0 UnSorted 90 | 1 YSorted 91 | 2 YXSorted 92 | 3 YXBanded 93 | END 94 | 95 | REQUEST QueryVersion ALIASES Empty 96 | 97 | RESPONSE QueryVersion 98 | 8 "major version" UINT16 99 | 10 "minor version" UINT16 100 | END 101 | 102 | REQUEST Rectangles 103 | 4 operation SHAPE_OP 104 | 5 "destination kind" SHAPE_KIND 105 | 6 ordering ENUM8 shape_sort 106 | 8 "destination window" WINDOW 107 | 12 x-offset INT16 108 | 14 y-offset INT16 109 | 16 rectangles LISTofRECTANGLE 110 | END 111 | 112 | REQUEST Mask 113 | 4 operation SHAPE_OP 114 | 5 destination-kind SHAPE_KIND 115 | 8 destination-window WINDOW 116 | 12 x-offset INT16 117 | 14 y-offset INT16 118 | 16 source-bitmap PIXMAP constants none 119 | END 120 | 121 | REQUEST Combine 122 | 4 operation SHAPE_OP 123 | 5 destination-kind SHAPE_KIND 124 | 6 source-kind SHAPE_KIND 125 | 8 "destination window" WINDOW 126 | 12 "x offset" INT16 127 | 14 "y offset" INT16 128 | 16 source-window WINDOW 129 | END 130 | 131 | REQUEST Offset 132 | 4 "destination kind" SHAPE_KIND 133 | 8 "destination window" WINDOW 134 | 12 "x offset" INT16 135 | 14 "y offset" INT16 136 | END 137 | 138 | REQUEST QueryExtents ALIASES WINDOW 139 | 140 | RESPONSE QueryExtents 141 | 8 "bounding shaped" BOOL 142 | 9 "clip shaped" BOOL 143 | 12 "bounding shape extents x" INT16 144 | 14 "bounding shape extents y" INT16 145 | 16 "bounding shape extents width" UINT16 146 | 18 "bounding shape extents height" UINT16 147 | 20 "clip shape extents x" INT16 148 | 22 "clip shape extents y" INT16 149 | 24 "clip shape extents width" UINT16 150 | 26 "clip shape extents height" UINT16 151 | END 152 | 153 | REQUEST SelectInput 154 | 4 "destination window" WINDOW 155 | 8 enable BOOL 156 | END 157 | 158 | REQUEST InputSelected ALIASES WINDOW 159 | 160 | RESPONSE InputSelected 161 | 1 enabled BOOL 162 | END 163 | 164 | REQUEST GetRectangles 165 | 4 window WINDOW 166 | 8 source-kind SHAPE_KIND 167 | END 168 | 169 | RESPONSE GetRectangles 170 | 1 ordering ENUM8 shape_sort 171 | 8 nrects COUNT32 172 | 32 rectangles LISTofRECTANGLE 173 | END 174 | 175 | EVENT ShapeNotify 176 | 1 "shape kind" SHAPE_KIND 177 | 4 "affected window" WINDOW 178 | 8 "x value of extents" INT16 179 | 10 "y value of extents" INT16 180 | 12 "width of extents" UINT16 181 | 14 "height of extents" UINT16 182 | 16 "server time" TIMESTAMP 183 | 22 shaped BOOL 184 | END 185 | 186 | EOF 187 | -------------------------------------------------------------------------------- /stringlist.c: -------------------------------------------------------------------------------- 1 | /* This file is part of "xtrace" 2 | * Copyright (C) 2009 Bernhard R. Link 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License version 2 as 5 | * published by the Free Software Foundation. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program; if not, write to the Free Software 14 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | */ 16 | 17 | #include 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #include "stringlist.h" 26 | 27 | static struct string_bucket { 28 | struct string_bucket *next; 29 | size_t ofs; 30 | char data[]; 31 | } *stringlist; 32 | 33 | static struct bucket { 34 | struct bucket *next; 35 | size_t size, ofs; 36 | char data[]; 37 | } *buckets; 38 | 39 | #define STRINGLIST_SIZE 16 * 1024 40 | #define BUCKET_SIZE 32 * 1024 41 | 42 | void stringlist_init(void) { 43 | stringlist = malloc(STRINGLIST_SIZE); 44 | if( stringlist == NULL ) { 45 | fputs("Out of memory!\n", stderr); 46 | return; 47 | } 48 | stringlist->ofs = STRINGLIST_SIZE - 49 | ((char*)&stringlist->data-(char*)stringlist); 50 | stringlist->next = NULL; 51 | 52 | buckets = malloc(BUCKET_SIZE); 53 | if( buckets == NULL ) { 54 | fputs("Out of memory!\n", stderr); 55 | return; 56 | } 57 | buckets->size = BUCKET_SIZE; 58 | buckets->ofs = sizeof(struct bucket); 59 | buckets->next = NULL; 60 | } 61 | 62 | void stringlist_done(void) { 63 | while( stringlist != NULL ) { 64 | struct string_bucket *n = stringlist->next; 65 | free(stringlist); 66 | stringlist = n; 67 | } 68 | while( buckets != NULL ) { 69 | struct bucket *n = buckets->next; 70 | free(buckets); 71 | buckets = n; 72 | } 73 | } 74 | 75 | const void *finalize_data(const void *data, size_t len, size_t align) { 76 | void *p; 77 | size_t next_ofs; 78 | 79 | if( buckets == NULL ) 80 | return NULL; 81 | 82 | next_ofs = ((buckets->ofs + align - 1)/align)*align; 83 | if( next_ofs >= buckets->size || len > buckets->size - next_ofs ) { 84 | struct bucket *n; 85 | size_t size; 86 | 87 | if( len >= BUCKET_SIZE/2 ) 88 | size = len; 89 | else 90 | size = BUCKET_SIZE; 91 | next_ofs = ((sizeof(struct bucket) + align - 1)/align)*align; 92 | size += next_ofs; 93 | n = malloc(size); 94 | if( n == NULL ) { 95 | fputs("Out of memory!\n", stderr); 96 | stringlist_done(); 97 | return NULL; 98 | } 99 | n->size = size; 100 | n->ofs = next_ofs; 101 | if( n->size - n->ofs == len ) { 102 | n->ofs = n->size; 103 | p = ((char*)buckets) + next_ofs; 104 | memcpy(p, data, len); 105 | n->next = buckets->next; 106 | buckets->next = n; 107 | return p; 108 | } 109 | n->next = buckets; 110 | buckets = n; 111 | } 112 | assert( len <= buckets->size - next_ofs ); 113 | p = ((char*)buckets) + next_ofs; 114 | memcpy(p, data, len); 115 | buckets->ofs = next_ofs + len; 116 | return p; 117 | } 118 | 119 | const char *string_add_l(const char *string, size_t len) { 120 | char *p; 121 | 122 | if( stringlist == NULL ) 123 | return NULL; 124 | 125 | if( stringlist->ofs <= len ) { 126 | struct string_bucket *n; 127 | size_t size; 128 | 129 | size = STRINGLIST_SIZE; 130 | if( len >= size ) 131 | size = ((char*)&stringlist->data-(char*)stringlist) 132 | + 1 + len; 133 | 134 | n = malloc(size); 135 | if( n == NULL ) { 136 | fputs("Out of memory!\n", stderr); 137 | stringlist_done(); 138 | return NULL; 139 | } 140 | n->ofs = size - 141 | ((char*)&n->data-(char*)n); 142 | assert( n->ofs > len ); 143 | if( n->ofs == len + 1 ) { 144 | n->ofs = 0; 145 | memcpy(n->data, string, len); 146 | n->data[len] = '\0'; 147 | n->next = stringlist->next; 148 | stringlist->next = n; 149 | return n->data; 150 | } 151 | n->next = stringlist; 152 | stringlist = n; 153 | } 154 | assert( stringlist->ofs > len ); 155 | 156 | stringlist->ofs -= len + 1; 157 | p = stringlist->data + stringlist->ofs; 158 | memcpy(p, string, len); 159 | p[len] = '\0'; 160 | return p; 161 | } 162 | 163 | const char *string_add(const char *string) { 164 | return string_add_l(string, strlen(string)); 165 | } 166 | -------------------------------------------------------------------------------- /stringlist.h: -------------------------------------------------------------------------------- 1 | #ifndef XTRACE_STRINGLIST_H 2 | #define XTRACE_STRINGLIST_H 3 | const char *string_add_l(const char *, size_t); 4 | const char *string_add(const char *); 5 | const void *finalize_data(const void *, size_t len, size_t align); 6 | void stringlist_init(void); 7 | void stringlist_done(void); 8 | #endif 9 | 10 | -------------------------------------------------------------------------------- /sync.proto: -------------------------------------------------------------------------------- 1 | EXTENSION "SYNC" XSync 2 | USE core 3 | 4 | REQUESTS 5 | Initialize RESPONDS 6 | ListSystemCounters RESPONDS 7 | CreateCounter 8 | SetCounter 9 | ChangeCounter 10 | QueryCounter RESPONDS 11 | DestroyCounter 12 | Await 13 | CreateAlarm 14 | ChangeAlarm 15 | QueryAlarm RESPONDS 16 | DestroyAlarm 17 | SetPriority 18 | GetPriority RESPONDS 19 | CreateFence 20 | TriggerFence 21 | ResetFence 22 | DestroyFence 23 | QueryFence RESPONDS 24 | AwaitFence /* 19 */ 25 | END 26 | 27 | EVENTS 28 | CounterNotify 29 | AlarmNotify 30 | END 31 | 32 | ERRORS 33 | BadCounter 34 | BadAlarm 35 | END 36 | 37 | # XSyncCounter, XSyncAlarm and XSyncFence are just IDs: 38 | TYPE Counter CARD32 39 | TYPE Alarm CARD32 40 | TYPE Fence CARD32 41 | # a XSyncValue is two 32 bit integers meaning on 64 bit one: 42 | TYPE Value INT32_32 43 | 44 | CONSTANTS alarm_state 45 | 0 Active 46 | 1 Inactive 47 | 2 Destroyed 48 | END 49 | TYPE AlarmState ENUM8 alarm_state 50 | 51 | CONSTANTS test_type 52 | 0 PositiveTransition 53 | 1 NegativeTransition 54 | 2 PositiveComparison 55 | 3 NegativeComparison 56 | END 57 | TYPE TestType ENUM32 test_type 58 | 59 | CONSTANTS value_type 60 | 0 Absolute 61 | 1 Relative 62 | END 63 | TYPE ValueType ENUM32 value_type 64 | 65 | REQUEST Initialize 66 | 4 major-version UINT8 67 | 5 minor-version UINT8 68 | END 69 | RESPONSE Initialize 70 | 8 major-version UINT8 71 | 9 minor-version UINT8 72 | END 73 | 74 | LIST SystemCounter variable min-length 14 75 | 0 counter Counter 76 | 4 resolution Value 77 | 12 name_length COUNT16 78 | 14 name STRING8 79 | ROUND 80 | END 81 | 82 | REQUEST ListSystemCounters ALIASES Empty 83 | RESPONSE ListSystemCounters 84 | 8 num-counters COUNT32 85 | 32 counter LISTofSystemCounter 86 | END 87 | 88 | REQUEST CreateCounter 89 | 4 counter Counter 90 | 8 initial-value Value 91 | END 92 | 93 | REQUEST SetCounter 94 | 4 counter Counter 95 | 8 value Value 96 | END 97 | 98 | REQUEST ChangeCounter 99 | 4 counter Counter 100 | 8 value Value 101 | END 102 | 103 | REQUEST QueryCounter 104 | 4 counter Counter 105 | END 106 | RESPONSE QueryCounter 107 | 8 value Value 108 | END 109 | 110 | REQUEST DestroyCounter 111 | 4 counter Counter 112 | END 113 | 114 | LIST WaitCondition length 28 115 | 0 counter Counter 116 | 4 value-type ValueType 117 | 8 wait-value Value 118 | 16 test-type TestType 119 | 20 event-threshold Value 120 | END 121 | 122 | REQUEST Await 123 | 4 conditions LISTofWaitCondition 124 | END 125 | 126 | VALUES AlarmAttributes 127 | 1<<0 Counter Counter 128 | 1<<1 ValueType ValueType 129 | 1<<2 Value Value 130 | 1<<3 TestType TestType 131 | 1<<4 Delta Value 132 | 1<<5 Events BOOL 133 | END 134 | 135 | REQUEST CreateAlarm 136 | 4 alarm Alarm 137 | 8 value-mask STORE16 138 | 12 values LISTofAlarmAttributes 139 | END 140 | 141 | REQUEST ChangeAlarm 142 | 4 alarm Alarm 143 | 8 value-mask STORE16 144 | 12 values LISTofAlarmAttributes 145 | END 146 | 147 | REQUEST QueryAlarm 148 | 4 alarm Alarm 149 | END 150 | RESPONSE QueryAlarm 151 | 8 counter Counter 152 | 12 value-type ValueType 153 | 16 wait-value Value 154 | 24 test-type TestType 155 | 28 delta Value 156 | 36 events BOOL 157 | 37 state AlarmState 158 | END 159 | 160 | REQUEST DestroyAlarm 161 | 4 alarm Alarm 162 | END 163 | 164 | REQUEST SetPriority 165 | 4 client-resource-id CARD32 constants none 166 | 8 priority INT32 167 | END 168 | 169 | REQUEST GetPriority 170 | 4 client-resource-id CARD32 constants none 171 | END 172 | RESPONSE GetPriority 173 | 8 priority INT32 174 | END 175 | 176 | REQUEST CreateFence 177 | 4 drawable DRAWABLE 178 | 8 fid Fence 179 | 12 initial-triggered BOOL 180 | END 181 | 182 | templateREQUEST Fence 183 | 4 fid Fence 184 | END 185 | 186 | REQUEST TriggerFence ALIASES Fence 187 | REQUEST ResetFence ALIASES Fence 188 | REQUEST DestroyFence ALIASES Fence 189 | REQUEST QueryFence ALIASES Fence 190 | 191 | RESPONSE QueryFence 192 | 8 triggered BOOL 193 | END 194 | 195 | REQUEST AwaitFence ALIASES Empty 196 | 197 | EVENT CounterNotify 198 | 4 counter Counter 199 | 8 wait-value Value 200 | 16 counter-value Value 201 | 24 time TIMESTAMP 202 | 28 count UINT16 203 | 30 destroyed BOOL 204 | END 205 | 206 | EVENT AlarmNotify 207 | 4 alarm Alarm 208 | 8 counter-value Value 209 | 16 alarm-value Value 210 | 24 time TIMESTAMP 211 | 28 state AlarmState 212 | END 213 | 214 | EOF 215 | -------------------------------------------------------------------------------- /translate.h: -------------------------------------------------------------------------------- 1 | #ifndef XTRACE_TRANSLATE_H 2 | #define XTRACE_TRANSLATE_H 3 | 4 | struct parser; 5 | 6 | void finalize_everything(struct parser *); 7 | struct parser *parser_init(void); 8 | void add_searchpath(struct parser *, const char *); 9 | bool translate(struct parser *, const char *); 10 | bool parser_free(struct parser *); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /vidmode.proto: -------------------------------------------------------------------------------- 1 | # This file is part of "xtrace" 2 | # Copyright (C) 2006 Bernhard R. Link 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License version 2 as 5 | # published by the Free Software Foundation. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | # 12 | # You should have received a copy of the GNU General Public License 13 | # along with this program; if not, write to the Free Software 14 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | # 16 | # This file is based on /usr/include/X11/extensions/xf86vmstr.h which states: 17 | ## Copyright 1995 Kaleb S. KEITHLEY 18 | ## 19 | ## Permission is hereby granted, free of charge, to any person obtaining 20 | ## a copy of this software and associated documentation files (the 21 | ## "Software"), to deal in the Software without restriction, including 22 | ## without limitation the rights to use, copy, modify, merge, publish, 23 | ## distribute, sublicense, and/or sell copies of the Software, and to 24 | ## permit persons to whom the Software is furnished to do so, subject to 25 | ## the following conditions: 26 | ## 27 | ## The above copyright notice and this permission notice shall be 28 | ## included in all copies or substantial portions of the Software. 29 | ## 30 | ## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 31 | ## EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 32 | ## MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 33 | ## IN NO EVENT SHALL Kaleb S. KEITHLEY BE LIABLE FOR ANY CLAIM, DAMAGES 34 | ## OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 35 | ## ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 36 | ## OTHER DEALINGS IN THE SOFTWARE. 37 | ## 38 | ## Except as contained in this notice, the name of Kaleb S. KEITHLEY 39 | ## shall not be used in advertising or otherwise to promote the sale, use 40 | ## or other dealings in this Software without prior written authorization 41 | ## from Kaleb S. KEITHLEY 42 | 43 | EXTENSION "XFree86-VidModeExtension" VidMode 44 | USE core 45 | 46 | REQUESTS 47 | QueryVersion RESPONDS 48 | GetModeLine RESPONDS 49 | ModModeLine 50 | SwitchMode 51 | GetMonitor RESPONDS 52 | LockModeSwitch 53 | GetAllModeLines RESPONDS 54 | AddModeLine 55 | DeleteModeLine 56 | ValidateModeLine RESPONDS 57 | SwitchToMode 58 | GetViewPort RESPONDS 59 | SetViewPort 60 | GetDotClocks RESPONDS 61 | SetClientVersion 62 | SetGamma 63 | GetGamma RESPONDS 64 | GetGammaRamp RESPONDS 65 | SetGammaRamp 66 | GetGammaRampSize RESPONDS 67 | GetPermissions RESPONDS 68 | END 69 | 70 | EVENTS 71 | END 72 | 73 | ERRORS 74 | BadClock 75 | BadHTimings 76 | BadVTimings 77 | ModeUnsuitable 78 | ExtensionDisabled 79 | ClientNotLocal 80 | ZoomLocked 81 | END 82 | 83 | BITMASK xf86vidmode_perms 84 | 1 read 85 | 2 write 86 | END 87 | 88 | BITMASK xf86vidmode_flags 89 | # taken from xvidtune: 90 | 1 +hsync 91 | 2 -hsync 92 | 4 +vsync 93 | 8 -vsync 94 | 16 interlace 95 | 32 doublescan 96 | 64 csync 97 | 128 +csync 98 | 256 -csync 99 | END 100 | 101 | REQUEST QueryVersion 102 | END 103 | RESPONSE QueryVersion 104 | 8 major-version UINT16 105 | 10 minor-version UINT16 106 | END 107 | 108 | REQUEST GetModeLine 109 | 4 screen UINT16 110 | END 111 | 112 | REQUEST GetAllModeLines ALIASES GetModeLine 113 | 114 | REQUEST GetMonitor ALIASES GetModeLine 115 | 116 | REQUEST GetViewPort ALIASES GetModeLine 117 | 118 | REQUEST GetDotClocks ALIASES GetModeLine 119 | 120 | REQUEST GetPermissions ALIASES GetModeLine 121 | 122 | REQUEST GetGamma ALIASES GetModeLine 123 | 124 | RESPONSE GetModeLine 125 | 8 dotclock UINT32 126 | 12 hdisplay UINT16 127 | 14 hsyncstart UINT16 128 | 16 hsyncend UINT16 129 | 18 htotal UINT16 130 | 20 hskew UINT16 131 | 22 vdisplay UINT16 132 | 24 vsyncstart UINT16 133 | 26 vsyncend UINT16 134 | 28 vtotal UINT16 135 | 32 flags BITMASK32 xf86vidmode_flags 136 | 36 reserved1 UINT32 137 | 40 reserved2 UINT32 138 | 44 reserved3 UINT32 139 | 48 privsize UINT32 140 | END 141 | 142 | LIST Modes length 48 143 | # This is somehow buggy, xf86vmstr.h values cannot 144 | # be, this looks a bit better, but I'm still not sure 145 | 0 dotclock UINT32 146 | 4 hdisplay UINT16 147 | 6 hsyncstart UINT16 148 | 8 hsyncend UINT16 149 | 10 htotal UINT16 150 | 12 hskew UINT32 151 | 16 vdisplay UINT16 152 | 18 vsyncstart UINT16 153 | 20 vsyncend UINT16 154 | 22 vtotal UINT16 155 | 28 flags BITMASK32 xf86vidmode_flags 156 | 32 reserved1 UINT32 157 | 36 reserved2 UINT32 158 | 40 reserved3 UINT32 159 | 44 privsize UINT32 160 | END 161 | 162 | RESPONSE GetAllModeLines 163 | 8 modecount UINT32 164 | 8 modecount COUNT32 165 | 32 modes LISTofModes 166 | END 167 | 168 | LIST Sync length 4 169 | 0 min UINT16 170 | 2 max UINT16 171 | END 172 | 173 | RESPONSE GetMonitor 174 | 8 vendorLength COUNT8 175 | 32 vendor STRING8 176 | 9 modelLength COUNT8 177 | LATER model STRING8 178 | 10 nhsync COUNT8 179 | LATER hsync LISTofSync 180 | 11 nvsync COUNT8 181 | LATER vsync LISTofSync 182 | END 183 | 184 | REQUEST AddModeLine 185 | 4 screen CARD32 186 | 8 dotclock UINT32 187 | 12 hdisplay UINT16 188 | 14 hsyncstart UINT16 189 | 16 hsyncend UINT16 190 | 18 htotal UINT16 191 | 20 hskew UINT16 192 | 22 vdisplay UINT16 193 | 24 vsyncstart UINT16 194 | 26 vsyncend UINT16 195 | 28 vtotal UINT16 196 | 32 flags BITMASK32 xf86vidmode_flags 197 | 36 reserved1 UINT32 198 | 40 reserved2 UINT32 199 | 44 reserved3 UINT32 200 | 48 privsize UINT32 201 | 52 after_dotclock UINT32 202 | 56 after_hdisplay UINT16 203 | 58 after_hsyncstart UINT16 204 | 60 after_hsyncend UINT16 205 | 62 after_htotal UINT16 206 | 64 after_hskew UINT16 207 | 66 after_vdisplay UINT16 208 | 68 after_vsyncstart UINT16 209 | 70 after_vsyncend UINT16 210 | 72 after_vtotal UINT16 211 | 76 after_flags CARD32 212 | 80 reserved4 UINT32 213 | 84 reserved5 UINT32 214 | 88 reserved6 UINT32 215 | END 216 | 217 | REQUEST ModModeLine 218 | 4 screen CARD32 219 | 8 hdisplay UINT16 220 | 10 hsyncstart UINT16 221 | 12 hsyncend UINT16 222 | 14 htotal UINT16 223 | 16 hskew UINT16 224 | 18 vdisplay UINT16 225 | 20 vsyncstart UINT16 226 | 22 vsyncend UINT16 227 | 24 vtotal UINT16 228 | 28 flags BITMASK32 xf86vidmode_flags 229 | 32 reserved1 UINT32 230 | 36 reserved2 UINT32 231 | 40 reserved3 UINT32 232 | 44 privsize UINT32 233 | END 234 | 235 | REQUEST ValidateModeLine 236 | 4 screen CARD32 237 | 8 dotclock UINT32 238 | 12 hdisplay UINT16 239 | 14 hsyncstart UINT16 240 | 16 hsyncend UINT16 241 | 18 htotal UINT16 242 | 20 hskew UINT16 243 | 22 vdisplay UINT16 244 | 24 vsyncstart UINT16 245 | 26 vsyncend UINT16 246 | 28 vtotal UINT16 247 | 32 flags BITMASK32 xf86vidmode_flags 248 | 36 reserved1 UINT32 249 | 40 reserved2 UINT32 250 | 44 reserved3 UINT32 251 | 48 privsize UINT32 252 | END 253 | RESPONSE ValidateModeLine 254 | 8 status CARD32 255 | END 256 | 257 | REQUEST DeleteModeLine ALIASES ValidateModeLine 258 | 259 | REQUEST SwitchToMode ALIASES ValidateModeLine 260 | 261 | REQUEST SwitchMode 262 | 4 screen CARD16 263 | 6 zoom UINT16 264 | END 265 | REQUEST LockModeSwitch 266 | 4 screen CARD16 267 | 6 lock CARD16 268 | END 269 | 270 | RESPONSE GetViewPort 271 | 8 x UINT32 272 | 12 y UINT32 273 | END 274 | 275 | REQUEST SetViewPort 276 | 4 screen CARD16 277 | 8 x UINT32 278 | 12 y UINT32 279 | END 280 | 281 | RESPONSE GetDotClocks 282 | 8 flags BITMASK32 xf86vidmode_flags 283 | 12 clocks UINT32 284 | 16 maxclocks UINT32 285 | END 286 | 287 | REQUEST SetClientVersion 288 | 4 major UINT16 289 | 6 minor UINT16 290 | END 291 | 292 | RESPONSE GetGamma 293 | 8 red UINT32 294 | 12 green UINT32 295 | 16 blue UINT32 296 | END 297 | 298 | REQUEST SetGamma 299 | 4 screen CARD16 300 | 8 red UINT32 301 | 12 green UINT32 302 | 16 blue UINT32 303 | END 304 | 305 | REQUEST SetGammaRamp 306 | 4 screen CARD16 307 | 8 size COUNT32 308 | 12 red LISTofUINT16 309 | 8 size COUNT32 310 | LATER green LISTofUINT16 311 | 8 size COUNT32 312 | LATER blue LISTofUINT16 313 | END 314 | 315 | REQUEST GetGammaRamp 316 | 4 screen CARD16 317 | 6 size UINT16 318 | END 319 | RESPONSE GetGammaRamp 320 | 8 size COUNT16 321 | 32 red LISTofUINT16 322 | 8 size COUNT16 323 | LATER green LISTofUINT16 324 | 8 size COUNT16 325 | LATER blue LISTofUINT16 326 | END 327 | 328 | REQUEST GetGammaRampSize 329 | 4 screen CARD16 330 | END 331 | 332 | RESPONSE GetGammaRampSize 333 | 8 size UINT16 334 | END 335 | RESPONSE GetPermissions 336 | 8 permissions BITMASK32 xf86vidmode_perms 337 | END 338 | 339 | EOF 340 | -------------------------------------------------------------------------------- /x11client.c: -------------------------------------------------------------------------------- 1 | /* This file is part of "xtrace" 2 | * Copyright (C) 2005 Bernhard R. Link 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License version 2 as 5 | * published by the Free Software Foundation. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program; if not, write to the Free Software 14 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | */ 16 | #include 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | #include "xtrace.h" 36 | 37 | int connectToServer(const char *displayname,int family,const char *hostname,int display) { 38 | const char *msg; 39 | int fd; 40 | 41 | fd = socket(family,SOCK_STREAM,0); 42 | if( fd < 0 ) { 43 | int e = errno; 44 | fprintf(stderr,"Error opening socket for '%s': %d=%s\n",displayname,e,strerror(e)); 45 | return fd; 46 | } 47 | if( family == AF_INET ) { 48 | struct sockaddr_in addr; 49 | struct addrinfo hints; 50 | struct addrinfo *res; 51 | int tmp=1; 52 | int r; 53 | 54 | memset(&hints,0,sizeof(struct addrinfo)); 55 | hints.ai_family = family; 56 | hints.ai_socktype = SOCK_STREAM; 57 | r = getaddrinfo(hostname, NULL, &hints, &res); 58 | if( r != 0 ) { 59 | close(fd); 60 | fprintf(stderr,"Error resolving hostname '%s' taken from '%s'\nError was: %s\n",hostname,displayname,gai_strerror(r)); 61 | return -1; 62 | } 63 | assert( res->ai_addrlen == sizeof(addr)); 64 | memcpy(&addr,res->ai_addr,sizeof(addr)); 65 | freeaddrinfo(res); 66 | addr.sin_port = calculateTCPport(display); 67 | setsockopt(fd,SOL_SOCKET,SO_KEEPALIVE,(char *)&tmp,sizeof(tmp)); 68 | if( connect(fd,(struct sockaddr*)&addr,sizeof(addr)) < 0 ) { 69 | int e = errno; 70 | close(fd); 71 | fprintf(stderr,"Error connecting to '%s' (resolved to '%s') for '%s': %d=%s\n",hostname,inet_ntoa(addr.sin_addr),displayname,e,strerror(e)); 72 | return -1; 73 | } 74 | } else { 75 | struct sockaddr_un addr; 76 | 77 | msg = generateSocketName(&addr,display); 78 | if( msg != NULL ) { 79 | close(fd); 80 | fprintf(stderr,"Error calculating socket name for '%s': %s\n",displayname,msg); 81 | return -1; 82 | } 83 | 84 | if( connect(fd,(struct sockaddr*)&addr,sizeof(addr)) < 0 ) { 85 | int e = errno; 86 | close(fd); 87 | fprintf(stderr,"Error connecting to unix socket '%s' for '%s': %d=%s\n",addr.sun_path,displayname,e,strerror(e)); 88 | return -1; 89 | } 90 | } 91 | return fd; 92 | } 93 | -------------------------------------------------------------------------------- /x11common.c: -------------------------------------------------------------------------------- 1 | /* This file is part of "xtrace" 2 | * Copyright (C) 2005 Bernhard R. Link 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License version 2 as 5 | * published by the Free Software Foundation. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program; if not, write to the Free Software 14 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | */ 16 | #include 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include "xtrace.h" 30 | 31 | #define X_TCP_PORT 6000 32 | 33 | const char *parseDisplay(const char *displayname, 34 | char **protocol, char **hostname, 35 | int *display, int *screen, int *family ) { 36 | const char *p = displayname; 37 | const char *q; 38 | 39 | /* Xlib reads display names as 40 | * [protocol/] [hostname] : displaynumber [.screennumber] 41 | */ 42 | 43 | /* find the protocol */ 44 | while( *p != '\0' && *p != ':' && *p != '/' ) 45 | p++; 46 | if( *p == '/' ) { 47 | if( p != displayname ) { 48 | *protocol = strndup(displayname,p-displayname); 49 | if( *protocol == NULL ) 50 | return "Out of Memory"; 51 | } else 52 | *protocol = NULL; 53 | p++; 54 | q = p; 55 | while( *p != '\0' && *p != ':' ) 56 | p++; 57 | } else { 58 | *protocol = NULL; 59 | q = displayname; 60 | } 61 | if( *p == '\0' ) { 62 | free(*protocol); 63 | *protocol = NULL; 64 | return "No colon (':') found"; 65 | } 66 | if( p != q && !(p-q == 4 && strncmp(q,"unix",4) == 0)) { 67 | *hostname = strndup(q,p-q); 68 | if( *hostname == NULL ) 69 | return "Out of Memory"; 70 | if( *protocol == NULL ) 71 | *protocol = strdup("tcp"); 72 | } else { 73 | *hostname = NULL; 74 | free(*protocol); 75 | *protocol = strdup("local"); 76 | } 77 | if( *protocol == NULL ) { 78 | free(*hostname); 79 | *hostname = NULL; 80 | return "Out of Memory"; 81 | } 82 | assert( *p == ':' ); 83 | /* TODO: make sure we are in C locale, otherwise this can go wrong */ 84 | p++; 85 | *display = strtol(p,(char**)&q,10); 86 | if( *q == '.' ) { 87 | p = q + 1; 88 | *screen = strtol(p,(char**)&q,10); 89 | } 90 | if( *q != '\0' ) { 91 | free(*protocol); 92 | *protocol = NULL; 93 | free(*hostname); 94 | *hostname = NULL; 95 | return "Garbage after first colon, only digits and a single dot allowed"; 96 | } 97 | if( strcasecmp(*protocol,"inet")==0||strcasecmp(*protocol,"tcp")==0 ) { 98 | *family = AF_INET; 99 | } else if( strcasecmp(*protocol,"unix")==0||strcasecmp(*protocol,"local")==0 ) { 100 | *family = AF_UNIX; 101 | } else { 102 | free(*protocol); 103 | free(*hostname); 104 | *protocol = NULL; 105 | *hostname = NULL; 106 | return "Unknown protocol"; 107 | } 108 | return NULL; 109 | } 110 | 111 | const char *generateSocketName(struct sockaddr_un *addr,int display) { 112 | addr->sun_family = AF_UNIX; 113 | /* TODO: length-check ? */ 114 | snprintf(addr->sun_path,sizeof(addr->sun_path),"/tmp/.X11-unix/X%d",display); 115 | return NULL; 116 | } 117 | 118 | uint16_t calculateTCPport(int display) { 119 | return htons(X_TCP_PORT+display); 120 | } 121 | -------------------------------------------------------------------------------- /x11server.c: -------------------------------------------------------------------------------- 1 | /* This file is part of "xtrace" 2 | * Copyright (C) 2005 Bernhard R. Link 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License version 2 as 5 | * published by the Free Software Foundation. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program; if not, write to the Free Software 14 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | */ 16 | #include 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #include "xtrace.h" 37 | 38 | int listenForClients(const char *displayname,int family,int display) { 39 | int fd; 40 | const char *msg; 41 | struct sockaddr_in inaddr; 42 | struct sockaddr_un unaddr; 43 | struct sockaddr *address; 44 | size_t addresslen; 45 | 46 | fd = socket(family,SOCK_STREAM,0); 47 | if( fd < 0 ) { 48 | int e = errno; 49 | fprintf(stderr,"Error opening socket for '%s': %d=%s\n",displayname,e,strerror(e)); 50 | return -1; 51 | } 52 | if( family == AF_INET ) { 53 | int tmp=1; 54 | 55 | inaddr.sin_family = family; 56 | inaddr.sin_port = calculateTCPport(display); 57 | inaddr.sin_addr.s_addr = htonl(INADDR_ANY); 58 | setsockopt(fd,SOL_SOCKET,SO_KEEPALIVE,(char *)&tmp,sizeof(tmp)); 59 | address = (struct sockaddr*)&inaddr; 60 | addresslen = sizeof(inaddr); 61 | } else { 62 | msg = generateSocketName(&unaddr,display); 63 | if( msg != NULL ) { 64 | close(fd); 65 | fprintf(stderr,"Error calculating socket name for '%s': %s\n",displayname,msg); 66 | return -1; 67 | } 68 | unlink(unaddr.sun_path); 69 | address = (struct sockaddr*)&unaddr; 70 | addresslen = sizeof(unaddr); 71 | } 72 | if( bind(fd,address,addresslen) < 0 ) { 73 | int e = errno; 74 | close(fd); 75 | fprintf(stderr,"Error binding socket for '%s': %d=%s\n",displayname,e,strerror(e)); 76 | return -1; 77 | } 78 | if( listen(fd,20) < 0 ) { 79 | int e = errno; 80 | close(fd); 81 | fprintf(stderr,"Error listening for '%s': %d=%s\n",displayname,e,strerror(e)); 82 | return -1; 83 | } 84 | return fd; 85 | } 86 | 87 | #ifndef HAVE_ASPRINTF 88 | #warning using asprint replacement 89 | static int asprintf(char **r, const char *fmt, ...) { 90 | va_list ap; 91 | /* that's ugly, but we will not need longer values here... */ 92 | char buffer[100]; 93 | int len; 94 | 95 | va_start(ap, fmt); 96 | len = vsnprintf(buffer, 99, fmt, ap); 97 | buffer[99] = '\0'; 98 | *r = strdup(buffer); 99 | if( *r == NULL ) 100 | return -1; 101 | return len; 102 | } 103 | #endif 104 | 105 | int acceptClient(int family,int listener, char **from) { 106 | int fd; 107 | socklen_t len; 108 | 109 | if( family == AF_INET ) { 110 | struct sockaddr_in inaddr; 111 | 112 | len = sizeof(inaddr); 113 | fd = accept(listener, (struct sockaddr*)&inaddr, &len); 114 | if( asprintf(from,"%s:%d",inet_ntoa(inaddr.sin_addr),ntohs(inaddr.sin_port)) < 0 || *from == NULL ) { 115 | close(fd); 116 | return -1; 117 | } 118 | 119 | } else if( family == AF_UNIX ) { 120 | struct sockaddr_un unaddr; 121 | 122 | len = sizeof(unaddr); 123 | fd = accept(listener, (struct sockaddr*)&unaddr, &len); 124 | if( len > sizeof(sa_family_t) ) { 125 | *from = strndup(unaddr.sun_path,len-sizeof(sa_family_t)); 126 | } else 127 | *from = strdup("unknown(local)"); 128 | if( *from == NULL ) { 129 | close(fd); 130 | return -1; 131 | } 132 | } else 133 | return -1; 134 | 135 | return fd; 136 | } 137 | -------------------------------------------------------------------------------- /xinerama.proto: -------------------------------------------------------------------------------- 1 | EXTENSION "XINERAMA" Xinerama 2 | USE core 3 | 4 | REQUESTS 5 | QueryVersion RESPONDS 6 | GetState RESPONDS 7 | GetScreenCount RESPONDS 8 | GetScreenSize RESPONDS 9 | IsActive RESPONDS 10 | QueryScreens RESPONDS 11 | END 12 | 13 | EVENTS 14 | END 15 | 16 | ERRORS 17 | END 18 | 19 | LIST ScreenInfo length 8 20 | 0 x INT16 21 | 2 y INT16 22 | 4 width UINT16 23 | 6 height UINT16 24 | END 25 | 26 | REQUEST QueryVersion 27 | 4 major-version UINT8 28 | 5 minor-version UINT8 29 | END 30 | RESPONSE QueryVersion 31 | 8 major-version UINT16 32 | 10 minor-version UINT16 33 | END 34 | 35 | REQUEST GetState 36 | 4 window WINDOW 37 | END 38 | RESPONSE GetState 39 | 1 state CARD8 constants bool 40 | 8 window WINDOW 41 | END 42 | 43 | REQUEST GetScreenCount 44 | 4 window WINDOW 45 | END 46 | RESPONSE GetScreenCount 47 | 1 ScreenCount INT8 48 | 8 window WINDOW 49 | END 50 | 51 | REQUEST GetScreenSize 52 | 4 window WINDOW 53 | 8 screen UINT32 54 | END 55 | RESPONSE GetScreenSize 56 | 8 width UINT32 57 | 12 height UINT32 58 | 16 window WINDOW 59 | 20 screen UINT32 60 | END 61 | 62 | REQUEST IsActive 63 | END 64 | RESPONSE IsActive 65 | 8 state CARD32 constants bool 66 | END 67 | 68 | REQUEST QueryScreens 69 | END 70 | RESPONSE QueryScreens 71 | 8 number COUNT32 72 | 32 screens LISTofScreenInfo 73 | END 74 | 75 | EOF 76 | -------------------------------------------------------------------------------- /xkb.proto: -------------------------------------------------------------------------------- 1 | EXTENSION "XKEYBOARD" Xkb 2 | USE core 3 | 4 | REQUESTS 5 | UseExtension RESPONDS /* 0 */ 6 | # TODO: 7 | SelectEvents UNSUPPORTED /* 1 */ 8 | Unknown UNSUPPORTED 9 | Bell /* 3 */ 10 | GetState RESPONDS UNSUPPORTED /* 4 */ 11 | LatchLockState UNSUPPORTED /* 5 */ 12 | GetControls RESPONDS UNSUPPORTED /* 6 */ 13 | SetControls UNSUPPORTED /* 7 */ 14 | GetMap RESPONDS /* 8 */ 15 | SetMap UNSUPPORTED /* 9 */ 16 | GetCompatMap RESPONDS UNSUPPORTED /* 10 */ 17 | SetCompatMap UNSUPPORTED /* 11 */ 18 | GetIndicatorState RESPONDS UNSUPPORTED /* 12 */ 19 | GetIndicatorMap RESPONDS UNSUPPORTED /* 13 */ 20 | SetIndicatorMap UNSUPPORTED /* 14 */ 21 | GetNamedIndicator RESPONDS /* 15 */ 22 | SetNamedIndicator UNSUPPORTED /* 16 */ 23 | GetNames RESPONDS /* 17 */ 24 | SetNames UNSUPPORTED /* 18 */ 25 | GetGeometry RESPONDS UNSUPPORTED /* 19 */ 26 | SetGeometry UNSUPPORTED /* 20 */ 27 | PerClientFlags UNSUPPORTED /* 21 */ 28 | ListComponents RESPONDS UNSUPPORTED /* 22 */ 29 | GetKbdByName RESPONDS UNSUPPORTED /* 23 */ 30 | GetDeviceInfo RESPONDS UNSUPPORTED /* 24 */ 31 | SetDeviceInfo UNSUPPORTED /* 25 */ 32 | END 33 | 34 | EVENTS 35 | XkbEvent 36 | END 37 | 38 | ERRORS 39 | # this also packs the type in subvalues, 40 | # to support this we need support of parsing error packets, too 41 | "Keyboard" 42 | END 43 | 44 | REQUEST UseExtension 45 | 4 major UINT16 46 | 6 minor UINT16 47 | END 48 | RESPONSE UseExtension 49 | 8 major UINT16 50 | 10 minor UINT16 51 | END 52 | 53 | CONSTANTS DEVICESPEC 54 | 0x100 UseCoreKbd 55 | 0x200 UseCorePtr 56 | END 57 | TYPE DEVICESPEC UINT16 constants DEVICESPEC 58 | 59 | CONSTANTS BELLCLASSSPEC 60 | 0 KbdFeedback 61 | 5 LedFeedback 62 | 0x300 DefaultXI 63 | # AllXI ??? 64 | END 65 | TYPE BELLCLASSSPEC ENUM16 BELLCLASSSPEC 66 | 67 | CONSTANTS IDSPEC 68 | 0x400 DfltXIId 69 | END 70 | TYPE IDSPEC UINT16 constants IDSPEC 71 | 72 | REQUEST Bell 73 | 4 deviceSpec DEVICESPEC 74 | 6 bellClass BELLCLASSSPEC 75 | 8 bellID IDSPEC 76 | 10 percent INT8 77 | 11 forceSound BOOL 78 | 12 eventOnly BOOL 79 | 14 pitch INT16 80 | 16 duration INT16 81 | 20 name ATOM 82 | 24 window WINDOW 83 | END 84 | 85 | TYPE KEYCODE UINT8 86 | 87 | REQUEST GetMap 88 | 4 deviceSpec DEVICESPEC 89 | 6 full UINT16 90 | 8 partial UINT16 91 | 10 firstType UINT8 92 | 11 nTypes UINT8 93 | 12 firstKeySym KEYCODE 94 | 13 nKeySyms UINT8 95 | 14 firstKeyAct KEYCODE 96 | 15 nKeyActs UINT8 97 | 16 firstKeyBehavior KEYCODE 98 | 17 nKeyBehaviors UINT8 99 | 18 virtualMods UINT16 100 | END 101 | 102 | RESPONSE GetMap 103 | 2 deviceID UINT8 104 | 10 minKeyCode KEYCODE 105 | 11 maxKeyCode KEYCODE 106 | 12 present UINT16 107 | 14 firstType UINT8 108 | 15 nTypes UINT8 109 | 16 totalTypes UINT8 110 | 17 firstKeySym KEYCODE 111 | 18 totalSyms UINT16 112 | 20 nKeySyms UINT8 113 | 21 firstKeyAct KEYCODE 114 | 22 totalActs UINT16 115 | 24 nKeyActs UINT8 116 | 25 firstKeyBehavior KEYCODE 117 | 26 nKeyBehaviors UINT8 118 | 27 totalKeyBehaviors UINT8 119 | 28 firstKeyExplicit KEYCODE 120 | 29 nKeyExplicit UINT8 121 | 30 totalKeyExplicit UINT8 122 | 31 firstModMapKey KEYCODE 123 | 32 nModMapKeys UINT8 124 | 33 totalModMapKeys UINT8 125 | 34 firstVModMapKey KEYCODE 126 | 35 nVModMapKeys UINT8 127 | 36 totalVModMapKeys UINT8 128 | 38 virtualMods UINT16 129 | # TODO 130 | 40 not-yet-supported LISTofCARD8 131 | END 132 | 133 | BITMASK namedetailmask 134 | 1 keycodes 135 | 2 geometry 136 | 4 symbols 137 | 8 phys_symbols 138 | 16 type 139 | 32 compat 140 | 64 key_type_names 141 | 128 key_type_level_names 142 | 256 indicators 143 | 512 key_names 144 | 1024 key_aliases 145 | 2048 vmods 146 | 4096 groups 147 | 8192 radio_groups 148 | END 149 | 150 | REQUEST GetNames 151 | 4 deviceSpec DEVICESPEC 152 | 8 which BITMASK32 namedetailmask 153 | END 154 | 155 | RESPONSE GetNames 156 | 1 deviceID UINT8 157 | 8 which BITMASK32 namedetailmask 158 | 12 minKeyCode KEYCODE 159 | 13 maxKeyCode KEYCODE 160 | 14 nTypes UINT8 161 | 15 groupNames UINT8 162 | 16 virtualMods UINT16 163 | 18 firstKey KEYCODE 164 | 19 nKeys UINT8 165 | 20 indicators CARD32 166 | 24 nRadioGroups UINT8 167 | 25 nKeyAliases UINT8 168 | 26 nKTLevels UINT16 169 | # TODO 170 | 32 valueList LISTofCARD8 171 | END 172 | 173 | CONSTANTS LEDCLASSSPEC 174 | 0 KbdFeedbackClass 175 | 4 LedFeedbackClass 176 | 0x0300 DfltXIClass 177 | 0x0500 AllXIClasses 178 | 0xff00 XINone 179 | END 180 | 181 | REQUEST GetNamedIndicator 182 | 4 deviceSpec DEVICESPEC 183 | 6 ledClass ENUM16 LEDCLASSSPEC 184 | 8 ledID IDSPEC 185 | 12 indicator ATOM 186 | END 187 | 188 | RESPONSE GetNamedIndicator 189 | 1 deviceID UINT8 190 | 8 indicator ATOM 191 | 12 found BOOL 192 | 13 on BOOL 193 | 14 realIndicator BOOL 194 | 15 ndx UINT8 195 | 16 flags CARD8 196 | 17 whichGroups CARD8 197 | 18 groups CARD8 198 | 19 whichMods CARD8 199 | 20 mods CARD8 200 | 21 realMods CARD8 201 | 22 virtualMods CARD16 202 | 24 ctrls CARD32 203 | 28 supported BOOL 204 | END 205 | 206 | EVENT XkbEvent 207 | # all events packaged into one? WTF? 208 | 1 type UINT8 209 | 4 time TIMESTAMP 210 | 8 device CARD8 211 | # TODO: 212 | 9 not-yet-supported LISTofCARD8 213 | END 214 | 215 | EOF 216 | -------------------------------------------------------------------------------- /xtrace.1: -------------------------------------------------------------------------------- 1 | .TH XTRACE 1 "26 June 2009" "xtrace" XTRACE 2 | .SH NAME 3 | xtrace \- trace communication between X11 client and server 4 | .SH SYNOPSIS 5 | .BR xtrace " [ " \fIoptions\fP " ] [ " \-s " | " \-k " ] [ [ " \-W " ] [ " -- " ] " "\fIcommand args ...\fP" " ]" 6 | .SH DESCRIPTION 7 | Xtrace fakes an X server and forwards all connections to 8 | a real X server, displaying the communication between clients 9 | in (well, theoretically) human readable form. 10 | If a command is given, 11 | .B xtrace 12 | executes the named command with 13 | .B $DISPLAY 14 | set to the faked X server. If that command exits before any connections 15 | are made, 16 | .B xtrace 17 | exits immediately unless 18 | .B \-W 19 | is specified. 20 | .SH OPTIONS 21 | .TP 22 | .B \-I \fIdirectory\fP 23 | Look into \fIdirectory\fP for protocol description files. 24 | (i.e. the directory where the \fB.proto\fP files can be found). 25 | .TP 26 | .B \-s \fR|\fP \-\-stopwhendone \fR(default)\fP 27 | Terminate when all forwarded clients have disconnected. 28 | (Or when a program was run once the program has finished 29 | and all connections are closed). 30 | .TP 31 | .B \-k \fR|\fP \-\-keeprunning 32 | If all clients disconnected, wait for new ones to connect. 33 | .TP 34 | .B \-W \fR|\fP \-\-waitforclient 35 | Do not stop when the started program terminates before any connection 36 | was made. 37 | (Might be necessary if the program forks to background). 38 | .TP 39 | .B \-d \fIname\fP \fR|\fP \-\-display \fIname\fP 40 | Forward connections to the X server specified by \fIname\fP 41 | instead of the one specified by the environment variable 42 | \fBDISPLAY\fP. 43 | .TP 44 | .B \-D \fIname\fP \fR|\fP \-\-fakedisplay \fIname\fP 45 | Fake display \fIname\fP instead of \fB$FAKEDISPLAY\fP 46 | or \fB:9\fP respectively. 47 | .TP 48 | .B \-f \fIfilename\fP \fR|\fP \-\-authfile \fIfilename\fP 49 | Add an \fB-f\fP \fIfilename\fP to the arguments for all 50 | calls to xauth to get the authentication tokens of the 51 | X server to connect to. 52 | .TP 53 | .B \-F \fIfilename\fP \fR|\fP \-\-newauthfile \fIfilename\fP 54 | Add an \fB-f\fP \fIfilename\fP to the arguments for all 55 | calls to xauth to save the authentication tokens to 56 | connect to the faked X server. 57 | .TP 58 | .B \-c \fR|\fP \-\-copyauthentication \fR(default)\fP 59 | Copy the authentication tokens for the X server to connect 60 | to so that clients connecting to our fake server will use 61 | them. 62 | 63 | The commands run are roughly equivalent to: 64 | \fBxauth add $FAKEDISPLAY . `xauth list $DISPLAY | awk '$2=="MIT-MAGIC-COOKIE-1" {print $3}'`\fP 65 | 66 | Not that only \fBMIT-MAGIC-COOKIE-1\fP tokens are copied as xtrace does not yet 67 | support to change the authentication tokens so that \fBXDM-AUTHORIZATION-1\fP 68 | would be possible. 69 | .TP 70 | .B \-n \fR|\fP \-\-nocopyauthentication 71 | Do not call \fBxauth\fP and do fiddle with authentication tokens but 72 | leave that to the user to handle. 73 | .TP 74 | .B \-e \fR|\fP \-\-denyextensions 75 | Modify all server replies to say there are no extensions available. 76 | (As xtrace does supports only a small number of extensions 77 | anyway and calls all extended requests "unknown" and all replies to such 78 | requests "unexpected"). 79 | .TP 80 | .B \-w \fR|\fP \-\-readwritedebug 81 | Print how many bytes are read and/or written when. 82 | .TP 83 | .B \-m \fIcount\fP \fR|\fP \-\-maxklistlength \fIcount\fP 84 | Print only the first \fIcount\fP many elements of all lists. 85 | .TP 86 | .B \-i \fR|\fP \-\-interactive 87 | Only sent requests from the client to the server after 88 | interactive confirmation. 89 | Confirmation is given by pressing enter or a number 90 | followed by enter via stdin. 91 | This can give funny results when multiple clients are 92 | tunneled. 93 | .TP 94 | .B \-o \fR|\fP \-\-outfile \fIfilename\fP 95 | Dump output into \fIfilename\fP instead of stdout. 96 | .TP 97 | .B \-b \fR|\fP \-\-buffered 98 | Do not write every line on its own but wait until buffers 99 | are full. 100 | Speeds up things a little bit when outputting to a file. 101 | Not very useful at all together with \fB\-i\fP. 102 | .TP 103 | .B \-\-timestamps 104 | Print a timestamp before each line. 105 | 106 | Note that the time a packet is printed is between the time 107 | a packet is received and the time a packet is sent, 108 | but it gives no other information than that. 109 | .TP 110 | .B \-\-relative-timestamps 111 | Print a timestamp relative to the beginning of the connection 112 | before each line. 113 | 114 | Note that the time a packet is printed is between the time 115 | a packet is received and the time a packet is sent, 116 | but it gives no other information than that. 117 | 118 | .TP 119 | .B \-\-monotonic-timestamps 120 | Print a CLOCK_MONOTONIC (see 121 | .BR clock_gettime (3)) 122 | timestamp each time a package is printed. 123 | This is likely to be the uptime of your system. 124 | 125 | Note that the time a packet is printed is between the time 126 | a packet is received and the time a packet is sent, 127 | but it gives no other information than that. 128 | .TP 129 | .B \-\-print-offsets 130 | Print offsets of all fields 131 | (useful to debug nested lists in protocol descriptions) 132 | .TP 133 | .B \-\-print-counts 134 | Print counts 135 | (useful to debug lists in protocol descriptions) 136 | .SH "ENVIRONMENT VARIABLES" 137 | .TP 138 | .B DISPLAY 139 | Without \fB\-\-display\fP the content of this variable is used to 140 | determine the server to connect to. (And without \fB\-n\fP given 141 | to \fBxauth\fP to get the authentication tokens for this display.) 142 | .TP 143 | .B FAKEDISPLAY 144 | Without \fB\-\-fakedisplay\fP the content of this variable is used to 145 | determine how to listen for clients. (And without \fB\-n\fP given 146 | to \fBxauth\fP to set the authentication tokens for this display.) 147 | If neither is given, \fBxtrace\fP will try \fB:9\fP 148 | .TP 149 | .B XAUTHORITY 150 | Without \fB-n\fP and without \fB-f\fP or \fB-F\fP your \fBxauth\fP 151 | program will most likely look into this variable for the file 152 | to get/save the authentication tokens from/into. If this is not 153 | set it will most likely use \fI$HOME\fP\fB/.Xauthority\fP. 154 | 155 | .SH "REPORTING BUGS" 156 | Report bugs to or the Debian BTS. 157 | .SH "SEE ALSO" 158 | .BR xauth (1), 159 | .BR x (7x), 160 | .SH COPYRIGHT 161 | Copyright \(co 2005 Bernhard R. Link 162 | .br 163 | This is free software; see the source for copying conditions. There is NO 164 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 165 | -------------------------------------------------------------------------------- /xtrace.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | extern size_t authdata_len; 4 | extern char *authdata; 5 | extern FILE *out; 6 | 7 | bool generateAuthorisation(const char *displayname); 8 | const char *parseDisplay(const char *displayname, 9 | char **protocol, char **hostname, 10 | int *display, int *screen, int *family ); 11 | int connectToServer(const char *displayname,int family,const char *hostname,int display); 12 | int listenForClients(const char *displayname,int family,int display); 13 | struct sockaddr_un; 14 | const char *generateSocketName(struct sockaddr_un *addr,int display); 15 | uint16_t calculateTCPport(int display); 16 | int acceptClient(int family,int listener, char **from); 17 | 18 | #define FDQUEUE_MAX_FD 16 19 | struct fdqueue { 20 | int fd[FDQUEUE_MAX_FD]; 21 | int nfd; 22 | }; 23 | 24 | extern struct connection { 25 | struct connection *next; 26 | int id; char *from; 27 | int client_fd,server_fd; 28 | bool bigendian; 29 | unsigned char clientbuffer[16*4096]; 30 | unsigned int clientcount,clientignore; 31 | enum client_state { c_start=0, c_normal, c_amlost } clientstate; 32 | unsigned char serverbuffer[16*4096]; 33 | unsigned int servercount,serverignore; 34 | enum server_state { s_start=0, s_normal, s_amlost} serverstate; 35 | struct fdqueue clientfdq; 36 | struct fdqueue serverfdq; 37 | struct expectedreply *expectedreplies; 38 | uint64_t seq; 39 | struct usedextension *usedextensions; 40 | struct unknownextension *waiting, *unknownextensions; 41 | unsigned long long starttime; 42 | } *connections; 43 | void parse_server(struct connection *c); 44 | void parse_client(struct connection *c); 45 | void free_usedextensions(struct usedextension *); 46 | void free_unknownextensions(struct unknownextension *); 47 | bool copy_authentication(const char *fakedisplay,const char *display, const char *infile, const char *outfile); 48 | struct atom; 49 | struct atom *newAtom(const char *name, size_t len); 50 | const char *getAtom(struct connection *c, uint32_t atom); 51 | void internAtom(struct connection *c, uint32_t atom, struct atom *data); 52 | 53 | extern bool denyallextensions; 54 | extern size_t maxshownlistlen; 55 | extern bool print_timestamps; 56 | extern bool print_reltimestamps; 57 | extern bool print_uptimestamps; 58 | 59 | #ifdef __GNUC__ 60 | #define UNUSED __attribute__ ((unused)) 61 | #define FORMAT(func,fmtarg,dotarg) __attribute__((format(func,fmtarg,dotarg))); 62 | #else 63 | #define UNUSED 64 | #define FORMAT(func,fmtarg,dotarg) 65 | #endif 66 | 67 | #ifndef HAVE_STRNDUP 68 | char *strndup(const char *,size_t); 69 | #endif 70 | -------------------------------------------------------------------------------- /xvideo.proto: -------------------------------------------------------------------------------- 1 | # This file is part of xtrace. 2 | # Copyright (C) 2006 Bernhard R. Link 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License version 2 as 5 | # published by the Free Software Foundation. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | # 12 | # You should have received a copy of the GNU General Public License 13 | # along with this program; if not, write to the Free Software 14 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | # 16 | # This file is based on /usr/include/X11/extensions/Xvproto.h which states: 17 | # Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts, 18 | # and the Massachusetts Institute of Technology, Cambridge, Massachusetts. 19 | # 20 | # All Rights Reserved 21 | # 22 | # Permission to use, copy, modify, and distribute this software and its 23 | # documentation for any purpose and without fee is hereby granted, 24 | # provided that the above copyright notice appear in all copies and that 25 | # both that copyright notice and this permission notice appear in 26 | # supporting documentation, and that the names of Digital or MIT not be 27 | # used in advertising or publicity pertaining to distribution of the 28 | # software without specific, written prior permission. 29 | # 30 | # DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 31 | # ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL 32 | # DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 33 | # ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 34 | # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 35 | # ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 36 | # SOFTWARE. 37 | # 38 | # and on /usr/share/xcb/xv.xml, which states: 39 | # Copyright (C) 2006 Jeremy Kolb. 40 | # All Rights Reserved. 41 | # 42 | # Permission is hereby granted, free of charge, to any person obtaining a copy 43 | # of this software and associated documentation files (the "Software"), to deal 44 | # in the Software without restriction, including without limitation the rights 45 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 46 | # copies of the Software, and to permit persons to whom the Software is 47 | # furnished to do so, subject to the following conditions: 48 | # 49 | # The above copyright notice and this permission notice shall be included in all 50 | # copies or substantial portions of the Software. 51 | # 52 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 53 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 54 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 55 | # AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 56 | # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 57 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 58 | # 59 | # Except as contained in this notice, the names of the authors or their 60 | # institutions shall not be used in advertising or otherwise to promote the 61 | # sale, use or other dealings in this Software without prior written 62 | # authorization from the authors. 63 | 64 | EXTENSION "XVideo" XV 65 | USE core 66 | 67 | REQUESTS 68 | QueryExtension RESPONDS /* 0 */ 69 | QueryAdaptors RESPONDS 70 | QueryEncodings RESPONDS 71 | GrabPort RESPONDS 72 | UngrabPort 73 | PutVideo 74 | PutStill 75 | GetVideo 76 | GetStill 77 | StopVideo 78 | SelectVideoNotify /* 10 */ 79 | SelectPortNotify 80 | QueryBestSize RESPONDS 81 | SetPortAttribute 82 | GetPortAttribute RESPONDS 83 | QueryPortAttributes RESPONDS 84 | ListImageFormats RESPONDS 85 | QueryImageAttributes RESPONDS 86 | PutImage 87 | ShmPutImage 88 | END 89 | 90 | EVENTS 91 | VideoNotify 92 | PortNotify 93 | END 94 | 95 | ERRORS 96 | BadPort 97 | BadEncoding 98 | BadMode 99 | END 100 | 101 | TYPE PORT UINT32 102 | TYPE ENCODING UINT32 103 | 104 | BITMASK xvtype 105 | 1<<0 Input 106 | 1<<1 Output 107 | 1<<2 Video 108 | 1<<3 Still 109 | 1<<4 Image 110 | END 111 | 112 | CONSTANTS ImageFormatInfoType 113 | 0 RGB 114 | 1 YUV 115 | END 116 | 117 | CONSTANTS ImageFormatInfoFormat 118 | 0 Packed 119 | 1 Planar 120 | END 121 | 122 | BITMASK attribute_flag 123 | 1 Gettable 124 | 2 Settable 125 | END 126 | 127 | CONSTANTS video_notify_reason 128 | 0 Started 129 | 1 Stopped 130 | 2 Busy 131 | 3 Preempted 132 | 4 HardError 133 | END 134 | 135 | CONSTANTS scanline_order 136 | 0 TopToBottom 137 | 1 BottomToTop 138 | END 139 | 140 | CONSTANTS grab_port_status 141 | 0 Success 142 | 1 BadExtension 143 | 2 AlreadyGrabbed 144 | 3 InvalidTime 145 | 4 BadReply 146 | 5 BadAlloc 147 | END 148 | 149 | STRUCT Rational length 8 150 | 0 numerator INT32 151 | 4 denominator INT32 152 | END 153 | 154 | LIST XVFormat length 8 155 | 0 visual VISUALID 156 | 4 depth UINT8 157 | END 158 | 159 | LIST AdaptorInfo variable min-length 12 160 | 0 base_id PORT 161 | 6 num_ports UINT16 162 | 10 type BITMASK8 xvtype 163 | 4 name_size COUNT16 164 | 12 name STRING8 165 | ROUND 166 | 8 num_formats COUNT16 167 | LATER formats LISTofXVFormat 168 | END 169 | 170 | LIST EncodingInfo variable min-length 20 171 | 0 encoding ENCODING 172 | 4 name_size COUNT16 173 | 6 width UINT16 174 | 8 height UINT16 175 | 12 rate Rational 176 | 20 name STRING8 177 | ROUND 178 | END 179 | 180 | LIST AttributeInfo variable min-length 16 181 | 0 flags BITMASK32 attribute_flag 182 | 4 min INT32 183 | 8 max INT32 184 | 12 size COUNT32 185 | 16 name STRING8 186 | ROUND 187 | END 188 | 189 | LIST ImageFormatInfo length 128 190 | 0 id CARD32 191 | 4 type ENUM8 ImageFormatInfoType 192 | 5 byte_order CARD8 193 | SET_COUNTER 16 194 | 8 guid STRING8 195 | 24 bpp UINT8 196 | 25 num_planes UINT8 197 | 28 depth UINT8 198 | 32 red_mask CARD32 199 | 36 green_mask CARD32 200 | 40 blue_mask CARD32 201 | 44 format ENUM8 ImageFormatInfoFormat 202 | 48 y_sample_bits CARD32 203 | 52 u_sample_bits CARD32 204 | 56 v_sample_bits CARD32 205 | 60 vhorz_y_period CARD32 206 | 64 vhorz_u_period CARD32 207 | 68 vhorz_v_period CARD32 208 | 72 vvert_y_period CARD32 209 | 76 vvert_u_period CARD32 210 | 80 vvert_v_period CARD32 211 | SET_COUNTER 32 212 | 84 vcomp_order LISTofCARD8 213 | 116 vscanline_order ENUM8 scanline_order 214 | END 215 | 216 | REQUEST QueryExtension 217 | END 218 | RESPONSE QueryExtension 219 | 8 major UINT16 220 | 10 minor UINT16 221 | END 222 | 223 | REQUEST QueryAdaptors 224 | 4 window WINDOW 225 | END 226 | RESPONSE QueryAdaptors 227 | 8 num_adaptors COUNT16 228 | 32 adaptors LISTofAdaptorInfo 229 | END 230 | 231 | REQUEST QueryEncodings 232 | 4 port PORT 233 | END 234 | RESPONSE QueryEncodings 235 | 8 num_encodings COUNT16 236 | 32 encodings LISTofEncodingInfo 237 | END 238 | 239 | REQUEST GrabPort 240 | 4 port PORT 241 | 8 time TIMESTAMP 242 | END 243 | RESPONSE GrabPort 244 | 1 result ENUM8 grab_port_status 245 | END 246 | 247 | REQUEST UngrabPort 248 | 4 port PORT 249 | 8 time TIMESTAMP 250 | END 251 | 252 | templateREQUEST Put 253 | 4 port PORT 254 | 8 drawable DRAWABLE 255 | 12 gc GCONTEXT 256 | 16 vid_x INT16 257 | 18 vid_y INT16 258 | 20 vid_w UINT16 259 | 22 vid_h UINT16 260 | 24 drw_x INT16 261 | 26 drw_y INT16 262 | 28 drw_w UINT16 263 | 30 drw_h UINT16 264 | END 265 | 266 | REQUEST PutVideo ALIASES Put 267 | REQUEST PutStill ALIASES Put 268 | REQUEST GetVideo ALIASES Put 269 | REQUEST GetStill ALIASES Put 270 | 271 | REQUEST StopVideo 272 | 4 port PORT 273 | 8 drawable DRAWABLE 274 | END 275 | 276 | REQUEST SelectVideoNotify 277 | 4 drawable DRAWABLE 278 | 8 onoff BOOL 279 | END 280 | 281 | REQUEST SelectPortNotify 282 | 4 port PORT 283 | 8 onoff BOOL 284 | END 285 | 286 | REQUEST QueryBestSize 287 | 4 port PORT 288 | 8 vid_w UINT16 289 | 10 vid_h UINT16 290 | 12 drw_w UINT16 291 | 14 drw_h UINT16 292 | 16 motion BOOL 293 | END 294 | RESPONSE QueryBestSize 295 | 8 actual_width UINT16 296 | 10 actual_height UINT16 297 | END 298 | 299 | REQUEST SetPortAttribute 300 | 4 port PORT 301 | 8 attribute ATOM 302 | 12 value INT32 303 | END 304 | 305 | REQUEST GetPortAttribute 306 | 4 port PORT 307 | 8 attribute ATOM 308 | END 309 | RESPONSE GetPortAttribute 310 | 8 value INT32 311 | END 312 | 313 | REQUEST QueryPortAttributes 314 | 4 port PORT 315 | END 316 | RESPONSE QueryPortAttributes 317 | 8 num_attributes COUNT32 318 | 12 text_size UINT32 319 | 32 attributes LISTofAttributeInfo 320 | END 321 | 322 | REQUEST ListImageFormats 323 | 4 port PORT 324 | END 325 | RESPONSE ListImageFormats 326 | 8 num_formats COUNT32 327 | 32 format LISTofImageFormatInfo 328 | END 329 | 330 | REQUEST QueryImageAttributes 331 | 4 port PORT 332 | 8 id CARD32 333 | 12 width UINT16 334 | 14 height UINT16 335 | END 336 | RESPONSE QueryImageAttributes 337 | 12 data_size UINT32 338 | 16 width UINT16 339 | 18 height UINT16 340 | 8 num_planes COUNT32 341 | 32 pitches LISTofUINT32 342 | RESET_COUNTER 343 | LATER offsets LISTofUINT32 344 | END 345 | 346 | REQUEST PutImage 347 | 4 port PORT 348 | 8 drawable DRAWABLE 349 | 12 gc GCONTEXT 350 | 16 id CARD32 351 | 20 src_x INT16 352 | 22 src_y INT16 353 | 24 src_w UINT16 354 | 26 src_h UINT16 355 | 28 drw_x INT16 356 | 30 drw_y INT16 357 | 32 drw_w UINT16 358 | 34 drw_h UINT16 359 | 36 width UINT16 360 | 38 height UINT16 361 | 40 data LISTofCARD8 362 | END 363 | 364 | REQUEST ShmPutImage 365 | 4 port PORT 366 | 8 drawable DRAWABLE 367 | 12 gc GCONTEXT 368 | 16 shmseg Shm::ShmSeg 369 | 20 id CARD32 370 | 24 offset UINT32 371 | 28 src_x INT16 372 | 30 src_y INT16 373 | 32 src_w UINT16 374 | 34 src_h UINT16 375 | 36 drw_x INT16 376 | 38 drw_y INT16 377 | 40 drw_w UINT16 378 | 42 drw_h UINT16 379 | 44 width UINT16 380 | 46 height UINT16 381 | 48 send_event BOOL 382 | END 383 | 384 | EVENT VideoNotify 385 | 1 reason ENUM8 video_notify_reason 386 | 4 timestamp TIMESTAMP 387 | 8 drawable DRAWABLE 388 | 12 port PORT 389 | END 390 | 391 | EVENT PortNotify 392 | 4 timestamp TIMESTAMP 393 | 8 port PORT 394 | 12 attribute ATOM 395 | 16 value INT32 396 | END 397 | 398 | EOF 399 | --------------------------------------------------------------------------------